]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/IG2DNode.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scenegraph / src / org / simantics / scenegraph / g2d / IG2DNode.java
diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/IG2DNode.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/IG2DNode.java
new file mode 100644 (file)
index 0000000..4e816c0
--- /dev/null
@@ -0,0 +1,157 @@
+/*******************************************************************************\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.scenegraph.g2d;\r
+\r
+import java.awt.Composite;\r
+import java.awt.Graphics2D;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Point2D;\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.scenegraph.INode;\r
+import org.simantics.scenegraph.g2d.events.IEventHandler;\r
+\r
+/**\r
+ * \r
+ * \r
+ * @author Tuukka Lehtonen\r
+ */\r
+public interface IG2DNode extends INode, IEventHandler {\r
+\r
+    /**\r
+     * Set the z-index, i.e. the rendering order number for this 2D node.\r
+     * 2D nodes are sorted in ascending z-order for rendering.\r
+     * \r
+     * @param z\r
+     */\r
+    @SyncField("z")\r
+    public void setZIndex(int z);\r
+\r
+    /**\r
+     * @return the rendering order of this 2D node.\r
+     */\r
+    public int getZIndex();\r
+\r
+    /**\r
+     * @return <code>false</code> if this node will not render anything if\r
+     *         {@link #render(Graphics2D)} was invoked. Serves as a means to\r
+     *         optimize rendering. Should always return <code>true</code> by\r
+     *         default.\r
+     */\r
+    public boolean validate();\r
+\r
+    /**\r
+     * Perform the actual rendering. Node state changes should be avoided in\r
+     * this method. This method should not change the transform of the g2d\r
+     * instance. You should call g2d.create or copy the original transform and\r
+     * put it back at the end of this method according to what is specified in\r
+     * {@link Graphics2D#setTransform(AffineTransform)}.\r
+     * \r
+     * This method is always invoked so that the local transform of this\r
+     * {@link IG2DNode} has not been applied to the Graphics2D rendering\r
+     * context. It is this node's responsibility to apply its own transform\r
+     * during rendering if necessary.\r
+     * \r
+     * The method must also make sure that it returns the {@link Composite} of\r
+     * g2d to its original state using (see {@link Graphics2D#setComposite(Composite)).\r
+     * \r
+     * @param g2d\r
+     * \r
+     * @see #setTransform(AffineTransform)\r
+     * @see #getTransform()\r
+     */\r
+    public void render(Graphics2D g2d);\r
+\r
+    /**\r
+     * Mark the scene graph to be repainted in its current rendering context (UI\r
+     * component) as soon as is appropriate for the backend system.\r
+     */\r
+    public void repaint();\r
+\r
+    // Bounds and transformation\r
+\r
+    /**\r
+     * @return affine transformation set for this node to transform it into its\r
+     *         parent's coordinate space\r
+     */\r
+    public AffineTransform getTransform();\r
+\r
+    /**\r
+     * Set an affine transformation for this node that transforms its local\r
+     * coordinates into its parent's coordinate space\r
+     * \r
+     * @param transform local &rarr; parent transform\r
+     */\r
+    public void setTransform(AffineTransform transform);\r
+\r
+    /**\r
+     * Return bounds transformed with local transformation\r
+     * \r
+     * @return transformed bounds\r
+     */\r
+    public Rectangle2D getBounds();\r
+\r
+    /**\r
+     * Return bounds in local coordinates. May expose internal state of the\r
+     * node. The client is not allowed to modify the returned value.\r
+     * \r
+     * @return bounds\r
+     */\r
+    public Rectangle2D getBoundsInLocal();\r
+\r
+    public Rectangle2D getBoundsInLocal(boolean ignoreNulls);\r
+\r
+    // Helper methods for bounds checking\r
+\r
+    public boolean contains(Point2D point);\r
+\r
+    public boolean intersects(Rectangle2D rect);\r
+\r
+    public Point2D localToParent(Point2D point);\r
+\r
+    public Rectangle2D localToParent(Rectangle2D rect);\r
+\r
+    public Point2D parentToLocal(Point2D point);\r
+\r
+    public Rectangle2D parentToLocal(Rectangle2D rect);\r
+\r
+    public Point2D localToControl(Point2D point);\r
+\r
+    public Rectangle2D localToControl(Rectangle2D rect);\r
+\r
+    public Point2D controlToLocal(Point2D point);\r
+\r
+    public Rectangle2D controlToLocal(Rectangle2D rect);\r
+\r
+    /**\r
+     * @return root node of the 2D scene graph or <code>null</code> if this node is\r
+     *         not part of a properly rooted scene graph hierarchy\r
+     */\r
+    public G2DSceneGraph getRootNode2D();\r
+\r
+    /**\r
+     * @return true if this node has focus in the owner scene graph\r
+     */\r
+    public boolean hasFocus();\r
+\r
+    /**\r
+     * @return the node that has focus in the owner scene graph\r
+     */\r
+    public IG2DNode getFocusNode();\r
+\r
+    /**\r
+     * @param node the node to have focus in the owner scene graph. The\r
+     *        specified node must be a part of the same scene graph.\r
+     */\r
+    public void setFocusNode(IG2DNode node);\r
+\r
+}\r