- class MapPath extends AltosMapPath {
-
- boolean line_in(AltosPointDouble a, AltosPointDouble b) {
- final Rect bounds = canvas.getClipBounds();
- int left = (int) Math.floor (Math.min((float) a.x, (float) b.x) - stroke_width / 2.0f);
- int right = (int) Math.ceil(Math.max((float) a.x, (float) b.x) + stroke_width / 2.0f);
- int top = (int) Math.floor(Math.min((float) a.y, (float) b.y) - stroke_width / 2.0f);
- int bottom = (int) Math.ceil(Math.max((float) a.y, (float) b.y) + stroke_width / 2.0f);
-
- return left < bounds.right && bounds.left < right &&
- top < bounds.bottom && bounds.top < bottom;
- }
-
- public void paint(AltosMapTransform t) {
- AltosPointDouble prev = null;
- int cur_color = paint.getColor();
-
- for (AltosMapPathPoint point : points) {
- AltosPointDouble cur = t.screen(point.lat_lon);
-
- if (prev != null && line_in(prev, cur)) {
- int color;
- if (0 <= point.state && point.state < stateColors.length)
- color = stateColors[point.state];
- else
- color = stateColors[AltosLib.ao_flight_invalid];
- if (color != cur_color) {
- paint.setColor(color);
- cur_color = color;
- }
- canvas.drawLine((float) prev.x, (float) prev.y, (float) cur.x, (float) cur.y, paint);
- }
- prev = cur;
- }
- }
-
- public MapPath() {
- stroke_width = TabMapOffline.this.stroke_width;
- }
- }
-