Search in sources :

Example 66 with PointList

use of org.eclipse.draw2d.geometry.PointList in project yamcs-studio by yamcs.

the class AbstractPolyModel method configureProperties.

/**
 * {@inheritDoc}
 */
@Override
protected void configureProperties() {
    super.configureProperties();
    addProperty(new DoubleProperty(PROP_ROTATION, "Rotation Angle", WidgetPropertyCategory.Display, 0, 0, 360));
    addProperty(new PointListProperty(PROP_POINTS, "Points", WidgetPropertyCategory.Display, new PointList()));
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) PointListProperty(org.csstudio.opibuilder.properties.PointListProperty) DoubleProperty(org.csstudio.opibuilder.properties.DoubleProperty)

Example 67 with PointList

use of org.eclipse.draw2d.geometry.PointList in project yamcs-studio by yamcs.

the class AbstractPolyModel method setPoints.

/**
 * Sets the specified _points for the polygon.
 *
 * @param points
 *            the polygon points
 * @param rememberPoints true if the zero degree relative points should be remembered, false otherwise.
 */
public void setPoints(final PointList points, final boolean rememberPoints) {
    if (points.size() > 0) {
        PointList copy = points.getCopy();
        if (rememberPoints) {
            this.rememberZeroDegreePoints(copy);
        }
        Rectangle bounds = copy.getBounds();
        super.setPropertyValue(PROP_XPOS, bounds.x);
        super.setPropertyValue(PROP_YPOS, bounds.y);
        super.setPropertyValue(PROP_WIDTH, bounds.width);
        super.setPropertyValue(PROP_HEIGHT, bounds.height);
        super.setPropertyValue(PROP_POINTS, copy);
    }
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 68 with PointList

use of org.eclipse.draw2d.geometry.PointList in project yamcs-studio by yamcs.

the class AbstractPolyModel method doScale.

@Override
protected void doScale(double widthRatio, double heightRatio) {
    if (initialPoints == null) {
        initialPoints = getPoints();
    }
    PointList pl = initialPoints.getCopy();
    Point initLoc = pl.getBounds().getLocation();
    pl.translate((int) Math.round(initLoc.x * widthRatio) - initLoc.x, (int) Math.round(initLoc.y * heightRatio) - initLoc.y);
    WidgetScaleData scaleOptions = getScaleOptions();
    if (scaleOptions.isKeepWHRatio() && scaleOptions.isHeightScalable() && scaleOptions.isWidthScalable()) {
        widthRatio = Math.min(widthRatio, heightRatio);
        heightRatio = widthRatio;
    } else if (!scaleOptions.isHeightScalable())
        heightRatio = 1;
    else if (!scaleOptions.isWidthScalable())
        widthRatio = 1;
    PointsUtil.scalePoints(pl, widthRatio, heightRatio);
    setPoints(pl, true);
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Point(org.eclipse.draw2d.geometry.Point) WidgetScaleData(org.csstudio.opibuilder.datadefinition.WidgetScaleData)

Example 69 with PointList

use of org.eclipse.draw2d.geometry.PointList in project yamcs-studio by yamcs.

the class PolylineFigure method setBounds.

@Override
public void setBounds(Rectangle rect) {
    PointList points = getPoints();
    if (!points.getBounds().equals(rect)) {
        int oldX = getLocation().x;
        int oldY = getLocation().y;
        points.translate(rect.x - oldX, rect.y - oldY);
        setPoints(PointsUtil.scalePointsBySize(points, rect.width, rect.height));
    }
    super.setBounds(rect);
    // figure should be forced to be moved since the bounds of a polyline might be unchanged.
    fireFigureMoved();
// bounds = bounds.getExpanded(lineWidth / 2, lineWidth / 2);
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Point(org.eclipse.draw2d.geometry.Point) PolarPoint(org.csstudio.swt.widgets.figureparts.PolarPoint)

Example 70 with PointList

use of org.eclipse.draw2d.geometry.PointList in project yamcs-studio by yamcs.

the class PolylineFigure method drawPolyLineWithArrow.

private void drawPolyLineWithArrow(Graphics graphics) {
    PointList points = getPoints().getCopy();
    graphics.pushState();
    if (points.size() >= 2) {
        Point endPoint = points.getLastPoint();
        Point firstPoint = points.getFirstPoint();
        if (arrowType == ArrowType.To || arrowType == ArrowType.Both) {
            // draw end arrow
            PointList arrowPoints = calcArrowPoints(points.getPoint(points.size() - 2), endPoint, arrowLineLength, ARROW_ANGLE);
            if (fillArrow)
                points.setPoint(arrowPoints.getLastPoint(), points.size() - 1);
            arrowPoints.setPoint(endPoint, 2);
            if (fillArrow) {
                if (isEnabled())
                    graphics.setBackgroundColor(graphics.getForegroundColor());
                graphics.fillPolygon(arrowPoints);
            } else {
                graphics.drawLine(endPoint, arrowPoints.getFirstPoint());
                graphics.drawLine(endPoint, arrowPoints.getMidpoint());
            }
        }
        if (arrowType == ArrowType.From || arrowType == ArrowType.Both) {
            // draw start arrow
            PointList arrowPoints = calcArrowPoints(points.getPoint(1), firstPoint, arrowLineLength, ARROW_ANGLE);
            if (fillArrow)
                points.setPoint(arrowPoints.getLastPoint(), 0);
            arrowPoints.setPoint(firstPoint, 2);
            if (fillArrow) {
                if (isEnabled())
                    graphics.setBackgroundColor(graphics.getForegroundColor());
                graphics.fillPolygon(arrowPoints);
            } else {
                graphics.drawLine(firstPoint, arrowPoints.getFirstPoint());
                graphics.drawLine(firstPoint, arrowPoints.getMidpoint());
            }
        }
    }
    graphics.drawPolyline(points);
    graphics.popState();
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Point(org.eclipse.draw2d.geometry.Point) PolarPoint(org.csstudio.swt.widgets.figureparts.PolarPoint)

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