Search in sources :

Example 1 with Connection

use of org.eclipse.draw2d.Connection in project dbeaver by serge-rider.

the class GraphAnimation method recordFinalState.

public static void recordFinalState(IFigure child) {
    if (child instanceof Connection) {
        recordFinalState((Connection) child);
        return;
    }
    Rectangle rect2 = child.getBounds().getCopy();
    Rectangle rect1 = (Rectangle) initialStates.get(child);
    if (rect1.isEmpty()) {
        rect1.x = rect2.x;
        rect1.y = rect2.y;
        rect1.width = rect2.width;
    }
    finalStates.put(child, rect2);
}
Also used : Connection(org.eclipse.draw2d.Connection) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 2 with Connection

use of org.eclipse.draw2d.Connection in project archi by archimatetool.

the class ArchiConnectionEndpointLocator method relocate.

/**
 * Relocates the given IFigure at either the source or target end of the
 * Connection, based on the <code>boolean</code> given in the constructor
 * {@link #ConnectionEndpointLocator(Connection, boolean)}.
 *
 * @param figure
 *            The figure to relocate
 */
public void relocate(IFigure figure) {
    Connection conn = getConnection();
    Point startPoint = Point.SINGLETON;
    Point endPoint = new Point();
    int startPointPosition = 0;
    int endPointPosition = 1;
    if (isEnd()) {
        startPointPosition = conn.getPoints().size() - 1;
        endPointPosition = startPointPosition - 1;
    }
    conn.getPoints().getPoint(startPoint, startPointPosition);
    conn.getPoints().getPoint(endPoint, endPointPosition);
    int quadrant;
    quadrant = calculateConnectionLocation(startPoint, endPoint);
    int cos = 1;
    transposer.setEnabled(false);
    /*
		 * Label placement calculations are done as if the connection point is
		 * along the left or right side of the figure. If the connection point
		 * is along the top or bottom, values are transposed.
		 */
    if (quadrant == 1 || quadrant == 3)
        transposer.setEnabled(true);
    if (quadrant == 3 || quadrant == 4)
        cos = -1;
    Dimension figureSize = transposer.t(figure.getPreferredSize());
    startPoint = transposer.t(startPoint);
    endPoint = transposer.t(endPoint);
    double tan = calculateTan(startPoint, endPoint);
    int figureWidth = figureSize.width;
    int figureHeight = figureSize.height;
    int yShift = calculateYShift(figureWidth, figureHeight);
    Point figurePoint = new Point(startPoint.x + (uDistance * cos) + figureWidth * ((cos - 1) / 2), (int) (startPoint.y + cos * uDistance * tan + vDistance + yShift));
    figureBounds.setSize(transposer.t(figureSize));
    figureBounds.setLocation(transposer.t(figurePoint));
    figure.setBounds(figureBounds);
}
Also used : Connection(org.eclipse.draw2d.Connection) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Example 3 with Connection

use of org.eclipse.draw2d.Connection in project knime-core by knime.

the class SnapToPortGeometry method populateRowsAndCols.

/**
 * Updates the cached row and column Entries using the provided parts.
 * Columns are only the center of a node figure while rows are all ports of
 * a node.
 *
 * @param parts a List of EditParts
 */
protected void populateRowsAndCols(final List parts, final List dragedParts) {
    // add the port edit parts to a list
    List<AbstractPortEditPart> portList = getPorts(parts);
    // create all row relevant points fromt the port list
    List<Entry> rowVector = new ArrayList<Entry>();
    for (int i = 0; i < portList.size(); i++) {
        GraphicalEditPart child = portList.get(i);
        Rectangle bounds = getFigureBounds(child);
        // get information is this is an inport
        boolean inport = false;
        if (portList.get(i) instanceof NodeInPortEditPart || portList.get(i) instanceof WorkflowInPortEditPart) {
            inport = true;
        }
        // get information is this is a model port
        rowVector.add(new Entry(0, bounds.y + (bounds.height - 1) / 2, inport, portList.get(i).getType()));
    }
    // add the port edit parts to a list
    List<AbstractPortEditPart> dargedPortList = getPorts(dragedParts);
    for (int i = 0; i < dargedPortList.size(); i++) {
        // for each port get a possible connection (if connected)
        AbstractPortEditPart portPart = dargedPortList.get(i);
        List sourceConnections = portPart.getSourceConnections();
        for (int j = 0; j < sourceConnections.size(); j++) {
            ConnectionContainerEditPart conPart = (ConnectionContainerEditPart) sourceConnections.get(j);
            Point p = ((Connection) conPart.getFigure()).getPoints().getPoint(2);
            rowVector.add(new Entry(0, p.y, true, portPart.getType()));
        }
        List targetConnections = portPart.getTargetConnections();
        for (int j = 0; j < targetConnections.size(); j++) {
            ConnectionContainerEditPart conPart = (ConnectionContainerEditPart) targetConnections.get(j);
            PointList pList = ((Connection) conPart.getFigure()).getPoints();
            Point p = pList.getPoint(pList.size() - 3);
            rowVector.add(new Entry(0, p.y, false, portPart.getType()));
        }
    }
    List<Entry> colVector = new ArrayList<Entry>();
    for (int i = 0; i < parts.size(); i++) {
        GraphicalEditPart child = (GraphicalEditPart) parts.get(i);
        Rectangle bounds = getFigureBounds(child);
        colVector.add(new Entry(0, bounds.x + (bounds.width - 1) / 2));
    }
    m_rows = rowVector.toArray(new Entry[rowVector.size()]);
    m_cols = colVector.toArray(new Entry[colVector.size()]);
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) AbstractPortEditPart(org.knime.workbench.editor2.editparts.AbstractPortEditPart) ArrayList(java.util.ArrayList) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Connection(org.eclipse.draw2d.Connection) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point) NodeInPortEditPart(org.knime.workbench.editor2.editparts.NodeInPortEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) ArrayList(java.util.ArrayList) PointList(org.eclipse.draw2d.geometry.PointList) List(java.util.List) WorkflowInPortEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 4 with Connection

