Search in sources :

Example 56 with PointList

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;
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Point(org.eclipse.draw2d.geometry.Point)

Example 57 with PointList

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;
    }
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point)

Example 58 with PointList

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;
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) ArrayList(java.util.ArrayList) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point)

Example 59 with PointList

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);
    }
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) ConnectionModel(org.csstudio.opibuilder.model.ConnectionModel) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point)

Example 60 with PointList

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));
    }
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) ConnectionModel(org.csstudio.opibuilder.model.ConnectionModel) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension)

Aggregations

PointList (org.eclipse.draw2d.geometry.PointList)80 Point (org.eclipse.draw2d.geometry.Point)49 Rectangle (org.eclipse.draw2d.geometry.Rectangle)15 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)10 ArrayList (java.util.ArrayList)9 ConnectionModel (org.csstudio.opibuilder.model.ConnectionModel)8 Polyline (org.eclipse.draw2d.Polyline)7 List (java.util.List)6 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)6 AbstractPolyModel (org.csstudio.opibuilder.widgets.model.AbstractPolyModel)5 Dimension (org.eclipse.draw2d.geometry.Dimension)5 Bendpoint (org.eclipse.draw2d.Bendpoint)4 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)4 SetWidgetPropertyCommand (org.csstudio.opibuilder.commands.SetWidgetPropertyCommand)3 AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)3 PolarPoint (org.csstudio.swt.widgets.figureparts.PolarPoint)3 AbsoluteBendpoint (org.eclipse.draw2d.AbsoluteBendpoint)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 PropertyChangeListener (java.beans.PropertyChangeListener)2 ConnectionReconnectCommand (org.csstudio.opibuilder.commands.ConnectionReconnectCommand)2