root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLyrRaster.java @ 1034
History | View | Annotate | Download (3.06 KB)
1 |
package com.iver.cit.gvsig.fmap.layers; |
---|---|
2 |
|
3 |
import com.iver.cit.gvsig.fmap.DriverException; |
4 |
import com.iver.cit.gvsig.fmap.ViewPort; |
5 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
6 |
import com.iver.cit.gvsig.fmap.drivers.GeorreferencedRasterDriver; |
7 |
import com.iver.cit.gvsig.fmap.operations.Cancellable; |
8 |
|
9 |
import com.iver.utiles.XMLEntity; |
10 |
|
11 |
import org.cresques.cts.IProjection; |
12 |
|
13 |
import java.awt.Graphics2D; |
14 |
import java.awt.Point; |
15 |
import java.awt.geom.Rectangle2D; |
16 |
import java.awt.image.BufferedImage; |
17 |
|
18 |
|
19 |
/**
|
20 |
* Clase b?sica de capa raster.
|
21 |
*
|
22 |
* @author Vicente Caballero Navarro
|
23 |
*/
|
24 |
public class FLyrRaster extends FLyrDefault implements RasterOperations { |
25 |
private RasterAdapter source;
|
26 |
|
27 |
/**
|
28 |
* Devuelve el RasterAdapter de la capa.
|
29 |
*
|
30 |
* @return RasterAdapter.
|
31 |
*/
|
32 |
public RasterAdapter getSource() {
|
33 |
return source;
|
34 |
} |
35 |
|
36 |
/**
|
37 |
* Inserta el RasterAdapter.
|
38 |
*
|
39 |
* @param ra RasterAdapter.
|
40 |
*/
|
41 |
public void setSource(RasterAdapter ra) { |
42 |
source = ra; |
43 |
} |
44 |
|
45 |
/*
|
46 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#load()
|
47 |
*/
|
48 |
public void load() throws DriverIOException { |
49 |
((RasterFileAdapter) source).start(); |
50 |
} |
51 |
|
52 |
/**
|
53 |
* @see com.iver.cit.gvsig.fmap.layers.LayerOperations#draw(java.awt.image.BufferedImage,
|
54 |
* java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort,
|
55 |
* com.iver.cit.gvsig.fmap.operations.Cancellable)
|
56 |
*/
|
57 |
public void draw(BufferedImage image, Graphics2D g, ViewPort vp, |
58 |
Cancellable cancel) throws DriverException {
|
59 |
try {
|
60 |
((RasterFileAdapter) source).draw(image, g, vp, cancel); |
61 |
} catch (DriverIOException e) {
|
62 |
throw new DriverException(e); |
63 |
} |
64 |
|
65 |
if (getVirtualLayers() != null) { |
66 |
getVirtualLayers().draw(image, g, vp, cancel); |
67 |
} |
68 |
} |
69 |
|
70 |
/**
|
71 |
* Inserta la proyecci?n.
|
72 |
*
|
73 |
* @param proj Proyecci?n.
|
74 |
*/
|
75 |
public void setProjection(IProjection proj) { |
76 |
super.setProjection(proj);
|
77 |
|
78 |
if (source.getDriver() instanceof GeorreferencedRasterDriver) { |
79 |
GeorreferencedRasterDriver geoDrv = (GeorreferencedRasterDriver) source.getDriver(); |
80 |
|
81 |
if (geoDrv.getProjection() == null) { |
82 |
geoDrv.setProjection(proj); |
83 |
} |
84 |
} |
85 |
} |
86 |
|
87 |
/*
|
88 |
* @see com.iver.cit.gvsig.fmap.layers.LayerOperations#getFullExtent()
|
89 |
*/
|
90 |
public Rectangle2D getFullExtent() throws DriverException { |
91 |
return ((RasterFileAdapter) source).getFullExtent();
|
92 |
} |
93 |
|
94 |
/**
|
95 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#queryByPoint(com.iver.cit.gvsig.fmap.operations.QueriedPoint)
|
96 |
*/
|
97 |
public String queryByPoint(Point point) { |
98 |
return null; |
99 |
} |
100 |
|
101 |
/**
|
102 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#getProperties()
|
103 |
*/
|
104 |
public XMLEntity getXMLEntity() {
|
105 |
XMLEntity xml = super.getXMLEntity();
|
106 |
|
107 |
if (source instanceof RasterFileAdapter) { |
108 |
xml.putProperty("file", ((RasterFileAdapter) source).getFile());
|
109 |
} |
110 |
|
111 |
xml.putProperty("driverName", getSource().getDriver().getName());
|
112 |
|
113 |
return xml;
|
114 |
} |
115 |
|
116 |
/* (non-Javadoc)
|
117 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.operations.Cancellable)
|
118 |
*/
|
119 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel) |
120 |
throws DriverException {
|
121 |
draw(null, g, viewPort, cancel);
|
122 |
} |
123 |
} |