MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / drawMarker

Method drawMarker

CodenameOne/src/com/codename1/maps/MapView.java:461–494  ·  view source on GitHub ↗
(Graphics g, Marker m)

Source from the content-addressed store, hash-verified

459 }
460
461 private void drawMarker(Graphics g, Marker m) {
462 if (!m.isVisible()) {
463 return;
464 }
465 Point p = engine.latLngToScreen(m.getPosition());
466 EncodedImage icon = m.getIcon();
467 if (icon != null) {
468 int w = icon.getWidth();
469 int h = icon.getHeight();
470 int dx = p.getX() - (int) (w * m.getAnchorU());
471 int dy = p.getY() - (int) (h * m.getAnchorV());
472 g.drawImage(icon, dx, dy);
473 return;
474 }
475 // Default marker: the standard Material Design map pin glyph, anchored
476 // at the marker's tip (anchor defaults to 0.5, 1.0 -- bottom center).
477 Font pin = markerFont();
478 String glyph = String.valueOf(FontImage.MATERIAL_PLACE);
479 int gw = pin.stringWidth(glyph);
480 int gh = pin.getHeight();
481 int gx = p.getX() - (int) (gw * m.getAnchorU());
482 int gy = p.getY() - (int) (gh * m.getAnchorV());
483 int prevAlpha = g.getAlpha();
484 g.setFont(pin);
485 g.setAlpha(255);
486 g.setColor(0x8e1c16);
487 g.drawString(glyph, gx - 1, gy);
488 g.drawString(glyph, gx + 1, gy);
489 g.drawString(glyph, gx, gy - 1);
490 g.drawString(glyph, gx, gy + 1);
491 g.setColor(0xe53935);
492 g.drawString(glyph, gx, gy);
493 g.setAlpha(prevAlpha);
494 }
495
496 private Font markerFont() {
497 if (markerFont == null) {

Callers 1

drawOverlaysMethod · 0.95

Calls 15

getWidthMethod · 0.95
getHeightMethod · 0.95
getXMethod · 0.95
getYMethod · 0.95
markerFontMethod · 0.95
valueOfMethod · 0.95
stringWidthMethod · 0.95
getHeightMethod · 0.95
isVisibleMethod · 0.65
latLngToScreenMethod · 0.65
getPositionMethod · 0.65
getIconMethod · 0.65

Tested by

no test coverage detected