use of org.apache.pivot.wtk.Dimensions in project pivot by apache.
the class TerraListButtonSkin method getPreferredSize.
@Override
public Dimensions getPreferredSize() {
ListButton listButton = (ListButton) getComponent();
Button.DataRenderer dataRenderer = listButton.getDataRenderer();
// Determine the preferred width and height of the current button data
dataRenderer.render(listButton.getButtonData(), listButton, false);
Dimensions contentSize = dataRenderer.getPreferredSize();
int preferredWidth = contentSize.width;
int preferredHeight = contentSize.height + padding.getHeight() + 2;
// The preferred width of the button is the max. width of the rendered
// content plus padding and the trigger width
List<?> listData = listButton.getListData();
for (Object item : listData) {
dataRenderer.render(item, listButton, false);
preferredWidth = Math.max(preferredWidth, dataRenderer.getPreferredWidth(-1));
}
preferredWidth += TRIGGER_WIDTH + padding.getWidth() + 2;
return new Dimensions(preferredWidth, preferredHeight);
}
use of org.apache.pivot.wtk.Dimensions in project pivot by apache.
the class TerraMenuButtonSkin method getPreferredSize.
@Override
public Dimensions getPreferredSize() {
MenuButton menuButton = (MenuButton) getComponent();
Button.DataRenderer dataRenderer = menuButton.getDataRenderer();
dataRenderer.render(menuButton.getButtonData(), menuButton, false);
Dimensions contentSize = dataRenderer.getPreferredSize();
int preferredWidth = contentSize.width + TRIGGER_WIDTH + padding.left + padding.right + 2;
int preferredHeight = contentSize.height + padding.top + padding.bottom + 2;
// Adjust for preferred aspect ratio
float aspectRatio = (float) preferredWidth / (float) preferredHeight;
if (!Float.isNaN(minumumAspectRatio) && aspectRatio < minumumAspectRatio) {
preferredWidth = (int) (preferredHeight * minumumAspectRatio);
}
if (!Float.isNaN(maximumAspectRatio) && aspectRatio > maximumAspectRatio) {
preferredHeight = (int) (preferredWidth / maximumAspectRatio);
}
return new Dimensions(preferredWidth, preferredHeight);
}
use of org.apache.pivot.wtk.Dimensions in project pivot by apache.
the class TerraCalendarButtonSkin method getPreferredSize.
@Override
public Dimensions getPreferredSize() {
CalendarButton calendarButton = (CalendarButton) getComponent();
Button.DataRenderer dataRenderer = calendarButton.getDataRenderer();
dataRenderer.render(calendarButton.getButtonData(), calendarButton, false);
Dimensions contentSize = dataRenderer.getPreferredSize();
int preferredWidth = contentSize.width + paddingWidth();
int preferredHeight = contentSize.height + paddingHeight();
return new Dimensions(preferredWidth, preferredHeight);
}
use of org.apache.pivot.wtk.Dimensions in project pivot by apache.
the class TerraCheckboxSkin method getPreferredSize.
@Override
public Dimensions getPreferredSize() {
Checkbox checkbox = (Checkbox) getComponent();
Button.DataRenderer dataRenderer = checkbox.getDataRenderer();
dataRenderer.render(checkbox.getButtonData(), checkbox, false);
int preferredWidth = CHECKBOX_SIZE;
int preferredHeight = CHECKBOX_SIZE;
Object buttonData = checkbox.getButtonData();
if (buttonData != null) {
dataRenderer.render(buttonData, checkbox, false);
preferredWidth += dataRenderer.getPreferredWidth(-1) + spacing * 2;
preferredHeight = Math.max(preferredHeight, dataRenderer.getPreferredHeight(-1));
}
return new Dimensions(preferredWidth, preferredHeight);
}
use of org.apache.pivot.wtk.Dimensions in project pivot by apache.
the class TerraColorChooserButtonSkin method getPreferredSize.
@Override
public Dimensions getPreferredSize() {
ColorChooserButton colorChooserButton = (ColorChooserButton) getComponent();
Button.DataRenderer dataRenderer = colorChooserButton.getDataRenderer();
dataRenderer.render(colorChooserButton.getButtonData(), colorChooserButton, false);
Dimensions contentSize = dataRenderer.getPreferredSize();
int preferredWidth = contentSize.width + paddingWidth();
int preferredHeight = contentSize.height + paddingHeight();
return new Dimensions(preferredWidth, preferredHeight);
}
Aggregations