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