-/*******************************************************************************\r
- * Copyright (c) 2011 Association for Decentralized Information Management in\r
- * 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.rendering;\r
-\r
-import java.awt.BasicStroke;\r
-import java.awt.Color;\r
-import java.awt.Graphics2D;\r
-import java.awt.geom.Ellipse2D;\r
-import java.awt.geom.Line2D;\r
-import java.awt.geom.Path2D;\r
-import java.io.Serializable;\r
-\r
-public class ExampleConnectionStyle implements ConnectionStyle, Serializable {\r
-\r
- private static final long serialVersionUID = -5799681720482456895L;\r
-\r
- public final static BasicStroke SOLID = \r
- new BasicStroke(1f); \r
- \r
- public final static BasicStroke BOLD = \r
- new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL); \r
- \r
- @Override\r
- public void drawLine(Graphics2D g, double x1, double y1, double x2,\r
- double y2, boolean isTransient) {\r
- g.setColor(Color.BLACK);\r
- if(isTransient)\r
- g.draw(new Line2D.Double(x1, y1, x2, y2));\r
- else {\r
- g.setStroke(BOLD);\r
- g.draw(new Line2D.Double(x1, y1, x2, y2));\r
- g.setStroke(SOLID);\r
- }\r
- }\r
-\r
- @Override\r
- public void drawPath(Graphics2D g, Path2D path, boolean isTransient) {\r
- g.setColor(Color.BLACK);\r
- if(isTransient)\r
- g.draw(path);\r
- else {\r
- g.setStroke(BOLD);\r
- g.draw(path);\r
- g.setStroke(SOLID);\r
- }\r
- }\r
-\r
- @Override\r
- public void drawBranchPoint(Graphics2D g, double x, double y) {\r
- g.setColor(Color.BLACK);\r
- g.fill(new Ellipse2D.Double(x-3, y-3, 6, 6)); \r
- }\r
-\r
- @Override\r
- public void drawDegeneratedLine(Graphics2D g, double x, double y,\r
- boolean isHorizontal, boolean isTransient) {\r
- double d = getDegeneratedLineLength()*0.5;\r
- if(isHorizontal)\r
- g.draw(new Line2D.Double(x-d, y, x+d, y));\r
- else\r
- g.draw(new Line2D.Double(x, y-d, x, y+d));\r
- }\r
-\r
- @Override\r
- public double getDegeneratedLineLength() {\r
- return 8.0;\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2011 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.rendering;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Path2D;
+import java.io.Serializable;
+
+public class ExampleConnectionStyle implements ConnectionStyle, Serializable {
+
+ private static final long serialVersionUID = -5799681720482456895L;
+
+ public final static BasicStroke SOLID =
+ new BasicStroke(1f);
+
+ public final static BasicStroke BOLD =
+ new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
+
+ @Override
+ public void drawLine(Graphics2D g, double x1, double y1, double x2,
+ double y2, boolean isTransient) {
+ g.setColor(Color.BLACK);
+ if(isTransient)
+ g.draw(new Line2D.Double(x1, y1, x2, y2));
+ else {
+ g.setStroke(BOLD);
+ g.draw(new Line2D.Double(x1, y1, x2, y2));
+ g.setStroke(SOLID);
+ }
+ }
+
+ @Override
+ public void drawPath(Graphics2D g, Path2D path, boolean isTransient) {
+ g.setColor(Color.BLACK);
+ if(isTransient)
+ g.draw(path);
+ else {
+ g.setStroke(BOLD);
+ g.draw(path);
+ g.setStroke(SOLID);
+ }
+ }
+
+ @Override
+ public void drawBranchPoint(Graphics2D g, double x, double y) {
+ g.setColor(Color.BLACK);
+ g.fill(new Ellipse2D.Double(x-3, y-3, 6, 6));
+ }
+
+ @Override
+ public void drawDegeneratedLine(Graphics2D g, double x, double y,
+ boolean isHorizontal, boolean isTransient) {
+ double d = getDegeneratedLineLength()*0.5;
+ if(isHorizontal)
+ g.draw(new Line2D.Double(x-d, y, x+d, y));
+ else
+ g.draw(new Line2D.Double(x, y-d, x, y+d));
+ }
+
+ @Override
+ public double getDegeneratedLineLength() {
+ return 8.0;
+ }
+
+}