use of org.eclipse.draw2d.geometry.PointList in project knime-core by knime.
the class NodeInPortFigure method createShapePoints.
/**
* Create a point list for the port figure (a polygon).
*
* There are two shapes. A triangular one for the data ports and a square
* shaped one for the model ports.
*
* @param r The bounds
* @return the pointlist (size=3)
*/
@Override
protected PointList createShapePoints(final Rectangle r) {
if (getType().equals(BufferedDataTable.TYPE)) {
PointList points = new PointList(3);
points.addPoint(new Point(r.x, r.y));
points.addPoint(new Point(r.x + r.width - 1, r.y + (r.height / 2) - 1));
points.addPoint(new Point(r.x, r.y + r.height - 1));
return points;
}
PointList points = new PointList(4);
points.addPoint(new Point(r.x, r.y));
points.addPoint(new Point(r.x + r.width - 1, r.y));
points.addPoint(new Point(r.x + r.width - 1, r.y + r.height - 1));
points.addPoint(new Point(r.x, r.y + r.height - 1));
return points;
}
use of org.eclipse.draw2d.geometry.PointList in project knime-core by knime.
the class WorkflowOutPortFigure method createShapePoints.
/**
* {@inheritDoc}
*/
@Override
protected PointList createShapePoints(final Rectangle rect) {
Rectangle r = getBounds().getCopy();
if (getType().equals(BufferedDataTable.TYPE)) {
// triangle
PointList list = new PointList(3);
list.addPoint(r.x, r.y);
list.addPoint(r.x + r.width, r.y + (r.height / 2));
list.addPoint(r.x, r.y + r.height);
return list;
} else {
// square
PointList list = new PointList(4);
list.addPoint(new Point(r.x, r.y));
list.addPoint(new Point(r.x + r.width, r.y));
list.addPoint(new Point(r.x + r.width, r.y + r.height));
list.addPoint(new Point(r.x, r.y + r.height));
return list;
}
}
use of org.eclipse.draw2d.geometry.PointList in project yamcs-studio by yamcs.
the class PasteWidgetsAction method getWidgetsIntrinsicRelativePositions.
private List<Point> getWidgetsIntrinsicRelativePositions(List<AbstractWidgetModel> widgets) {
PointList pointList = new PointList(widgets.size());
for (AbstractWidgetModel widgetModel : widgets) {
pointList.addPoint(widgetModel.getLocation());
}
Point upperLeftCorner = pointList.getBounds().getLocation();
List<Point> result = new ArrayList<Point>(widgets.size());
for (int i = 0; i < widgets.size(); i++) {
result.add(pointList.getPoint(i).translate(-upperLeftCorner.x, -upperLeftCorner.y));
}
return result;
}
use of org.eclipse.draw2d.geometry.PointList in project yamcs-studio by yamcs.
the class LinkingContainerEditpart method updateConnectionList.
private void updateConnectionList() {
if (connectionList == null || originalPoints == null)
return;
double scaleFactor = ((LinkingContainerFigure) getFigure()).getZoomManager().getZoom();
final Point tranlateSize = getRelativeToRoot();
tranlateSize.scale(scaleFactor);
log.log(Level.FINEST, String.format("Relative to root translation (scaled by %s): %s ", scaleFactor, tranlateSize));
Point scaledCropTranslation = new Point();
if (cropTranslation != null)
scaledCropTranslation = cropTranslation.getCopy();
scaledCropTranslation.scale(scaleFactor);
for (ConnectionModel conn : connectionList) {
PointList points = originalPoints.get(conn).getCopy();
if (points == null)
continue;
log.log(Level.FINER, "Connector: " + conn.getName());
for (int i = 0; i < points.size(); i++) {
Point point = points.getPoint(i);
if (getWidgetModel().isAutoSize()) {
point.translate(scaledCropTranslation);
// box
if (point.x() <= tranlateSize.x())
point.translate(conn.getLineWidth() / 2, 0);
if (point.y() <= tranlateSize.y())
point.translate(0, conn.getLineWidth() / 2);
}
point.scale(scaleFactor);
points.setPoint(point, i);
}
conn.setPoints(points);
}
}
use of org.eclipse.draw2d.geometry.PointList in project yamcs-studio by yamcs.
the class LinkingContainerEditpart method performAutosize.
/**
* Automatically set the container size according its children's geography size.
*/
@Override
public void performAutosize() {
Rectangle childrenRange = GeometryUtil.getChildrenRange(this);
if (connectionList != null) {
for (ConnectionModel connModel : connectionList) {
final PointList connectionPoints = connModel.getPoints();
childrenRange.union(connectionPoints.getBounds());
}
}
cropTranslation = new Point(-childrenRange.x, -childrenRange.y);
getWidgetModel().setSize(new Dimension(childrenRange.width + figure.getInsets().left + figure.getInsets().right, childrenRange.height + figure.getInsets().top + figure.getInsets().bottom));
for (Object editPart : getChildren()) {
AbstractWidgetModel widget = ((AbstractBaseEditPart) editPart).getWidgetModel();
widget.setLocation(widget.getLocation().translate(cropTranslation));
}
}
Aggregations