--- /dev/null
+/*******************************************************************************\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