use of org.eclipse.draw2d.Connection in project jbosstools-hibernate by jbosstools.

the class GraphAnimation method recordFinalState.

public static void recordFinalState(IFigure child) {
    if (child instanceof Connection) {
        recordFinalState((Connection) child);
        return;
    }
    Rectangle rect2 = child.getBounds().getCopy();
    Rectangle rect1 = (Rectangle) initialStates.get(child);
    if (rect1.isEmpty()) {
        rect1.x = rect2.x;
        rect1.y = rect2.y;
        rect1.width = rect2.width;
    }
    finalStates.put(child, rect2);
}
Also used : Connection(org.eclipse.draw2d.Connection) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 5 with Connection

use of org.eclipse.draw2d.Connection in project statecharts by Yakindu.

the class TreeLayout method getTreeLevels.

protected List<List<TreeNode>> getTreeLevels(List<TreeNode> treeNodeList, int level) {
    final List<List<TreeNode>> levelElements = new ArrayList<List<TreeNode>>();
    final List<TreeNode> nextRankElements = new ArrayList<TreeNode>();
    levelElements.add(new ArrayList<TreeNode>());
    levelElements.get(0).addAll(treeNodeList);
    for (final TreeNode treeNode : treeNodeList) {
        // Set level of the treeNode
        treeNode.level = level;
        if (treeNode.children.isEmpty()) {
            // calculate child GraphNodes in next Rank
            final List<Connection> connectionList = TreeLayoutUtil.getTreeFigureIncomingConnections(connectionLayer, treeNode.getFigure());
            for (int i = 0; i < connectionList.size(); i++) {
                final Connection connection = connectionList.get(i);
                if (connection.getSourceAnchor().getOwner() != null) {
                    final IFigure childFig = connection.getSourceAnchor().getOwner();
                    final TreeNode childTreeNode = new TreeNode(treeNode, childFig);
                    treeNode.children.add(childTreeNode);
                }
            }
        }
        treeNode.children = sortTreeNodeList(treeNode.children);
        nextRankElements.addAll(treeNode.children);
    }
    // add ranks for childTreeNodeList
    if (!nextRankElements.isEmpty()) {
        levelElements.addAll(getTreeLevels(nextRankElements, ++level));
    }
    return levelElements;
}
Also used : ArrayList(java.util.ArrayList) Connection(org.eclipse.draw2d.Connection) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

Connection (org.eclipse.draw2d.Connection)19 Point (org.eclipse.draw2d.geometry.Point)11 Rectangle (org.eclipse.draw2d.geometry.Rectangle)6 ArrayList (java.util.ArrayList)5 IFigure (org.eclipse.draw2d.IFigure)3 PointList (org.eclipse.draw2d.geometry.PointList)3 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)2 List (java.util.List)2 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)2 CreateBendpointCommand (com.archimatetool.editor.diagram.commands.CreateBendpointCommand)1 MoveBendpointCommand (com.archimatetool.editor.diagram.commands.MoveBendpointCommand)1 LinkedList (java.util.LinkedList)1 FixedPointsConnectionRouter (org.csstudio.opibuilder.editparts.FixedPointsConnectionRouter)1 ConnectionLayer (org.eclipse.draw2d.ConnectionLayer)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)1 Vector (org.eclipse.draw2d.geometry.Vector)1 EObject (org.eclipse.emf.ecore.EObject)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 NodeEditPart (org.eclipse.gef.NodeEditPart)1