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