]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/DiagramHints.java
Merge "Databoard and SCL enchancements."
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / diagram / DiagramHints.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.g2d.diagram;\r
13 \r
14 import java.awt.Color;\r
15 import java.awt.Point;\r
16 import java.awt.geom.Point2D;\r
17 import java.util.List;\r
18 import java.util.Map;\r
19 \r
20 import org.simantics.g2d.canvas.ICanvasContext;\r
21 import org.simantics.g2d.canvas.ICanvasParticipant;\r
22 import org.simantics.g2d.connection.IConnectionAdvisor;\r
23 import org.simantics.g2d.layers.ILayers;\r
24 import org.simantics.g2d.layers.ILayersEditor;\r
25 import org.simantics.g2d.routing.IRouter2;\r
26 import org.simantics.scenegraph.g2d.snap.ISnapAdvisor;\r
27 import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
28 import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;\r
29 import org.simantics.utils.page.MarginUtils.Margins;\r
30 \r
31 /**\r
32  * These hints are meant to be used with IDiagram instances.\r
33  * \r
34  * @author Toni Kalajainen\r
35  */\r
36 public class DiagramHints {\r
37 \r
38     /**\r
39      * A hint for disabling painting of the diagram the hint is associated with.\r
40      * \r
41      * <p>\r
42      * By default diagram viewers perform a zoom-to-fit operation on the opened\r
43      * diagram immediately after opening. Sometimes it is desirable to allow\r
44      * disabling of this fitting process. Due to the SWT/AWT interplay nature of\r
45      * diagram editors, the process of zoom-to-fit is rather asynchronous and\r
46      * needs to schedule runnables into the toolkit threads. Since editor\r
47      * opening is synchronously performed in the SWT thread we can safely veto\r
48      * the zoom-to-fit operation by removing this hint from the diagram after\r
49      * opening the editor.\r
50      * \r
51      * <p>\r
52      * Can also be set for an {@link ICanvasContext} to enable or disable\r
53      * initial zoom to fit for the context regardless of the diagram in\r
54      * question.\r
55      */\r
56     public static final Key KEY_INITIAL_ZOOM_TO_FIT   = new KeyOf(Boolean.class, "INITIAL_ZOOM_TO_FIT");\r
57 \r
58     /** Diagram */\r
59     public static final Key KEY_DIAGRAM               = new KeyOf(IDiagram.class, "DIAGRAM");\r
60 \r
61     public static final Key KEY_SELECTION_FRAME_COLOR = new KeyOf(Color.class, "SELECTION_FRAME_COLOR");\r
62 \r
63     public static final Key KEY_TEXT                  = new KeyOf(String.class, "DIAGRAM_TEXT");\r
64 \r
65     public static final Key KEY_CANVAS_COLOR          = new KeyOf(Color.class, "CANVAS_COLOR");\r
66 \r
67     // Layer composition List<LayerInfo>\r
68     public static final Key KEY_LAYER_COMPOSITION     = new KeyOf(List.class, "LAYER_COMPOSITION");\r
69 \r
70     // public static final Key KEY_BOUNDS = ElementHints.KEY_BOUNDS;\r
71 \r
72     public final static Key KEY_MARGINS               = new KeyOf(Margins.class, "MARGINS");\r
73 \r
74     public final static Key KEY_MARGINS_NO_RULER      = new KeyOf(Margins.class, "MARGINS_NO_RULER");\r
75 \r
76     /**\r
77      * For diagrams, this hint defines the default routing algorithm applied to\r
78      * any connection that does not defined its own routing. For connection\r
79      * elements, this hint defines the selected connection-specific routing\r
80      * strategy.\r
81      */\r
82     public static final Key ROUTE_ALGORITHM           = new KeyOf(IRouter2.class, "ROUTE_ALGORITHM");\r
83 \r
84     public static final Key PROPERTIES                = new KeyOf(Map.class, "PROPERTIES");\r
85 \r
86     public static final Key CONNECTION_ADVISOR        = new KeyOf(IConnectionAdvisor.class, "CONNECTION_ADVISOR");\r
87 \r
88     public static final Key SNAP_ADVISOR              = new KeyOf(ISnapAdvisor.class, "SNAP_ADVISOR");\r
89 \r
90     public static final Key KEY_LAYERS                = new KeyOf(ILayers.class, "LAYERS");\r
91 \r
92     public static final Key KEY_LAYERS_EDITOR         = new KeyOf(ILayersEditor.class, "LAYERS_EDITOR");\r
93 \r
94     public static final Key KEY_FIXED_LAYERS          = new KeyOf(String[].class, "FIXED_LAYERS");\r
95 \r
96     public static final Key KEY_MUTATOR                = new KeyOf(DiagramMutator.class, "MUTATIONS");\r
97 \r
98     public static final Key KEY_NAVIGATION_ENABLED = new KeyOf(Boolean.class, "NAVIGATION_ENABLED");\r
99 \r
100     /**\r
101      * A hint for describing the target rasterized size of element images in a\r
102      * diagram. This is useful for UI components like the symbol library which\r
103      * always shows symbols in a certain size in pixels. Images are generally\r
104      * pre-rasterized and mipmapped in order to speed up SVG rendering. This\r
105      * allows making sure that the symbol is properly rasterized at its target\r
106      * resolution instead of having to resort to mipmaps. If this hint is not provided,\r
107      * a default procedure for resolving the mipmap sizes is followed.\r
108      */\r
109     public static final Key KEY_ELEMENT_RASTER_TARGET_SIZE = new KeyOf(Point.class, "ELEMENT_RASTER_TARGET_SIZE");\r
110 \r
111     /**\r
112      * This hint is used to mark an element that is being inline edited on a\r
113      * diagram. This hint can be used for example to make sure that only one\r
114      * element is being inline edited at any given time on a single diagram.\r
115      */\r
116     public static final Key KEY_ACTIVE_INLINE_EDITOR = new KeyOf(ICanvasParticipant.class, "ACTIVE_INLINE_EDITOR");\r
117 \r
118     /**\r
119      * <code>true</code> to allow connection branching. <code>null</code> or\r
120      * <code>false</code> will disable connection branching.\r
121      * \r
122      * This is a hint for editing, not for visualisation.\r
123      * \r
124      * If the hint is not present, the default interpretation should be to allow branching.\r
125      */\r
126     public static final Key KEY_ALLOW_CONNECTION_BRANCHING = new KeyOf(Boolean.class, "ALLOW_CONNECTION_BRANCHING");\r
127 \r
128     /**\r
129      * <code>true</code> to create flags when connections are left in the air,\r
130      * <code>null</code> or <code>false</code> will leave the connections\r
131      * hanging in the air.\r
132      * \r
133      * This is a hint for editing, not for visualisation.\r
134      * \r
135      * If the hint is not present, the default interpretation should be not to\r
136      * use connection flags.\r
137      */\r
138     public static final Key KEY_USE_CONNECTION_FLAGS = new KeyOf(Boolean.class, "USE_CONNECTION_FLAGS");\r
139 \r
140     /**\r
141      * <code>true</code> to allow adding of route points into connections or\r
142      * <code>false</code> to deny route points from being added/created.\r
143      * \r
144      * This is a hint for editing, not for visualisation.\r
145      * \r
146      * If the hint is not present, the default interpretation should be to use\r
147      * route points\r
148      */\r
149     public static final Key KEY_ALLOW_ROUTE_POINTS = new KeyOf(Boolean.class, "ALLOW_ROUTE_POINTS");\r
150 \r
151 \r
152     /**\r
153      * A Hint for other participants to use for showing the context menu at the\r
154      * contol position specified by the Point2D argument.\r
155      */\r
156     public static final Key SHOW_POPUP_MENU                = new KeyOf(Point2D.class, "SHOW_POPUP_MENU_CMD");\r
157 \r
158     /**\r
159      * Screen position of mouse on canvas control when the menu was invoked to\r
160      * be opened. For use by menu contributions.\r
161      */\r
162     public static final Key POPUP_MENU_CONTROL_POSITION    = new KeyOf(Point2D.class, "POPUP_MENU_CONTROL_POSITION");\r
163 \r
164     /**\r
165      * Canvas position of mouse on canvas control when the menu was invoked to\r
166      * be opened. For use by menu contributions.\r
167      */\r
168     public static final Key POPUP_MENU_CANVAS_POSITION     = new KeyOf(Point2D.class, "POPUP_MENU_CANVAS_POSITION");\r
169 \r
170     /**\r
171      * {@link System#currentTimeMillis()} from the time of processing the popup\r
172      * menu show event.\r
173      */\r
174     public static final Key POPUP_MENU_SHOWN               = new KeyOf(Long.class, "POPUP_MENU_SHOWN");\r
175 \r
176     /**\r
177      * {@link System#currentTimeMillis()} from the time of processing the popup\r
178      * menu hide event.\r
179      */\r
180     public static final Key POPUP_MENU_HIDDEN              = new KeyOf(Long.class, "POPUP_MENU_HIDDEN");\r
181 \r
182 }\r