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);
}
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);
}
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;
}
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();
}
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;
}
Aggregations