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);
}
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);
}
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();
}
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);
}
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();
}
}
Aggregations