]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/canvas/Hints.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / canvas / Hints.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.g2d.canvas;
13
14 import java.awt.Color;
15 import java.awt.Paint;
16 import java.awt.dnd.DnDConstants;
17 import java.awt.dnd.DragGestureRecognizer;
18 import java.awt.geom.AffineTransform;
19 import java.awt.geom.Rectangle2D;
20
21 import org.simantics.g2d.canvas.impl.ToolMode;
22 import org.simantics.g2d.dnd.DragInteractor;
23 import org.simantics.g2d.participant.CanvasBoundsParticipant;
24 import org.simantics.utils.datastructures.hints.IHintContext.Key;
25 import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
26 import org.simantics.utils.datastructures.hints.IHintContext.MouseSpecificKeyOf;
27 import org.simantics.utils.page.PageDesc;
28
29 /**
30  * @author Toni Kalajainen
31  */
32 public class Hints {
33
34     public static final IToolMode POINTERTOOL              = new ToolMode("PointerTool");
35     public static final IToolMode PANTOOL                  = new ToolMode("PanTool");
36     public static final IToolMode CONNECTTOOL              = new ToolMode("ConnectTool");
37
38     /** Selected Tool */
39     public static final Key KEY_TOOL = new MouseSpecificKeyOf(0, IToolMode.class);
40
41     /** Transform that converts point from canvas to control */
42     public static final Key KEY_CANVAS_TRANSFORM = new KeyOf(AffineTransform.class, "CANVAS_TRANSFORM");
43
44     /**
45      * Rendering surface boundaries.
46      * 
47      * @see CanvasBoundsParticipant
48      */
49     public static final Key KEY_CONTROL_BOUNDS = new KeyOf(Rectangle2D.class, "CONTROL_BOUNDS");
50
51     /**
52      * Visible canvas boundaries.
53      * 
54      * @see CanvasBoundsParticipant
55      */
56     public static final Key KEY_CANVAS_BOUNDS = new KeyOf(Rectangle2D.class, "CANVAS_BOUNDS");
57
58     /** Background color - BackgroundPainter */
59     public static final Key KEY_BACKGROUND_COLOR = new KeyOf(Color.class, "BACKGROUND_COLOR");
60     public static final Key KEY_BACKGROUND_PAINT = new KeyOf(Paint.class, "BACKGROUND_PAINT");
61
62     /** The color of the grid */
63     public static final Key KEY_GRID_COLOR = new KeyOf(Color.class, "GRID_COLOR");
64
65     /** Parent canvas (in hierarchical canvas structure) */
66     public static final Key KEY_SUPER_CANVAS = new KeyOf(ICanvasContext.class, "SUPER_CANVAS");
67
68     /** Description of a page size for canvas or diagram. */
69     public static final Key KEY_PAGE_DESC = new KeyOf(PageDesc.class, "PAGE_DESC");
70
71     /** Indicate whether or not to display page bounds. */
72     public static final Key KEY_DISPLAY_PAGE = new KeyOf(Boolean.class, "DISPLAY_PAGE");
73
74     /** Indicate whether or not to display page margins. */
75     public static final Key KEY_DISPLAY_MARGINS = new KeyOf(Boolean.class, "DISPLAY_MARGINS");
76
77     /**
78      * A hint for disabling painting of the diagram the hint is associated with.
79      * Can also be used with a canvas context to signal that the nothing should
80      * be painted on the canvas.
81      */
82     public static final Key KEY_DISABLE_PAINTING = new KeyOf(Boolean.class, "DISABLE_PAINTING");
83
84     /**
85      * Used by {@link DragInteractor} during its {@link DragGestureRecognizer}
86      * initialization to get the allowed DND actions by the drag source. See
87      * {@link DnDConstants} for the values of which this value can ORed from.
88      */
89     public static final Key KEY_ALLOWED_DRAG_ACTIONS = new KeyOf(Integer.class, "ALLOWED_DRAG_ACTIONS");
90
91     /**
92      * Set to true when the canvas is rendering to a printer
93      */
94     public static final Key KEY_PRINT = new KeyOf(Boolean.class, "PRINTING");
95    
96     
97     private interface Dirty {}
98
99     /**
100      * The existence of this hint generically used to signal that something in
101      * the related observable has been modified that may cause it to be out of
102      * sync with its visual appearance which is represented by a scene graph.
103      * 
104      * @see #VALUE_DIRTY
105      * 
106      * @author Tuukka Lehtonen
107      */
108     public static final Key KEY_DIRTY = new KeyOf(Dirty.class, "DIRTY");
109
110     /**
111      * The value to use for indicating that the scene graph of an observable may be
112      * dirty and needs to be updated.
113      * 
114      * @see KEY_DIRTY
115      */
116     public static final Dirty VALUE_SG_DIRTY = new Dirty() {
117         @Override
118         public String toString() { return "SG_DIRTY"; }
119     };
120
121     /**
122      * The value to use for indicating that the scene graph of an observable
123      * should be updated after a delay. The delay is left up to the party
124      * tracking this hint value.
125      * 
126      * @see KEY_DIRTY
127      */
128     public static final Dirty VALUE_SG_DELAYED_UPDATE = new Dirty() {
129         @Override
130         public String toString() { return "SG_DELAYED_UPDATE"; }
131     };
132
133     /**
134      * The value to use for indicating that the z-order of diagram elements may
135      * have changed.
136      * 
137      * @see KEY_DIRTY
138      */
139     public static final Dirty VALUE_Z_ORDER_CHANGED = new Dirty() {
140         @Override
141         public String toString() { return "Z_ORDER_CHANGED"; }
142     };
143
144 }