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.g2d.canvas;
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;
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;
30 * @author Toni Kalajainen
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");
39 public static final Key KEY_TOOL = new MouseSpecificKeyOf(0, IToolMode.class);
41 /** Transform that converts point from canvas to control */
42 public static final Key KEY_CANVAS_TRANSFORM = new KeyOf(AffineTransform.class, "CANVAS_TRANSFORM");
45 * Rendering surface boundaries.
47 * @see CanvasBoundsParticipant
49 public static final Key KEY_CONTROL_BOUNDS = new KeyOf(Rectangle2D.class, "CONTROL_BOUNDS");
52 * Visible canvas boundaries.
54 * @see CanvasBoundsParticipant
56 public static final Key KEY_CANVAS_BOUNDS = new KeyOf(Rectangle2D.class, "CANVAS_BOUNDS");
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");
62 /** The color of the grid */
63 public static final Key KEY_GRID_COLOR = new KeyOf(Color.class, "GRID_COLOR");
65 /** Parent canvas (in hierarchical canvas structure) */
66 public static final Key KEY_SUPER_CANVAS = new KeyOf(ICanvasContext.class, "SUPER_CANVAS");
68 /** Description of a page size for canvas or diagram. */
69 public static final Key KEY_PAGE_DESC = new KeyOf(PageDesc.class, "PAGE_DESC");
71 /** Indicate whether or not to display page bounds. */
72 public static final Key KEY_DISPLAY_PAGE = new KeyOf(Boolean.class, "DISPLAY_PAGE");
74 /** Indicate whether or not to display page margins. */
75 public static final Key KEY_DISPLAY_MARGINS = new KeyOf(Boolean.class, "DISPLAY_MARGINS");
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.
82 public static final Key KEY_DISABLE_PAINTING = new KeyOf(Boolean.class, "DISABLE_PAINTING");
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.
89 public static final Key KEY_ALLOWED_DRAG_ACTIONS = new KeyOf(Integer.class, "ALLOWED_DRAG_ACTIONS");
92 * Set to true when the canvas is rendering to a printer
94 public static final Key KEY_PRINT = new KeyOf(Boolean.class, "PRINTING");
97 * Set this hint to <code>true</code> to prevent any modifications from
98 * being made to the diagram model by the diagram loading logic. Using this
99 * may be necessary for printing.
101 public static final Key KEY_DISABLE_GRAPH_MODIFICATIONS = new KeyOf(Boolean.class, "DISABLE_GRAPH_MODIFICATIONS");
103 private interface Dirty {}
106 * The existence of this hint generically used to signal that something in
107 * the related observable has been modified that may cause it to be out of
108 * sync with its visual appearance which is represented by a scene graph.
112 * @author Tuukka Lehtonen
114 public static final Key KEY_DIRTY = new KeyOf(Dirty.class, "DIRTY");
117 * The value to use for indicating that the scene graph of an observable may be
118 * dirty and needs to be updated.
122 public static final Dirty VALUE_SG_DIRTY = new Dirty() {
124 public String toString() { return "SG_DIRTY"; }
128 * The value to use for indicating that the scene graph of an observable
129 * should be updated after a delay. The delay is left up to the party
130 * tracking this hint value.
134 public static final Dirty VALUE_SG_DELAYED_UPDATE = new Dirty() {
136 public String toString() { return "SG_DELAYED_UPDATE"; }
140 * The value to use for indicating that the z-order of diagram elements may
145 public static final Dirty VALUE_Z_ORDER_CHANGED = new Dirty() {
147 public String toString() { return "Z_ORDER_CHANGED"; }