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;
}
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);
}
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);
}
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));
}
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);
}
Aggregations