Search in sources :

Example 6 with PrecisionRectangle

use of org.eclipse.draw2d.geometry.PrecisionRectangle in project yamcs-studio by yamcs.

the class ROIFigure method getGeoBoundsFromROI.

private PrecisionRectangle getGeoBoundsFromROI(Rectangle roiDataBounds) {
    PrecisionPoint lt = ((GraphArea) getParent()).getGeoLocation(roiDataBounds.preciseX() - intensityGraphFigure.getCropLeft(), roiDataBounds.preciseY() - intensityGraphFigure.getCropTop());
    PrecisionPoint rb = ((GraphArea) getParent()).getGeoLocation(roiDataBounds.preciseX() + roiDataBounds.preciseWidth() - intensityGraphFigure.getCropLeft(), roiDataBounds.preciseY() + roiDataBounds.preciseHeight() - intensityGraphFigure.getCropTop());
    return new PrecisionRectangle(lt.preciseX() - getBounds().x, lt.preciseY() - getBounds().y, rb.preciseX() - lt.preciseX(), rb.preciseY() - lt.preciseY());
}
Also used : PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint) GraphArea(org.csstudio.swt.widgets.figures.IntensityGraphFigure.GraphArea)

Example 7 with PrecisionRectangle

use of org.eclipse.draw2d.geometry.PrecisionRectangle in project yamcs-studio by yamcs.

the class ROIFigure method getROIFromGeoBounds.

private Rectangle getROIFromGeoBounds(PrecisionRectangle roiBounds) {
    PrecisionPoint lt = ((GraphArea) getParent()).getDataLocation(roiBounds.preciseX(), roiBounds.preciseY());
    PrecisionPoint rb = ((GraphArea) getParent()).getDataLocation(roiBounds.preciseX() + roiBounds.preciseWidth(), roiBounds.preciseY() + roiBounds.preciseHeight());
    return new Rectangle((int) Math.round(lt.preciseX()) + intensityGraphFigure.getCropLeft(), (int) Math.round(lt.preciseY()) + intensityGraphFigure.getCropTop(), (int) Math.ceil(rb.preciseX() - lt.preciseX()), (int) Math.ceil(rb.preciseY() - lt.preciseY()));
}
Also used : PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint) GraphArea(org.csstudio.swt.widgets.figures.IntensityGraphFigure.GraphArea)

Example 8 with PrecisionRectangle

use of org.eclipse.draw2d.geometry.PrecisionRectangle in project yamcs-studio by yamcs.

the class GraphicalFeedbackChildEditPolicy method showChangeBoundsFeedback.

/**
 * Shows or updates feedback for a change bounds request.
 *
 * @param request
 *            the request
 */
@Override
protected void showChangeBoundsFeedback(final ChangeBoundsRequest request) {
    IFigure feedbackFigure = getDragSourceFeedbackFigure();
    PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
    getHostFigure().translateToAbsolute(rect);
    Point moveDelta = request.getMoveDelta();
    rect.translate(moveDelta);
    Dimension sizeDelta = request.getSizeDelta();
    rect.resize(sizeDelta);
    feedbackFactory.showChangeBoundsFeedback((AbstractWidgetModel) getHost().getModel(), rect, feedbackFigure, request);
    feedbackFigure.repaint();
}
Also used : PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) IFigure(org.eclipse.draw2d.IFigure)

Example 9 with PrecisionRectangle

use of org.eclipse.draw2d.geometry.PrecisionRectangle in project yamcs-studio by yamcs.

the class WidgetXYLayoutEditPolicy method getConstraintForResize.

// super.super.getConstraintFor() has been overriden to fix a bug when handle bounds does not equal with bounds. For example, polyline figue.
/**
 * Generates a draw2d constraint object derived from the specified child
 * EditPart using the provided Request. The returned constraint will be
 * translated to the application's model later using
 * {@link #translateToModelConstraint(Object)}.
 *
 * @param request
 *            the ChangeBoundsRequest
 * @param child
 *            the child EditPart for which the constraint should be
 *            generated
 * @return the draw2d constraint
 */
protected Object getConstraintForResize(ChangeBoundsRequest request, GraphicalEditPart child) {
    Rectangle bounds = child.getFigure().getBounds();
    if (child.getFigure() instanceof HandleBounds) {
        bounds = ((HandleBounds) child.getFigure()).getHandleBounds();
    }
    Rectangle rect = new PrecisionRectangle(bounds);
    child.getFigure().translateToAbsolute(rect);
    rect = request.getTransformedRectangle(rect);
    child.getFigure().translateToRelative(rect);
    rect.translate(getLayoutOrigin().getNegated());
    return getConstraintFor(rect);
}
Also used : HandleBounds(org.eclipse.gef.handles.HandleBounds) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Aggregations

PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)9 Point (org.eclipse.draw2d.geometry.Point)4 Rectangle (org.eclipse.draw2d.geometry.Rectangle)4 IFigure (org.eclipse.draw2d.IFigure)3 GraphArea (org.csstudio.swt.widgets.figures.IntensityGraphFigure.GraphArea)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)2 HandleBounds (org.eclipse.gef.handles.HandleBounds)2 ChangeBoundsRequest (org.eclipse.gef.requests.ChangeBoundsRequest)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 PointList (org.eclipse.draw2d.geometry.PointList)1 EditPart (org.eclipse.gef.EditPart)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 CreateRequest (org.eclipse.gef.requests.CreateRequest)1 NodeAnnotation (org.knime.core.node.workflow.NodeAnnotation)1 AbstractPortEditPart (org.knime.workbench.editor2.editparts.AbstractPortEditPart)1 NodeAnnotationEditPart (org.knime.workbench.editor2.editparts.NodeAnnotationEditPart)1 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)1 NodeInPortEditPart (org.knime.workbench.editor2.editparts.NodeInPortEditPart)1