Search in sources :

Example 36 with Dimensions

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

the class TerraRollupSkin method getBaseline.

@Override
public int getBaseline(int width, int height) {
    Rollup rollup = (Rollup) getComponent();
    Component heading = rollup.getHeading();
    int baseline = -1;
    if (heading != null) {
        int headingWidth, headingHeight;
        if (fill) {
            headingWidth = Math.max(width - rollupButton.getPreferredWidth(-1) - buffer, 0);
            headingHeight = heading.getPreferredHeight(headingWidth);
        } else {
            Dimensions headingPreferredSize = heading.getPreferredSize();
            headingWidth = headingPreferredSize.width;
            headingHeight = headingPreferredSize.height;
        }
        baseline = heading.getBaseline(headingWidth, headingHeight);
    }
    return baseline;
}
Also used : Rollup(org.apache.pivot.wtk.Rollup) Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component)

Example 37 with Dimensions

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

the class TerraRollupSkin method layout.

@Override
public void layout() {
    Rollup rollup = (Rollup) getComponent();
    Component heading = rollup.getHeading();
    Component content = rollup.getContent();
    Dimensions rollupButtonSize = rollupButton.getPreferredSize();
    rollupButton.setSize(rollupButtonSize.width, rollupButtonSize.height);
    int x = rollupButtonSize.width + buffer;
    int y = 0;
    int justifiedWidth = Math.max(getWidth() - rollupButtonSize.width - buffer, 0);
    if (heading != null) {
        int headingWidth, headingHeight;
        if (fill) {
            headingWidth = justifiedWidth;
            headingHeight = heading.getPreferredHeight(headingWidth);
        } else {
            Dimensions headingPreferredSize = heading.getPreferredSize();
            headingWidth = headingPreferredSize.width;
            headingHeight = headingPreferredSize.height;
        }
        heading.setLocation(x, y);
        heading.setSize(headingWidth, headingHeight);
        y += headingHeight + spacing;
    }
    if (content != null) {
        boolean contentVisible = false;
        if (rollup.isExpanded() || (expandTransition != null && !expandTransition.isReversed())) {
            Dimensions size;
            if (fill) {
                size = new Dimensions(justifiedWidth, content.getPreferredHeight(justifiedWidth));
            } else {
                size = content.getPreferredSize();
            }
            content.setLocation(x, y);
            content.setSize(size);
            contentVisible = true;
        }
        content.setVisible(contentVisible);
    }
    y = (heading == null ? 0 : (heading.getHeight() - rollupButtonSize.height) / 2 + 1);
    rollupButton.setLocation(0, y);
}
Also used : Rollup(org.apache.pivot.wtk.Rollup) Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component)

Example 38 with Dimensions

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

the class TerraLinkButtonSkin method paint.

@Override
public void paint(Graphics2D graphics) {
    LinkButton linkButton = (LinkButton) getComponent();
    Dimensions size = getSize();
    Button.DataRenderer dataRenderer = linkButton.getDataRenderer();
    dataRenderer.render(linkButton.getButtonData(), linkButton, highlighted);
    dataRenderer.setSize(size);
    dataRenderer.paint(graphics);
}
Also used : LinkButton(org.apache.pivot.wtk.LinkButton) Button(org.apache.pivot.wtk.Button) Dimensions(org.apache.pivot.wtk.Dimensions) LinkButton(org.apache.pivot.wtk.LinkButton)

Example 39 with Dimensions

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

the class TerraMenuItemSkin method getPreferredSize.

@Override
public Dimensions getPreferredSize() {
    Button.DataRenderer dataRenderer = prepare();
    Dimensions preferredSize = dataRenderer.getPreferredSize();
    return new Dimensions(preferredSize.width + EXPANDER_SIZE, Math.max(preferredSize.height, EXPANDER_SIZE));
}
Also used : Button(org.apache.pivot.wtk.Button) Dimensions(org.apache.pivot.wtk.Dimensions)

Example 40 with Dimensions

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

the class TerraAccordionSkin method getPreferredSize.

@Override
public Dimensions getPreferredSize() {
    Accordion accordion = (Accordion) getComponent();
    int preferredHeight = 0;
    int maxPanelHeaderWidth = 0;
    for (PanelHeader panelHeader : panelHeaders) {
        Dimensions preferredSize = panelHeader.getPreferredSize();
        maxPanelHeaderWidth = Math.max(preferredSize.width, maxPanelHeaderWidth);
        preferredHeight += preferredSize.height - 1;
    }
    int maxPanelWidth = 0;
    int maxPanelHeight = 0;
    for (Component panel : accordion.getPanels()) {
        Dimensions preferredSize = panel.getPreferredSize();
        maxPanelWidth = Math.max(preferredSize.width, maxPanelWidth);
        maxPanelHeight = Math.max(maxPanelHeight, preferredSize.height);
    }
    int preferredWidth = Math.max(maxPanelHeaderWidth, maxPanelWidth + (padding.getWidth() + 2));
    preferredHeight += (maxPanelHeight + padding.getHeight() + 2);
    return new Dimensions(preferredWidth, preferredHeight);
}
Also used : Accordion(org.apache.pivot.wtk.Accordion) Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component) GradientPaint(java.awt.GradientPaint)

Aggregations

Dimensions (org.apache.pivot.wtk.Dimensions)76 Component (org.apache.pivot.wtk.Component)40 GradientPaint (java.awt.GradientPaint)21 Point (org.apache.pivot.wtk.Point)16 FontRenderContext (java.awt.font.FontRenderContext)9 Button (org.apache.pivot.wtk.Button)9 Paint (java.awt.Paint)7 Rectangle2D (java.awt.geom.Rectangle2D)6 LineMetrics (java.awt.font.LineMetrics)5 BoxPane (org.apache.pivot.wtk.BoxPane)5 FlowPane (org.apache.pivot.wtk.FlowPane)5 Label (org.apache.pivot.wtk.Label)5 ScrollPane (org.apache.pivot.wtk.ScrollPane)4 Separator (org.apache.pivot.wtk.Separator)4 Form (org.apache.pivot.wtk.Form)3 ImageView (org.apache.pivot.wtk.ImageView)3 Image (org.apache.pivot.wtk.media.Image)3 Color (java.awt.Color)2 Font (java.awt.Font)2 LineBreakMeasurer (java.awt.font.LineBreakMeasurer)2