]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/canvas/Hints.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / canvas / Hints.java
diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/canvas/Hints.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/canvas/Hints.java
new file mode 100644 (file)
index 0000000..bf04939
--- /dev/null
@@ -0,0 +1,144 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.g2d.canvas;\r
+\r
+import java.awt.Color;\r
+import java.awt.Paint;\r
+import java.awt.dnd.DnDConstants;\r
+import java.awt.dnd.DragGestureRecognizer;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.g2d.canvas.impl.ToolMode;\r
+import org.simantics.g2d.dnd.DragInteractor;\r
+import org.simantics.g2d.participant.CanvasBoundsParticipant;\r
+import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
+import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;\r
+import org.simantics.utils.datastructures.hints.IHintContext.MouseSpecificKeyOf;\r
+import org.simantics.utils.page.PageDesc;\r
+\r
+/**\r
+ * @author Toni Kalajainen\r
+ */\r
+public class Hints {\r
+\r
+    public static final IToolMode POINTERTOOL              = new ToolMode("PointerTool");\r
+    public static final IToolMode PANTOOL                  = new ToolMode("PanTool");\r
+    public static final IToolMode CONNECTTOOL              = new ToolMode("ConnectTool");\r
+\r
+    /** Selected Tool */\r
+    public static final Key KEY_TOOL = new MouseSpecificKeyOf(0, IToolMode.class);\r
+\r
+    /** Transform that converts point from canvas to control */\r
+    public static final Key KEY_CANVAS_TRANSFORM = new KeyOf(AffineTransform.class, "CANVAS_TRANSFORM");\r
+\r
+    /**\r
+     * Rendering surface boundaries.\r
+     * \r
+     * @see CanvasBoundsParticipant\r
+     */\r
+    public static final Key KEY_CONTROL_BOUNDS = new KeyOf(Rectangle2D.class, "CONTROL_BOUNDS");\r
+\r
+    /**\r
+     * Visible canvas boundaries.\r
+     * \r
+     * @see CanvasBoundsParticipant\r
+     */\r
+    public static final Key KEY_CANVAS_BOUNDS = new KeyOf(Rectangle2D.class, "CANVAS_BOUNDS");\r
+\r
+    /** Background color - BackgroundPainter */\r
+    public static final Key KEY_BACKGROUND_COLOR = new KeyOf(Color.class, "BACKGROUND_COLOR");\r
+    public static final Key KEY_BACKGROUND_PAINT = new KeyOf(Paint.class, "BACKGROUND_PAINT");\r
+\r
+    /** The color of the grid */\r
+    public static final Key KEY_GRID_COLOR = new KeyOf(Color.class, "GRID_COLOR");\r
+\r
+    /** Parent canvas (in hierarchical canvas structure) */\r
+    public static final Key KEY_SUPER_CANVAS = new KeyOf(ICanvasContext.class, "SUPER_CANVAS");\r
+\r
+    /** Description of a page size for canvas or diagram. */\r
+    public static final Key KEY_PAGE_DESC = new KeyOf(PageDesc.class, "PAGE_DESC");\r
+\r
+    /** Indicate whether or not to display page bounds. */\r
+    public static final Key KEY_DISPLAY_PAGE = new KeyOf(Boolean.class, "DISPLAY_PAGE");\r
+\r
+    /** Indicate whether or not to display page margins. */\r
+    public static final Key KEY_DISPLAY_MARGINS = new KeyOf(Boolean.class, "DISPLAY_MARGINS");\r
+\r
+    /**\r
+     * A hint for disabling painting of the diagram the hint is associated with.\r
+     * Can also be used with a canvas context to signal that the nothing should\r
+     * be painted on the canvas.\r
+     */\r
+    public static final Key KEY_DISABLE_PAINTING = new KeyOf(Boolean.class, "DISABLE_PAINTING");\r
+\r
+    /**\r
+     * Used by {@link DragInteractor} during its {@link DragGestureRecognizer}\r
+     * initialization to get the allowed DND actions by the drag source. See\r
+     * {@link DnDConstants} for the values of which this value can ORed from.\r
+     */\r
+    public static final Key KEY_ALLOWED_DRAG_ACTIONS = new KeyOf(Integer.class, "ALLOWED_DRAG_ACTIONS");\r
+\r
+    /**\r
+     * Set to true when the canvas is rendering to a printer\r
+     */\r
+    public static final Key KEY_PRINT = new KeyOf(Boolean.class, "PRINTING");\r
+   \r
+    \r
+    private interface Dirty {}\r
+\r
+    /**\r
+     * The existence of this hint generically used to signal that something in\r
+     * the related observable has been modified that may cause it to be out of\r
+     * sync with its visual appearance which is represented by a scene graph.\r
+     * \r
+     * @see #VALUE_DIRTY\r
+     * \r
+     * @author Tuukka Lehtonen\r
+     */\r
+    public static final Key KEY_DIRTY = new KeyOf(Dirty.class, "DIRTY");\r
+\r
+    /**\r
+     * The value to use for indicating that the scene graph of an observable may be\r
+     * dirty and needs to be updated.\r
+     * \r
+     * @see KEY_DIRTY\r
+     */\r
+    public static final Dirty VALUE_SG_DIRTY = new Dirty() {\r
+        @Override\r
+        public String toString() { return "SG_DIRTY"; }\r
+    };\r
+\r
+    /**\r
+     * The value to use for indicating that the scene graph of an observable\r
+     * should be updated after a delay. The delay is left up to the party\r
+     * tracking this hint value.\r
+     * \r
+     * @see KEY_DIRTY\r
+     */\r
+    public static final Dirty VALUE_SG_DELAYED_UPDATE = new Dirty() {\r
+        @Override\r
+        public String toString() { return "SG_DELAYED_UPDATE"; }\r
+    };\r
+\r
+    /**\r
+     * The value to use for indicating that the z-order of diagram elements may\r
+     * have changed.\r
+     * \r
+     * @see KEY_DIRTY\r
+     */\r
+    public static final Dirty VALUE_Z_ORDER_CHANGED = new Dirty() {\r
+        @Override\r
+        public String toString() { return "Z_ORDER_CHANGED"; }\r
+    };\r
+\r
+}\r