source: osm/applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapRectangleImpl.java@ 26648

Last change on this file since 26648 was 26648, checked in by bastik, 14 years ago

applied josm 6825 - Display imagery providers bbox in a slippy map (patch by Don-vip)

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.gui.jmapviewer;
3
4import java.awt.Color;
5import java.awt.Graphics;
6import java.awt.Point;
7
8import org.openstreetmap.gui.jmapviewer.interfaces.MapRectangle;
9import org.openstreetmap.josm.data.Bounds;
10
11/**
12 * @author Vincent
13 *
14 */
15public class MapRectangleImpl implements MapRectangle {
16
17 private Coordinate topLeft;
18 private Coordinate bottomRight;
19 Color color;
20
21 public MapRectangleImpl(Bounds bounds) {
22 this(bounds, Color.BLUE);
23 }
24
25 public MapRectangleImpl(Bounds bounds, Color color) {
26 this.topLeft = new Coordinate(bounds.getMax().lat(), bounds.getMin().lon());
27 this.bottomRight = new Coordinate(bounds.getMin().lat(), bounds.getMax().lon());
28 this.color = color;
29 }
30
31 /* (non-Javadoc)
32 * @see org.openstreetmap.gui.jmapviewer.interfaces.MapRectangle#getTopLeft()
33 */
34 @Override
35 public Coordinate getTopLeft() {
36 return topLeft;
37 }
38
39 /* (non-Javadoc)
40 * @see org.openstreetmap.gui.jmapviewer.interfaces.MapRectangle#getBottomRight()
41 */
42 @Override
43 public Coordinate getBottomRight() {
44 return bottomRight;
45 }
46
47 /* (non-Javadoc)
48 * @see org.openstreetmap.gui.jmapviewer.interfaces.MapRectangle#paint(java.awt.Graphics, java.awt.Point, java.awt.Point)
49 */
50 @Override
51 public void paint(Graphics g, Point topLeft, Point bottomRight) {
52 g.setColor(color);
53 g.drawRect(topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y);
54 }
55
56 @Override
57 public String toString() {
58 return "MapRectangle from " + topLeft + " to " + bottomRight;
59 }
60}
Note: See TracBrowser for help on using the repository browser.