blob: 8c3c8c1b7cde4fe1fa9470a1c17aebd7b86473dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package com.benburwell.planes.gui.aircraftmap;
import com.benburwell.planes.gui.GraphicsTheme;
import java.awt.*;
/**
* Created by ben on 11/19/16.
*/
public class Plane extends GeoPoint implements Drawable {
private String name;
private final int DOT_DIMENSION = 4;
private final int TEXT_OFFSET_X = 10;
private final int TEXT_OFFSET_Y = 15;
public Plane(String name, double latitude, double longitude) {
super(latitude, longitude);
this.name = name;
}
public void drawOn(Graphics g, AircraftMap map) {
int x = this.getX(map);
int y = this.getY(map);
if (x >= 0 && x <= map.getSize().getWidth() && y >= 0 && y <= map.getSize().getHeight()) {
// draw the plane dot
g.setColor(GraphicsTheme.Colors.ORANGE);
g.drawRect(x - (DOT_DIMENSION / 2), y - (DOT_DIMENSION / 2), DOT_DIMENSION, DOT_DIMENSION);
// draw the name of the plane
g.setColor(GraphicsTheme.Colors.BLUE);
g.drawString(this.name, this.getX(map) + TEXT_OFFSET_X, this.getY(map) + TEXT_OFFSET_Y);
} else {
System.out.println("Skipping drawing plane at " + x + "," + y + " which is not within bounds");
}
}
}
|