]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/G2DRenderingHints.java
Support SVG generation from scenegraph
[simantics/platform.git] / bundles / org.simantics.scenegraph / src / org / simantics / scenegraph / g2d / G2DRenderingHints.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.scenegraph.g2d;
13
14 import java.awt.Component;
15 import java.awt.geom.Rectangle2D;
16 import java.util.Map;
17
18 /**
19  * @author Tuukka Lehtonen
20  * See {@link G2DPDFRenderingHints}
21  */
22 public final class G2DRenderingHints {
23
24     public static final Key KEY_BEGIN_ELEMENT = new G2DRenderingHints.Key(0);
25     public static final Key KEY_END_ELEMENT = new G2DRenderingHints.Key(1);
26     public static final Key KEY_ELEMENT_ID = new G2DRenderingHints.Key(2);
27
28     public static class Key extends java.awt.RenderingHints.Key {
29
30         public Key(int privateKey) {
31             super(privateKey);    
32         }
33     
34         @Override
35         public boolean isCompatibleValue(Object val) {
36             switch (intKey()) {
37                 case 0:
38                     return val == null || val instanceof String 
39                             || val instanceof Map;
40                 case 1:
41                     return val == null || val instanceof Object;
42                 case 2:
43                     return val == null || val instanceof Object;
44                 default:
45                     throw new RuntimeException("Not possible!");
46             }
47         }
48     }
49         
50     /**
51      * A rendering hint for storing the boundaries of the control area within a
52      * Graphics2D instance.
53      */
54     public static final Key KEY_CONTROL_BOUNDS = new Key(1000) {
55         @Override
56         public boolean isCompatibleValue(Object val) {
57             return val instanceof Rectangle2D;
58         }
59     };
60
61     /**
62      * A rendering hint for storing the root AWT Component on which the scene
63      * graph is rendered within a Graphics2D instance.
64      */
65     public static final Key KEY_COMPONENT      = new Key(1001) {
66         @Override
67         public boolean isCompatibleValue(Object val) {
68             return val instanceof Component;
69         }
70     };
71
72 }