/** * Constructs a new {@link LayoutPoint} from the given event. The event must be from a {@link * MouseListener} associated with the {@link LayoutCanvas} such that the {@link MouseEvent#x} and * {@link MouseEvent#y} fields are relative to the canvas. * * @param canvas The {@link LayoutCanvas} this point is within. * @param event The mouse event to construct the {@link LayoutPoint} from. * @return A {@link LayoutPoint} which corresponds to the given {@link MouseEvent}. */ public static LayoutPoint create(LayoutCanvas canvas, MouseEvent event) { // The mouse event coordinates should already be relative to the canvas // widget. assert event.widget == canvas : event.widget; return ControlPoint.create(canvas, event).toLayout(); }
/** * Constructs a new {@link LayoutPoint} from the given event. The event must be from a {@link * DragSourceListener} associated with the {@link LayoutCanvas} such that the {@link * DragSourceEvent#x} and {@link DragSourceEvent#y} fields are relative to the canvas. * * @param canvas The {@link LayoutCanvas} this point is within. * @param event The mouse event to construct the {@link LayoutPoint} from. * @return A {@link LayoutPoint} which corresponds to the given {@link DragSourceEvent}. */ public static LayoutPoint create(LayoutCanvas canvas, DragSourceEvent event) { // The drag source event coordinates should already be relative to the // canvas widget. return ControlPoint.create(canvas, event).toLayout(); }
/** * Returns the equivalent {@link ControlPoint} to this {@link LayoutPoint}. * * @return The equivalent {@link ControlPoint} to this {@link LayoutPoint} */ public ControlPoint toControl() { int cx = mCanvas.getHorizontalTransform().translate(x); int cy = mCanvas.getVerticalTransform().translate(y); return ControlPoint.create(mCanvas, cx, cy); }