]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/EdgeVisuals.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / EdgeVisuals.java
diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/EdgeVisuals.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/EdgeVisuals.java
new file mode 100644 (file)
index 0000000..8700405
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************\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.element.handler;\r
+\r
+import java.awt.Color;\r
+import java.awt.Shape;\r
+import java.awt.Stroke;\r
+import java.util.EnumSet;\r
+\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.impl.ConfigurableEdgeVisuals;\r
+import org.simantics.g2d.element.handler.impl.StaticEdgeVisuals;\r
+\r
+/**\r
+ * Edge visual properties\r
+ * \r
+ * @See {@link ConfigurableEdgeVisuals}\r
+ * @See {@link StaticEdgeVisuals}\r
+ * @author Toni Kalajainen\r
+ * \r
+ * TODO: configurable arrow shape\r
+ */\r
+public interface EdgeVisuals extends ElementHandler {\r
+\r
+    public static enum StrokeType { Absolute, Relative }\r
+\r
+    public static enum ArrowType { None, Stroke, Fill, Both }\r
+\r
+    public static interface Arrow {\r
+        ArrowType getType();\r
+        Color getStrokeColor();\r
+        Color getFillColor();\r
+        /**\r
+         * @return the renderable arrow shape described by this arrow type. The\r
+         *         returned shape is interpreted to be facing in the positive X\r
+         *         direction (right), with 0 degree rotation\r
+         */\r
+        Shape getShape();\r
+    }\r
+\r
+    public static enum EdgeEnd {\r
+        Begin, End;\r
+        public EdgeEnd other() {\r
+            return this == Begin ? End : Begin;\r
+        }\r
+    }\r
+\r
+    public static EnumSet<EdgeEnd> BEGIN = EnumSet.of(EdgeEnd.Begin);\r
+    public static EnumSet<EdgeEnd> END   = EnumSet.of(EdgeEnd.End);\r
+    public static EnumSet<EdgeEnd> BOTH  = EnumSet.allOf(EdgeEnd.class);\r
+\r
+    Stroke getStroke(IElement e);\r
+    void setStroke(IElement e, Stroke s);\r
+\r
+    StrokeType getStrokeType(IElement e);\r
+    void setStrokeType(IElement e, StrokeType t);\r
+\r
+    ArrowType getArrowType(IElement e, EdgeEnd end);\r
+    void setArrowType(IElement e, EdgeEnd end, ArrowType arrowType);\r
+\r
+    double getArrowSize(IElement e, EdgeEnd end);\r
+    void setArrowSize(IElement e, EdgeEnd end, double size);\r
+\r
+    // TODO: weight, transparency, corner rounds/rounding size\r
+\r
+}\r