Changeset 5500 in josm for trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
- Timestamp:
- 2012-09-04T00:13:37+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r5311 r5500 4 4 import static org.openstreetmap.josm.tools.I18n.marktr; 5 5 6 import java.awt.Color; 6 7 import java.awt.Cursor; 8 import java.awt.Graphics; 7 9 import java.awt.Point; 10 import java.awt.Polygon; 8 11 import java.awt.Rectangle; 9 12 import java.awt.geom.AffineTransform; … … 108 111 protected EastNorth center = calculateDefaultCenter(); 109 112 113 private static final Object paintRequestLock = new Object(); 114 private Rectangle paintRect = null; 115 private Polygon paintPoly = null; 116 110 117 public NavigatableComponent() { 111 118 setLayout(null); … … 1266 1273 Cursors = c; 1267 1274 } 1275 1276 @Override 1277 public void paint(Graphics g) { 1278 synchronized (paintRequestLock) { 1279 if (paintRect != null) { 1280 Graphics g2 = g.create(); 1281 g2.setColor(Color.BLACK); 1282 g2.setXORMode(Color.WHITE); 1283 g2.drawRect(paintRect.x, paintRect.y, paintRect.width, paintRect.height); 1284 } 1285 if (paintPoly != null) { 1286 Graphics g2 = g.create(); 1287 g2.setColor(Color.WHITE); 1288 g2.drawPolyline(paintPoly.xpoints, paintPoly.ypoints, paintPoly.npoints); 1289 } 1290 } 1291 super.paint(g); 1292 } 1293 1294 /** 1295 * Requests to paint the given {@code Rectangle}. 1296 * @param r The Rectangle to draw 1297 * @see #requestClearRect 1298 * @since 5500 1299 */ 1300 public void requestPaintRect(Rectangle r) { 1301 if (r != null) { 1302 synchronized (paintRequestLock) { 1303 paintRect = r; 1304 } 1305 repaint(); 1306 } 1307 } 1308 1309 /** 1310 * Requests to paint the given {@code Polygon} as a polyline (unclosed polygon). 1311 * @param p The Polygon to draw 1312 * @see #requestClearPoly 1313 * @since 5500 1314 */ 1315 public void requestPaintPoly(Polygon p) { 1316 if (p != null) { 1317 synchronized (paintRequestLock) { 1318 paintPoly = p; 1319 } 1320 repaint(); 1321 } 1322 } 1323 1324 /** 1325 * Requests to clear the rectangled previously drawn. 1326 * @see #requestPaintRect 1327 * @since 5500 1328 */ 1329 public void requestClearRect() { 1330 synchronized (paintRequestLock) { 1331 paintRect = null; 1332 } 1333 repaint(); 1334 } 1335 1336 /** 1337 * Requests to clear the polyline previously drawn. 1338 * @see #requestPaintPoly 1339 * @since 5500 1340 */ 1341 public void requestClearPoly() { 1342 synchronized (paintRequestLock) { 1343 paintPoly = null; 1344 } 1345 repaint(); 1346 } 1268 1347 }
Note:
See TracChangeset
for help on using the changeset viewer.
