Search in sources :

Example 1 with AbstractPolyModel

use of org.csstudio.opibuilder.widgets.model.AbstractPolyModel in project yamcs-studio by yamcs.

the class AbstractPolyFeedbackFactory method createInitialBoundsCommand.

/**
 * {@inheritDoc}
 */
@Override
public final Command createInitialBoundsCommand(final AbstractWidgetModel widgetModel, final CreateRequest request, final Rectangle bounds) {
    // $NON-NLS-1$
    assert widgetModel instanceof AbstractPolyModel : "widgetModel instanceof AbstractPolyModel";
    assert request != null;
    assert bounds != null;
    AbstractPolyModel abstractPolyElement = (AbstractPolyModel) widgetModel;
    PointList points = (PointList) request.getExtendedData().get(PROP_POINTS);
    // necessary if the call was occurred by a "Drag and Drop" action
    if (points == null) {
        points = (PointList) widgetModel.getProperty(AbstractPolyModel.PROP_POINTS).getPropertyValue();
    }
    // the points are viewer relative and need to be translated to the
    // specified bounds, to reflect zoom level, scrollbar occurence etc.
    PointList scaledPoints = PointListHelper.scaleTo(points, bounds);
    return new ChangePolyPointsCommand(abstractPolyElement, scaledPoints);
}
Also used : AbstractPolyModel(org.csstudio.opibuilder.widgets.model.AbstractPolyModel) PointList(org.eclipse.draw2d.geometry.PointList)

Example 2 with AbstractPolyModel

use of org.csstudio.opibuilder.widgets.model.AbstractPolyModel in project yamcs-studio by yamcs.

the class AbstractPolyFeedbackFactory method createChangeBoundsCommand.

/**
 * {@inheritDoc}
 */
@Override
public final Command createChangeBoundsCommand(final AbstractWidgetModel model, final ChangeBoundsRequest request, final Rectangle targetBounds) {
    // $NON-NLS-1$
    assert model instanceof AbstractPolyModel : "model instanceof AbstractPolyModel";
    Rectangle correctedBounds = targetBounds;
    // if (model instanceof PolyLineModel) {
    // PolyLineModel polyline = (PolyLineModel) model;
    // int correctedX = targetBounds.x + (polyline.getLineWidth() / 2);
    // int correctedY = targetBounds.y + (polyline.getLineWidth() / 2);
    // correctedBounds = new Rectangle(correctedX, correctedY, targetBounds.width, targetBounds.height);
    // }
    AbstractPolyModel abstractPolyElement = (AbstractPolyModel) model;
    // try to get a point list from the request (this happens only, when
    // poly point handles are dragged arround)
    PointList points = (PointList) request.getExtendedData().get(PROP_POINTS);
    // otherwise take the points from the model
    if (points == null) {
        points = ((AbstractPolyModel) model).getPoints();
    }
    assert points != null;
    // the points are viewer relative and need to be translated to the
    // specified bounds, to reflect zoom level, scrollbar occurence etc.
    points = PointListHelper.scaleTo(points, correctedBounds);
    return new ChangePolyPointsCommand(abstractPolyElement, points);
}
Also used : AbstractPolyModel(org.csstudio.opibuilder.widgets.model.AbstractPolyModel) PointList(org.eclipse.draw2d.geometry.PointList) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 3 with AbstractPolyModel

use of org.csstudio.opibuilder.widgets.model.AbstractPolyModel in project yamcs-studio by yamcs.

the class AbstractPolyFeedbackFactory method createCustomHandles.

/**
 * {@inheritDoc}
 */
@Override
public final List<Handle> createCustomHandles(final GraphicalEditPart hostEP) {
    assert hostEP != null;
    // $NON-NLS-1$
    assert hostEP.getModel() instanceof AbstractPolyModel : "hostEP.getModel() instanceof AbstractPolyModel";
    // create some custom handles, which enable the user to drag arround
    // single points of the polyline
    List<Handle> handles = new ArrayList<Handle>();
    AbstractPolyModel abstractPolyElement = (AbstractPolyModel) hostEP.getModel();
    int pointCount = abstractPolyElement.getPoints().size();
    for (int i = 0; i < pointCount; i++) {
        PolyPointHandle myHandle = new PolyPointHandle(hostEP, i);
        handles.add(myHandle);
    }
    return handles;
}
Also used : AbstractPolyModel(org.csstudio.opibuilder.widgets.model.AbstractPolyModel) ArrayList(java.util.ArrayList) Handle(org.eclipse.gef.Handle)

Example 4 with AbstractPolyModel

use of org.csstudio.opibuilder.widgets.model.AbstractPolyModel in project yamcs-studio by yamcs.

the class PolyPointDragTracker method createSourceRequest.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
protected Request createSourceRequest() {
    ChangeBoundsRequest request = new ChangeBoundsRequest();
    // TODO: swende: ugly
    request.setEditParts(getTargetEditPart());
    PointList points = ((AbstractPolyModel) _owner.getModel()).getPoints();
    request.getExtendedData().put(AbstractPolyFeedbackFactory.PROP_POINTS, points.getCopy());
    request.setType(RequestConstants.REQ_RESIZE);
    _oldPoints = points.getCopy();
    return request;
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) PointList(org.eclipse.draw2d.geometry.PointList) AbstractPolyModel(org.csstudio.opibuilder.widgets.model.AbstractPolyModel)

Example 5 with AbstractPolyModel

use of org.csstudio.opibuilder.widgets.model.AbstractPolyModel in project yamcs-studio by yamcs.

the class AbstractPolyFeedbackFactory method showChangeBoundsFeedback.

/**
 * {@inheritDoc}
 */
@Override
public final void showChangeBoundsFeedback(final AbstractWidgetModel model, final PrecisionRectangle bounds, final IFigure feedbackFigure, final ChangeBoundsRequest request) {
    assert model != null;
    // $NON-NLS-1$
    assert model instanceof AbstractPolyModel : "model instanceof AbstractPolyModel";
    assert bounds != null;
    assert feedbackFigure != null;
    // $NON-NLS-1$
    assert feedbackFigure instanceof PolyFeedbackFigureWithRectangle : "feedbackFigure instanceof AbstractPolyFeedbackFigure";
    assert request != null;
    PolyFeedbackFigureWithRectangle figure = (PolyFeedbackFigureWithRectangle) feedbackFigure;
    figure.translateToRelative(bounds);
    // try to get a point list from the request (this happens only, when
    // poly point handles are dragged arround)
    PointList points = (PointList) request.getExtendedData().get(PROP_POINTS);
    // otherwise take the points from the model
    if (points == null) {
        points = ((AbstractPolyModel) model).getPoints();
    }
    // scale the points to the specified bounds
    PointList scaledPoints = PointListHelper.scaleTo(points.getCopy(), bounds);
    // apply the scaled points
    figure.setPoints(scaledPoints);
}
Also used : AbstractPolyModel(org.csstudio.opibuilder.widgets.model.AbstractPolyModel) PointList(org.eclipse.draw2d.geometry.PointList)

Aggregations

AbstractPolyModel (org.csstudio.opibuilder.widgets.model.AbstractPolyModel)6 PointList (org.eclipse.draw2d.geometry.PointList)5 ArrayList (java.util.ArrayList)1 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 Handle (org.eclipse.gef.Handle)1 ChangeBoundsRequest (org.eclipse.gef.requests.ChangeBoundsRequest)1