summaryrefslogtreecommitdiff
path: root/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols
diff options
context:
space:
mode:
authorBen Burwell <ben.burwell@trifecta.com>2016-11-20 02:38:23 -0500
committerBen Burwell <ben.burwell@trifecta.com>2016-11-20 02:39:13 -0500
commit7411558abf4aba7d600bb9fc713d36032e4a6df3 (patch)
tree56ccca55dc7175bf3bca88e123334ed3da878333 /src/main/java/com/benburwell/planes/gui/aircraftmap/symbols
parentf1e32ed443bafc03448f0f3b36c712b9293e71e7 (diff)
Show routes
Diffstat (limited to 'src/main/java/com/benburwell/planes/gui/aircraftmap/symbols')
-rw-r--r--src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/AirportSymbol.java2
-rw-r--r--src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/NDBSymbol.java2
-rw-r--r--src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/PlaneSymbol.java8
-rw-r--r--src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/RouteSymbol.java56
-rw-r--r--src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/VORDMESymbol.java2
-rw-r--r--src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/VORSymbol.java2
-rw-r--r--src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/VORTACSymbol.java2
7 files changed, 65 insertions, 9 deletions
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
index b97a7fa..7467a0f 100644
--- a/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/AirportSymbol.java
+++ b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/AirportSymbol.java
@@ -39,7 +39,7 @@ public class AirportSymbol extends GeoPoint implements Drawable {
int x = this.getX(map);
int y = this.getY(map);
- g.setColor(GraphicsTheme.Colors.MAGENTA);
+ g.setColor(GraphicsTheme.Styles.MAP_AIRPORT_COLOR);
g.drawRect(x - 2, y - 2, 4, 4);
g.drawString(this.getDisplayName(), x + 6, y);
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
index 74f4441..e3b23f5 100644
--- a/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/NDBSymbol.java
+++ b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/NDBSymbol.java
@@ -28,7 +28,7 @@ public class NDBSymbol extends GeoPoint implements Drawable {
@Override
public void drawOn(Graphics g, AircraftMap map) {
if (this.shouldDrawOn(map)) {
- g.setColor(GraphicsTheme.Colors.VIOLET);
+ g.setColor(GraphicsTheme.Styles.MAP_NAVAID_COLOR);
int x = this.getX(map);
int y = this.getY(map);
diff --git a/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/PlaneSymbol.java b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/PlaneSymbol.java
index 3e6b51c..a522b04 100644
--- a/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/PlaneSymbol.java
+++ b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/PlaneSymbol.java
@@ -50,8 +50,8 @@ public class PlaneSymbol extends GeoPoint implements Drawable {
}
public Color getPlaneColor() {
- Color minColor = GraphicsTheme.Colors.RED;
- Color maxColor = GraphicsTheme.Colors.GREEN;
+ Color minColor = GraphicsTheme.Styles.MAP_PLANE_MIN_COLOR;
+ Color maxColor = GraphicsTheme.Styles.MAP_PLANE_MAX_COLOR;
float[] minHsb = Color.RGBtoHSB(minColor.getRed(), minColor.getGreen(), minColor.getBlue(), null);
float[] maxHsb = Color.RGBtoHSB(maxColor.getRed(), maxColor.getGreen(), maxColor.getBlue(), null);
@@ -123,14 +123,14 @@ public class PlaneSymbol extends GeoPoint implements Drawable {
g2d.dispose();
// draw the history track
- g.setColor(GraphicsTheme.Colors.BASE_4);
+ g.setColor(GraphicsTheme.Styles.MAP_PLANE_TRACK_COLOR);
this.historyTrack.forEach(pos -> {
GeoPoint p = new GeoPoint(pos);
g.fillRect(p.getX(map) - 2, p.getY(map) - 2, 4, 4);
});
// draw the name of the plane
- g.setColor(GraphicsTheme.Colors.BASE_5);
+ g.setColor(GraphicsTheme.Styles.MAP_LABEL_COLOR);
g.drawString(this.getDisplayName(), x + TEXT_OFFSET_X, y + TEXT_OFFSET_Y);
String infoString = String.format("%d%s %.1f", this.getFlightLevel(), this.getVerticalRateIndicator(), this.getSpeed());
g.drawString(infoString, x + TEXT_OFFSET_X, y + TEXT_OFFSET_Y + g.getFontMetrics().getHeight());
diff --git a/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/RouteSymbol.java b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/RouteSymbol.java
new file mode 100644
index 0000000..edd622a
--- /dev/null
+++ b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/RouteSymbol.java
@@ -0,0 +1,56 @@
+package com.benburwell.planes.gui.aircraftmap.symbols;
+
+import com.benburwell.planes.graph.Airway;
+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.Graphics;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author ben
+ */
+public class RouteSymbol implements Drawable {
+ private final Airway airway;
+
+ public RouteSymbol(Airway airway) {
+ this.airway = airway;
+ }
+
+ private boolean inRange(int lo, int n, int hi) {
+ return lo <= n && n <= hi;
+ }
+
+ @Override
+ public void drawOn(Graphics graphicsContext, AircraftMap map) {
+ int w = map.getWidth();
+ int h = map.getHeight();
+ graphicsContext.setColor(GraphicsTheme.Styles.MAP_ROUTE_COLOR);
+ List<GeoPoint> points = this.airway.getPoints().stream().map(GeoPoint::new).collect(Collectors.toList());
+ for (int i = 0; i < points.size() - 1; i++) {
+ GeoPoint p1 = points.get(i);
+ int p1x = p1.getX(map);
+ int p1y = p1.getY(map);
+
+ GeoPoint p2 = points.get(i + 1);
+ int p2x = p2.getX(map);
+ int p2y = p2.getY(map);
+
+ boolean p1OnMap = inRange(0, p1x, w) && inRange(0, p1y, h);
+ boolean p2OnMap = inRange(0, p2x, w) && inRange(0, p2y, h);
+ boolean showEdge = p1OnMap || p2OnMap;
+ if (showEdge) {
+ graphicsContext.drawLine(p1x, p1y, p2x, p2y);
+ graphicsContext.fillOval(p1x - 2, p1y - 2, 4, 4);
+ }
+ }
+ int pnx = points.get(points.size() - 1).getX(map);
+ int pny = points.get(points.size() - 1).getY(map);
+ if (inRange(0, pnx, w) && inRange(0, pny, h)) {
+ graphicsContext.fillOval(pnx - 2, pny - 2, 4, 4);
+ }
+ }
+}
diff --git a/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/VORDMESymbol.java b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/VORDMESymbol.java
index b4edc28..6b12260 100644
--- a/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/VORDMESymbol.java
+++ b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/VORDMESymbol.java
@@ -21,7 +21,7 @@ public class VORDMESymbol extends VORSymbol implements Drawable {
if (this.shouldDrawOn(map)) {
int x = this.getX(map);
int y = this.getY(map);
- graphicsContext.setColor(GraphicsTheme.Colors.VIOLET);
+ graphicsContext.setColor(GraphicsTheme.Styles.MAP_NAVAID_COLOR);
graphicsContext.drawRect(x - VORSymbol.RADIUS, y - VORSymbol.HEIGHT, VORSymbol.RADIUS * 2, VORSymbol.HEIGHT * 2);
}
}
diff --git a/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/VORSymbol.java b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/VORSymbol.java
index 5164248..f4a73dc 100644
--- a/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/VORSymbol.java
+++ b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/VORSymbol.java
@@ -32,7 +32,7 @@ public class VORSymbol extends GeoPoint implements Drawable {
if (this.shouldDrawOn(map)) {
int x = this.getX(map);
int y = this.getY(map);
- graphicsContext.setColor(GraphicsTheme.Colors.VIOLET);
+ graphicsContext.setColor(GraphicsTheme.Styles.MAP_NAVAID_COLOR);
// center dot
graphicsContext.fillOval(x - DOT_RADIUS, y - DOT_RADIUS, DOT_RADIUS * 2, DOT_RADIUS * 2);
diff --git a/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/VORTACSymbol.java b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/VORTACSymbol.java
index a8d0bdb..1ca1290 100644
--- a/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/VORTACSymbol.java
+++ b/src/main/java/com/benburwell/planes/gui/aircraftmap/symbols/VORTACSymbol.java
@@ -21,7 +21,7 @@ public class VORTACSymbol extends VORSymbol implements Drawable {
if (this.shouldDrawOn(map)) {
int x = this.getX(map);
int y = this.getY(map);
- graphicsContext.setColor(GraphicsTheme.Colors.VIOLET);
+ graphicsContext.setColor(GraphicsTheme.Styles.MAP_NAVAID_COLOR);
int[] xs = { x - VORSymbol.X_OFFSET, x + VORSymbol.X_OFFSET, x + VORSymbol.X_OFFSET, x - VORSymbol.X_OFFSET, x - VORSymbol.X_OFFSET };
int[] ys = { y + VORSymbol.RADIUS, y + VORSymbol.RADIUS, y + VORSymbol.RADIUS * 2, y + VORSymbol.RADIUS * 2, y + VORSymbol.RADIUS };