Revision 980 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/NewMapControl.java
NewMapControl.java | ||
---|---|---|
1 | 1 |
package com.iver.cit.gvsig.fmap; |
2 | 2 |
|
3 |
import java.awt.Color; |
|
3 | 4 |
import java.awt.Dimension; |
4 | 5 |
import java.awt.Graphics; |
5 | 6 |
import java.awt.Graphics2D; |
... | ... | |
48 | 49 |
private MapTool currentMapTool = null; |
49 | 50 |
private int status = ACTUALIZADO; |
50 | 51 |
private BufferedImage image = null; |
51 |
private BufferedImage backimage = null; |
|
52 | 52 |
private String currentTool; |
53 | 53 |
private CancelDraw canceldraw; |
54 | 54 |
private boolean isCancelled = true; |
... | ... | |
110 | 110 |
}else{ |
111 | 111 |
vp = mapContext.getViewPort(); |
112 | 112 |
// vp.setImageSize(new Dimension(getWidth(), getHeight())); |
113 |
System.err.println("Viewport en setMapContext:" + vp); |
|
113 |
// System.err.println("Viewport en setMapContext:" + vp);
|
|
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
mapContext.addAtomicEventListener(mapContextListener); |
... | ... | |
217 | 217 |
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics) |
218 | 218 |
*/ |
219 | 219 |
protected void paintComponent(Graphics g) { |
220 |
if (image == null) return; |
|
220 | 221 |
if (status == ACTUALIZADO) { |
221 | 222 |
logger.debug("Dibujando la imagen obtenida"); |
222 |
if (image != null) { |
|
223 |
g.drawImage(image, 0, 0,vp.getBackColor(), this); |
|
224 |
} else { |
|
223 |
System.out.println("Dibujando la imagen obtenida" + System.currentTimeMillis()); |
|
224 |
/* else { |
|
225 | 225 |
image = new BufferedImage(this.getWidth(), this.getHeight(), |
226 | 226 |
BufferedImage.TYPE_INT_ARGB); |
227 |
} |
|
227 |
} |
|
228 |
*/ |
|
229 |
if (currentMapTool != null) { |
|
230 |
currentMapTool.paintComponent(g); |
|
231 |
} |
|
232 |
/* else if (image != null) { |
|
233 |
g.drawImage(image, 0, 0,vp.getBackColor(), this); |
|
234 |
} */ |
|
228 | 235 |
|
229 |
if (currentMapTool != null) { |
|
230 |
currentMapTool.paintComponent(g); |
|
231 |
} |
|
232 | 236 |
} else if (status == DESACTUALIZADO) { |
233 | 237 |
logger.debug("Obteniendo la imagen de la cartograf?a"); |
234 |
if (backimage !=null){ |
|
235 |
g.drawImage(backimage,0,0,vp.getBackColor(),this); |
|
236 |
} |
|
237 |
image = new BufferedImage(this.getWidth(), this.getHeight(), |
|
238 |
BufferedImage.TYPE_INT_ARGB); |
|
238 |
|
|
239 |
g.setColor(vp.getBackColor()); |
|
240 |
g.fillRect(0, 0, getWidth(), getHeight()); |
|
239 | 241 |
|
240 | 242 |
cancelDrawing(); |
241 |
|
|
242 |
drawer = new Drawer(image, (Graphics2D) image.getGraphics(), |
|
243 |
if (image != null) |
|
244 |
{ |
|
245 |
drawer = new Drawer(image, (Graphics2D) image.getGraphics(), |
|
243 | 246 |
canceldraw); |
244 |
drawer.start(); |
|
245 |
timer.start(); |
|
246 |
status = ACTUALIZADO; |
|
247 |
drawer.start(); |
|
248 |
timer.start(); |
|
249 |
status = ACTUALIZADO; |
|
250 |
} |
|
247 | 251 |
} |
248 | 252 |
|
249 | 253 |
} |
... | ... | |
262 | 266 |
*/ |
263 | 267 |
public void drawMap() { |
264 | 268 |
status = DESACTUALIZADO; |
265 |
vp.setImageSize(new Dimension(getWidth(), getHeight())); |
|
266 |
backimage=new BufferedImage(this.getWidth(), this.getHeight(), |
|
267 |
BufferedImage.TYPE_INT_ARGB); |
|
268 |
backimage.setRGB(2,4,5); |
|
269 | 269 |
repaint(); |
270 | 270 |
} |
271 | 271 |
|
... | ... | |
285 | 285 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent) |
286 | 286 |
*/ |
287 | 287 |
public void componentResized(ComponentEvent e) { |
288 |
vp.setImageSize(new Dimension(getWidth(), getHeight())); |
|
289 |
|
|
290 |
image = new BufferedImage(this.getWidth(), this.getHeight(), |
|
291 |
BufferedImage.TYPE_INT_ARGB); |
|
292 |
image.getGraphics().setColor(vp.getBackColor()); |
|
293 |
image.getGraphics().fillRect(0, 0, getWidth(), getHeight()); |
|
294 |
|
|
288 | 295 |
drawMap(); |
289 | 296 |
} |
290 | 297 |
|
... | ... | |
316 | 323 |
this.g = g; |
317 | 324 |
this.image = image; |
318 | 325 |
this.cancel = cancel; |
326 |
|
|
319 | 327 |
} |
320 | 328 |
|
321 | 329 |
/** |
... | ... | |
324 | 332 |
public void run() { |
325 | 333 |
try { |
326 | 334 |
synchronized (Drawer.class) { |
335 |
|
|
327 | 336 |
mapContext.draw(image, (Graphics2D) image.getGraphics(), |
328 | 337 |
cancel); |
329 | 338 |
timer.stop(); |
Also available in: Unified diff