use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.
the class BaseSpinner method calcPreferredSize.
/**
* {@inheritDoc}
*/
protected Dimension calcPreferredSize() {
if (!isInitialized()) {
initSpinner();
}
Dimension d = super.calcPreferredSize();
if (overlayStyle.getBorder() != null) {
d.setWidth(Math.max(overlayStyle.getBorder().getMinimumWidth(), d.getWidth()));
d.setHeight(Math.max(overlayStyle.getBorder().getMinimumHeight(), d.getHeight()));
}
return d;
}
use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.
the class MigLayout method checkCache.
/**
* Check if something has changed and if so recreate it to the cached
* objects.
*
* @param parent The parent that is the target for this layout manager.
*/
private void checkCache(Container parent) {
if (parent == null) {
return;
}
if (dirty) {
grid = null;
}
cleanConstraintMaps(parent);
// Check if the grid is valid
int mc = PlatformDefaults.getModCount();
if (lastModCount != mc) {
grid = null;
lastModCount = mc;
}
// if (!parent.isValid()) {
if (!lastWasInvalid) {
lastWasInvalid = true;
int hash = 0;
// Added in 3.7.3 to resolve a timing regression introduced in 3.7.1
boolean resetLastInvalidOnParent = false;
for (ComponentWrapper wrapper : ccMap.keySet()) {
Object component = wrapper.getComponent();
if (component instanceof TextArea) {
resetLastInvalidOnParent = true;
}
hash ^= wrapper.getLayoutHashCode();
hash += 285134905;
}
if (resetLastInvalidOnParent) {
resetLastInvalidOnParent(parent);
}
if (hash != lastHash) {
grid = null;
lastHash = hash;
}
Dimension ps = new Dimension(parent.getWidth(), parent.getHeight());
if (lastInvalidSize == null || !lastInvalidSize.equals(ps)) {
grid = null;
lastInvalidSize = ps;
}
}
/*} else {
lastWasInvalid = false;
}*/
ContainerWrapper par = checkParent(parent);
setDebug(par, getDebugMillis() > 0);
if (grid == null) {
grid = new Grid(par, lc, rowSpecs, colSpecs, ccMap, callbackList);
}
dirty = false;
}
use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.
the class MigLayout method getSizeImpl.
// Implementation method that does the job.
private Dimension getSizeImpl(Container parent, int sizeType) {
checkCache(parent);
Style i = parent.getStyle();
int w = LayoutUtil.getSizeSafe(grid != null ? grid.getWidth() : null, sizeType) + i.getHorizontalPadding();
int h = LayoutUtil.getSizeSafe(grid != null ? grid.getHeight() : null, sizeType) + i.getVerticalPadding();
return new Dimension(w, h);
}
use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.
the class LayerWithZoomLevels method zoomTo.
/**
* Zoom the map the the giving bounding box
*
* @param boundingBox to zoom to
* @throws IllegalArgumentException if the boundingBox is not wg84 format
*/
public void zoomTo(BoundingBox boundingBox) {
if (boundingBox.projected()) {
throw new IllegalArgumentException("boundingBox should be wg84 format");
}
Dimension dimension = null;
if (getWidth() == 0 || getHeight() == 0) {
dimension = getPreferredSize();
} else {
dimension = new Dimension(getWidth(), getHeight());
}
final BoundingBox projectedBBOX = _map.projection().fromWGS84(boundingBox);
Tile tile = new Tile(dimension, projectedBBOX, null);
_zoom = _map.maxZoomFor(tile);
_center = tile.position(tile.dimension().getWidth() / 2, tile.dimension().getHeight() / 2);
_needTiles = true;
super.repaint();
}
use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.
the class WrappingLayout method layoutSize.
private Dimension layoutSize(Container parent, SizeGetter getter) {
int ncomponents = parent.getComponentCount();
int w = 0;
int h = 0;
int v = Preferences.userNodeForPackage(HorizontalList.class).getInt("previewIconWidth", 24);
if (v > maxButtonWidth && maxButtonWidth > -1) {
maxButtonWidth = v;
}
for (int i = 0; i < ncomponents; i++) {
Component comp = parent.getComponent(i);
Dimension d = getter.getSize(comp, maxButtonWidth);
if (w < d.width) {
w = d.width;
}
if (h < d.height) {
h = d.height;
}
}
if (ncomponents < 1) {
return new Dimension(10, 10);
}
int parentWidth = Math.max(w, parent.getWidth());
int columns = parentWidth / w;
int rows = ncomponents / columns;
if (ncomponents % columns != 0) {
rows += 1;
}
return new Dimension(columns * w + (2) + columns, rows * h + (rows - 1) + rows);
}
Aggregations