use of org.eclipse.draw2d.geometry.Dimension in project knime-core by knime.
the class WorkflowEditor method getEditorGridY.
/**
* Returns the grid vertical spacing or the y value from the preference page, if the editor's property is not
* set.
*
* @return the editors grid, or the value from the pref page (if not set in the editor)
*/
public int getEditorGridY() {
GraphicalViewer viewer = getViewer();
if (viewer == null) {
return getPrefGridYSize();
}
Dimension grid = (Dimension) viewer.getProperty(SnapToGrid.PROPERTY_GRID_SPACING);
if (grid != null) {
return grid.height;
}
return getPrefGridYSize();
}
use of org.eclipse.draw2d.geometry.Dimension in project knime-core by knime.
the class WorkflowEditor method applyEditorSettings.
/**
* Applies the settings to the editor. Can't be null. Settings are not stored in the workflow manager.
* @see #getCurrentEditorSettings()
* @see #getEditorSettingsDefault()
* @param settings to apply
*/
public void applyEditorSettings(final EditorUIInformation settings) {
getViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, Boolean.valueOf(settings.getSnapToGrid()));
getViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, Boolean.valueOf(settings.getShowGrid()));
getViewer().setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(settings.getGridX(), settings.getGridY()));
setZoomfactor(settings.getZoomLevel());
m_hasCurvedConnections = settings.getHasCurvedConnections();
m_connectionLineWidth = settings.getConnectionLineWidth();
}
use of org.eclipse.draw2d.geometry.Dimension in project yamcs-studio by yamcs.
the class AbstractContainerEditpart method performAutosize.
/**
* Automatically set the container size according its children's geography size.
*/
public void performAutosize() {
Rectangle childrenRange = GeometryUtil.getChildrenRange(this);
Point tranlateSize = new Point(childrenRange.x, childrenRange.y);
getWidgetModel().setSize(new Dimension(childrenRange.width + figure.getInsets().left + figure.getInsets().right, childrenRange.height + figure.getInsets().top + figure.getInsets().bottom));
for (Object editpart : getChildren()) {
AbstractWidgetModel widget = ((AbstractBaseEditPart) editpart).getWidgetModel();
widget.setLocation(widget.getLocation().translate(tranlateSize.getNegated()));
}
}
use of org.eclipse.draw2d.geometry.Dimension in project yamcs-studio by yamcs.
the class AbstractContainerModel method scaleChildren.
public void scaleChildren() {
Dimension size = getSize();
double newWidthRatio = size.width / (double) getOriginSize().width;
double newHeightRatio = size.height / (double) getOriginSize().height;
for (AbstractWidgetModel child : getChildren()) {
child.scale(newWidthRatio, newHeightRatio);
}
}
use of org.eclipse.draw2d.geometry.Dimension in project yamcs-studio by yamcs.
the class ArrayFeedbackFactory method showChangeBoundsFeedback.
@Override
public void showChangeBoundsFeedback(AbstractWidgetModel widgetModel, PrecisionRectangle bounds, IFigure feedbackFigure, ChangeBoundsRequest request) {
ArrayModel arrayModel = (ArrayModel) widgetModel;
if (arrayModel.getChildren().isEmpty()) {
super.showChangeBoundsFeedback(widgetModel, bounds, feedbackFigure, request);
return;
}
Dimension sizeDelta = request.getSizeDelta();
if (arrayModel.isHorizontal()) {
int eWidth = arrayModel.getChildren().get(0).getWidth();
bounds.width -= sizeDelta.width;
sizeDelta.width = Math.round((float) sizeDelta.width / eWidth) * eWidth;
bounds.width += sizeDelta.width;
} else {
int eHeight = arrayModel.getChildren().get(0).getHeight();
bounds.height -= sizeDelta.height;
sizeDelta.height = Math.round((float) sizeDelta.height / eHeight) * eHeight;
bounds.height += sizeDelta.height;
}
super.showChangeBoundsFeedback(widgetModel, bounds, feedbackFigure, request);
}
Aggregations