double offset_x, offset_y;
+ int width, height;
+
public AltosLatLon lat_lon (AltosPointDouble point) {
double lat, lon;
double rads;
return screen(point(lat, lon));
}
+ /* Return first longitude value which ends up on-screen */
+ public double first_lon(double lon) {
+ /* Find a longitude left of the screen */
+ for (;;) {
+ double x = lon * scale_x - offset_x;
+ if (x < 0)
+ break;
+ lon -= 360.0;
+ }
+ /* Find the first longitude on the screen */
+ for (;;) {
+ double x = lon * scale_x - offset_x;
+ if (x >= 0)
+ break;
+ lon += 360.0;
+ }
+ return lon;
+ }
+
+ /* Return last longitude value which ends up on-screen */
+ public double last_lon(double lon) {
+ lon = first_lon(lon);
+
+ for(;;) {
+ double next_lon = lon + 360.0;
+ double next_x = next_lon * scale_x - offset_x;
+ if (next_x >= width)
+ break;
+ lon = next_lon;
+ }
+ return lon;
+ }
+
private boolean has_location;
public boolean has_location() {
scale_x = 256/360.0 * Math.pow(2, zoom);
scale_y = 256/(2.0*Math.PI) * Math.pow(2, zoom);
+ this.width = width;
+ this.height = height;
+
AltosPointDouble centre_pt = point(centre_lat_lon);
has_location = (centre_lat_lon.lat != 0 || centre_lat_lon.lon != 0);
class MapMark extends AltosMapMark {
public void paint(AltosMapTransform t) {
- AltosPointDouble pt = t.screen(lat_lon);
+ double lat = lat_lon.lat;
+ double lon;
+ double first_lon = t.first_lon(lat_lon.lon);
+ double last_lon = t.last_lon(lat_lon.lon);
+ for (lon = first_lon; lon <= last_lon; lon += 360.0) {
+ AltosPointDouble pt = t.screen(lat, lon);
- g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
- g.setStroke(new BasicStroke(stroke_width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
+ g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ g.setStroke(new BasicStroke(stroke_width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
- if (0 <= state && state < AltosUIMap.stateColors.length)
- g.setColor(AltosUIMap.stateColors[state]);
- else
- g.setColor(AltosUIMap.stateColors[AltosLib.ao_flight_invalid]);
-
- g.drawOval((int)pt.x-5, (int)pt.y-5, 10, 10);
- g.drawOval((int)pt.x-20, (int)pt.y-20, 40, 40);
- g.drawOval((int)pt.x-35, (int)pt.y-35, 70, 70);
-
- if (label != null) {
- Rectangle2D bounds;
- bounds = line_font.getStringBounds(label, g.getFontRenderContext());
- float x = (float) pt.x;
- float y = (float) pt.y + (float) bounds.getHeight() / 2.0f;
-
- g.setFont(line_font);
- g.setColor(Color.WHITE);
- for (int dy = -2; dy <= 2; dy += 2)
- for (int dx = -2; dx <= 2; dx += 2)
- g.drawString(label, x + dx, y + dy);
if (0 <= state && state < AltosUIMap.stateColors.length)
g.setColor(AltosUIMap.stateColors[state]);
else
g.setColor(AltosUIMap.stateColors[AltosLib.ao_flight_invalid]);
- g.drawString(label, x, y);
+
+ g.drawOval((int)pt.x-5, (int)pt.y-5, 10, 10);
+ g.drawOval((int)pt.x-20, (int)pt.y-20, 40, 40);
+ g.drawOval((int)pt.x-35, (int)pt.y-35, 70, 70);
+
+ if (label != null) {
+ Rectangle2D bounds;
+ bounds = line_font.getStringBounds(label, g.getFontRenderContext());
+ float x = (float) pt.x;
+ float y = (float) pt.y + (float) bounds.getHeight() / 2.0f;
+
+ g.setFont(line_font);
+ g.setColor(Color.WHITE);
+ for (int dy = -2; dy <= 2; dy += 2)
+ for (int dx = -2; dx <= 2; dx += 2)
+ g.drawString(label, x + dx, y + dy);
+ if (0 <= state && state < AltosUIMap.stateColors.length)
+ g.setColor(AltosUIMap.stateColors[state]);
+ else
+ g.setColor(AltosUIMap.stateColors[AltosLib.ao_flight_invalid]);
+ g.drawString(label, x, y);
+ }
}
}