Revision 5393 branches/MULTITHREADING_DEVELOPMENT/extensions/extWMS/src/com/iver/cit/gvsig/fmap/layers/FLyrWMS.java
FLyrWMS.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package com.iver.cit.gvsig.fmap.layers; |
42 | 42 |
|
43 |
import java.awt.Color; |
|
43 | 44 |
import java.awt.Component; |
44 | 45 |
import java.awt.Dimension; |
45 | 46 |
import java.awt.Graphics2D; |
... | ... | |
62 | 63 |
import java.util.Hashtable; |
63 | 64 |
import java.util.Iterator; |
64 | 65 |
import java.util.Map; |
66 |
import java.util.Timer; |
|
65 | 67 |
import java.util.TimerTask; |
66 | 68 |
import java.util.Vector; |
67 | 69 |
|
... | ... | |
76 | 78 |
import org.cresques.px.Extent; |
77 | 79 |
import org.cresques.px.PxRaster; |
78 | 80 |
import org.exolab.castor.xml.ValidationException; |
81 |
import org.gvsig.remoteClient.taskplanning.ICancellable; |
|
82 |
import org.gvsig.remoteClient.taskplanning.retrieving.URLRetrieveTask; |
|
79 | 83 |
import org.gvsig.remoteClient.utils.Utilities; |
80 | 84 |
import org.gvsig.remoteClient.wms.WMSStatus; |
81 | 85 |
|
... | ... | |
94 | 98 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint; |
95 | 99 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.StringXMLItem; |
96 | 100 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.XMLItem; |
97 |
import com.iver.cit.gvsig.fmap.operations.Cancellable; |
|
98 | 101 |
import com.iver.cit.gvsig.fmap.rendering.XmlBuilder; |
99 | 102 |
import com.iver.cit.gvsig.wmc.WebMapContextTags; |
100 | 103 |
import com.iver.utiles.StringUtilities; |
101 | 104 |
import com.iver.utiles.XMLEntity; |
105 |
import com.iver.utiles.swing.threads.Cancellable; |
|
102 | 106 |
|
103 | 107 |
/** |
104 | 108 |
* FMap's WMS Layer class. |
... | ... | |
143 | 147 |
private Dimension fixedSize; |
144 | 148 |
private boolean queryable = true; |
145 | 149 |
private VisualStatusWMS visualStatus = new VisualStatusWMS(); |
150 |
private final long latency = 1000; // milliseconds |
|
146 | 151 |
|
152 |
private class MyCancellable implements ICancellable |
|
153 |
{ |
|
154 |
|
|
155 |
private Cancellable original; |
|
156 |
public MyCancellable(Cancellable cancelOriginal) |
|
157 |
{ |
|
158 |
this.original = cancelOriginal; |
|
159 |
} |
|
160 |
public boolean isCanceled() { |
|
161 |
return original.isCanceled(); |
|
162 |
} |
|
163 |
|
|
164 |
} |
|
165 |
|
|
147 | 166 |
public FLyrWMS(){ |
148 | 167 |
super(); |
149 | 168 |
} |
... | ... | |
533 | 552 |
*/ |
534 | 553 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
535 | 554 |
Cancellable cancel,double scale) throws DriverException { |
536 |
|
|
537 | 555 |
if (isWithinScale(scale)){ |
538 | 556 |
Point2D p = viewPort.getOffset(); |
539 | 557 |
// p will be (0, 0) when drawing a view or other when painting onto |
... | ... | |
582 | 600 |
wmsStatus.setDimensions(dimensions); |
583 | 601 |
wmsStatus.setTransparency(wmsTransparency); |
584 | 602 |
wmsStatus.setOnlineResource((String) onlineResources.get("GetMap")); |
585 |
|
|
586 |
getDriver().getMap(wmsStatus); |
|
603 |
|
|
604 |
getDriver().getMap(wmsStatus, new MyCancellable(cancel));
|
|
587 | 605 |
SwingUtilities.invokeAndWait(getDriver()); |
588 | 606 |
File f = getDriver().getFile(); |
589 | 607 |
String nameWorldFile = f.getPath() + getExtensionWorldFile(); |
... | ... | |
664 | 682 |
wmsStatus.setTransparency(wmsTransparency); |
665 | 683 |
wmsStatus.setOnlineResource((String) onlineResources.get("GetMap")); |
666 | 684 |
|
667 |
getDriver().getMap(wmsStatus); |
|
685 |
getDriver().getMap(wmsStatus, new MyCancellable(cancel));
|
|
668 | 686 |
|
669 |
SwingUtilities.invokeAndWait(getDriver()); |
|
687 |
// SwingUtilities.invokeAndWait(getDriver()); |
|
688 |
getDriver().run(); |
|
689 |
URLRetrieveTask task = new URLRetrieveTask(request); |
|
670 | 690 |
|
691 |
if (cancel.isCanceled()) |
|
692 |
System.err.println("CANCELADO!!!!"); |
|
693 |
|
|
671 | 694 |
File f = getDriver().getFile(); |
695 |
g.setColor(Color.BLACK); |
|
696 |
|
|
672 | 697 |
String nameWordFile = f.getPath() + getExtensionWorldFile(); |
673 | 698 |
com.iver.andami.Utilities.createTemp(nameWordFile, this.getDataWorldFile(bBox, sz)); |
674 | 699 |
|
... | ... | |
692 | 717 |
e.printStackTrace(); |
693 | 718 |
} catch (InterruptedException e) { |
694 | 719 |
e.printStackTrace(); |
695 |
} catch (InvocationTargetException e) { |
|
720 |
/* } catch (InvocationTargetException e) {
|
|
696 | 721 |
e.printStackTrace(); |
697 |
System.err.println(e.getCause()); |
|
722 |
System.err.println(e.getCause()); */
|
|
698 | 723 |
} |
699 | 724 |
|
700 | 725 |
} |
... | ... | |
797 | 822 |
} else { |
798 | 823 |
// Para no pedir imagenes demasiado grandes, vamos |
799 | 824 |
// a hacer lo mismo que hace EcwFile: chunkear. |
800 |
// Llamamos a drawView con cuadraditos m�s peque�os
|
|
825 |
// Llamamos a drawView con cuadraditos m?s peque?os
|
|
801 | 826 |
// del BufferedImage ni caso, cuando se imprime viene con null |
802 | 827 |
|
803 | 828 |
Tiling tiles = new Tiling(maxTilePrintWidth, maxTilePrintHeight, g.getClipRect()); |
... | ... | |
1378 | 1403 |
return xml.getXML(); |
1379 | 1404 |
} |
1380 | 1405 |
|
1381 |
private class MyTimerTask extends TimerTask { |
|
1382 |
private Cancellable cancel; |
|
1383 |
|
|
1384 |
public MyTimerTask(Cancellable cancel) { |
|
1385 |
super(); |
|
1386 |
this.cancel = cancel; |
|
1387 |
} |
|
1388 |
|
|
1389 |
public void run() { |
|
1390 |
while (!cancel.isCanceled()) {} |
|
1391 |
try { |
|
1392 |
getDriver().cancel(WMSOperations.GET_MAP); |
|
1393 |
} catch (IllegalStateException e) { |
|
1394 |
// TODO Auto-generated catch block |
|
1395 |
e.printStackTrace(); |
|
1396 |
} catch (ValidationException e) { |
|
1397 |
// TODO Auto-generated catch block |
|
1398 |
e.printStackTrace(); |
|
1399 |
} catch (UnsupportedVersionException e) { |
|
1400 |
// TODO Auto-generated catch block |
|
1401 |
e.printStackTrace(); |
|
1402 |
} catch (IOException e) { |
|
1403 |
// TODO Auto-generated catch block |
|
1404 |
e.printStackTrace(); |
|
1405 |
} |
|
1406 |
} |
|
1407 |
} |
|
1408 |
|
|
1409 | 1406 |
/* This is unuseful until the layers will hold its own ImageBuffer */ |
1410 | 1407 |
public void getCapabilities(int eventType, String message) { /* Nothing */ } |
1411 | 1408 |
public void getFeatureInfo(int eventType, String message) { /* Nothing */ } |
Also available in: Unified diff