1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
package com.benburwell.planes.gui.aircraftmap.symbols;
import com.benburwell.planes.data.Runway;
import com.benburwell.planes.gui.GraphicsTheme;
import com.benburwell.planes.gui.aircraftmap.AircraftMap;
import com.benburwell.planes.gui.aircraftmap.DisplayMode;
import com.benburwell.planes.gui.aircraftmap.Drawable;
import com.benburwell.planes.gui.aircraftmap.GeoPoint;
import java.awt.*;
import java.awt.geom.AffineTransform;
/**
* @author ben
*/
public class RunwaySymbol implements Drawable {
public final double FEET_PER_MILE = 6076.12;
private Runway runway;
public RunwaySymbol(Runway r) {
this.runway = r;
}
@Override
public void drawOn(Graphics g, AircraftMap map, DisplayMode displayMode) {
if (!displayMode.equals(DisplayMode.HIDDEN)) {
GeoPoint he = new GeoPoint(this.runway.getHeLatitude(), this.runway.getHeLongitude(), 0);
int hex = he.getX(map);
int hey = he.getY(map);
GeoPoint le = new GeoPoint(this.runway.getLeLatitude(), this.runway.getLeLongitude(), 0);
int lex = le.getX(map);
int ley = le.getY(map);
if (he.shouldDrawOn(map) && le.shouldDrawOn(map)) {
//if (this.runway.getWidth() != null && this.runway.getLength() != null) {
// double dx = hex - lex;
// double dy = hey - ley;
// int width = (int) ((this.runway.getWidth() / FEET_PER_MILE) * map.getPixelsPerNauticalMile());
// int length = (int) ((this.runway.getLength() / FEET_PER_MILE) * map.getPixelsPerNauticalMile());
// AffineTransform at = new AffineTransform();
// at.setToRotation(Math.atan(dy / dx), lex, ley);
// Graphics2D g2d = (Graphics2D) g.create();
// g2d.setColor(GraphicsTheme.Styles.MAP_RUNWAY_BORDER_COLOR);
// g2d.setTransform(at);
// g2d.drawRect(lex - (width / 2), ley - (length / 2), width, length);
// g2d.dispose();
//}
g.setColor(GraphicsTheme.Styles.MAP_RUNWAY_BORDER_COLOR);
g.drawLine(lex, ley, hex, hey);
if (displayMode.equals(DisplayMode.DETAILED)) {
g.drawString(runway.getLeIdent(), lex, ley);
g.drawString(runway.getHeIdent(), hex, hey);
}
}
}
}
}
|