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