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 FlowchartCardPainter extends AbstractFlowchartPainter implements FlowchartRealizerConstants {
25
26
27 public FlowchartCardPainter() {
28 super();
29 outline = new GeneralPath();
30 }
31
32 protected void updateOutline(NodeRealizer context) {
33 GeneralPath shape = (GeneralPath) getOutline();
34 shape.reset();
35 double height = context.getHeight();
36 double width = context.getWidth();
37 double x = context.getX();
38 double y = context.getY();
39 double borderDistance;
40 GenericNodeRealizer cast_gnr = (GenericNodeRealizer) context;
41 if (cast_gnr.getStyleProperty(PROPERTY_BORDER_DISTANCE) != null) {
42 borderDistance = ((Double) cast_gnr.getStyleProperty(PROPERTY_BORDER_DISTANCE)).byteValue();
43 } else {
44 borderDistance = Math.min(Math.min(FLOWCHART_DEFAULT_CARD_BORDER_DISTANCE, width/2), height);
45 }
46
47 shape.moveTo((float)(x + borderDistance), (float)y);
48 shape.lineTo((float)(x + width), (float)y);
49 shape.lineTo((float)(x + width), (float)(y + height));
50 shape.lineTo((float)x, (float)(y + height));
51 shape.lineTo((float)x, (float)(y + borderDistance));
52 shape.closePath();
53 }
54
55
56 }
57