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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.g2d.element.handler.impl;
\r
14 import java.awt.Stroke;
\r
16 import org.simantics.g2d.element.IElement;
\r
17 import org.simantics.g2d.element.handler.EdgeVisuals;
\r
20 * Edge visuals that are the same for all edges of the class.
\r
22 * @author Toni Kalajainen
\r
24 public class StaticEdgeVisuals implements EdgeVisuals {
\r
26 private static final long serialVersionUID = -2263869759801224096L;
\r
28 public static final StaticEdgeVisuals DEFAULT_EDGE_VISUALS =
\r
29 new StaticEdgeVisuals(ArrowType.None, ArrowType.Stroke, ConfigurableEdgeVisuals.DEFAULT_STROKE, 3.0, 3.0);
\r
31 ArrowType beginArrow, endArrow;
\r
33 StrokeType strokeType;
\r
34 double beginArrowSize, endArrowSize;
\r
36 public StaticEdgeVisuals(ArrowType beginArrow, ArrowType endArrow, Stroke stroke, double beginArrowSize, double endArrowSize)
\r
38 this.beginArrow = beginArrow;
\r
39 this.endArrow = endArrow;
\r
40 this.stroke = stroke;
\r
41 this.strokeType = StrokeType.Relative;
\r
42 this.beginArrowSize = beginArrowSize;
\r
43 this.endArrowSize = endArrowSize;
\r
47 public ArrowType getArrowType(IElement e, EdgeEnd end) {
\r
48 if (end==EdgeEnd.Begin)
\r
50 if (end==EdgeEnd.End)
\r
52 throw new RuntimeException();
\r
56 public StrokeType getStrokeType(IElement e) {
\r
61 public Stroke getStroke(IElement e) {
\r
66 public void setArrowType(IElement e, EdgeEnd end, ArrowType arrowType) {
\r
67 throw new RuntimeException("Cannot modify static edge visuals");
\r
71 public void setStroke(IElement e, Stroke s) {
\r
72 throw new RuntimeException("Cannot modify static edge visuals");
\r
76 public void setStrokeType(IElement e, StrokeType t) {
\r
77 throw new RuntimeException("Cannot modify static edge visuals");
\r
81 public double getArrowSize(IElement e, EdgeEnd end) {
\r
82 if (end == EdgeEnd.Begin)
\r
83 return beginArrowSize;
\r
84 if (end==EdgeEnd.End)
\r
85 return endArrowSize;
\r
90 public void setArrowSize(IElement e, EdgeEnd end, double size) {
\r
91 throw new RuntimeException("Cannot modify arrow size");
\r