1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.scenegraph.g2d;
14 import java.awt.Component;
15 import java.awt.geom.AffineTransform;
16 import java.awt.geom.Rectangle2D;
19 import org.simantics.scenegraph.g2d.color.ColorFilter;
22 * @author Tuukka Lehtonen
23 * See {@link G2DPDFRenderingHints}
25 public final class G2DRenderingHints {
27 public static final Key KEY_BEGIN_ELEMENT = new G2DRenderingHints.Key(0);
28 public static final Key KEY_END_ELEMENT = new G2DRenderingHints.Key(1);
29 public static final Key KEY_ELEMENT_ID = new G2DRenderingHints.Key(2);
31 public static class Key extends java.awt.RenderingHints.Key {
33 public Key(int privateKey) {
38 public boolean isCompatibleValue(Object val) {
41 return val == null || val instanceof String
42 || val instanceof Map;
44 return val == null || val instanceof Object;
46 return val == null || val instanceof Object;
48 throw new RuntimeException("Not possible!");
54 * A rendering hint for storing the boundaries of the control area within a
55 * Graphics2D instance.
57 public static final Key KEY_CONTROL_BOUNDS = new Key(1000) {
59 public boolean isCompatibleValue(Object val) {
60 return val instanceof Rectangle2D;
65 * A rendering hint for storing the root AWT Component on which the scene
66 * graph is rendered within a Graphics2D instance.
68 public static final Key KEY_COMPONENT = new Key(1001) {
70 public boolean isCompatibleValue(Object val) {
71 return val instanceof Component;
76 * If this hint is not specified, the default interpretation should be
81 public static enum TextRenderingMode {
87 * A rendering hint for telling text rendering Simantics G2D scene graph node
88 * implementations how to render the text: as text or paths.
92 public static final Key KEY_TEXT_RENDERING_MODE = new Key(2004) {
94 public boolean isCompatibleValue(Object val) {
95 return val instanceof TextRenderingMode;
100 * Instead of rendering SVGNode using SVG Salamander pass it to G2D as SVGPassthruShape in String format.
104 public static final Key KEY_SVG_PASSTHRU = new Key(2005) {
106 public boolean isCompatibleValue(Object val) {
107 return val instanceof Boolean;
112 * The current Graphics2D AffineTransform for all nodes under the special
113 * spatialRoot : RTreeNode.
115 * This can be used to optimize the creation and of new AffineTransforms by
116 * not having to use Graphics2D.getTransform to retrieve the current
117 * transformation which always creates new instances.
119 public static final Key KEY_TRANSFORM_UNDER_SPATIAL_ROOT = new Key(2006) {
121 public boolean isCompatibleValue(Object val) {
122 return val instanceof AffineTransform || val == null;
127 * A rendering hint for storing the active ColorFilter which can be used e.g.
128 * for coloring BufferedImages.
130 public static final Key KEY_COLOR_FILTER = new Key(2007) {
132 public boolean isCompatibleValue(Object val) {
133 return val instanceof ColorFilter || val == null;