]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
90da81ed9893f5c84ca57674893419da998b37a5
[simantics/sysdyn.git] /
1 package org.simantics.sysdyn.ui.elements2.connections;\r
2 \r
3 import java.awt.Color;\r
4 import java.awt.Graphics2D;\r
5 import java.awt.Stroke;\r
6 import java.awt.geom.Path2D;\r
7 \r
8 import org.simantics.diagram.connection.rendering.BasicConnectionStyle;\r
9 \r
10 public class FlowConnectionStyle  extends BasicConnectionStyle {\r
11 \r
12     private static final long serialVersionUID = 2777194644079591357L;\r
13 \r
14     Color                     lineColor;\r
15     Stroke                    lineStroke;\r
16 \r
17     public FlowConnectionStyle(Color lineColor, Stroke lineStroke) {\r
18         super(lineColor, Color.BLACK, 0.5, lineStroke, lineStroke, 0.8);\r
19         this.lineColor = lineColor;\r
20         this.lineStroke = lineStroke;\r
21     }\r
22     \r
23     @Override\r
24     public void drawBranchPoint(Graphics2D g, double x, double y) {\r
25     }\r
26 \r
27     @Override\r
28     public void drawLine(Graphics2D g, double x1, double y1, double x2, double y2, boolean isTransient) {\r
29         System.out.println("DrawLine");\r
30     }\r
31 \r
32     @Override\r
33     public void drawPath(Graphics2D g, Path2D path, boolean isTransient) {\r
34         if (lineColor != null)\r
35             g.setColor(lineColor);\r
36         if (lineStroke != null)\r
37             g.setStroke(lineStroke);\r
38 \r
39         Path2D p1 = Flows.createOffsetPath(path, 1);\r
40         Path2D p2 = Flows.createOffsetPath(path, -1);\r
41         p1.append(p2, false);\r
42         g.draw(p1);\r
43     }\r
44 \r
45     @Override\r
46     public void drawDegeneratedLine(Graphics2D g, double x, double y, boolean isHorizontal, boolean isTransient) {\r
47     }\r
48 \r
49     @Override\r
50     public double getDegeneratedLineLength() {\r
51         return 0;\r
52     }\r
53     \r
54 }\r