Revision 43616 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/MapControl.java
MapControl.java | ||
---|---|---|
287 | 287 |
*/ |
288 | 288 |
private static boolean drawAnimationEnabled = true; |
289 | 289 |
|
290 |
public static final int PAINT_PARTIAL_DRAWING_LAYERS = 0; |
|
291 |
public static final int PAINT_WHEN_DRAW_LAYERS_IS_COMPLETED = 1; |
|
292 |
|
|
293 |
private int paintMode = PAINT_PARTIAL_DRAWING_LAYERS; |
|
294 |
|
|
290 | 295 |
/** |
291 | 296 |
* <p> |
292 | 297 |
* Inner model with the layers, event support for drawing them, and the |
... | ... | |
628 | 633 |
|
629 | 634 |
this.drawer = new Drawer(); |
630 | 635 |
// Timer para mostrar el redibujado mientras se dibuja |
631 |
timer = |
|
632 |
new Timer(1000 / MapContext.getDrawFrameRate(), |
|
636 |
timer = new Timer(1000 / MapContext.getDrawFrameRate(), |
|
633 | 637 |
new ActionListener() { |
634 |
|
|
638 |
@Override |
|
635 | 639 |
public void actionPerformed(ActionEvent e) { |
636 |
|
|
637 |
if (drawAnimationEnabled) { |
|
640 |
if ( paintMode!=PAINT_WHEN_DRAW_LAYERS_IS_COMPLETED && drawAnimationEnabled) { |
|
638 | 641 |
MapControl.this.repaint(); |
639 | 642 |
} |
640 | 643 |
} |
641 |
}); |
|
644 |
} |
|
645 |
); |
|
642 | 646 |
initializeGrid(); |
643 | 647 |
|
644 | 648 |
if(ToolsLocator.getDisposableManager() != null) { |
... | ... | |
647 | 651 |
LOG.warn("Can't retrieve the disposable manager,"); |
648 | 652 |
} |
649 | 653 |
} |
650 |
|
|
654 |
|
|
655 |
public void setPaintMode(int paintMode) { |
|
656 |
this.paintMode = paintMode; |
|
657 |
} |
|
658 |
|
|
659 |
public int getPaintMode() { |
|
660 |
return this.paintMode; |
|
661 |
} |
|
662 |
|
|
651 | 663 |
/** |
652 | 664 |
* <p> |
653 | 665 |
* Sets a <code>MapContext</code> to this component. |
... | ... | |
1028 | 1040 |
private boolean adaptToImageSize() { |
1029 | 1041 |
if ((image == null) || (vp.getImageWidth() != this.getWidth()) |
1030 | 1042 |
|| (vp.getImageHeight() != this.getHeight())) { |
1031 |
image = |
|
1032 |
new BufferedImage(this.getWidth(), this.getHeight(), |
|
1043 |
image = new BufferedImage(this.getWidth(), this.getHeight(), |
|
1033 | 1044 |
BufferedImage.TYPE_INT_ARGB); |
1034 |
// ESTILO MAC |
|
1035 |
// image = GraphicsEnvironment.getLocalGraphicsEnvironment() |
|
1036 |
// .getDefaultScreenDevice().getDefaultConfiguration() |
|
1037 |
// .createCompatibleImage(this.getWidth(), this.getHeight()); |
|
1038 | 1045 |
vp.setImageSize(new Dimension(getWidth(), getHeight())); |
1039 | 1046 |
getMapContext().getViewPort().refreshExtent(); |
1040 |
|
|
1041 |
Graphics gTemp = image.createGraphics(); |
|
1042 |
Color theBackColor = vp.getBackColor(); |
|
1043 |
if (theBackColor == null) { |
|
1044 |
gTemp.setColor(Color.WHITE); |
|
1045 |
} else { |
|
1046 |
gTemp.setColor(theBackColor); |
|
1047 |
} |
|
1048 |
|
|
1049 |
gTemp.fillRect(0, 0, getWidth(), getHeight()); |
|
1050 |
gTemp.dispose(); |
|
1047 |
clearImage(image); |
|
1051 | 1048 |
status = DESACTUALIZADO; |
1052 |
// g.drawImage(image,0,0,null); |
|
1053 | 1049 |
return true; |
1054 | 1050 |
} |
1055 | 1051 |
return false; |
1056 | 1052 |
} |
1057 | 1053 |
|
1054 |
private void clearImage(BufferedImage image) { |
|
1055 |
if( image == null ) { |
|
1056 |
return; |
|
1057 |
} |
|
1058 |
Graphics gTemp = image.createGraphics(); |
|
1059 |
Color theBackColor = vp.getBackColor(); |
|
1060 |
if (theBackColor == null) { |
|
1061 |
gTemp.setColor(Color.WHITE); |
|
1062 |
} else { |
|
1063 |
gTemp.setColor(theBackColor); |
|
1064 |
} |
|
1065 |
gTemp.fillRect(0, 0, getWidth(), getHeight()); |
|
1066 |
gTemp.dispose(); |
|
1067 |
} |
|
1068 |
|
|
1058 | 1069 |
/** |
1059 | 1070 |
* <p> |
1060 | 1071 |
* Paints the graphical information of this component using a double buffer. |
... | ... | |
1113 | 1124 |
} |
1114 | 1125 |
} |
1115 | 1126 |
} else if ((status == DESACTUALIZADO)) { |
1116 |
|
|
1117 | 1127 |
mapControlDrawer.drawImage(image, 0, 0); |
1118 |
|
|
1119 | 1128 |
drawer.put(new PaintingRequest()); |
1120 | 1129 |
timer.start(); |
1121 | 1130 |
} |
... | ... | |
1168 | 1177 |
*/ |
1169 | 1178 |
public void drawMap(boolean doClear) { |
1170 | 1179 |
cancelDrawing(); |
1171 |
//System.out.println("drawMap con doClear=" + doClear); |
|
1172 | 1180 |
status = DESACTUALIZADO; |
1173 | 1181 |
if (doClear) { |
1174 |
// image = null; // Se usa para el PAN |
|
1175 |
if (image != null) { |
|
1176 |
Graphics2D g = image.createGraphics(); |
|
1177 |
Color theBackColor = vp.getBackColor(); |
|
1178 |
if (theBackColor == null) { |
|
1179 |
g.setColor(Color.WHITE); |
|
1180 |
} else { |
|
1181 |
g.setColor(theBackColor); |
|
1182 |
} |
|
1183 |
g.fillRect(0, 0, vp.getImageWidth(), vp.getImageHeight()); |
|
1184 |
g.dispose(); |
|
1185 |
} |
|
1182 |
clearImage(image); |
|
1186 | 1183 |
} |
1187 | 1184 |
repaint(); |
1188 | 1185 |
} |
... | ... | |
1329 | 1326 |
public void paint() { |
1330 | 1327 |
try { |
1331 | 1328 |
canceldraw.setCanceled(false); |
1332 |
Graphics2D g = image.createGraphics(); |
|
1333 |
|
|
1334 |
ViewPort viewPort = mapContext.getViewPort(); |
|
1335 |
|
|
1336 | 1329 |
if (status == DESACTUALIZADO) { |
1337 |
Graphics2D gTemp = image.createGraphics(); |
|
1338 |
Color theBackColor = viewPort.getBackColor(); |
|
1339 |
if (theBackColor == null) { |
|
1340 |
gTemp.setColor(Color.WHITE); |
|
1341 |
} else { |
|
1342 |
gTemp.setColor(theBackColor); |
|
1330 |
BufferedImage drawImage = image; |
|
1331 |
if( paintMode == PAINT_WHEN_DRAW_LAYERS_IS_COMPLETED ) { |
|
1332 |
drawImage = new BufferedImage( |
|
1333 |
image.getWidth(), |
|
1334 |
image.getHeight(), |
|
1335 |
BufferedImage.TYPE_INT_ARGB |
|
1336 |
); |
|
1343 | 1337 |
} |
1344 |
gTemp.fillRect(0, 0, viewPort.getImageWidth(), viewPort |
|
1345 |
.getImageHeight()); |
|
1346 |
mapContext.draw(image, g, canceldraw, mapContext |
|
1347 |
.getScaleView()); |
|
1338 |
clearImage(drawImage); |
|
1339 |
Graphics2D g = drawImage.createGraphics(); |
|
1340 |
mapContext.draw(drawImage, g, canceldraw, mapContext.getScaleView()); |
|
1341 |
g.dispose(); |
|
1342 |
image = drawImage; |
|
1348 | 1343 |
if (!canceldraw.isCanceled()) { |
1349 | 1344 |
status = ACTUALIZADO; |
1350 | 1345 |
} |
1351 | 1346 |
} |
1352 |
|
|
1353 | 1347 |
timer.stop(); |
1354 | 1348 |
repaint(); |
1355 | 1349 |
|
Also available in: Unified diff