Problem mit PolylineConnection (Draw2D/SWT)

fmacloud

Mitglied
Hallo hab mal ne Frage bezüglich PolylineConnections. Wie schaffe ich es denn, dass die beiden Pfeile nicht übereinander liegen sondern nebeneinander?

Code:
import org.eclipse.draw2d.ChopboxAnchor;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Connection;
import org.eclipse.draw2d.ConnectionEndpointLocator;
import org.eclipse.draw2d.ConnectionLayer;
import org.eclipse.draw2d.ConnectionRouter;
import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.Layer;
import org.eclipse.draw2d.LayeredPane;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.LineBorder;
import org.eclipse.draw2d.PolygonDecoration;
import org.eclipse.draw2d.PolylineConnection;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;


public class diagramm {

	public static Display display = new Display();
	public static Shell shells = new Shell (display,SWT.TOOL|SWT.CLOSE|SWT.RESIZE);;
	public static LightweightSystem lws = new LightweightSystem();
	public static FigureCanvas fCan = new FigureCanvas(shells);

	public static String name;
	static IFigure root;
    static Layer figures;
	static ConnectionLayer connections;
    static ConnectionRouter router;

    
    public static void main(String[] args) {

    	PolylineConnection verbindung = new PolylineConnection();
    	PolylineConnection verbindung2 = new PolylineConnection();
    	name = "shell";
        root = new LayeredPane();
        figures = new Layer();
        connections = new ConnectionLayer();
        root.add( figures );
        root.add( connections );
        XYLayout layout = new XYLayout();
        figures.setLayoutManager( layout );

        shells.setLayout(new FillLayout());
        fCan = new FigureCanvas(shells);
	
        IFigure zustand = new Label("Label");
        IFigure zustand2 = new Label("Label_2");
    
		zustand.setBounds(new Rectangle(25,25,150,60));
		zustand.setOpaque(true);
		zustand.setBackgroundColor(ColorConstants.buttonLightest);
		zustand.setBorder(new LineBorder(2));

		zustand2.setBounds(new Rectangle(25,175,160,60));
		zustand2.setOpaque(true);
		zustand2.setBackgroundColor(ColorConstants.buttonLightest);
		zustand2.setBorder(new LineBorder(2));
		
		figures.add(zustand);
		figures.add(zustand2);
		
		shells.setText(name);
		shells.setSize(450,450);
		shells.open();
	
		fCan.getLightweightSystem().setContents(root);
		router = null;
		connections.setConnectionRouter(router);
		
		Label pfeil1,pfeil2;

		pfeil1 = new Label(" Pfeil 1 ");
		pfeil1.setOpaque(true);
		pfeil1.setBackgroundColor(ColorConstants.button);
		pfeil1.setBorder(new LineBorder());

		pfeil2 = new Label(" Pfeil 2 ");
		pfeil2.setOpaque(true);
		pfeil2.setBackgroundColor(ColorConstants.button);
		pfeil2.setBorder(new LineBorder());

		verbindung.setSourceAnchor(new ChopboxAnchor(zustand));
		verbindung.setTargetAnchor(new ChopboxAnchor(zustand2));
		verbindung.setTargetDecoration(new PolygonDecoration());
		verbindung.add(pfeil1, new ConnectionEndpointLocator(verbindung,true));
		verbindung.setForegroundColor(ColorConstants.black);
		Connection con = verbindung;
		connections.add(con);
		
		verbindung2.setSourceAnchor(new ChopboxAnchor(zustand2));
		verbindung2.setTargetAnchor(new ChopboxAnchor(zustand));
		verbindung2.setTargetDecoration(new PolygonDecoration());
		verbindung2.add(pfeil2, new ConnectionEndpointLocator(verbindung2,true));
		verbindung2.setForegroundColor(ColorConstants.black);
		Connection con2 = verbindung2;
		connections.add(con2);
		

		while (!shells.isDisposed())
    	while (!display.readAndDispatch())
    		display.sleep();
    }

}
 
Zurück