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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.g2d.canvas;
\r
14 import java.awt.Color;
\r
15 import java.awt.Paint;
\r
16 import java.awt.dnd.DnDConstants;
\r
17 import java.awt.dnd.DragGestureRecognizer;
\r
18 import java.awt.geom.AffineTransform;
\r
19 import java.awt.geom.Rectangle2D;
\r
21 import org.simantics.g2d.canvas.impl.ToolMode;
\r
22 import org.simantics.g2d.dnd.DragInteractor;
\r
23 import org.simantics.g2d.participant.CanvasBoundsParticipant;
\r
24 import org.simantics.utils.datastructures.hints.IHintContext.Key;
\r
25 import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
\r
26 import org.simantics.utils.datastructures.hints.IHintContext.MouseSpecificKeyOf;
\r
27 import org.simantics.utils.page.PageDesc;
\r
30 * @author Toni Kalajainen
\r
32 public class Hints {
\r
34 public static final IToolMode POINTERTOOL = new ToolMode("PointerTool");
\r
35 public static final IToolMode PANTOOL = new ToolMode("PanTool");
\r
36 public static final IToolMode CONNECTTOOL = new ToolMode("ConnectTool");
\r
38 /** Selected Tool */
\r
39 public static final Key KEY_TOOL = new MouseSpecificKeyOf(0, IToolMode.class);
\r
41 /** Transform that converts point from canvas to control */
\r
42 public static final Key KEY_CANVAS_TRANSFORM = new KeyOf(AffineTransform.class, "CANVAS_TRANSFORM");
\r
45 * Rendering surface boundaries.
\r
47 * @see CanvasBoundsParticipant
\r
49 public static final Key KEY_CONTROL_BOUNDS = new KeyOf(Rectangle2D.class, "CONTROL_BOUNDS");
\r
52 * Visible canvas boundaries.
\r
54 * @see CanvasBoundsParticipant
\r
56 public static final Key KEY_CANVAS_BOUNDS = new KeyOf(Rectangle2D.class, "CANVAS_BOUNDS");
\r
58 /** Background color - BackgroundPainter */
\r
59 public static final Key KEY_BACKGROUND_COLOR = new KeyOf(Color.class, "BACKGROUND_COLOR");
\r
60 public static final Key KEY_BACKGROUND_PAINT = new KeyOf(Paint.class, "BACKGROUND_PAINT");
\r
62 /** The color of the grid */
\r
63 public static final Key KEY_GRID_COLOR = new KeyOf(Color.class, "GRID_COLOR");
\r
65 /** Parent canvas (in hierarchical canvas structure) */
\r
66 public static final Key KEY_SUPER_CANVAS = new KeyOf(ICanvasContext.class, "SUPER_CANVAS");
\r
68 /** Description of a page size for canvas or diagram. */
\r
69 public static final Key KEY_PAGE_DESC = new KeyOf(PageDesc.class, "PAGE_DESC");
\r
71 /** Indicate whether or not to display page bounds. */
\r
72 public static final Key KEY_DISPLAY_PAGE = new KeyOf(Boolean.class, "DISPLAY_PAGE");
\r
74 /** Indicate whether or not to display page margins. */
\r
75 public static final Key KEY_DISPLAY_MARGINS = new KeyOf(Boolean.class, "DISPLAY_MARGINS");
\r
78 * A hint for disabling painting of the diagram the hint is associated with.
\r
79 * Can also be used with a canvas context to signal that the nothing should
\r
80 * be painted on the canvas.
\r
82 public static final Key KEY_DISABLE_PAINTING = new KeyOf(Boolean.class, "DISABLE_PAINTING");
\r
85 * Used by {@link DragInteractor} during its {@link DragGestureRecognizer}
\r
86 * initialization to get the allowed DND actions by the drag source. See
\r
87 * {@link DnDConstants} for the values of which this value can ORed from.
\r
89 public static final Key KEY_ALLOWED_DRAG_ACTIONS = new KeyOf(Integer.class, "ALLOWED_DRAG_ACTIONS");
\r
92 * Set to true when the canvas is rendering to a printer
\r
94 public static final Key KEY_PRINT = new KeyOf(Boolean.class, "PRINTING");
\r
97 private interface Dirty {}
\r
100 * The existence of this hint generically used to signal that something in
\r
101 * the related observable has been modified that may cause it to be out of
\r
102 * sync with its visual appearance which is represented by a scene graph.
\r
104 * @see #VALUE_DIRTY
\r
106 * @author Tuukka Lehtonen
\r
108 public static final Key KEY_DIRTY = new KeyOf(Dirty.class, "DIRTY");
\r
111 * The value to use for indicating that the scene graph of an observable may be
\r
112 * dirty and needs to be updated.
\r
116 public static final Dirty VALUE_SG_DIRTY = new Dirty() {
\r
118 public String toString() { return "SG_DIRTY"; }
\r
122 * The value to use for indicating that the scene graph of an observable
\r
123 * should be updated after a delay. The delay is left up to the party
\r
124 * tracking this hint value.
\r
128 public static final Dirty VALUE_SG_DELAYED_UPDATE = new Dirty() {
\r
130 public String toString() { return "SG_DELAYED_UPDATE"; }
\r
134 * The value to use for indicating that the z-order of diagram elements may
\r
139 public static final Dirty VALUE_Z_ORDER_CHANGED = new Dirty() {
\r
141 public String toString() { return "Z_ORDER_CHANGED"; }
\r