Revision 955 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; |
|
4 | 3 |
import java.awt.Dimension; |
5 | 4 |
import java.awt.Graphics; |
6 | 5 |
import java.awt.Graphics2D; |
... | ... | |
49 | 48 |
private MapTool currentMapTool = null; |
50 | 49 |
private int status = ACTUALIZADO; |
51 | 50 |
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; |
55 | 55 |
private Timer timer; |
56 |
private ViewPort vp; |
|
57 |
private Color backColor = Color.WHITE; |
|
56 |
protected ViewPort vp; |
|
58 | 57 |
private Drawer drawer; |
59 | 58 |
|
60 | 59 |
private MapToolListener mapToolListener = new MapToolListener(); |
... | ... | |
218 | 217 |
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics) |
219 | 218 |
*/ |
220 | 219 |
protected void paintComponent(Graphics g) { |
221 |
if (status == ACTUALIZADO) {
|
|
222 |
logger.debug("Dibujando la imagen obtenida");
|
|
220 |
if (status == ACTUALIZADO) { |
|
221 |
logger.debug("Dibujando la imagen obtenida"); |
|
223 | 222 |
if (image != null) { |
224 |
g.drawImage(image, 0, 0, this); |
|
223 |
g.drawImage(image, 0, 0,vp.getBackColor(), this);
|
|
225 | 224 |
} else { |
226 | 225 |
image = new BufferedImage(this.getWidth(), this.getHeight(), |
227 | 226 |
BufferedImage.TYPE_INT_ARGB); |
... | ... | |
232 | 231 |
} |
233 | 232 |
} else if (status == DESACTUALIZADO) { |
234 | 233 |
logger.debug("Obteniendo la imagen de la cartograf?a"); |
235 |
image = new BufferedImage(this.getWidth(), this.getHeight(),
|
|
236 |
BufferedImage.TYPE_INT_ARGB);
|
|
237 |
image.getGraphics().setColor(backColor);
|
|
238 |
image.getGraphics().fillRect(0, 0, image.getWidth(),
|
|
239 |
image.getHeight());
|
|
240 |
|
|
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);
|
|
239 |
|
|
241 | 240 |
cancelDrawing(); |
242 | 241 |
|
243 | 242 |
drawer = new Drawer(image, (Graphics2D) image.getGraphics(), |
... | ... | |
246 | 245 |
timer.start(); |
247 | 246 |
status = ACTUALIZADO; |
248 | 247 |
} |
248 |
|
|
249 | 249 |
} |
250 | 250 |
|
251 | 251 |
/** |
... | ... | |
263 | 263 |
public void drawMap() { |
264 | 264 |
status = DESACTUALIZADO; |
265 | 265 |
vp.setImageSize(new Dimension(getWidth(), getHeight())); |
266 |
|
|
266 |
backimage=new BufferedImage(this.getWidth(), this.getHeight(), |
|
267 |
BufferedImage.TYPE_INT_ARGB); |
|
268 |
backimage.setRGB(2,4,5); |
|
267 | 269 |
repaint(); |
268 | 270 |
} |
269 | 271 |
|
... | ... | |
292 | 294 |
public void componentShown(ComponentEvent e) { |
293 | 295 |
} |
294 | 296 |
|
295 |
/**
|
|
297 |
/** |
|
296 | 298 |
* DOCUMENT ME! |
297 | 299 |
* |
298 |
* @return DOCUMENT ME! |
|
299 |
*/ |
|
300 |
public Color getBackColor() { |
|
301 |
return backColor; |
|
302 |
} |
|
303 |
|
|
304 |
/** |
|
305 |
* DOCUMENT ME! |
|
306 |
* |
|
307 |
* @param backColor DOCUMENT ME! |
|
308 |
*/ |
|
309 |
public void setBackColor(Color backColor) { |
|
310 |
this.backColor = backColor; |
|
311 |
} |
|
312 |
|
|
313 |
/** |
|
314 |
* DOCUMENT ME! |
|
315 |
* |
|
316 | 300 |
* @author Vicente Caballero Navarro |
317 | 301 |
*/ |
318 | 302 |
public class Drawer extends Thread { |
... | ... | |
345 | 329 |
timer.stop(); |
346 | 330 |
isCancelled = true; |
347 | 331 |
System.err.println("Cancelado"); |
348 |
image.setRGB(5, 5, Color.BLACK.getRGB()); |
|
349 | 332 |
repaint(); |
350 | 333 |
} |
351 | 334 |
} catch (Throwable e) { |
... | ... | |
478 | 461 |
} |
479 | 462 |
|
480 | 463 |
public class MapContextListener implements AtomicEventListener{ |
481 |
/** |
|
464 |
public void colorEvent(AtomicEvent e){ |
|
465 |
boolean redraw = false; |
|
466 |
ColorEvent[] colorEvents = e.getColorEvents(); |
|
467 |
//No hace falta el "for" pero estar?a bien si se necesita poner alguna condici?n a la hora de dibujar la vista. |
|
468 |
///for (int i = 0; i < colorEvents.length; i++) { |
|
469 |
//if (colorEvents[i].getProperty().equals("visible")){ |
|
470 |
redraw = true; |
|
471 |
//} |
|
472 |
///} |
|
473 |
if (redraw){ |
|
474 |
NewMapControl.this.drawMap(); |
|
475 |
} |
|
476 |
} |
|
477 |
/** |
|
482 | 478 |
* @see com.iver.cit.gvsig.fmap.AtomicEventListener#atomicEvent(com.iver.cit.gvsig.fmap.AtomicEvent) |
483 | 479 |
*/ |
484 | 480 |
public void atomicEvent(AtomicEvent e) { |
Also available in: Unified diff