Hi,
I have given a sample code here:
[code]
package research;
import java.awt.Point; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent;
import javax.swing.JApplet;
import com.mindfusion.jdiagram.Arrow; import com.mindfusion.jdiagram.ArrowStyle; import com.mindfusion.jdiagram.Box; import com.mindfusion.jdiagram.FlowChart; import com.mindfusion.jdiagram.FlowChartAdapter; import com.mindfusion.jdiagram.GraphicsUnit; import com.mindfusion.jdiagram.ItemMouseEvent; import com.mindfusion.jdiagram.RerouteArrows; import com.mindfusion.jdiagram.ShadowsStyle; import com.mindfusion.jdiagram.SnapToAnchor;
public class Goop extends JApplet { private static final long serialVersionUID = 1L;
private FlowChart flowChart;
@Override public void init() { super.init(); flowChart = new FlowChart(); flowChart.setSelectionOnTop(false); flowChart.setShadowsStyle(ShadowsStyle.None); this.getContentPane().add(flowChart); flowChart.setMeasureUnit(GraphicsUnit.Pixel);
flowChart.setArrowStyle(ArrowStyle.Cascading); flowChart.setSnapToAnchor(SnapToAnchor.OnCreateOrModify); flowChart.setRouteArrows(true); flowChart.getRoutingOptions().setTriggerRerouting( RerouteArrows.WhileCreating | RerouteArrows.WhenModified | RerouteArrows.WhenIntersectNode);
testRouting(); }
Box one, two;
Arrow three;
private void testRouting() { one = new Box(flowChart); two = new Box(flowChart); one.setBounds(12, 379, 125, 92); two.setBounds(112, 87, 125, 75); flowChart.add(one); flowChart.add(two);
three = new Arrow(flowChart, one, two); three.setSnapToNodeBorder(true); three.setAutoRoute(false); three.setStyle(ArrowStyle.Polyline);
three.setSegmentCount(2); three.getControlPoints().set(0, new Point(137, 424)); three.getControlPoints().set(1, new Point(170, 424)); three.getControlPoints().set(2, new Point(170, 162));
flowChart.add(three);
flowChart.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (flowChart.getItemAt(e.getPoint(), true) != null) { return; }
one.setBounds(12, 70, 125, 92); for (Arrow arrow : one.getOutgoingArrows()) { arrow.setStyle(ArrowStyle.Cascading); arrow.route(); } } });
flowChart.addFlowChartListener(new FlowChartAdapter() { @Override public void itemModified(ItemMouseEvent e) { three.setStyle(ArrowStyle.Cascading); three.route(); } }); } }
[/code]
I have a lot of functionality build around JDiagram and there are specific situations I want the arrow to be polyline initially and on modifying a symbol, its arrows are made cascading (aligning in this case).
If you click on a blank area of the canvas, the bottom box aligns its lower border with the top symbol. During the aligning, the arrow is made cascading. The arrow routes between the centers of the two symbols.
Also, if you drag the top symbol to the right, you will notice that the start and end points of the arrow where it snapped to the boxes change.
Can I change this behavior?
Thanks, Praveen
|