use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.
the class Tree method calcPreferredSize.
/**
* {@inheritDoc}
*/
protected Dimension calcPreferredSize() {
Dimension d = super.calcPreferredSize();
// if the tree is entirely collapsed try to reserve at least 6 rows for the content
int count = getComponentCount();
for (int iter = 0; iter < count; iter++) {
if (getComponentAt(iter) instanceof Container) {
return d;
}
}
int size = Math.max(1, model.getChildren(null).size());
if (size < 6) {
return new Dimension(Math.max(d.getWidth(), Display.getInstance().getDisplayWidth() / 4 * 3), d.getHeight() / size * 6);
}
return d;
}
use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.
the class BoxLayout method getPreferredSize.
/**
* {@inheritDoc}
*/
public Dimension getPreferredSize(Container parent) {
int width = 0;
int height = 0;
int numOfcomponents = parent.getComponentCount();
for (int i = 0; i < numOfcomponents; i++) {
Component cmp = parent.getComponentAt(i);
Style stl = cmp.getStyle();
if (axis == Y_AXIS) {
int cmpH = cmp.getPreferredH() + stl.getVerticalMargins();
height += cmpH;
width = Math.max(width, cmp.getPreferredW() + stl.getHorizontalMargins());
} else {
int cmpW = cmp.getPreferredW() + stl.getHorizontalMargins();
width += cmpW;
height = Math.max(height, cmp.getPreferredH() + stl.getVerticalMargins());
}
}
Style s = parent.getStyle();
dim.setWidth(width + s.getHorizontalPadding());
dim.setHeight(height + s.getVerticalPadding());
return dim;
}
use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.
the class BorderLayout method getPreferredSize.
/**
* {@inheritDoc}
*/
public Dimension getPreferredSize(Container parent) {
dim.setWidth(0);
dim.setHeight(0);
Component east = getEast();
Component west = getWest();
Component south = getSouth();
Component north = getNorth();
Component center = getCenter();
if (east != null) {
dim.setWidth(east.getPreferredW() + east.getStyle().getMarginLeftNoRTL() + east.getStyle().getMarginRightNoRTL());
dim.setHeight(Math.max(east.getPreferredH() + east.getStyle().getMarginTop() + east.getStyle().getMarginBottom(), dim.getHeight()));
}
if (west != null) {
dim.setWidth(dim.getWidth() + west.getPreferredW() + west.getStyle().getMarginLeftNoRTL() + west.getStyle().getMarginRightNoRTL());
dim.setHeight(Math.max(west.getPreferredH() + west.getStyle().getMarginTop() + west.getStyle().getMarginBottom(), dim.getHeight()));
}
if (center != null) {
dim.setWidth(dim.getWidth() + center.getPreferredW() + center.getStyle().getMarginLeftNoRTL() + center.getStyle().getMarginRightNoRTL());
dim.setHeight(Math.max(center.getPreferredH() + center.getStyle().getMarginTop() + center.getStyle().getMarginBottom(), dim.getHeight()));
}
if (north != null) {
dim.setWidth(Math.max(north.getPreferredW() + north.getStyle().getMarginLeftNoRTL() + north.getStyle().getMarginRightNoRTL(), dim.getWidth()));
dim.setHeight(dim.getHeight() + north.getPreferredH() + north.getStyle().getMarginTop() + north.getStyle().getMarginBottom());
}
if (south != null) {
dim.setWidth(Math.max(south.getPreferredW() + south.getStyle().getMarginLeftNoRTL() + south.getStyle().getMarginRightNoRTL(), dim.getWidth()));
dim.setHeight(dim.getHeight() + south.getPreferredH() + south.getStyle().getMarginTop() + south.getStyle().getMarginBottom());
}
dim.setWidth(dim.getWidth() + parent.getStyle().getHorizontalPadding());
dim.setHeight(dim.getHeight() + parent.getStyle().getVerticalPadding());
return dim;
}
use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.
the class ImageIO method getImageSize.
/**
* Returns the image size in pixels
* @param imageFilePath the path to the image
* @return the size in pixels
*/
public Dimension getImageSize(String imageFilePath) throws IOException {
Image img = Image.createImage(imageFilePath);
Dimension d = new Dimension(img.getWidth(), img.getHeight());
img.dispose();
return d;
}
use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.
the class CodenameOneMiGComponentWrapper method getLayoutHashCode.
public int getLayoutHashCode() {
Dimension d = c.getPreferredSize();
int hash = (d.getWidth() << 10) + (d.getHeight() << 15);
if (c.isVisible())
hash += 1324511;
String id = getLinkId();
if (id != null)
hash += id.hashCode();
return hash;
}
Aggregations