Revision 5327 branches/MULTITHREADING_DEVELOPMENT/extensions/extWMS/src/com/iver/cit/gvsig/fmap/layers/FLyrWMS.java
FLyrWMS.java | ||
---|---|---|
85 | 85 |
import com.iver.cit.gvsig.fmap.ViewPort; |
86 | 86 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
87 | 87 |
import com.iver.cit.gvsig.fmap.drivers.UnsupportedVersionException; |
88 |
import com.iver.cit.gvsig.fmap.drivers.wms.ExperimentalAsynchronousFMapWMSDriver; |
|
88 | 89 |
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriver; |
89 | 90 |
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriverFactory; |
90 | 91 |
import com.iver.cit.gvsig.fmap.drivers.wms.WMSException; |
... | ... | |
142 | 143 |
private Dimension fixedSize; |
143 | 144 |
private boolean queryable = true; |
144 | 145 |
private VisualStatusWMS visualStatus = new VisualStatusWMS(); |
145 |
private DrawingProperties dProperties = new DrawingProperties(); |
|
146 | 146 |
|
147 | 147 |
public FLyrWMS(){ |
148 | 148 |
super(); |
... | ... | |
583 | 583 |
wmsStatus.setTransparency(wmsTransparency); |
584 | 584 |
wmsStatus.setOnlineResource((String) onlineResources.get("GetMap")); |
585 | 585 |
|
586 |
getDriver().getMap(wmsStatus); |
|
587 |
SwingUtilities.invokeAndWait(getDriver()); |
|
588 |
File f = getDriver().getFile(); |
|
589 |
String nameWorldFile = f.getPath() + getExtensionWorldFile(); |
|
590 |
com.iver.andami.Utilities.createTemp(nameWorldFile, this.getDataWorldFile(bBox, fixedSize)); |
|
586 | 591 |
|
587 |
dProperties.bBox = bBox;
|
|
588 |
dProperties.graphics = g;
|
|
589 |
dProperties.sz = fixedSize;
|
|
590 |
dProperties.viewPort = vp;
|
|
592 |
if(status!=null && firstLoad){
|
|
593 |
status.applyStatus(this);
|
|
594 |
firstLoad = false;
|
|
595 |
}
|
|
591 | 596 |
|
592 |
getDriver().getMap(wmsStatus); |
|
593 |
// String nameWorldFile = f.getPath() + getExtensionWorldFile(); |
|
594 |
// com.iver.andami.Utilities.createTemp(nameWorldFile, this.getDataWorldFile(bBox, fixedSize)); |
|
595 |
// |
|
596 |
// if(status!=null && firstLoad){ |
|
597 |
// status.applyStatus(this); |
|
598 |
// firstLoad = false; |
|
599 |
// } |
|
600 |
// |
|
601 |
// // And finally, obtain the extent intersecting the view and the BBox |
|
602 |
// // to draw to. |
|
603 |
// Rectangle2D extent = new Rectangle2D.Double(); |
|
604 |
// Rectangle2D.intersect(vp.getAdjustedExtent(), bBox, extent); |
|
605 |
// |
|
606 |
// ViewPortData vpData = new ViewPortData( |
|
607 |
// vp.getProjection(), new Extent(extent), fixedSize ); |
|
608 |
// vpData.setMat(vp.getAffineTransform()); |
|
609 |
// |
|
610 |
// rasterProcess(g, vpData, f); |
|
597 |
// And finally, obtain the extent intersecting the view and the BBox |
|
598 |
// to draw to. |
|
599 |
Rectangle2D extent = new Rectangle2D.Double(); |
|
600 |
Rectangle2D.intersect(vp.getAdjustedExtent(), bBox, extent); |
|
611 | 601 |
|
602 |
ViewPortData vpData = new ViewPortData( |
|
603 |
vp.getProjection(), new Extent(extent), fixedSize ); |
|
604 |
vpData.setMat(vp.getAffineTransform()); |
|
605 |
|
|
606 |
rasterProcess(g, vpData, f); |
|
607 |
|
|
612 | 608 |
} catch (ValidationException e) { |
613 | 609 |
throw new DriverException(PluginServices.getText(this, "unknown_response_format"), e); |
614 | 610 |
} catch (UnsupportedVersionException e) { |
615 | 611 |
throw new DriverException(PluginServices.getText(this, "version_conflict"), e); |
616 | 612 |
} catch (IOException e) { |
617 | 613 |
throw new DriverException(PluginServices.getText(this, "connect_error"), e); |
618 |
} catch (WMSException e) { |
|
619 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), e.getMessage()); |
|
620 |
this.setVisible(false); |
|
614 |
} catch (IllegalStateException e) { |
|
615 |
e.printStackTrace(); |
|
616 |
} catch (InterruptedException e) { |
|
617 |
e.printStackTrace(); |
|
618 |
} catch (InvocationTargetException e) { |
|
619 |
e.printStackTrace(); |
|
621 | 620 |
} |
622 | 621 |
|
623 | 622 |
|
... | ... | |
665 | 664 |
wmsStatus.setTransparency(wmsTransparency); |
666 | 665 |
wmsStatus.setOnlineResource((String) onlineResources.get("GetMap")); |
667 | 666 |
|
668 |
|
|
669 |
dProperties.bBox = bBox; |
|
670 |
dProperties.graphics = g; |
|
671 |
dProperties.sz = sz; |
|
672 |
dProperties.viewPort = vp; |
|
673 | 667 |
getDriver().getMap(wmsStatus); |
674 |
// String nameWordFile = f.getPath() + getExtensionWorldFile(); |
|
675 |
// com.iver.andami.Utilities.createTemp(nameWordFile, this.getDataWorldFile(bBox, sz)); |
|
676 |
// |
|
677 |
// if(status!=null && firstLoad){ |
|
678 |
// status.applyStatus(this); |
|
679 |
// firstLoad = false; |
|
680 |
// } |
|
681 |
// ViewPortData vpData = new ViewPortData( |
|
682 |
// vp.getProjection(), new Extent(bBox), sz ); |
|
683 |
// vpData.setMat(vp.getAffineTransform()); |
|
684 |
// |
|
685 |
// rasterProcess(g, vpData, f); |
|
686 | 668 |
|
669 |
SwingUtilities.invokeAndWait(getDriver()); |
|
670 |
|
|
671 |
File f = getDriver().getFile(); |
|
672 |
String nameWordFile = f.getPath() + getExtensionWorldFile(); |
|
673 |
com.iver.andami.Utilities.createTemp(nameWordFile, this.getDataWorldFile(bBox, sz)); |
|
674 |
|
|
675 |
if(status!=null && firstLoad){ |
|
676 |
status.applyStatus(this); |
|
677 |
firstLoad = false; |
|
678 |
} |
|
679 |
ViewPortData vpData = new ViewPortData( |
|
680 |
vp.getProjection(), new Extent(bBox), sz ); |
|
681 |
vpData.setMat(vp.getAffineTransform()); |
|
682 |
|
|
683 |
rasterProcess(g, vpData, f); |
|
684 |
|
|
687 | 685 |
} catch (ValidationException e) { |
688 | 686 |
throw new DriverException(PluginServices.getText(this, "unknown_response_format"), e); |
689 | 687 |
} catch (UnsupportedVersionException e) { |
690 | 688 |
throw new DriverException(PluginServices.getText(this, "version_conflict"), e); |
691 | 689 |
} catch (IOException e) { |
692 | 690 |
throw new DriverException(PluginServices.getText(this, "connect_error"), e); |
693 |
} catch (WMSException e) { |
|
694 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), e.getMessage()); |
|
695 |
this.setVisible(false); |
|
691 |
} catch (IllegalStateException e) { |
|
692 |
e.printStackTrace(); |
|
693 |
} catch (InterruptedException e) { |
|
694 |
e.printStackTrace(); |
|
695 |
} catch (InvocationTargetException e) { |
|
696 |
e.printStackTrace(); |
|
697 |
System.err.println(e.getCause()); |
|
696 | 698 |
} |
697 | 699 |
|
698 | 700 |
} |
... | ... | |
814 | 816 |
} |
815 | 817 |
} |
816 | 818 |
|
819 |
|
|
817 | 820 |
/** |
818 | 821 |
* Devuelve el FMapWMSDriver. |
819 | 822 |
* |
... | ... | |
824 | 827 |
* @throws UnsupportedVersionException |
825 | 828 |
* @throws IOException |
826 | 829 |
*/ |
827 |
private FMapWMSDriver getDriver() |
|
830 |
private ExperimentalAsynchronousFMapWMSDriver getDriver()
|
|
828 | 831 |
throws IllegalStateException, ValidationException, |
829 | 832 |
UnsupportedVersionException, IOException { |
830 |
FMapWMSDriver drv = FMapWMSDriverFactory.getDriverForHost(host); |
|
833 |
ExperimentalAsynchronousFMapWMSDriver drv = FMapWMSDriverFactory.getDriverForHost(host);
|
|
831 | 834 |
drv.addListener(this); |
832 |
System.err.println("********** capa afegeix el listener"); |
|
833 | 835 |
// if (wms == null) { |
834 | 836 |
// wms = FMapWMSDriverFactory.getDriverForHost(host); |
835 | 837 |
// System.out.println("********** capa afegeix el listener"); |
... | ... | |
839 | 841 |
// return wms; |
840 | 842 |
return drv; |
841 | 843 |
} |
842 |
|
|
843 |
/** |
|
844 |
* Devuelve el FMapWMSDriver. |
|
845 |
* |
|
846 |
* @return FMapWMSDriver |
|
847 |
* |
|
848 |
* @throws IllegalStateException |
|
849 |
* @throws ValidationException |
|
850 |
* @throws UnsupportedVersionException |
|
851 |
* @throws IOException |
|
852 |
*/ |
|
853 |
// public void setDriver(FMapWMSDriver drv) { |
|
854 |
// wms = drv; |
|
855 |
// } |
|
856 | 844 |
|
857 | 845 |
/** |
858 | 846 |
* Devuelve el URL. |
... | ... | |
1417 | 1405 |
} |
1418 | 1406 |
} |
1419 | 1407 |
} |
1420 |
|
|
1421 |
private class DrawingProperties { |
|
1422 |
Graphics2D graphics; |
|
1423 |
Rectangle2D bBox; |
|
1424 |
Dimension sz; |
|
1425 |
ViewPort viewPort; |
|
1426 |
} |
|
1427 |
|
|
1408 |
|
|
1409 |
/* This is unuseful until the layers will hold its own ImageBuffer */ |
|
1428 | 1410 |
public void getCapabilities(int eventType, String message) { /* Nothing */ } |
1429 | 1411 |
public void getFeatureInfo(int eventType, String message) { /* Nothing */ } |
1430 | 1412 |
public void getMap(int eventType, File mapFile, String message) { |
1431 |
File f = mapFile; |
|
1413 |
/*File f = mapFile;
|
|
1432 | 1414 |
Graphics2D g = dProperties.graphics; |
1433 | 1415 |
ViewPort vp = dProperties.viewPort; |
1434 | 1416 |
Rectangle2D bBox = dProperties.bBox; |
... | ... | |
1455 | 1437 |
vp.getProjection(), new Extent(extent), fixedSize ); |
1456 | 1438 |
vpData.setMat(vp.getAffineTransform()); |
1457 | 1439 |
|
1458 |
rasterProcess(g, vpData, f); |
|
1440 |
rasterProcess(g, vpData, f);*/
|
|
1459 | 1441 |
} |
1460 | 1442 |
} |
Also available in: Unified diff