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