use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class PointLayer method paint.
/**
* {@inheritDoc}
*/
public void paint(Graphics g, Tile tile) {
Point pos = tile.pointPosition(this);
int width = 6;
int height = 6;
if (icon != null) {
width = icon.getWidth();
height = icon.getHeight();
}
int x = pos.getX() - width / 2;
int y = pos.getY() - height / 2;
if (icon == null) {
g.fillRect(x, y, width, height);
} else {
g.drawImage(icon, x, y);
}
if (name != null && displayName) {
g.drawString(getName(), x + width + 1, pos.getY() - g.getFont().getHeight() / 2 - 1);
}
}
use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class LayerWithZoomLevels method drawPointer.
private void drawPointer(Graphics g) {
if (drawMapPointer) {
g.setColor(0xFF0000);
int centerX = getWidth() / 2;
int centerY = getHeight() / 2;
int halfSize = 5;
g.drawRoundRect(centerX - halfSize, centerY - halfSize, 2 * halfSize, 2 * halfSize, halfSize, halfSize);
}
}
use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class LayerWithZoomLevels method drawDebug.
private void drawDebug(Graphics g) {
g.setColor(0x000000);
g.setFont(Font.createSystemFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN, Font.SIZE_MEDIUM));
g.drawString(_map.projection().toWGS84(_center).toString(), 5, 5);
g.drawString("Zoom:" + _zoom, 5, 5 + g.getFont().getHeight());
for (int i = 0; i < _layers.size(); i++) {
LayerWithZoomLevels lwzl = (LayerWithZoomLevels) _layers.elementAt(i);
g.drawString("Layer " + lwzl.layer.getName(), 5, 5 + (i + 2) * g.getFont().getHeight());
}
}
use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class LayerWithZoomLevels method paintBackground.
/**
* {@inheritDoc}
*/
public void paintBackground(Graphics g) {
super.paintBackground(g);
if (Display.getInstance().areMutableImagesFast()) {
if (buffer == null) {
buffer = Image.createImage(getWidth(), getHeight());
}
if (_needTiles || refreshLayers) {
paintmap(buffer.getGraphics());
refreshLayers = false;
}
g.translate(-translateX, -translateY);
if (scaleX > 0) {
float tx = (float) zoomCenterX / (float) getWidth();
tx = tx * (float) (scaleX - getWidth());
float ty = (float) zoomCenterY / (float) getHeight();
ty = ty * (float) (scaleY - getHeight());
g.drawImage(buffer, -(int) tx, -(int) ty, scaleX, scaleY);
} else {
g.drawImage(buffer, (getWidth() - buffer.getWidth()) / 2, (getHeight() - buffer.getHeight()) / 2);
}
g.translate(translateX, translateY);
} else {
int clipx = g.getClipX();
int clipy = g.getClipY();
int clipw = g.getClipWidth();
int cliph = g.getClipHeight();
if (scaleX > 0) {
float sx = (float) scaleX / (float) getWidth();
float sy = (float) scaleY / (float) getHeight();
float tx = (float) zoomCenterX / (float) getWidth();
tx = -tx * (float) (scaleX - getWidth()) / sx;
float ty = (float) zoomCenterY / (float) getHeight();
ty = -ty * (float) (scaleY - getHeight()) / sy;
g.translate((int) tx, (int) ty);
g.scale(sx, sy);
paintmap(g);
g.resetAffine();
g.translate(-(int) tx, -(int) ty);
} else {
g.translate(-translateX, -translateY);
paintmap(g);
g.translate(translateX, translateY);
}
g.setClip(clipx, clipy, clipw, cliph);
}
}
use of com.codename1.ui.Graphics 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);
}
Aggregations