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);
}
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);
}
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()]);
}
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);
}
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;
}
Aggregations