1
14 package demo.view.flowchart.painters;
15
16 import y.view.NodeRealizer;
17 import y.view.GenericNodeRealizer;
18
19 import java.awt.geom.GeneralPath;
20
21
24 public class FlowchartDisplayPainter extends AbstractFlowchartPainter{
25
26
27
28 public FlowchartDisplayPainter() {
29 super();
30 outline = new GeneralPath();
31 }
32
33 protected void updateOutline(NodeRealizer context) {
34
35 GeneralPath shapePath = (GeneralPath) getOutline();
36 shapePath.reset();
37
38 double x = context.getX();
39 double y = context.getY();
40 double width = context.getWidth();
41 double height = context.getHeight();
42 double capRadiusHighDependency;
43 GenericNodeRealizer cast_gnr = (GenericNodeRealizer) context;
44 if (cast_gnr.getStyleProperty(PROPERTY_RADIUS) != null) {
45 capRadiusHighDependency = ((Double) cast_gnr.getStyleProperty(PROPERTY_RADIUS)).doubleValue();
46 capRadiusHighDependency = Math.min(capRadiusHighDependency, 0.5);
47 } else {
48 capRadiusHighDependency = FLOWCHART_DEFAULT_DISPLAY_RADIUS;
49 }
50 double borderDistance = capRadiusHighDependency * Math.min(width, height);
51
52 shapePath.moveTo((float)x, (float)(y + height/2));
53 shapePath.quadTo((float)(x + borderDistance), (float)(y + borderDistance), (float)(x + 4*borderDistance), (float)y);
54 shapePath.lineTo((float)(x + width - borderDistance), (float)y);
55 shapePath.quadTo((float)(x + width + borderDistance), (float)(y + height/2), (float)(x + width - borderDistance), (float)(y + height));
56 shapePath.lineTo((float)(x + 4*borderDistance), (float)(y + height));
57 shapePath.quadTo((float)(x + borderDistance), (float)(y + height - borderDistance), (float)x, (float)(y + height/2));
58 }
59 }
60