diff options
author | Ben Burwell <ben.burwell@trifecta.com> | 2016-11-19 12:32:17 -0500 |
---|---|---|
committer | Ben Burwell <ben.burwell@trifecta.com> | 2016-11-19 12:32:17 -0500 |
commit | b8c30e5edd18fc830b944431fda32334af1f9801 (patch) | |
tree | 9ac8bda83a7f807b7184902ec18f2fbbe3e80918 /src/com/benburwell/planes/gui/aircraftmap/Plane.java | |
parent | 7a2a21ec5120d2c0edadaab405ff9256a4b75635 (diff) |
Refactor aircraft map into top-level classes
Diffstat (limited to 'src/com/benburwell/planes/gui/aircraftmap/Plane.java')
-rw-r--r-- | src/com/benburwell/planes/gui/aircraftmap/Plane.java | 37 |
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"); + } + } +} |