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