Search in sources :

Example 61 with Dimension

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

the class PolyPointDragTracker method updateSourceRequest.

/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings("unchecked")
protected void updateSourceRequest() {
    super.updateSourceRequest();
    ChangeBoundsRequest request = (ChangeBoundsRequest) getSourceRequest();
    PrecisionPoint location = new PrecisionPoint(getLocation().x, getLocation().y);
    if (_snapToHelper != null) {
        _snapToHelper.snapPoint(request, PositionConstants.NORTH_WEST, new PrecisionPoint(getLocation().x, getLocation().y), location);
    }
    _owner.getFigure().translateToRelative(location);
    PointList oldPoints = ((PointList) request.getExtendedData().get(EXT_DATA_POINTS)).getCopy();
    PointList newPoints = oldPoints.getCopy();
    newPoints.setPoint(location.getCopy(), _pointIndex);
    // calculate difference
    Rectangle oldBounds = _oldPoints.getBounds();
    Rectangle newBounds = newPoints.getBounds();
    request.setLocation(getLocation());
    Dimension locationDiff = newBounds.getLocation().getDifference(oldBounds.getLocation());
    _owner.getFigure().translateToAbsolute(locationDiff);
    Dimension sizeDiff = newBounds.getSize().getDifference(oldBounds.getSize());
    _owner.getFigure().translateToAbsolute(sizeDiff);
    request.setMoveDelta(new Point(locationDiff.width, locationDiff.height));
    request.setSizeDelta(sizeDiff);
    request.getExtendedData().put(EXT_DATA_POINTS, newPoints);
    request.getExtendedData().put(EXT_DATA_POINT_INDEX, _pointIndex);
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) PointList(org.eclipse.draw2d.geometry.PointList) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint)

Example 62 with Dimension

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

the class PolyPointLocator method relocate.

/**
 * {@inheritDoc}
 */
@Override
public void relocate(final IFigure target) {
    Point p = _referenceFigure.getPoints().getPoint(_pointIndex);
    _referenceFigure.translateToAbsolute(p);
    target.translateToRelative(p);
    Rectangle relativeBounds = new PrecisionRectangle(getReferenceBox().getResized(-1, -1));
    Dimension targetSize = target.getPreferredSize();
    relativeBounds.x = p.x - ((targetSize.width + 1) / 2);
    relativeBounds.y = p.y - ((targetSize.height + 1) / 2);
    relativeBounds.setSize(targetSize);
    target.setBounds(relativeBounds);
}
Also used : PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 63 with Dimension

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

the class ImageBoolButtonFigure method layout.

@Override
protected void layout() {
    Rectangle clientArea = getClientArea().getCopy();
    if (boolLabel.isVisible()) {
        Dimension labelSize = boolLabel.getPreferredSize();
        boolLabel.setBounds(new Rectangle(getLabelLocation(clientArea.x + clientArea.width / 2 - labelSize.width / 2, clientArea.y + clientArea.height / 2 - labelSize.height / 2), new Dimension(labelSize.width, labelSize.height)));
    }
    super.layout();
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 64 with Dimension

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

the class FillParentContainerAction method run.

@Override
public void run(IAction action) {
    AbstractBaseEditPart widget = (AbstractBaseEditPart) selection.getFirstElement();
    AbstractContainerEditpart containerEditpart = getParentContainerEditpart();
    Dimension size = null;
    if (containerEditpart instanceof DisplayEditpart)
        size = ((DisplayEditpart) containerEditpart).getWidgetModel().getSize();
    else
        size = containerEditpart.getFigure().getClientArea().getSize();
    Command cmd = new SetBoundsCommand(widget.getWidgetModel(), new Rectangle(0, 0, size.width, size.height));
    execute(cmd);
}
Also used : AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) SetBoundsCommand(org.csstudio.opibuilder.commands.SetBoundsCommand) Command(org.eclipse.gef.commands.Command) AbstractContainerEditpart(org.csstudio.opibuilder.editparts.AbstractContainerEditpart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) SetBoundsCommand(org.csstudio.opibuilder.commands.SetBoundsCommand) Dimension(org.eclipse.draw2d.geometry.Dimension) DisplayEditpart(org.csstudio.opibuilder.editparts.DisplayEditpart)

Example 65 with Dimension

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

the class AbstractSymbolImage method setBounds.

public void setBounds(Rectangle newBounds) {
    if (newBounds == null || newBounds.equals(this.bounds) || newBounds.width <= 0 || newBounds.height <= 0)
        return;
    if (this.bounds == null) {
        this.bounds = newBounds.getCopy();
        resizeImage();
        return;
    }
    Rectangle oldBounds = this.bounds.getCopy();
    this.bounds = newBounds.getCopy();
    if (autoSize) {
        Dimension dim = getAutoSizedDimension();
        if (dim == null)
            return;
        if (newBounds.width != dim.width || newBounds.height != dim.height)
            resizeImage();
    } else {
        if (oldBounds.width != newBounds.width || oldBounds.height != newBounds.height)
            resizeImage();
    }
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension)

Aggregations

Dimension (org.eclipse.draw2d.geometry.Dimension)180 Rectangle (org.eclipse.draw2d.geometry.Rectangle)80 Point (org.eclipse.draw2d.geometry.Point)70 IFigure (org.eclipse.draw2d.IFigure)31 List (java.util.List)16 Insets (org.eclipse.draw2d.geometry.Insets)10 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)8 PointList (org.eclipse.draw2d.geometry.PointList)6 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)6 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)6 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)5 ArrayList (java.util.ArrayList)4 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)4 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)4 Font (org.eclipse.swt.graphics.Font)4 Point (org.eclipse.swt.graphics.Point)4 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)3 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)3 Label (org.eclipse.draw2d.Label)3 SimpleHtmlFigure (org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)3