001/* ============ 002 * FXGraphics2D 003 * ============ 004 * 005 * (C)opyright 2014-2020, by Object Refinery Limited. 006 * 007 * http://www.jfree.org/fxgraphics2d/index.html 008 * 009 * The FXGraphics2D class has been developed by Object Refinery Limited for 010 * use in Orson Charts (http://www.object-refinery.com/orsoncharts) 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 the Object Refinery Limited nor the 022 * names of its contributors may be used to endorse or promote products 023 * derived from this software 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 OBJECT REFINERY LIMITED BE LIABLE FOR ANY 029 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 030 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 031 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 032 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 033 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 034 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 035 * 036 */ 037 038package org.jfree.fx; 039 040import java.awt.GraphicsConfiguration; 041import java.awt.GraphicsDevice; 042 043/** 044 * A graphics device for FXGraphics2D. 045 */ 046public class FXGraphicsDevice extends GraphicsDevice { 047 048 private final String id; 049 050 GraphicsConfiguration defaultConfig; 051 052 /** 053 * Creates a new instance. 054 * 055 * @param id the id. 056 * @param defaultConfig the default configuration. 057 */ 058 public FXGraphicsDevice(String id, GraphicsConfiguration defaultConfig) { 059 this.id = id; 060 this.defaultConfig = defaultConfig; 061 } 062 063 /** 064 * Returns the device type. 065 * 066 * @return The device type. 067 */ 068 @Override 069 public int getType() { 070 return GraphicsDevice.TYPE_RASTER_SCREEN; 071 } 072 073 /** 074 * Returns the id string (defined in the constructor). 075 * 076 * @return The id string. 077 */ 078 @Override 079 public String getIDstring() { 080 return this.id; 081 } 082 083 /** 084 * Returns all configurations for this device. 085 * 086 * @return All configurations for this device. 087 */ 088 @Override 089 public GraphicsConfiguration[] getConfigurations() { 090 return new GraphicsConfiguration[] { getDefaultConfiguration() }; 091 } 092 093 /** 094 * Returns the default configuration for this device. 095 * 096 * @return The default configuration for this device. 097 */ 098 @Override 099 public GraphicsConfiguration getDefaultConfiguration() { 100 return this.defaultConfig; 101 } 102 103}