org.eclipse.draw2d.ConnectionLayer Java Examples

The following examples show how to use org.eclipse.draw2d.ConnectionLayer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GenericLevelPresets.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected IFigure createMain ()
{
    final Figure baseFigure = new LayeredPane ();

    final Layer rootFigure = new Layer ();

    this.connLayer = new ConnectionLayer ();
    this.connLayer.setAntialias ( 1 );
    this.connLayer.setConnectionRouter ( ConnectionRouter.NULL );

    baseFigure.add ( this.connLayer );
    baseFigure.add ( rootFigure );

    rootFigure.setLayoutManager ( new BorderLayout () );
    rootFigure.setBackgroundColor ( ColorConstants.white );

    rootFigure.add ( createArrowFigure (), BorderLayout.RIGHT );
    rootFigure.add ( createEntryGrid ( this.connLayer ), BorderLayout.CENTER );

    return baseFigure;
}
 
Example #2
Source File: TreeLayoutUtil.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
private static int getDeepestTreeLevel(ConnectionLayer connectionLayer,
		IFigure figure) {
	final List<Connection> connectionList = getOutgoingConnections(
			connectionLayer, figure);
	if (connectionList.size() > 0) {
		final int[] ret = new int[connectionList.size()];
		for (int i = 0; i < connectionList.size(); i++) {
			ret[i] = 1 + getDeepestTreeLevel(connectionLayer,
					connectionList.get(i).getTargetAnchor().getOwner());
		}
		int maxLevel = ret[0];
		if (ret.length > 1) {
			for (int i = 1; i < ret.length; i++) {
				if (ret[i] > maxLevel) {
					maxLevel = ret[i];
				}
			}
		}
		return maxLevel;
	}
	return 0;
}
 
Example #3
Source File: TreeLayoutUtil.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns incoming connection figures of the figure parameter.
 * 
 * @param connectionLayer
 * @param figure
 * @return
 */
public static List<Connection> getIncomingConnections(
		ConnectionLayer connectionLayer, IFigure figure) {

	final List<Connection> incomingConnectionList = new ArrayList<Connection>();

	for (final Object object : connectionLayer.getChildren()) {
		if (object instanceof Connection) {
			final Connection connection = (Connection) object;
			if (connection.getTargetAnchor().getOwner() == figure) {
				incomingConnectionList.add(connection);
			}
		}
	}
	return incomingConnectionList;
}
 
Example #4
Source File: TreeLayoutUtil.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns outgoing connection figures of the figure parameter.
 * 
 * @param connectionLayer
 * @param figure
 * @return
 */
public static List<Connection> getOutgoingConnections(
		ConnectionLayer connectionLayer, IFigure figure) {

	final List<Connection> outgoingConnectionList = new ArrayList<Connection>();

	for (final Object object : connectionLayer.getChildren()) {
		if (object instanceof Connection) {
			final Connection connection = (Connection) object;
			if (connection.getSourceAnchor().getOwner() == figure) {
				outgoingConnectionList.add(connection);
			}
		}
	}
	return outgoingConnectionList;
}
 
Example #5
Source File: TreeLayout.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public TreeLayout(int rankSpacing, ConnectionLayer connectionLayer) {
	super();
	this.rankSpacing = rankSpacing;
	this.connectionLayer = connectionLayer;
	isVertical = true;
	isTopLeftAlignment = true;
	leafSpacing = 5;
	maxTreeLevel = 0;
	graphSize = new Dimension();
}
 
Example #6
Source File: ManualOverride.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IFigure createMain ()
{
    final LayeredPane root = new LayeredPane ();

    final Layer figureLayer = new Layer ();
    figureLayer.setLayoutManager ( new FlowLayout () );

    final ConnectionLayer connectionLayer = new ConnectionLayer ();
    connectionLayer.setAntialias ( SWT.ON );

    final Figure figure = new Figure ();
    figureLayer.add ( figure );

    final GridLayout gridLayout = new GridLayout ( 3, true );
    gridLayout.horizontalSpacing = 50;
    gridLayout.verticalSpacing = 50;
    figure.setLayoutManager ( gridLayout );

    final Figure rpvFigure = createRPV ();
    final Figure pvFigure = createPV ();
    final Figure rmvFigure = createRMV ();
    final Figure mvFigure = createMV ();
    final Figure rvFigure = createRV ();

    figure.add ( rpvFigure, new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 1 ) );
    figure.add ( pvFigure, new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 2 ) );
    figure.add ( rvFigure, new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 3 ) );

    figure.add ( rmvFigure, new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 1 ) );

    figure.add ( mvFigure, new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 1 ) );
    figure.add ( new Figure (), new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 1 ) ); // placeholder

    connectionLayer.add ( this.p2rConnection = createConnection ( this.pvRect, this.rvRect ) );
    connectionLayer.add ( this.m2rConnection = createConnection ( this.mvRect, this.rvRect ) );

    connectionLayer.add ( this.rp2pConnection = createConnection ( this.rpvRect, this.pvRect ) );
    connectionLayer.add ( this.rm2pConnection = createConnection ( this.rmvRect, this.pvRect ) );

    root.add ( figureLayer );
    root.add ( connectionLayer );

    return root;
}
 
Example #7
Source File: TreeLayoutUtil.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Returns only elements parent figure is a direct parent. Indirect
 * connections are filtered out. Use if children can have many parents.
 * 
 * @param connectionLayer
 * @param parentFigure
 * @return
 */
public static List<Connection> getTreeFigureIncomingConnections(
		ConnectionLayer connectionLayer, IFigure parentFigure) {

	final List<Connection> connectionList = getIncomingConnections(
			connectionLayer, parentFigure);
	final List<Connection> indirectChildren = new ArrayList<Connection>();

	final int parentFigureTreeLevel = getDeepestTreeLevel(connectionLayer,
			parentFigure);
	for (final Connection connection : connectionList) {
		final IFigure childFigure = connection.getSourceAnchor().getOwner();

		final int childTreeLevel = getDeepestTreeLevel(connectionLayer,
				childFigure);

		if (childTreeLevel == parentFigureTreeLevel + 1) {
			
			//get LayoutConstraint of child Figure;
			Object object = parentFigure.getParent().getLayoutManager()
					.getConstraint(childFigure);
			if (object instanceof TreeLayoutConstraint) {
				TreeLayoutConstraint childConstraint = (TreeLayoutConstraint) object;
				
				final IFigure constrainedParentFig = childConstraint
						.getTreeParentFigure();
				
				if (constrainedParentFig == null) {
					childConstraint.setTreeParentFigure(parentFigure);
				} else if (constrainedParentFig != parentFigure) {
						indirectChildren.add(connection);
				}
			}
		} 
		else {
			indirectChildren.add(connection);
		}
	}
	connectionList.removeAll(indirectChildren);
	return connectionList;
}