Search in sources :

Example 56 with Component

use of org.apache.pivot.wtk.Component in project pivot by apache.

the class StackPaneSkin method getPreferredSize.

@Override
public Dimensions getPreferredSize() {
    int preferredWidth = 0;
    int preferredHeight = 0;
    StackPane stackPane = (StackPane) getComponent();
    for (Component component : stackPane) {
        Dimensions preferredCardSize = component.getPreferredSize();
        preferredWidth = Math.max(preferredWidth, preferredCardSize.width);
        preferredHeight = Math.max(preferredHeight, preferredCardSize.height);
    }
    preferredWidth += padding.getWidth();
    preferredHeight += padding.getHeight();
    return new Dimensions(preferredWidth, preferredHeight);
}
Also used : Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component) StackPane(org.apache.pivot.wtk.StackPane)

Example 57 with Component

use of org.apache.pivot.wtk.Component in project pivot by apache.

the class BorderSkin method getBaseline.

@Override
public int getBaseline(int width, int height) {
    int baseline = -1;
    Border border = (Border) getComponent();
    // Delegate baseline calculation to the content component
    Component content = border.getContent();
    if (content != null) {
        int clientWidth = Math.max(width - paddingThicknessWidth(), 0);
        int clientHeight = Math.max(height - paddingThicknessHeight(), 0);
        baseline = content.getBaseline(clientWidth, clientHeight);
    }
    // Include top padding value and top border thickness
    if (baseline != -1) {
        baseline += (padding.top + topThickness);
    }
    return baseline;
}
Also used : Component(org.apache.pivot.wtk.Component) Border(org.apache.pivot.wtk.Border) Paint(java.awt.Paint)

Example 58 with Component

use of org.apache.pivot.wtk.Component in project pivot by apache.

the class BorderSkin method layout.

@Override
public void layout() {
    int width = getWidth();
    int height = getHeight();
    Border border = (Border) getComponent();
    Component content = border.getContent();
    if (content != null) {
        content.setLocation(padding.left + thickness, padding.top + topThickness);
        int contentWidth = Math.max(width - paddingThicknessWidth(), 0);
        int contentHeight = Math.max(height - paddingThicknessHeight(), 0);
        content.setSize(contentWidth, contentHeight);
    }
}
Also used : Component(org.apache.pivot.wtk.Component) Border(org.apache.pivot.wtk.Border) Paint(java.awt.Paint)

Example 59 with Component

use of org.apache.pivot.wtk.Component in project pivot by apache.

the class BorderSkin method getPreferredSize.

@Override
public Dimensions getPreferredSize() {
    int preferredWidth = 0;
    int preferredHeight = 0;
    Border border = (Border) getComponent();
    String title = border.getTitle();
    if (title != null && title.length() > 0) {
        FontRenderContext fontRenderContext = Platform.getFontRenderContext();
        Rectangle2D headingBounds = font.getStringBounds(title, fontRenderContext);
        preferredWidth = (int) Math.ceil(headingBounds.getWidth());
    }
    Component content = border.getContent();
    if (content != null) {
        Dimensions preferredSize = content.getPreferredSize();
        preferredWidth = Math.max(preferredWidth, preferredSize.width);
        preferredHeight += preferredSize.height;
    }
    preferredWidth += paddingThicknessWidth();
    preferredHeight += paddingThicknessHeight();
    return new Dimensions(preferredWidth, preferredHeight);
}
Also used : Rectangle2D(java.awt.geom.Rectangle2D) RoundRectangle2D(java.awt.geom.RoundRectangle2D) Dimensions(org.apache.pivot.wtk.Dimensions) FontRenderContext(java.awt.font.FontRenderContext) Component(org.apache.pivot.wtk.Component) Border(org.apache.pivot.wtk.Border) Paint(java.awt.Paint)

Example 60 with Component

use of org.apache.pivot.wtk.Component in project pivot by apache.

the class BorderSkin method getPreferredHeight.

@Override
public int getPreferredHeight(int width) {
    int preferredHeight = 0;
    Border border = (Border) getComponent();
    Component content = border.getContent();
    if (content != null) {
        int widthUpdated = width;
        if (widthUpdated != -1) {
            widthUpdated = Math.max(widthUpdated - paddingThicknessWidth(), 0);
        }
        preferredHeight = content.getPreferredHeight(widthUpdated);
    }
    preferredHeight += paddingThicknessHeight();
    return preferredHeight;
}
Also used : Component(org.apache.pivot.wtk.Component) Border(org.apache.pivot.wtk.Border) Paint(java.awt.Paint)

Aggregations

Component (org.apache.pivot.wtk.Component)209 Dimensions (org.apache.pivot.wtk.Dimensions)40 Point (org.apache.pivot.wtk.Point)38 GradientPaint (java.awt.GradientPaint)33 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)24 TextInput (org.apache.pivot.wtk.TextInput)21 Label (org.apache.pivot.wtk.Label)20 BoxPane (org.apache.pivot.wtk.BoxPane)18 Paint (java.awt.Paint)17 Button (org.apache.pivot.wtk.Button)15 PushButton (org.apache.pivot.wtk.PushButton)14 ScrollPane (org.apache.pivot.wtk.ScrollPane)14 TablePane (org.apache.pivot.wtk.TablePane)14 Window (org.apache.pivot.wtk.Window)14 IOException (java.io.IOException)13 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)13 Frame (org.apache.pivot.wtk.Frame)13 FlowPane (org.apache.pivot.wtk.FlowPane)12 ComponentStateListener (org.apache.pivot.wtk.ComponentStateListener)11 ComponentMouseButtonListener (org.apache.pivot.wtk.ComponentMouseButtonListener)10