| 1 | package org.openstreetmap.gui.jmapviewer.scene.entities;
|
|---|
| 2 |
|
|---|
| 3 | import java.awt.Color;
|
|---|
| 4 | import java.awt.Font;
|
|---|
| 5 | import java.awt.Graphics2D;
|
|---|
| 6 | import java.awt.geom.AffineTransform;
|
|---|
| 7 |
|
|---|
| 8 | import org.openstreetmap.gui.jmapviewer.interfaces.MapViewInterface;
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 | public class MapLabel extends MapObject {
|
|---|
| 12 | private String label="";
|
|---|
| 13 | private Color color = Color.black;
|
|---|
| 14 | private Font font = new Font("SanSerif", Font.BOLD, 12);
|
|---|
| 15 |
|
|---|
| 16 | public MapLabel(String label) {
|
|---|
| 17 | super();
|
|---|
| 18 | this.label=label;
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | @Override
|
|---|
| 22 | public void initialize(MapViewInterface view) {
|
|---|
| 23 |
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | /**
|
|---|
| 27 | * @return the font
|
|---|
| 28 | */
|
|---|
| 29 | public Font getFont() {
|
|---|
| 30 | return font;
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | /**
|
|---|
| 34 | * @param font the font to set
|
|---|
| 35 | */
|
|---|
| 36 | public void setFont(Font font) {
|
|---|
| 37 | this.font = font;
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | /**
|
|---|
| 41 | * @param color the color to set
|
|---|
| 42 | */
|
|---|
| 43 | public void setColor(Color color) {
|
|---|
| 44 | this.color = color;
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | /**
|
|---|
| 48 | * @return the color
|
|---|
| 49 | */
|
|---|
| 50 | public Color getColor() {
|
|---|
| 51 | return color;
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | @Override
|
|---|
| 55 | protected void drawObject(Graphics2D g2, AffineTransform at) {
|
|---|
| 56 | g2.setFont(font);
|
|---|
| 57 | g2.setColor(color);
|
|---|
| 58 | g2.drawString(label, (int)at.getTranslateX(), (int)at.getTranslateY());
|
|---|
| 59 | }
|
|---|
| 60 | }
|
|---|