use of org.apache.pivot.wtk.Dimensions in project pivot by apache.
the class TerraFormSkin method getPreferredHeight.
@Override
public int getPreferredHeight(int width) {
int preferredHeight = 0;
Form form = (Form) getComponent();
Form.SectionSequence sections = form.getSections();
// Determine the field width constraint
int fieldWidth = (fill && width != -1) ? getFieldWidth(width) : -1;
for (int sectionIndex = 0, sectionCount = sections.getLength(); sectionIndex < sectionCount; sectionIndex++) {
Form.Section section = sections.get(sectionIndex);
if (sectionIndex > 0 || section.getHeading() != null) {
Separator separator = separators.get(sectionIndex);
preferredHeight += separator.getPreferredHeight(width);
preferredHeight += verticalSpacing;
}
for (int fieldIndex = 0, fieldCount = section.getLength(); fieldIndex < fieldCount; fieldIndex++) {
Component field = section.get(fieldIndex);
if (field.isVisible()) {
// Determine the label size and baseline
Label label = labels.get(sectionIndex).get(fieldIndex);
Dimensions labelSize = label.getPreferredSize();
int labelAscent = label.getBaseline(labelSize.width, labelSize.height);
int labelDescent = labelSize.height - labelAscent;
// Determine the field size and baseline
Dimensions fieldSize;
if (fill && fieldWidth != -1) {
fieldSize = new Dimensions(fieldWidth, field.getPreferredHeight(fieldWidth));
} else {
fieldSize = field.getPreferredSize();
}
int fieldAscent = field.getBaseline(fieldSize.width, fieldSize.height);
if (fieldAscent == -1) {
fieldAscent = fieldSize.height;
}
int fieldDescent = fieldSize.height - fieldAscent;
// Determine the row height
int maximumAscent = Math.max(labelAscent, fieldAscent);
int maximumDescent = Math.max(labelDescent, fieldDescent);
int rowHeight = maximumAscent + maximumDescent;
preferredHeight += rowHeight;
if (fieldIndex > 0) {
preferredHeight += verticalSpacing;
}
}
}
}
preferredHeight += (padding.top + padding.bottom);
return preferredHeight;
}
use of org.apache.pivot.wtk.Dimensions in project pivot by apache.
the class TerraFrameSkin method getPreferredSize.
@Override
public Dimensions getPreferredSize() {
int preferredWidth = 0;
int preferredHeight = 0;
Frame frame = (Frame) getComponent();
// Include title bar width plus left/right title bar borders
Dimensions titleBarSize = titleBarTablePane.getPreferredSize();
preferredWidth = Math.max(preferredWidth, titleBarSize.width + 2);
// Include title bar height plus top/bottom title bar borders
preferredHeight += titleBarSize.height + 2;
// Include menu bar size
MenuBar menuBar = frame.getMenuBar();
if (menuBar != null) {
Dimensions preferredMenuBarSize = menuBar.getPreferredSize();
preferredWidth = Math.max(preferredWidth, preferredMenuBarSize.width);
preferredHeight += preferredMenuBarSize.height;
}
Component content = frame.getContent();
if (content != null) {
Dimensions preferredContentSize = content.getPreferredSize();
preferredWidth = Math.max(preferredWidth, preferredContentSize.width);
preferredHeight += preferredContentSize.height;
}
// Add padding, borders, and content bevel
preferredWidth += (padding.left + padding.right) + 2;
preferredHeight += (padding.top + padding.bottom) + (showContentBevel ? 1 : 0) + 2;
return new Dimensions(preferredWidth, preferredHeight);
}
use of org.apache.pivot.wtk.Dimensions in project pivot by apache.
the class TerraSheetSkin method getPreferredSize.
@Override
public Dimensions getPreferredSize() {
Dimensions preferredSize = Dimensions.ZERO;
Sheet sheet = (Sheet) getComponent();
Component content = sheet.getContent();
if (content != null) {
preferredSize = content.getPreferredSize();
}
// Account for border in the size
return preferredSize.expand(2).expand(padding);
}
use of org.apache.pivot.wtk.Dimensions in project pivot by apache.
the class TerraSplitPaneSkin method getPreferredSize.
@Override
public Dimensions getPreferredSize() {
int preferredWidth = splitterThickness;
int preferredHeight = splitterThickness;
SplitPane splitPane = (SplitPane) getComponent();
Component topLeft = splitPane.getTopLeft();
if (topLeft != null) {
Dimensions size = topLeft.getPreferredSize();
preferredWidth += size.width;
preferredHeight += size.height;
}
Component bottomRight = splitPane.getBottomRight();
if (bottomRight != null) {
Dimensions size = bottomRight.getPreferredSize();
preferredWidth += size.width;
preferredHeight += size.height;
}
return new Dimensions(preferredWidth, preferredHeight);
}
use of org.apache.pivot.wtk.Dimensions in project pivot by apache.
the class TerraTabPaneSkin method getPreferredSize.
@Override
public Dimensions getPreferredSize() {
TabPane tabPane = (TabPane) getComponent();
int preferredWidth;
int preferredHeight;
Component selectedTab = tabPane.getSelectedTab();
Component corner = tabPane.getCorner();
switch(tabOrientation) {
case HORIZONTAL:
{
if (selectedTab == null && selectionChangeTransition == null) {
preferredWidth = getPreferredTabWidth(-1) + (padding.left + padding.right + 2);
preferredHeight = 1;
} else {
Dimensions preferredTabSize = getPreferredTabSize();
preferredWidth = preferredTabSize.width + (padding.left + padding.right + 2);
preferredHeight = preferredTabSize.height + (padding.top + padding.bottom);
if (selectionChangeTransition != null) {
float scale = selectionChangeTransition.getScale();
preferredHeight = (int) (preferredHeight * scale);
}
preferredHeight += 2;
}
int buttonAreaPreferredWidth = tabButtonPanorama.getPreferredWidth(-1);
if (corner != null) {
buttonAreaPreferredWidth += corner.getPreferredWidth(-1);
preferredHeight += Math.max(corner.getPreferredHeight(-1), Math.max(tabButtonPanorama.getPreferredHeight(-1) - 1, 0));
// space between corner and
buttonAreaPreferredWidth += 2;
// panorama
} else {
preferredHeight += Math.max(tabButtonPanorama.getPreferredHeight(-1) - 1, 0);
}
preferredWidth = Math.max(preferredWidth, buttonAreaPreferredWidth);
break;
}
case VERTICAL:
{
if (selectedTab == null && selectionChangeTransition == null) {
preferredWidth = 1;
preferredHeight = getPreferredTabHeight(-1) + (padding.top + padding.bottom + 2);
} else {
Dimensions preferredTabSize = getPreferredTabSize();
preferredWidth = preferredTabSize.width + (padding.left + padding.right);
preferredHeight = preferredTabSize.height + (padding.top + padding.bottom + 2);
if (selectionChangeTransition != null) {
float scale = selectionChangeTransition.getScale();
preferredWidth = (int) (preferredWidth * scale);
}
preferredWidth += 2;
}
int buttonAreaPreferredHeight = tabButtonPanorama.getPreferredHeight(-1);
if (corner != null) {
buttonAreaPreferredHeight += corner.getPreferredHeight(-1);
preferredWidth += Math.max(corner.getPreferredWidth(-1), Math.max(tabButtonPanorama.getPreferredWidth(-1) - 1, 0));
// space between corner and
buttonAreaPreferredHeight += 2;
// panorama
} else {
preferredWidth += Math.max(tabButtonPanorama.getPreferredWidth(-1) - 1, 0);
}
preferredHeight = Math.max(preferredHeight, buttonAreaPreferredHeight);
break;
}
default:
{
preferredWidth = 0;
preferredHeight = 0;
}
}
return new Dimensions(preferredWidth, preferredHeight);
}
Aggregations