--- /dev/null
+/*******************************************************************************\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.impl;\r
+\r
+import java.awt.Stroke;\r
+\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.EdgeVisuals;\r
+\r
+/**\r
+ * Edge visuals that are the same for all edges of the class.\r
+ * \r
+ * @author Toni Kalajainen\r
+ */\r
+public class StaticEdgeVisuals implements EdgeVisuals {\r
+\r
+ private static final long serialVersionUID = -2263869759801224096L;\r
+\r
+ public static final StaticEdgeVisuals DEFAULT_EDGE_VISUALS =\r
+ new StaticEdgeVisuals(ArrowType.None, ArrowType.Stroke, ConfigurableEdgeVisuals.DEFAULT_STROKE, 3.0, 3.0);\r
+\r
+ ArrowType beginArrow, endArrow;\r
+ Stroke stroke;\r
+ StrokeType strokeType;\r
+ double beginArrowSize, endArrowSize;\r
+\r
+ public StaticEdgeVisuals(ArrowType beginArrow, ArrowType endArrow, Stroke stroke, double beginArrowSize, double endArrowSize)\r
+ {\r
+ this.beginArrow = beginArrow;\r
+ this.endArrow = endArrow;\r
+ this.stroke = stroke;\r
+ this.strokeType = StrokeType.Relative;\r
+ this.beginArrowSize = beginArrowSize;\r
+ this.endArrowSize = endArrowSize;\r
+ }\r
+\r
+ @Override\r
+ public ArrowType getArrowType(IElement e, EdgeEnd end) {\r
+ if (end==EdgeEnd.Begin)\r
+ return beginArrow;\r
+ if (end==EdgeEnd.End)\r
+ return beginArrow;\r
+ throw new RuntimeException();\r
+ }\r
+\r
+ @Override\r
+ public StrokeType getStrokeType(IElement e) {\r
+ return strokeType;\r
+ }\r
+\r
+ @Override\r
+ public Stroke getStroke(IElement e) {\r
+ return stroke;\r
+ }\r
+\r
+ @Override\r
+ public void setArrowType(IElement e, EdgeEnd end, ArrowType arrowType) {\r
+ throw new RuntimeException("Cannot modify static edge visuals");\r
+ }\r
+\r
+ @Override\r
+ public void setStroke(IElement e, Stroke s) {\r
+ throw new RuntimeException("Cannot modify static edge visuals");\r
+ }\r
+\r
+ @Override\r
+ public void setStrokeType(IElement e, StrokeType t) {\r
+ throw new RuntimeException("Cannot modify static edge visuals");\r
+ }\r
+\r
+ @Override\r
+ public double getArrowSize(IElement e, EdgeEnd end) {\r
+ if (end == EdgeEnd.Begin)\r
+ return beginArrowSize;\r
+ if (end==EdgeEnd.End)\r
+ return endArrowSize;\r
+ return 0;\r
+ }\r
+\r
+ @Override\r
+ public void setArrowSize(IElement e, EdgeEnd end, double size) {\r
+ throw new RuntimeException("Cannot modify arrow size");\r
+ }\r
+\r
+\r
+}\r