-/*******************************************************************************\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.diagram.connection;\r
-\r
-import java.awt.Color;\r
-import java.awt.Stroke;\r
-import java.util.Arrays;\r
-\r
-import org.simantics.g2d.element.handler.EdgeVisuals.StrokeType;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class ConnectionVisuals {\r
-\r
- public final float[] color;\r
- public final StrokeType strokeType;\r
- public final Stroke stroke;\r
-\r
- public ConnectionVisuals(float[] color, StrokeType strokeType, Stroke stroke) {\r
- if (color != null && color.length < 3)\r
- throw new IllegalArgumentException("colors must have at least 3 components (rgb), got " + color.length);\r
- this.color = color;\r
- this.strokeType = strokeType;\r
- this.stroke = stroke;\r
- }\r
-\r
- public Color toColor() {\r
- if (color == null)\r
- return null;\r
- if (color.length == 3)\r
- return new Color(color[2], color[1], color[0]);\r
- return new Color(color[2], color[1], color[0], color[3]);\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- final int prime = 31;\r
- int result = 1;\r
- result = prime * result + Arrays.hashCode(color);\r
- result = prime * result + ((stroke == null) ? 0 : stroke.hashCode());\r
- result = prime * result + ((strokeType == null) ? 0 : strokeType.hashCode());\r
- return result;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (this == obj)\r
- return true;\r
- if (obj == null)\r
- return false;\r
- if (!(obj instanceof ConnectionVisuals))\r
- return false;\r
- ConnectionVisuals other = (ConnectionVisuals) obj;\r
- if (!Arrays.equals(color, other.color))\r
- return false;\r
- if (stroke == null) {\r
- if (other.stroke != null)\r
- return false;\r
- } else if (!stroke.equals(other.stroke))\r
- return false;\r
- if (strokeType == null) {\r
- if (other.strokeType != null)\r
- return false;\r
- } else if (!strokeType.equals(other.strokeType))\r
- return false;\r
- return true;\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.diagram.connection;
+
+import java.awt.Color;
+import java.awt.Stroke;
+import java.util.Arrays;
+
+import org.simantics.g2d.element.handler.EdgeVisuals.StrokeType;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class ConnectionVisuals {
+
+ public final float[] color;
+ public final StrokeType strokeType;
+ public final Stroke stroke;
+ public final Double branchPointRadius;
+ public final Double rounding;
+
+ public ConnectionVisuals(float[] color, StrokeType strokeType, Stroke stroke, Double rounding) {
+ this(color, strokeType, stroke, null, rounding);
+ }
+
+ public ConnectionVisuals(float[] color, StrokeType strokeType, Stroke stroke, Double branchPointRadius, Double rounding) {
+ if (color != null && color.length < 3)
+ throw new IllegalArgumentException("colors must have at least 3 components (rgb), got " + color.length);
+ this.color = color;
+ this.strokeType = strokeType;
+ this.stroke = stroke;
+ this.branchPointRadius = branchPointRadius;
+ this.rounding = rounding;
+ }
+
+ public Color toColor() {
+ if (color == null)
+ return null;
+ if (color.length == 3)
+ return new Color(color[2], color[1], color[0]);
+ return new Color(color[2], color[1], color[0], color[3]);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((branchPointRadius == null) ? 0 : branchPointRadius.hashCode());
+ result = prime * result + Arrays.hashCode(color);
+ result = prime * result + ((rounding == null) ? 0 : rounding.hashCode());
+ result = prime * result + ((stroke == null) ? 0 : stroke.hashCode());
+ result = prime * result + ((strokeType == null) ? 0 : strokeType.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ConnectionVisuals other = (ConnectionVisuals) obj;
+ if (branchPointRadius == null) {
+ if (other.branchPointRadius != null)
+ return false;
+ } else if (!branchPointRadius.equals(other.branchPointRadius))
+ return false;
+ if (!Arrays.equals(color, other.color))
+ return false;
+ if (rounding == null) {
+ if (other.rounding != null)
+ return false;
+ } else if (!rounding.equals(other.rounding))
+ return false;
+ if (stroke == null) {
+ if (other.stroke != null)
+ return false;
+ } else if (!stroke.equals(other.stroke))
+ return false;
+ if (strokeType != other.strokeType)
+ return false;
+ return true;
+ }
+}