Search in sources :

Example 36 with PointList

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

the class AbstractPolyModel method setSize.

/**
 * {@inheritDoc}
 */
@Override
public void setSize(final int width, final int height) {
    if (getSize().width == width && getSize().height == height)
        return;
    PointList newPoints = PointsUtil.scalePointsBySize(getPoints(), width, height);
    setPoints(newPoints, true);
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList)

Example 37 with PointList

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

the class AbstractPolyModel method setLocation.

/**
 * {@inheritDoc}
 */
@Override
public void setLocation(final int x, final int y) {
    PointList points = getPoints();
    int oldX = getLocation().x;
    int oldY = getLocation().y;
    points.translate(x - oldX, y - oldY);
    setPoints(points, true);
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Point(org.eclipse.draw2d.geometry.Point)

Example 38 with PointList

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

the class AbstractPolyModel method rotatePoints.

/**
 * Rotates all points.
 *
 * @param points The PoinList, which points should be rotated
 * @param angle
 *            The angle to rotate
 * @return The rotated PointList
 */
public PointList rotatePoints(final PointList points, final double angle) {
    Rectangle pointBounds = points.getBounds();
    Point rotationPoint = pointBounds.getCenter();
    PointList newPoints = new PointList();
    for (int i = 0; i < points.size(); i++) {
        newPoints.addPoint(PointsUtil.rotate(points.getPoint(i), angle, rotationPoint));
    }
    Rectangle newPointBounds = newPoints.getBounds();
    if (!rotationPoint.equals(newPointBounds.getCenter())) {
        Dimension difference = rotationPoint.getCopy().getDifference(newPointBounds.getCenter());
        newPoints.translate(difference.width, difference.height);
    }
    return newPoints;
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point)

Example 39 with PointList

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

the class PolygonFigure method setBounds.

/**
 * Overridden, to ensure that the bounds rectangle gets repainted each time, the _points of the polygon change.
 * {@inheritDoc}
 */
@Override
public void setBounds(final 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));
    }
    invalidate();
    fireFigureMoved();
    repaint();
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList)

Example 40 with PointList

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

the class PolylineFigure method calcArrowPoints.

/**
 * Calculate the three points for an arrow.
 *
 * @param startPoint
 *            the start point of the line
 * @param endPoint
 *            the end point of the line
 * @param l
 *            the length of the arrow line
 * @param angle
 *            the radians angle between the line and the arrow line.
 * @return A point list which includes the three points: <br>
 *         0: Right arrow point; <br>
 *         1: Left arrow point; <br>
 *         2: Intersection point.
 */
public static PointList calcArrowPoints(Point startPoint, Point endPoint, int l, double angle) {
    PointList result = new PointList();
    PolarPoint ppE = PolarPoint.point2PolarPoint(endPoint, startPoint);
    PolarPoint ppR = new PolarPoint(l, ppE.theta - angle);
    PolarPoint ppL = new PolarPoint(l, ppE.theta + angle);
    // the intersection point bettwen arrow and line.
    PolarPoint ppI = new PolarPoint((int) (l * Math.cos(angle)), ppE.theta);
    Point pR = ppR.toPoint().translate(endPoint);
    Point pL = ppL.toPoint().translate(endPoint);
    Point pI = ppI.toPoint().translate(endPoint);
    result.addPoint(pR);
    result.addPoint(pL);
    result.addPoint(pI);
    return result;
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Point(org.eclipse.draw2d.geometry.Point) PolarPoint(org.csstudio.swt.widgets.figureparts.PolarPoint) 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