Search in sources :

Example 11 with Dimension

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;
}
Also used : Dimension(com.codename1.ui.geom.Dimension)

Example 12 with Dimension

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;
}
Also used : TextArea(com.codename1.ui.TextArea) Grid(com.codename1.ui.layouts.mig.Grid) Dimension(com.codename1.ui.geom.Dimension) ContainerWrapper(com.codename1.ui.layouts.mig.ContainerWrapper) ComponentWrapper(com.codename1.ui.layouts.mig.ComponentWrapper)

Example 13 with Dimension

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);
}
Also used : Style(com.codename1.ui.plaf.Style) Dimension(com.codename1.ui.geom.Dimension)

Example 14 with Dimension

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();
}
Also used : Dimension(com.codename1.ui.geom.Dimension)

Example 15 with Dimension

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);
}
Also used : HorizontalList(com.codename1.designer.HorizontalList) Dimension(java.awt.Dimension) Component(java.awt.Component)

Aggregations

Dimension (com.codename1.ui.geom.Dimension)74 Style (com.codename1.ui.plaf.Style)27 Component (com.codename1.ui.Component)16 Image (com.codename1.ui.Image)16 Rectangle (com.codename1.ui.geom.Rectangle)9 EncodedImage (com.codename1.ui.EncodedImage)8 Label (com.codename1.ui.Label)7 Container (com.codename1.ui.Container)6 FileEncodedImage (com.codename1.components.FileEncodedImage)5 StorageImage (com.codename1.components.StorageImage)5 ActionEvent (com.codename1.ui.events.ActionEvent)5 Form (com.codename1.ui.Form)4 Dimension (java.awt.Dimension)4 Font (com.codename1.ui.Font)3 FontImage (com.codename1.ui.FontImage)3 TextArea (com.codename1.ui.TextArea)3 ActionListener (com.codename1.ui.events.ActionListener)3 Point (com.codename1.ui.geom.Point)3 BorderLayout (com.codename1.ui.layouts.BorderLayout)3 Border (com.codename1.ui.plaf.Border)3