From 70d15df43ea0d57c3fe237211098645733048c45 Mon Sep 17 00:00:00 2001 From: Ben Burwell Date: Sat, 19 Nov 2016 22:14:13 -0500 Subject: Add airports --- .../planes/gui/aircraftmap/symbols/NDBSymbol.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/NDBSymbol.java (limited to 'src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/NDBSymbol.java') diff --git a/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/NDBSymbol.java b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/NDBSymbol.java new file mode 100644 index 0000000..08793ec --- /dev/null +++ b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/NDBSymbol.java @@ -0,0 +1,42 @@ +package com.benburwell.planes.gui.aircraftmap.symbols; + +import com.benburwell.planes.data.Position; +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 NDBSymbol extends GeoPoint implements Drawable { + public static final int INNER_RADIUS = 3; + public static final int OUTER_RADIUS = 9; + public static final int TEXT_OFFSET = 4; + + private String name; + private int frequency; + + public NDBSymbol(String name, Position pos, int frequency) { + super(pos.getLatitude(), pos.getLongitude(), pos.getAltitude()); + this.name = name; + this.frequency = frequency; + } + + @Override + public void drawOn(Graphics g, AircraftMap map) { + if (this.shouldDrawOn(map)) { + g.setColor(GraphicsTheme.Colors.VIOLET); + + int x = this.getX(map); + int y = this.getY(map); + g.fillOval(x - INNER_RADIUS, y - INNER_RADIUS, INNER_RADIUS * 2, INNER_RADIUS * 2); + g.drawOval(x - OUTER_RADIUS, y - OUTER_RADIUS, OUTER_RADIUS * 2, OUTER_RADIUS * 2); + + g.drawString(this.name, x + OUTER_RADIUS + TEXT_OFFSET, y); + g.drawString("" + this.frequency, x + OUTER_RADIUS + TEXT_OFFSET, y + g.getFontMetrics().getHeight()); + } + } +} -- cgit v1.2.3