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