Revision 38210 branches/v2_0_0_prep/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/MapControl.java
MapControl.java | ||
---|---|---|
297 | 297 |
|
298 | 298 |
/** |
299 | 299 |
* <p> |
300 |
* One of the possible status of <code>MapControl</code>. Determines that |
|
301 |
* only the graphical layer must be drawn / updated. |
|
302 |
* </p> |
|
303 |
*/ |
|
304 |
public static final int ONLY_GRAPHICS = 2; |
|
305 |
|
|
306 |
/** |
|
307 |
* <p> |
|
308 | 300 |
* Determines if the drawer can update this <code>MapControl</code> instance |
309 | 301 |
* when the timer launches an event. |
310 | 302 |
* </p> |
... | ... | |
1126 | 1118 |
mapControlDrawer.drawImage(image, 0, 0); |
1127 | 1119 |
} |
1128 | 1120 |
} |
1129 |
} else |
|
1130 |
if ((status == DESACTUALIZADO) || (status == ONLY_GRAPHICS)) { |
|
1121 |
} else if ((status == DESACTUALIZADO)) { |
|
1131 | 1122 |
|
1132 |
mapControlDrawer.drawImage(image, 0, 0);
|
|
1123 |
mapControlDrawer.drawImage(image, 0, 0);
|
|
1133 | 1124 |
|
1134 |
drawer.put(new PaintingRequest());
|
|
1135 |
timer.start();
|
|
1136 |
}
|
|
1125 |
drawer.put(new PaintingRequest());
|
|
1126 |
timer.start();
|
|
1127 |
}
|
|
1137 | 1128 |
cadgrid.drawGrid(mapControlDrawer); |
1138 | 1129 |
drawCursor(); |
1139 | 1130 |
} |
... | ... | |
1207 | 1198 |
} |
1208 | 1199 |
|
1209 | 1200 |
/** |
1210 |
* <p> |
|
1211 |
* Cancels any current drawing process, changing the status to |
|
1212 |
* <code>ONLY_GRAPHICS</code>, and forcing repaint only the graphical layer |
|
1213 |
* of the <code>MapContext</code>. |
|
1214 |
* </p> |
|
1201 |
* @deprecated use {@link #drawMap(boolean)} instead, or even |
|
1202 |
* better {@link #getMapContext()}.invalidate(). |
|
1215 | 1203 |
*/ |
1216 | 1204 |
public void drawGraphics() { |
1217 |
status = ONLY_GRAPHICS; |
|
1218 |
repaint(); |
|
1205 |
drawMap(false); |
|
1219 | 1206 |
} |
1220 | 1207 |
|
1221 | 1208 |
/** |
... | ... | |
1322 | 1309 |
* <li><i>2.4.- </i>Else, sets <i>status</i> to UPDATED.</li> |
1323 | 1310 |
* </ul> |
1324 | 1311 |
* </li> |
1325 |
* <li><i>3.- </i>Else, if <i>status</i> was ONLY_GRAPHICS: |
|
1326 |
* <ul> |
|
1327 |
* <li><i>3.1.- </i>Sets <i>status</i> to UPDATED.</li> |
|
1328 |
* <li><i>3.2.- </i>Notifies <i>MapContext</i> to be drawn invoking: <code>mapContext.drawGraphics(double-buffer, double-buffer's buffer, shared cancel-draw object, mapContext.getScaleView());</code> |
|
1329 |
* .</li> |
|
1330 |
* </ul> |
|
1331 |
* </li> |
|
1332 |
* <li><i>4.- </i>Stops the <i>timer</i>.</li> |
|
1333 |
* <li><i>5.- </i>Repaints this component invoking: |
|
1312 |
* <li><i>3.- </i>Stops the <i>timer</i>.</li> |
|
1313 |
* <li><i>4.- </i>Repaints this component invoking: |
|
1334 | 1314 |
* <code>repaint();</code></li> |
1335 | 1315 |
* </ul> |
1336 | 1316 |
* </p> |
... | ... | |
1345 | 1325 |
public void paint() { |
1346 | 1326 |
try { |
1347 | 1327 |
canceldraw.setCanceled(false); |
1348 |
/* |
|
1349 |
* if (image == null) |
|
1350 |
* { |
|
1351 |
* image = new BufferedImage(vp.getImageWidth(), |
|
1352 |
* vp.getImageHeight(), |
|
1353 |
* BufferedImage.TYPE_INT_ARGB); |
|
1354 |
* Graphics gTemp = image.createGraphics(); |
|
1355 |
* Color theBackColor = vp.getBackColor(); |
|
1356 |
* if (theBackColor == null) |
|
1357 |
* gTemp.setColor(Color.WHITE); |
|
1358 |
* else |
|
1359 |
* gTemp.setColor(theBackColor); |
|
1360 |
* |
|
1361 |
* gTemp.fillRect(0,0,getWidth(), getHeight()); |
|
1362 |
* gTemp.dispose(); |
|
1363 |
* // g.drawImage(image,0,0,null); |
|
1364 |
* |
|
1365 |
* System.out.println("Imagen con null en DESACTUALIZADO. Width = " |
|
1366 |
* + this.getWidth()); |
|
1367 |
* } |
|
1368 |
*/ |
|
1369 | 1328 |
Graphics2D g = image.createGraphics(); |
1370 | 1329 |
|
1371 | 1330 |
ViewPort viewPort = mapContext.getViewPort(); |
... | ... | |
1380 | 1339 |
} |
1381 | 1340 |
gTemp.fillRect(0, 0, viewPort.getImageWidth(), viewPort |
1382 | 1341 |
.getImageHeight()); |
1383 |
// ESTILO MAC |
|
1384 |
// BufferedImage imgMac = new |
|
1385 |
// BufferedImage(vp.getImageWidth(), vp.getImageHeight(), |
|
1386 |
// BufferedImage.TYPE_INT_ARGB); |
|
1387 |
// |
|
1388 |
// mapContext.draw(imgMac, g, canceldraw, |
|
1389 |
// mapContext.getScaleView()); |
|
1390 |
// g.drawImage(imgMac, 0, 0, null); |
|
1391 |
// FIN ESTILO MAC |
|
1392 |
// SIN MAC: |
|
1393 |
|
|
1394 | 1342 |
mapContext.draw(image, g, canceldraw, mapContext |
1395 | 1343 |
.getScaleView()); |
1396 | 1344 |
if (!canceldraw.isCanceled()) { |
1397 | 1345 |
status = ACTUALIZADO; |
1398 |
} else { |
|
1399 |
status = DESACTUALIZADO; |
|
1400 |
// getMapContext().getLayers().setDirty(true); |
|
1401 | 1346 |
} |
1347 |
} |
|
1402 | 1348 |
|
1403 |
} else |
|
1404 |
if (status == ONLY_GRAPHICS) { |
|
1405 |
status = ACTUALIZADO; |
|
1406 |
mapContext.drawGraphics(image, g, canceldraw, |
|
1407 |
mapContext.getScaleView()); |
|
1408 |
|
|
1409 |
} |
|
1410 |
|
|
1411 |
// status = FAST_PAINT; |
|
1412 |
// drawerAlive = false; |
|
1413 | 1349 |
timer.stop(); |
1414 | 1350 |
repaint(); |
1415 | 1351 |
|
1416 | 1352 |
} catch (Throwable e) { |
1417 | 1353 |
timer.stop(); |
1418 |
// isCancelled = true; |
|
1419 | 1354 |
e.printStackTrace(); |
1420 | 1355 |
throwException(e); |
1421 |
} finally { |
|
1422 |
} |
|
1356 |
} |
|
1423 | 1357 |
} |
1424 | 1358 |
} |
1425 | 1359 |
|
Also available in: Unified diff