Search in sources :

Example 1 with Orientation

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());
}
Also used : VerticalAlignment(org.apache.pivot.wtk.VerticalAlignment) Orientation(org.apache.pivot.wtk.Orientation) HorizontalAlignment(org.apache.pivot.wtk.HorizontalAlignment)

Example 2 with Orientation

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;
}
Also used : FillPane(org.apache.pivot.wtk.FillPane) Orientation(org.apache.pivot.wtk.Orientation) Component(org.apache.pivot.wtk.Component)

Example 3 with Orientation

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;
}
Also used : BoxPane(org.apache.pivot.wtk.BoxPane) Orientation(org.apache.pivot.wtk.Orientation) Component(org.apache.pivot.wtk.Component)

Example 4 with Orientation

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;
}
Also used : BoxPane(org.apache.pivot.wtk.BoxPane) Orientation(org.apache.pivot.wtk.Orientation) Component(org.apache.pivot.wtk.Component)

Example 5 with Orientation

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;
}
Also used : Ruler(org.apache.pivot.wtk.Ruler) Orientation(org.apache.pivot.wtk.Orientation)

Aggregations

Orientation (org.apache.pivot.wtk.Orientation)15 Component (org.apache.pivot.wtk.Component)6 Ruler (org.apache.pivot.wtk.Ruler)4 FontRenderContext (java.awt.font.FontRenderContext)3 Rectangle2D (java.awt.geom.Rectangle2D)3 BoxPane (org.apache.pivot.wtk.BoxPane)3 FillPane (org.apache.pivot.wtk.FillPane)3 NumberRuler (org.apache.pivot.wtk.NumberRuler)3 GlyphVector (java.awt.font.GlyphVector)2 StringCharacterIterator (java.text.StringCharacterIterator)2 Graphics2D (java.awt.Graphics2D)1 Rectangle (java.awt.Rectangle)1 Dimensions (org.apache.pivot.wtk.Dimensions)1 HorizontalAlignment (org.apache.pivot.wtk.HorizontalAlignment)1 SplitPane (org.apache.pivot.wtk.SplitPane)1 VerticalAlignment (org.apache.pivot.wtk.VerticalAlignment)1