Java Code Examples for org.eclipse.draw2d.geometry.Point#x()

The following examples show how to use org.eclipse.draw2d.geometry.Point#x() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CursorTimingsLayer.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Clip cursor connectors at the left/right side of the screen. This is a performance optimization for windows. When a connection is much larger than
 * the screen size, drawing takes ages.
 */
@Override
public PointList getPoints() {
	final PointList originalPoints = super.getPoints();
	if (originalPoints.size() == 2) {
		final Point targetPoint = originalPoints.getLastPoint();
		final Rectangle layerBounds = CursorTimingsLayer.this.getBounds();

		if (targetPoint.x() < layerBounds.x()) {
			// clip cursor on the left screen border
			targetPoint.setX(layerBounds.x());
			originalPoints.setPoint(targetPoint, 1);

		} else if (targetPoint.x() > layerBounds.right()) {
			// clip cursor on the right screen border
			targetPoint.setX(layerBounds.right());
			originalPoints.setPoint(targetPoint, 1);
		}
	}

	return originalPoints;
}
 
Example 2
Source File: DiagramElementsModifier.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Sets the points of a connection.
 * 
 * @param connection
 *            - The connection
 * @param bendpoints
 *            - Start, end and bending points
 */
public static void setConnectionPoints(ConnectionNodeEditPart connection, List<Point> bendpoints) {
	TransactionalEditingDomain editingDomain = connection.getEditingDomain();
	SetConnectionBendpointsCommand cmd = new SetConnectionBendpointsCommand(editingDomain);
	cmd.setEdgeAdapter(new EObjectAdapter(connection.getNotationView()));

	Point first = bendpoints.get(0);
	Point last = bendpoints.get(bendpoints.size() - 1);
	Point sourceRef = new Point(first.x(), first.y());
	Point targetRef = new Point(last.x(), last.y());
	PointList pointList = new PointList();

	for (Point bendpoint : bendpoints) {
		pointList.addPoint(new Point(bendpoint.x(), bendpoint.y()));
	}

	cmd.setNewPointList(pointList, sourceRef, targetRef);
	Command proxy = new ICommandProxy(cmd);
	proxy.execute();
}
 
Example 3
Source File: SequenceFlowLabelLocationCalculator.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected Point computeLabelLocation(final Bounds bounds, final Point edgeCenter, final org.omg.spec.dd.dc.Point pointA, final org.omg.spec.dd.dc.Point pointB) {
		boolean isVerticalAndFromUpToDown = pointA.getX() - pointB.getX() == 0 && (pointA.getY() - pointB.getY() > 0);
		boolean isVerticalAndFromDownToUp =pointA.getX() - pointB.getX() == 0 && (pointA.getY() - pointB.getY() < 0);
		boolean isHozitontalAndFromLeftToRigth = pointA.getY() - pointB.getY() == 0 && pointA.getX() - pointB.getX() < 0;
		boolean isHozitontalAndisFromRightToLeft = pointA.getY() - pointB.getY() == 0 && pointA.getX() - pointB.getX() > 0;
		if (isVerticalAndFromUpToDown) {
			return new Point(-(bounds.getY() - edgeCenter.y()), bounds.getX() - edgeCenter.x());//vertical Bottom-Up
		}
		if (isVerticalAndFromDownToUp) {
			return new Point(bounds.getY() - edgeCenter.y(), -(bounds.getX() - edgeCenter.x()));//vertical Up-Down
		}
		if (isHozitontalAndFromLeftToRigth) {
			return new Point(bounds.getX() - edgeCenter.x(), bounds.getY() - edgeCenter.y());//horizontal Left-to-Right
		}
		if (isHozitontalAndisFromRightToLeft) {
			return new Point(-(bounds.getX() - edgeCenter.x()), -(bounds.getY() - edgeCenter.y()));//horizontal Right-to-Left
		}
	return new Point(0, 0);
}
 
Example 4
Source File: CursorTimingsLayer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Point getLocation(PointList points) {
	final IFigure cursorLabel = (IFigure) getConnection().getChildren().get(1);
	final Dimension labelSize = cursorLabel.getPreferredSize();

	final Point firstPoint = points.getFirstPoint();
	final Point lastPoint = points.getLastPoint();
	final int direction = (lastPoint.x() > firstPoint.x()) ? 1 : -1;

	final Point point = super.getLocation(points);
	point.translate(((labelSize.width() / 2) + fDistance) * direction, 0);

	return point;
}