use of org.apache.pivot.wtk.Orientation in project pivot by apache.
the class BoxPanes method updateBoxPaneState.
private void updateBoxPaneState() {
Orientation orientation = null;
if (horizontalOrientationButton.isSelected()) {
orientation = Orientation.HORIZONTAL;
} else if (verticalOrientationButton.isSelected()) {
orientation = Orientation.VERTICAL;
}
if (orientation != null) {
boxPane.setOrientation(orientation);
}
HorizontalAlignment horizontalAlignment = null;
if (horizontalAlignmentLeftButton.isSelected()) {
horizontalAlignment = HorizontalAlignment.LEFT;
} else if (horizontalAlignmentRightButton.isSelected()) {
horizontalAlignment = HorizontalAlignment.RIGHT;
} else if (horizontalAlignmentCenterButton.isSelected()) {
horizontalAlignment = HorizontalAlignment.CENTER;
}
if (horizontalAlignment != null) {
boxPane.getStyles().put(Style.horizontalAlignment, horizontalAlignment);
}
VerticalAlignment verticalAlignment = null;
if (verticalAlignmentTopButton.isSelected()) {
verticalAlignment = VerticalAlignment.TOP;
} else if (verticalAlignmentBottomButton.isSelected()) {
verticalAlignment = VerticalAlignment.BOTTOM;
} else if (verticalAlignmentCenterButton.isSelected()) {
verticalAlignment = VerticalAlignment.CENTER;
}
if (verticalAlignment != null) {
boxPane.getStyles().put(Style.verticalAlignment, verticalAlignment);
}
boxPane.getStyles().put(Style.fill, fillCheckbox.isSelected());
}
use of org.apache.pivot.wtk.Orientation in project pivot by apache.
the class FillPaneSkin method getPreferredWidth.
@Override
public int getPreferredWidth(int height) {
FillPane fillPane = (FillPane) getComponent();
int preferredWidth = 0;
Orientation orientation = fillPane.getOrientation();
if (orientation == Orientation.HORIZONTAL) {
int heightUpdated = height;
// Include padding in constraint
if (heightUpdated != -1) {
heightUpdated = Math.max(heightUpdated - padding.getHeight(), 0);
}
// Preferred width is the sum of the preferred widths of all
// components
int j = 0;
for (int i = 0, n = fillPane.getLength(); i < n; i++) {
Component component = fillPane.get(i);
if (component.isVisible()) {
preferredWidth += component.getPreferredWidth(heightUpdated);
j++;
}
}
// Include spacing
if (j > 1) {
preferredWidth += spacing * (j - 1);
}
} else {
// Preferred width is the maximum preferred width of all components
for (int i = 0, n = fillPane.getLength(); i < n; i++) {
Component component = fillPane.get(i);
if (component.isVisible()) {
preferredWidth = Math.max(preferredWidth, component.getPreferredWidth());
}
}
}
// Include left and right padding values
preferredWidth += padding.getWidth();
return preferredWidth;
}
use of org.apache.pivot.wtk.Orientation in project pivot by apache.
the class BoxPaneSkin method getPreferredHeight.
@Override
public int getPreferredHeight(int width) {
BoxPane boxPane = (BoxPane) getComponent();
int preferredHeight = 0;
Orientation orientation = boxPane.getOrientation();
if (orientation == Orientation.HORIZONTAL) {
// Preferred height is the maximum preferred height of all components
for (int i = 0, n = boxPane.getLength(); i < n; i++) {
Component component = boxPane.get(i);
if (component.isVisible()) {
preferredHeight = Math.max(preferredHeight, component.getPreferredHeight());
}
}
} else {
int widthUpdated = width;
// Include padding in constraint
if (widthUpdated != -1) {
widthUpdated = Math.max(widthUpdated - padding.getWidth(), 0);
}
// Preferred height is the sum of the preferred heights of all
// components
int j = 0;
for (int i = 0, n = boxPane.getLength(); i < n; i++) {
Component component = boxPane.get(i);
if (component.isVisible()) {
preferredHeight += component.getPreferredHeight(fill ? widthUpdated : -1);
j++;
}
}
// Include spacing
if (j > 1) {
preferredHeight += spacing * (j - 1);
}
}
// Include top and bottom padding values
preferredHeight += padding.getHeight();
return preferredHeight;
}
use of org.apache.pivot.wtk.Orientation in project pivot by apache.
the class BoxPaneSkin method getPreferredWidth.
@Override
public int getPreferredWidth(int height) {
BoxPane boxPane = (BoxPane) getComponent();
int preferredWidth = 0;
Orientation orientation = boxPane.getOrientation();
if (orientation == Orientation.HORIZONTAL) {
int heightUpdated = height;
// Include padding in constraint
if (heightUpdated != -1) {
heightUpdated = Math.max(heightUpdated - padding.getHeight(), 0);
}
// Preferred width is the sum of the preferred widths of all components
int j = 0;
for (int i = 0, n = boxPane.getLength(); i < n; i++) {
Component component = boxPane.get(i);
if (component.isVisible()) {
preferredWidth += component.getPreferredWidth(fill ? heightUpdated : -1);
j++;
}
}
// Include spacing
if (j > 1) {
preferredWidth += spacing * (j - 1);
}
} else {
// Preferred width is the maximum preferred width of all components
for (int i = 0, n = boxPane.getLength(); i < n; i++) {
Component component = boxPane.get(i);
if (component.isVisible()) {
preferredWidth = Math.max(preferredWidth, component.getPreferredWidth());
}
}
}
// Include left and right padding values
preferredWidth += padding.getWidth();
return preferredWidth;
}
use of org.apache.pivot.wtk.Orientation in project pivot by apache.
the class RulerSkin method getPreferredHeight.
@Override
public int getPreferredHeight(int width) {
Ruler ruler = (Ruler) getComponent();
Orientation orientation = ruler.getOrientation();
// Give a little extra height if showing numbers
return (orientation == Orientation.HORIZONTAL) ? ((showMajorNumbers || showMinorNumbers) ? ((int) Math.ceil(charHeight) + MAJOR_SIZE + 5) : MAJOR_SIZE * 2) : 0;
}
Aggregations