Hi,
I have the following code:
private void TestArrows() {
flowChart = new FlowChart(); this.getContentPane().add(flowChart); flowChart.setMeasureUnit(GraphicsUnit.Pixel); flowChart.setRouteArrows(false);
Box top = new Box(flowChart); Box below1 = new Box(flowChart); Box below2 = new Box(flowChart); top.setObstacle(false); below1.setObstacle(false); below2.setObstacle(false);
below1.attachTo(top, AttachToNode.TopLeft); below2.attachTo(top, AttachToNode.TopLeft);
top.setBounds(new Rectangle2D.Float(100, 100, 100, 100)); below1.setBounds(new Rectangle2D.Float(150, 250, 100, 100)); below2.setBounds(new Rectangle2D.Float(350, 250, 100, 100)); flowChart.add(top); flowChart.add(below1); flowChart.add(below2);
Arrow top1 = new Arrow(flowChart, top, below1); Arrow top2 = new Arrow(flowChart, top, below2); flowChart.add(top1); flowChart.add(top2);
UpdateConnector(top, below1); UpdateConnector(top, below2); }
private void UpdateConnector(Box group, Box subordinate) {
// There will be only one connector Arrow connector = subordinate.getIncomingArrows().get(0); connector.getControlPoints().clear();
float midY = (subordinate.getBounds().y + group.getBounds().y + group.getBounds().height) / 2;
connector.getControlPoints().add(new Point2D.Float(group.getBounds().x + group.getBounds().width / 2, group.getBounds().y + group.getBounds().height)); connector.getControlPoints().add(new Point2D.Float(group.getBounds().x + group.getBounds().width / 2, midY)); connector.getControlPoints().add(new Point2D.Float(subordinate.getBounds().x + subordinate.getBounds().width / 2, midY)); connector.getControlPoints().add(new Point2D.Float(subordinate.getBounds().x + subordinate.getBounds().width / 2, subordinate.getBounds().y));
connector.setStyle(ArrowStyle.Cascading);
connector.updateFromPoints(); }
1. I have given the arrow a cascading feel and assigned 4 control points per arrow.
So, both arrows should appear with two bends, but when rendered, they come up with only 3 control points.
2. I can add the line flowChart.setArrowStyle(ArrowStyle.Cascading); This will make the arrows come up with two bends. But on moving the top box, the second arrow loses its shape. How do I prevent this?
Thanks, Praveen
|