Search in sources :

Example 66 with Dimension

use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.

the class TiledProvider method bboxFor.

/**
 * {@inheritDoc}
 */
public BoundingBox bboxFor(Coord position, int zoomLevel) {
    _zoomLevel = zoomLevel;
    Coord scale = scale(zoomLevel);
    Dimension tileSize = tileSize();
    double x = scale.getLongitude() * tileSize.getWidth();
    double y = scale.getLatitude() * tileSize.getHeight();
    Coord tileScale = new Coord(y, x, false);
    _tileNo = tileNo(position, projection().extent().getSouthWest(), tileScale);
    Coord start = tileCoord(_tileNo, projection().extent().getSouthWest(), tileScale);
    Coord end = start.translate(tileScale.getLatitude(), tileScale.getLongitude());
    return new BoundingBox(start, end);
}
Also used : Coord(com.codename1.maps.Coord) BoundingBox(com.codename1.maps.BoundingBox) Dimension(com.codename1.ui.geom.Dimension)

Example 67 with Dimension

use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.

the class LayerWithZoomLevels method getTiles.

private void getTiles() throws RuntimeException {
    _tiles = new Vector();
    Dimension tileSize = _map.tileSize();
    int posY = 0;
    _delta = null;
    while (posY - tileSize.getHeight() < getHeight()) {
        int posX = 0;
        while (posX - tileSize.getWidth() < getWidth()) {
            Tile tile;
            Coord cur = _map.translate(_center, _zoom, posX - getWidth() / 2, getHeight() / 2 - posY);
            if (_map.projection().extent().contains(cur)) {
                tile = _map.tileFor(_map.bboxFor(cur, _zoom));
                if (_delta == null) {
                    _delta = tile.pointPosition(cur);
                }
                tile.setsTileReadyListener(new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        refreshLayers = true;
                        repaint();
                    }
                });
                _tiles.addElement(new PositionedTile(new Point(posX, posY), tile));
            }
            posX += tileSize.getWidth();
        }
        posY += tileSize.getHeight();
    }
}
Also used : ActionListener(com.codename1.ui.events.ActionListener) ActionEvent(com.codename1.ui.events.ActionEvent) Dimension(com.codename1.ui.geom.Dimension) Point(com.codename1.ui.geom.Point) Vector(java.util.Vector) Point(com.codename1.ui.geom.Point)

Example 68 with Dimension

use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.

the class LayerWithZoomLevels method screenTile.

/**
 * {@inheritDoc}
 */
private Tile screenTile() {
    Dimension componentDimension = new Dimension(getWidth(), getHeight());
    Coord southWest = _map.translate(_center, _zoom, -getWidth() / 2, -getHeight() / 2);
    Coord northEast = _map.translate(_center, _zoom, getWidth() / 2, getHeight() / 2);
    BoundingBox bbox = new BoundingBox(southWest, northEast);
    return new Tile(componentDimension, bbox, null);
}
Also used : Dimension(com.codename1.ui.geom.Dimension)

Example 69 with Dimension

use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.

the class Tile method paintLoadingText.

private void paintLoadingText(Graphics g) {
    g.setColor(0x707070);
    g.fillRect(0, 0, dimension().getWidth(), dimension().getHeight());
    g.setColor(0xFFFFFF);
    g.setFont(f);
    Font f = g.getFont();
    int strWidth = f.stringWidth(tileLoadingText);
    g.drawString(tileLoadingText, (dimension().getWidth() - strWidth) / 2, (dimension().getHeight() - f.getHeight()) / 2);
}
Also used : Font(com.codename1.ui.Font) Point(com.codename1.ui.geom.Point)

Example 70 with Dimension

use of com.codename1.ui.geom.Dimension in project CodenameOne by codenameone.

the class Container method calcPreferredSize.

/**
 * {@inheritDoc}
 */
protected Dimension calcPreferredSize() {
    Dimension d = layout.getPreferredSize(this);
    Style style = getStyle();
    if (style.getBorder() != null && d.getWidth() != 0 && d.getHeight() != 0) {
        d.setWidth(Math.max(style.getBorder().getMinimumWidth(), d.getWidth()));
        d.setHeight(Math.max(style.getBorder().getMinimumHeight(), d.getHeight()));
    }
    if (UIManager.getInstance().getLookAndFeel().isBackgroundImageDetermineSize() && style.getBgImage() != null) {
        d.setWidth(Math.max(style.getBgImage().getWidth(), d.getWidth()));
        d.setHeight(Math.max(style.getBgImage().getHeight(), d.getHeight()));
    }
    return d;
}
Also used : Style(com.codename1.ui.plaf.Style) Dimension(com.codename1.ui.geom.Dimension)

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