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