1
14 package demo.view.flowchart.painters;
15
16
17 import y.view.GenericNodeRealizer;
18 import y.view.NodeRealizer;
19
20 import java.awt.geom.GeneralPath;
21
22
25 public class FlowchartDirectDataPainter extends AbstractFlowchartPainter {
26
27 public FlowchartDirectDataPainter() {
28 super();
29 this.outline = new GeneralPath();
30 this.innerShape = new GeneralPath();
31 }
32
33
34 protected void updateOutline(NodeRealizer context) {
35
36 GeneralPath shapePath = (GeneralPath) getOutline();
37 shapePath.reset();
38
39 double height = context.getHeight();
40 double width = context.getWidth();
41 double x = context.getX();
42 double y = context.getY();
43 double capRadiusHighDependency;
44
45 GenericNodeRealizer cast_gnr = (GenericNodeRealizer) context;
46 if (cast_gnr.getStyleProperty(PROPERTY_RADIUS) != null) {
47 capRadiusHighDependency = ((Double) cast_gnr.getStyleProperty(PROPERTY_RADIUS)).doubleValue();
48 capRadiusHighDependency = Math.min(capRadiusHighDependency, 0.5);
49 } else {
50 capRadiusHighDependency = FLOWCHART_DEFAULT_DIRECT_DATA_RADIUS;
51 }
52 double borderDistance = capRadiusHighDependency * Math.min(width, height);
53
54 shapePath.moveTo((float)(x + borderDistance), (float)y);
55 shapePath.lineTo((float)(x + width - borderDistance), (float)y);
56 shapePath.quadTo((float)(x + width + borderDistance), (float)(y + height / 2), (float)(x + width - borderDistance), (float)(y + height));
57 shapePath.lineTo((float)(x + borderDistance), (float)(y + height));
58 shapePath.quadTo((float)(x - borderDistance), (float)(y + height / 2), (float)(x + borderDistance), (float)y);
59 shapePath.closePath();
60 }
61
62 protected void updateInsideShape(NodeRealizer context) {
63 GeneralPath shapePath = (GeneralPath) getInnerShape();
64 shapePath.reset();
65 double height = context.getHeight();
66 double width = context.getWidth();
67 double capRadiusHighDependency;
68 GenericNodeRealizer cast_gnr = (GenericNodeRealizer) context;
69 if (cast_gnr.getStyleProperty(PROPERTY_RADIUS) != null) {
70 capRadiusHighDependency = ((Double) cast_gnr.getStyleProperty(PROPERTY_RADIUS)).doubleValue();
71 capRadiusHighDependency = Math.min(capRadiusHighDependency, 0.5);
72 } else {
73 capRadiusHighDependency = FLOWCHART_DEFAULT_DIRECT_DATA_RADIUS;
74 }
75 double borderDistance = capRadiusHighDependency * Math.min(width, height);
76 double x = context.getX();
77 double y = context.getY();
78 shapePath.moveTo((float)(x + width - borderDistance), (float)y);
79 shapePath.quadTo((float)(x + width - 3 * borderDistance), (float)(y + height / 2), (float)(x + width - borderDistance), (float)(y + height));
80 }
81
82 }