001/* =============== 002 * SkijaGraphics2D 003 * =============== 004 * 005 * (C)opyright 2021, by David Gilbert. 006 * 007 * The SkijaGraphics2D class has been developed by David Gilbert for 008 * use with Orson Charts (http://www.object-refinery.com/orsoncharts) and 009 * JFreeChart (http://www.jfree.org/jfreechart). It may be useful for other 010 * code that uses the Graphics2D API provided by Java2D. 011 * 012 * Redistribution and use in source and binary forms, with or without 013 * modification, are permitted provided that the following conditions are met: 014 * - Redistributions of source code must retain the above copyright 015 * notice, this list of conditions and the following disclaimer. 016 * - Redistributions in binary form must reproduce the above copyright 017 * notice, this list of conditions and the following disclaimer in the 018 * documentation and/or other materials provided with the distribution. 019 * - Neither the name of the Object Refinery Limited nor the 020 * names of its contributors may be used to endorse or promote products 021 * derived from this software without specific prior written permission. 022 * 023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 024 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 025 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 026 * ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY 027 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 028 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 029 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 030 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 031 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 032 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 033 * 034 */ 035 036package org.jfree.skija; 037 038import java.awt.*; 039 040/** 041 * A graphics device for SkijaGraphics2D. 042 */ 043public class SkijaGraphicsDevice extends GraphicsDevice { 044 045 private final String id; 046 047 GraphicsConfiguration defaultConfig; 048 049 /** 050 * Creates a new instance. 051 * 052 * @param id the id. 053 * @param defaultConfig the default configuration. 054 */ 055 public SkijaGraphicsDevice(String id, GraphicsConfiguration defaultConfig) { 056 this.id = id; 057 this.defaultConfig = defaultConfig; 058 } 059 060 /** 061 * Returns the device type. 062 * 063 * @return The device type. 064 */ 065 @Override 066 public int getType() { 067 return GraphicsDevice.TYPE_RASTER_SCREEN; 068 } 069 070 /** 071 * Returns the id string (defined in the constructor). 072 * 073 * @return The id string. 074 */ 075 @Override 076 public String getIDstring() { 077 return this.id; 078 } 079 080 /** 081 * Returns all configurations for this device. 082 * 083 * @return All configurations for this device. 084 */ 085 @Override 086 public GraphicsConfiguration[] getConfigurations() { 087 return new GraphicsConfiguration[] { getDefaultConfiguration() }; 088 } 089 090 /** 091 * Returns the default configuration for this device. 092 * 093 * @return The default configuration for this device. 094 */ 095 @Override 096 public GraphicsConfiguration getDefaultConfiguration() { 097 return this.defaultConfig; 098 } 099 100}