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