Search in sources :

Example 46 with PointList

use of org.eclipse.draw2d.geometry.PointList in project tdi-studio-se by Talend.

the class ConnectionFigure method setDecoration.

private void setDecoration() {
    if (!DesignerPlugin.getDefault().getPreferenceStore().getBoolean(TalendDesignerPrefConstants.EDITOR_LINESTYLE)) {
        this.setTargetDecoration(new PolygonDecoration());
        this.setLineWidth(1);
        return;
    }
    this.setLineWidth(2);
    PointList template = new PointList();
    PolygonDecoration targetDecoration = new DecorationFigure(this, false);
    targetDecoration.setScale(1, 1);
    template.addPoint(new Point(-11, -5.5));
    template.addPoint(new Point(-2, -5.5));
    template.addPoint(0, -1);
    template.addPoint(0, 1);
    template.addPoint(new Point(-2, 5.5));
    template.addPoint(new Point(-11, 5.5));
    targetDecoration.setTemplate(template);
    setTargetDecoration(targetDecoration);
    PolygonDecoration sourceDecoration = new DecorationFigure(this, true);
    sourceDecoration.setScale(1, 1);
    template = new PointList();
    template.addPoint(new Point(0, 5.5));
    template.addPoint(new Point(-9, 5.5));
    template.addPoint(-11, 1);
    template.addPoint(-11, -1);
    template.addPoint(new Point(-9, -5.5));
    template.addPoint(new Point(0, -5.5));
    sourceDecoration.setTemplate(template);
    setSourceDecoration(sourceDecoration);
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) PolygonDecoration(org.eclipse.draw2d.PolygonDecoration) Point(org.eclipse.draw2d.geometry.Point)

Example 47 with PointList

use of org.eclipse.draw2d.geometry.PointList in project tdi-studio-se by Talend.

the class DecisionBusinessItemShapeFigure method drawFigure.

private void drawFigure(Rectangle r, Graphics graphics) {
    PointList pointList = new PointList();
    pointList.removeAllPoints();
    pointList.addPoint(r.x + r.width / 2, r.y);
    pointList.addPoint(r.x + r.width, r.y + r.height / 2);
    pointList.addPoint(r.x + r.width / 2, r.y + r.height);
    pointList.addPoint(r.x, r.y + r.height / 2);
    graphics.fillPolygon(pointList);
    graphics.drawPolygon(pointList);
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList)

Example 48 with PointList

use of org.eclipse.draw2d.geometry.PointList in project tdi-studio-se by Talend.

the class InputBusinessItemShapeFigure method drawFigure.

private void drawFigure(Rectangle r, Graphics graphics) {
    int offset = (int) (r.height * 0.2);
    PointList pointList = new PointList();
    pointList.removeAllPoints();
    pointList.addPoint(r.x, r.y + offset);
    pointList.addPoint(r.x + r.width, r.y);
    pointList.addPoint(r.x + r.width, r.y + r.height);
    pointList.addPoint(r.x, r.y + r.height);
    graphics.fillPolygon(pointList);
    graphics.drawPolygon(pointList);
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList)

Example 49 with PointList

use of org.eclipse.draw2d.geometry.PointList in project Palladio-Editors-Sirius by PalladioSimulator.

the class AbstractRotatableImageEditPart method getFirstSegmentAngle.

/**
 * Angle in degrees [0..360]
 *
 * @param polylineConnection
 * @return the angle in degrees.
 */
public static double getFirstSegmentAngle(PolylineConnection polylineConnection) {
    PointList points = polylineConnection.getPoints();
    PrecisionPoint firstPoint = new PrecisionPoint(points.getFirstPoint());
    PrecisionPoint secondPoint = new PrecisionPoint(points.getPoint(1));
    Vector edgeVector = new Vector(firstPoint, secondPoint);
    double atan2 = Math.atan2(edgeVector.y, edgeVector.x);
    double degrees = Math.toDegrees(atan2);
    if (degrees < 0) {
        degrees = -degrees;
    } else {
        degrees = 180 + (180 - degrees);
    }
    return degrees;
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Vector(org.eclipse.draw2d.geometry.Vector) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint)

Example 50 with PointList

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

the class ConnectionBendpointEditPolicy method createHandlesForUserBendpoints.

private List createHandlesForUserBendpoints() {
    List<Object> list = new ArrayList<Object>();
    ConnectionEditPart connEP = (ConnectionEditPart) getHost();
    PointList points = getConnection().getPoints();
    List bendPoints = (List) getConnection().getRoutingConstraint();
    int bendPointIndex = 0;
    Point currBendPoint = null;
    if (bendPoints == null) {
        bendPoints = NULL_CONSTRAINT;
    } else if (!bendPoints.isEmpty()) {
        currBendPoint = ((Bendpoint) bendPoints.get(0)).getLocation();
    }
    for (int i = 0; i < points.size() - 1; i++) {
        // Put a create handle on the middle of every segment
        list.add(new ConnectionBendpointCreationHandel(connEP, bendPointIndex, i));
        // move handle
        if (i < points.size() - 1 && bendPointIndex < bendPoints.size() && currBendPoint.equals(points.getPoint(i + 1))) {
            list.add(new ConnectionBendpointMoveHandel(connEP, bendPointIndex, i + 1));
            // Go to the next user bendpoint
            bendPointIndex++;
            if (bendPointIndex < bendPoints.size()) {
                currBendPoint = ((Bendpoint) bendPoints.get(bendPointIndex)).getLocation();
            }
        }
    }
    return list;
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) ConnectionBendpointMoveHandel(org.knime.workbench.editor2.editparts.snap.ConnectionBendpointMoveHandel) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) PointList(org.eclipse.draw2d.geometry.PointList) List(java.util.List) Point(org.eclipse.draw2d.geometry.Point) AbsoluteBendpoint(org.eclipse.draw2d.AbsoluteBendpoint) Bendpoint(org.eclipse.draw2d.Bendpoint) AbsoluteBendpoint(org.eclipse.draw2d.AbsoluteBendpoint) Point(org.eclipse.draw2d.geometry.Point) Bendpoint(org.eclipse.draw2d.Bendpoint) ConnectionBendpointCreationHandel(org.knime.workbench.editor2.editparts.snap.ConnectionBendpointCreationHandel)

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