Search in sources :

Example 81 with Dimension

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

the class ArrayFigure method calculatePreferredSize.

/**
 * Calculate the preferred size based current layout and elements' size.
 *
 * @see org.eclipse.draw2d.XYLayout#calculatePreferredSize(org.eclipse.draw2d.IFigure, int, int)
 */
protected Dimension calculatePreferredSize() {
    Dimension result = new Dimension();
    Dimension elementSize = getElementSize();
    if (elementSize == null)
        return getSize();
    if (horizontal) {
        result.height = elementSize.height + (scrollbar.isVisible() ? SCROLLBAR_WIDTH : 0) + pane.getInsets().getHeight();
        if (spinner.isVisible() && result.height < SPINNER_HEIGHT)
            result.height = SPINNER_HEIGHT;
        result.width = elementSize.width * getVisibleElementsCount() + pane.getInsets().getWidth() + (spinner.isVisible() ? spinnerWidth : 0);
    } else {
        result.width = elementSize.width + pane.getInsets().getWidth() + (scrollbar.isVisible() ? SCROLLBAR_WIDTH : 0) + (spinner.isVisible() ? spinnerWidth : 0);
        result.height = elementSize.height * getVisibleElementsCount() + pane.getInsets().getHeight();
    }
    result.width += getInsets().getWidth();
    result.height += getInsets().getHeight();
    return result;
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 82 with Dimension

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

the class CheckBoxFigure method getAutoSizeDimension.

public Dimension getAutoSizeDimension() {
    Dimension d = boxFigure.getAutoSizeDimension();
    int textWidth = d.width();
    d.setWidth(textWidth + BOX_SIZE + GAP);
    return d;
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 83 with Dimension

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

the class IntensityGraphFigure method layout.

@Override
protected void layout() {
    Rectangle clientArea = getClientArea().getCopy();
    Rectangle yAxisBounds = null, xAxisBounds = null, rampBounds;
    // This is a temporary fix of cursor value problem when the axes are invisible
    // xAxis.isVisible();
    boolean xVisible = true;
    // yAxis.isVisible();
    boolean yVisible = true;
    if (yVisible) {
        Dimension yAxisSize = yAxis.getPreferredSize(clientArea.width, clientArea.height);
        yAxisBounds = new Rectangle(clientArea.x, clientArea.y, yAxisSize.width, // the height is not correct for now
        yAxisSize.height);
        clientArea.x += yAxisSize.width;
        clientArea.y += yAxis.getMargin();
        clientArea.height -= xVisible ? yAxis.getMargin() : 2 * yAxis.getMargin() - 1;
        clientArea.width -= yAxisSize.width;
    }
    if (xVisible) {
        Dimension xAxisSize = xAxis.getPreferredSize(clientArea.width, clientArea.height);
        xAxisBounds = new Rectangle((yVisible ? yAxisBounds.x + yAxisBounds.width - xAxis.getMargin() - 1 : clientArea.x), clientArea.y + clientArea.height - xAxisSize.height, xAxisSize.width, // the width is not correct for now
        xAxisSize.height);
        clientArea.height -= xAxisSize.height;
        // re-adjust yAxis height
        if (yVisible) {
            yAxisBounds.height -= (xAxisSize.height - yAxis.getMargin());
        } else {
            clientArea.x += xAxis.getMargin();
            clientArea.width -= xAxis.getMargin() - 1;
        }
    }
    if (colorMapRamp.isVisible()) {
        Dimension rampSize = colorMapRamp.getPreferredSize(clientArea.width, clientArea.height);
        rampBounds = new Rectangle(clientArea.x + clientArea.width - rampSize.width, clientArea.y, rampSize.width, clientArea.height);
        colorMapRamp.setBounds(rampBounds);
        clientArea.width -= (rampSize.width + GAP);
        // re-adjust xAxis width
        if (xVisible)
            if (yVisible)
                xAxisBounds.width -= (rampSize.width + GAP - 2 * xAxis.getMargin());
            else
                xAxisBounds.width -= (rampSize.width + GAP - xAxis.getMargin());
    } else {
        // re-adjust xAxis width
        if (xVisible) {
            if (yVisible)
                xAxisBounds.width += xAxis.getMargin();
            clientArea.width -= xAxis.getMargin();
        }
    }
    if (yVisible) {
        yAxis.setBounds(yAxisBounds);
    }
    if (xVisible) {
        xAxis.setBounds(xAxisBounds);
    }
    graphArea.setBounds(clientArea);
    super.layout();
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 84 with Dimension

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

the class RoundedRectangleFigure method setCornerWidth.

public void setCornerWidth(int value) {
    setCornerDimensions(new Dimension(value, corner.height));
    repaint();
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 85 with Dimension

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

the class ScrollBarFigureLayout method calculatePreferredSize.

/**
 * @see AbstractLayout#calculatePreferredSize(IFigure, int, int)
 */
protected Dimension calculatePreferredSize(IFigure parent, int w, int h) {
    Insets insets = transposer.t(parent.getInsets());
    Dimension d = new Dimension(16, 16 * 4);
    d.expand(insets.getWidth(), insets.getHeight());
    return transposer.t(d);
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) 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