Search in sources :

Example 56 with Dimension

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();
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 57 with Dimension

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();
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 58 with Dimension

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()));
    }
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 59 with Dimension

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);
    }
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 60 with Dimension

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);
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension) ArrayModel(org.csstudio.opibuilder.widgets.model.ArrayModel)

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