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;
20 * @author Tuukka Lehtonen
21 * See {@link G2DPDFRenderingHints}
23 public final class G2DRenderingHints {
25 public static final Key KEY_BEGIN_ELEMENT = new G2DRenderingHints.Key(0);
26 public static final Key KEY_END_ELEMENT = new G2DRenderingHints.Key(1);
27 public static final Key KEY_ELEMENT_ID = new G2DRenderingHints.Key(2);
29 public static class Key extends java.awt.RenderingHints.Key {
31 public Key(int privateKey) {
36 public boolean isCompatibleValue(Object val) {
39 return val == null || val instanceof String
40 || val instanceof Map;
42 return val == null || val instanceof Object;
44 return val == null || val instanceof Object;
46 throw new RuntimeException("Not possible!");
52 * A rendering hint for storing the boundaries of the control area within a
53 * Graphics2D instance.
55 public static final Key KEY_CONTROL_BOUNDS = new Key(1000) {
57 public boolean isCompatibleValue(Object val) {
58 return val instanceof Rectangle2D;
63 * A rendering hint for storing the root AWT Component on which the scene
64 * graph is rendered within a Graphics2D instance.
66 public static final Key KEY_COMPONENT = new Key(1001) {
68 public boolean isCompatibleValue(Object val) {
69 return val instanceof Component;
74 * If this hint is not specified, the default interpretation should be
79 public static enum TextRenderingMode {
85 * A rendering hint for telling text rendering Simantics G2D scene graph node
86 * implementations how to render the text: as text or paths.
90 public static final Key KEY_TEXT_RENDERING_MODE = new Key(2004) {
92 public boolean isCompatibleValue(Object val) {
93 return val instanceof TextRenderingMode;
98 * Instead of rendering SVGNode using SVG Salamander pass it to G2D as SVGPassthruShape in String format.
102 public static final Key KEY_SVG_PASSTHRU = new Key(2005) {
104 public boolean isCompatibleValue(Object val) {
105 return val instanceof Boolean;
110 * The current Graphics2D AffineTransform for all nodes under the special
111 * spatialRoot : RTreeNode.
113 * This can be used to optimize the creation and of new AffineTransforms by
114 * not having to use Graphics2D.getTransform to retrieve the current
115 * transformation which always creates new instances.
117 public static final Key KEY_TRANSFORM_UNDER_SPATIAL_ROOT = new Key(2006) {
119 public boolean isCompatibleValue(Object val) {
120 return val instanceof AffineTransform || val == null;