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