]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/EdgeVisuals.java
Sync git svn branch with SVN repository r33324.
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / EdgeVisuals.java
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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.g2d.element.handler;\r
13 \r
14 import java.awt.Color;\r
15 import java.awt.Shape;\r
16 import java.awt.Stroke;\r
17 import java.util.EnumSet;\r
18 \r
19 import org.simantics.g2d.element.IElement;\r
20 import org.simantics.g2d.element.handler.impl.ConfigurableEdgeVisuals;\r
21 import org.simantics.g2d.element.handler.impl.StaticEdgeVisuals;\r
22 \r
23 /**\r
24  * Edge visual properties\r
25  * \r
26  * @See {@link ConfigurableEdgeVisuals}\r
27  * @See {@link StaticEdgeVisuals}\r
28  * @author Toni Kalajainen\r
29  * \r
30  * TODO: configurable arrow shape\r
31  */\r
32 public interface EdgeVisuals extends ElementHandler {\r
33 \r
34     public static enum StrokeType { Absolute, Relative }\r
35 \r
36     public static enum ArrowType { None, Stroke, Fill, Both }\r
37 \r
38     public static interface Arrow {\r
39         ArrowType getType();\r
40         Color getStrokeColor();\r
41         Color getFillColor();\r
42         /**\r
43          * @return the renderable arrow shape described by this arrow type. The\r
44          *         returned shape is interpreted to be facing in the positive X\r
45          *         direction (right), with 0 degree rotation\r
46          */\r
47         Shape getShape();\r
48     }\r
49 \r
50     public static enum EdgeEnd {\r
51         Begin, End;\r
52         public EdgeEnd other() {\r
53             return this == Begin ? End : Begin;\r
54         }\r
55     }\r
56 \r
57     public static EnumSet<EdgeEnd> BEGIN = EnumSet.of(EdgeEnd.Begin);\r
58     public static EnumSet<EdgeEnd> END   = EnumSet.of(EdgeEnd.End);\r
59     public static EnumSet<EdgeEnd> BOTH  = EnumSet.allOf(EdgeEnd.class);\r
60 \r
61     Stroke getStroke(IElement e);\r
62     void setStroke(IElement e, Stroke s);\r
63 \r
64     StrokeType getStrokeType(IElement e);\r
65     void setStrokeType(IElement e, StrokeType t);\r
66 \r
67     ArrowType getArrowType(IElement e, EdgeEnd end);\r
68     void setArrowType(IElement e, EdgeEnd end, ArrowType arrowType);\r
69 \r
70     double getArrowSize(IElement e, EdgeEnd end);\r
71     void setArrowSize(IElement e, EdgeEnd end, double size);\r
72 \r
73     // TODO: weight, transparency, corner rounds/rounding size\r
74 \r
75 }\r