Hi,
I have the following code. It is a sample to highlight two problems I am facing:
[code] package goop;
import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.geom.Point2D;
import javax.swing.JApplet;
import com.mindfusion.diagramming.Behavior; import com.mindfusion.diagramming.Diagram; import com.mindfusion.diagramming.DiagramAdapter; import com.mindfusion.diagramming.DiagramLink; import com.mindfusion.diagramming.DiagramNode; import com.mindfusion.diagramming.DiagramView; import com.mindfusion.diagramming.GraphicsUnit; import com.mindfusion.diagramming.LinkEvent; import com.mindfusion.diagramming.LinkStyle; import com.mindfusion.diagramming.NodeEvent; import com.mindfusion.diagramming.RerouteLinks; import com.mindfusion.diagramming.ShadowsStyle; import com.mindfusion.diagramming.ShapeNode; import com.mindfusion.diagramming.SnapToAnchor;
public class GoopApplet extends JApplet {
private static final long serialVersionUID = 1L;
private Diagram flowChart;
DiagramView flowchartView;
@Override public void init() { super.init(); flowChart = new Diagram(); flowchartView = new DiagramView(flowChart); flowChart.setSelectionOnTop(false); flowChart.setShadowsStyle(ShadowsStyle.None); this.getContentPane().add(flowchartView); flowChart.setMeasureUnit(GraphicsUnit.Pixel);
flowChart.setAllowUnconnectedLinks(true); flowChart.setLinkStyle(LinkStyle.Cascading); flowChart.setSnapToAnchor(SnapToAnchor.OnCreateOrModify); flowChart.setRouteLinks(true); flowChart.getRoutingOptions().setTriggerRerouting( RerouteLinks.WhileCreating); flowChart.setLinksSnapToBorders(true);
testArrowDistortion(); }
DiagramNode one;
private void testArrowDistortion() { one = new ShapeNode(flowChart); one.setBounds(206, 237, 75, 125); flowChart.add(one);
DiagramLink arrow = new DiagramLink(flowChart, one, new Point2D.Float( 0, 0)); arrow.setAutoRoute(false); arrow.setStyle(LinkStyle.Polyline); arrow.setSegmentCount(3); arrow.getControlPoints().set(0, new Point2D.Float(257, 237)); arrow.getControlPoints().set(1, new Point2D.Float(257, 207)); arrow.getControlPoints().set(2, new Point2D.Float(481, 207)); arrow.getControlPoints().set(3, new Point2D.Float(481, 330)); arrow.setSnapToNodeBorder(true); flowChart.add(arrow);
flowchartView.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { one.setBounds(200, 200, 75, 125); }
super.mouseClicked(e); } });
//flowChart.addDiagramListener(new DiagramAdapter() { //@Override //public void nodeModified(NodeEvent e) { //e.getNode().getOutgoingLinks().get(0).setStyle( //LinkStyle.Cascading); //super.nodeModified(e); //} //}); } }
[/code]
There is one ShapeNode on the FlowChart and one DiagramLink connected to it at one end, with another end free.
1. When you right click the flowchart, the second ShapeNode is moved slightly. The arrow connected to it has its auto route set to false. When I programmatically move the ShapeNode, the free end of the arrow jumps to (0, 0).
2. I have also commented out some code that changes the Link style to cascading when the ShapeNode is moved. Then, the arrow jumps right to the top of the FlowChart.
Is there some way I can work around this?
Thanks, Praveen
|