summaryrefslogtreecommitdiff
path: root/src/com/benburwell/planes/gui/aircraftmap/Plane.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/benburwell/planes/gui/aircraftmap/Plane.java')
-rw-r--r--src/com/benburwell/planes/gui/aircraftmap/Plane.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/com/benburwell/planes/gui/aircraftmap/Plane.java b/src/com/benburwell/planes/gui/aircraftmap/Plane.java
new file mode 100644
index 0000000..8c3c8c1
--- /dev/null
+++ b/src/com/benburwell/planes/gui/aircraftmap/Plane.java
@@ -0,0 +1,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");
+ }
+ }
+}