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