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