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.RenderingHints; 042 043/** 044 * Defines the rendering hints that can be used with the {@link FXGraphics2D} 045 * class. There is just one hint defined at present:<br> 046 * <ul> 047 * <li>{@link #KEY_USE_FX_FONT_METRICS} that controls whether JavaFX font 048 * metrics or Java2D font metrics are used.</li> 049 * </ul> 050 * 051 * @since 1.5 052 */ 053public final class FXHints { 054 055 private FXHints() { 056 // no need to instantiate this 057 } 058 059 /** 060 * The key for the hint that controls whether JavaFX font metrics are 061 * used (better matching to rendering engine) or Java2D font metrics. 062 * A {@code Boolean} value (or {@code null}) can be assigned as the value 063 * for this key. 064 */ 065 public static final FXHints.Key KEY_USE_FX_FONT_METRICS 066 = new FXHints.Key(0); 067 068 /** 069 * A key for hints used by the {@link FXGraphics2D} class. 070 */ 071 public static class Key extends RenderingHints.Key { 072 073 /** 074 * Creates a new instance with the specified private key. 075 * 076 * @param privateKey the private key. 077 */ 078 public Key(int privateKey) { 079 super(privateKey); 080 } 081 082 /** 083 * Returns {@code true} if {@code val} is a value that is 084 * compatible with this key, and {@code false} otherwise. 085 * 086 * @param val the value. 087 * 088 * @return A boolean. 089 */ 090 @Override 091 public boolean isCompatibleValue(Object val) { 092 if (intKey() == 0) { 093 return val == null 094 || val instanceof Boolean; 095 } 096 throw new RuntimeException("Not expected!"); 097 } 098 } 099 100}