Search in sources :

Example 61 with Graphics

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

Example 62 with Graphics

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

Example 63 with Graphics

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

Example 64 with Graphics

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

Example 65 with Graphics

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

Aggregations

Image (com.codename1.ui.Image)18 Component (com.codename1.ui.Component)17 Point (com.codename1.ui.geom.Point)16 Style (com.codename1.ui.plaf.Style)15 Graphics (com.codename1.ui.Graphics)14 Form (com.codename1.ui.Form)12 Font (com.codename1.ui.Font)11 GeneralPath (com.codename1.ui.geom.GeneralPath)9 Rectangle (com.codename1.ui.geom.Rectangle)9 Animation (com.codename1.ui.animations.Animation)8 Dialog (com.codename1.ui.Dialog)7 Dimension (com.codename1.ui.geom.Dimension)6 Painter (com.codename1.ui.Painter)5 ActionEvent (com.codename1.ui.events.ActionEvent)5 FontImage (com.codename1.ui.FontImage)4 RGBImage (com.codename1.ui.RGBImage)4 Motion (com.codename1.ui.animations.Motion)4 ActionListener (com.codename1.ui.events.ActionListener)4 BorderLayout (com.codename1.ui.layouts.BorderLayout)4 IOException (java.io.IOException)4