From 70d15df43ea0d57c3fe237211098645733048c45 Mon Sep 17 00:00:00 2001 From: Ben Burwell Date: Sat, 19 Nov 2016 22:14:13 -0500 Subject: Add airports --- .../gui/aircraftmap/symbols/AirportSymbol.java | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/AirportSymbol.java (limited to 'src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/AirportSymbol.java') diff --git a/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/AirportSymbol.java b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/AirportSymbol.java new file mode 100644 index 0000000..5286f6f --- /dev/null +++ b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/AirportSymbol.java @@ -0,0 +1,48 @@ +package com.benburwell.planes.gui.aircraftmap.symbols; + +import com.benburwell.planes.data.Airport; +import com.benburwell.planes.gui.GraphicsTheme; +import com.benburwell.planes.gui.aircraftmap.AircraftMap; +import com.benburwell.planes.gui.aircraftmap.Drawable; +import com.benburwell.planes.gui.aircraftmap.GeoPoint; + +import java.awt.*; + +/** + * Created by ben on 11/19/16. + */ +public class AirportSymbol extends GeoPoint implements Drawable { + private String name; + private String iataCode; + private String localCode; + + public AirportSymbol(Airport airport) { + super(airport.getLatitude(), airport.getLongitude(), airport.getElevation()); + this.name = airport.getName(); + this.iataCode = airport.getIataCode(); + this.localCode = airport.getLocalCode(); + } + + public String getDisplayName() { + if (this.iataCode != null && !this.iataCode.isEmpty()) { + return this.iataCode; + } + if (this.localCode != null && !this.localCode.isEmpty()) { + return this.localCode; + } + return this.name; + } + + @Override + public void drawOn(Graphics g, AircraftMap map) { + if (this.shouldDrawOn(map)) { + int x = this.getX(map); + int y = this.getY(map); + + g.setColor(GraphicsTheme.Colors.MAGENTA); + + g.drawRect(x - 2, y - 2, 4, 4); + g.drawString(this.getDisplayName(), x + 6, y); + } + } +} -- cgit v1.2.3