Revision 35683
tags/v1_11_0_Build_1306/extensions/extRasterTools-SE/test-images/bilinear.rmf | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-15"?> |
|
2 |
<RasterMetaFile> |
|
3 |
<FLyrGeoRaster> |
|
4 |
<Projection></Projection> |
|
5 |
<Extent> |
|
6 |
<X>265346.52</X> |
|
7 |
<Y>4461775.0</Y> |
|
8 |
<RotationX>0.0</RotationX> |
|
9 |
<RotationY>0.0</RotationY> |
|
10 |
<PixelSizeX>12.5</PixelSizeX> |
|
11 |
<PixelSizeY>-12.5</PixelSizeY> |
|
12 |
<Width>0.0</Width> |
|
13 |
<Height>0.0</Height> |
|
14 |
</Extent> |
|
15 |
<Dimension> |
|
16 |
<ImagePxWidth>200.0</ImagePxWidth> |
|
17 |
<ImagePxHeight>200.0</ImagePxHeight> |
|
18 |
</Dimension> |
|
19 |
</FLyrGeoRaster> |
|
20 |
<ColorInterpretation> |
|
21 |
<BandCount>1</BandCount> |
|
22 |
<Band>Gray</Band> |
|
23 |
</ColorInterpretation> |
|
24 |
</RasterMetaFile> |
tags/v1_11_0_Build_1306/extensions/extRasterTools-SE/test-images/distInversa.rmf | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-15"?> |
|
2 |
<RasterMetaFile> |
|
3 |
<FLyrGeoRaster> |
|
4 |
<Projection></Projection> |
|
5 |
<Extent> |
|
6 |
<X>265346.52</X> |
|
7 |
<Y>4461775.0</Y> |
|
8 |
<RotationX>0.0</RotationX> |
|
9 |
<RotationY>0.0</RotationY> |
|
10 |
<PixelSizeX>12.5</PixelSizeX> |
|
11 |
<PixelSizeY>-12.5</PixelSizeY> |
|
12 |
<Width>0.0</Width> |
|
13 |
<Height>0.0</Height> |
|
14 |
</Extent> |
|
15 |
<Dimension> |
|
16 |
<ImagePxWidth>200.0</ImagePxWidth> |
|
17 |
<ImagePxHeight>200.0</ImagePxHeight> |
|
18 |
</Dimension> |
|
19 |
</FLyrGeoRaster> |
|
20 |
<ColorInterpretation> |
|
21 |
<BandCount>1</BandCount> |
|
22 |
<Band>Gray</Band> |
|
23 |
</ColorInterpretation> |
|
24 |
</RasterMetaFile> |
tags/v1_11_0_Build_1306/extensions/extRasterTools-SE/test-images/bSpline.rmf | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-15"?> |
|
2 |
<RasterMetaFile> |
|
3 |
<FLyrGeoRaster> |
|
4 |
<Projection></Projection> |
|
5 |
<Extent> |
|
6 |
<X>265346.52</X> |
|
7 |
<Y>4461775.0</Y> |
|
8 |
<RotationX>0.0</RotationX> |
|
9 |
<RotationY>0.0</RotationY> |
|
10 |
<PixelSizeX>12.5</PixelSizeX> |
|
11 |
<PixelSizeY>-12.5</PixelSizeY> |
|
12 |
<Width>0.0</Width> |
|
13 |
<Height>0.0</Height> |
|
14 |
</Extent> |
|
15 |
<Dimension> |
|
16 |
<ImagePxWidth>200.0</ImagePxWidth> |
|
17 |
<ImagePxHeight>200.0</ImagePxHeight> |
|
18 |
</Dimension> |
|
19 |
</FLyrGeoRaster> |
|
20 |
<ColorInterpretation> |
|
21 |
<BandCount>1</BandCount> |
|
22 |
<Band>Gray</Band> |
|
23 |
</ColorInterpretation> |
|
24 |
</RasterMetaFile> |
tags/v1_11_0_Build_1306/extensions/extRasterTools-SE/test-images/float.rmf | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-15"?> |
|
2 |
<RasterMetaFile> |
|
3 |
<Statistics> |
|
4 |
<BandCount>1</BandCount> |
|
5 |
<Band> |
|
6 |
<Max>2410.0</Max> |
|
7 |
<Min>514.0</Min> |
|
8 |
<SecondMax>2407.0</SecondMax> |
|
9 |
<SecondMin>514.0009765625</SecondMin> |
|
10 |
<MaxRGB>0.0</MaxRGB> |
|
11 |
<MinRGB>0.0</MinRGB> |
|
12 |
<SecondMaxRGB>0.0</SecondMaxRGB> |
|
13 |
<SecondMinRGB>255.0</SecondMinRGB> |
|
14 |
<Mean>1410.9055247992521</Mean> |
|
15 |
<Variance>182468.80240074173</Variance> |
|
16 |
</Band> |
|
17 |
</Statistics> |
|
18 |
<FLyrGeoRaster> |
|
19 |
<Projection></Projection> |
|
20 |
<Extent> |
|
21 |
<X>262846.525725</X> |
|
22 |
<Y>4464275.0</Y> |
|
23 |
<RotationX>0.0</RotationX> |
|
24 |
<RotationY>0.0</RotationY> |
|
25 |
<PixelSizeX>25.0</PixelSizeX> |
|
26 |
<PixelSizeY>-25.0</PixelSizeY> |
|
27 |
<Width>15025.0</Width> |
|
28 |
<Height>10250.0</Height> |
|
29 |
</Extent> |
|
30 |
<Dimension> |
|
31 |
<ImagePxWidth>601.0</ImagePxWidth> |
|
32 |
<ImagePxHeight>410.0</ImagePxHeight> |
|
33 |
</Dimension> |
|
34 |
</FLyrGeoRaster> |
|
35 |
</RasterMetaFile> |
tags/v1_11_0_Build_1306/extensions/extRasterTools-SE/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>extRasterTools-SE</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
<buildCommand> |
|
14 |
<name>de.loskutov.FileSync.FSBuilder</name> |
|
15 |
<arguments> |
|
16 |
</arguments> |
|
17 |
</buildCommand> |
|
18 |
</buildSpec> |
|
19 |
<natures> |
|
20 |
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature> |
|
21 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
22 |
<nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature> |
|
23 |
</natures> |
|
24 |
</projectDescription> |
|
0 | 25 |
tags/v1_11_0_Build_1306/extensions/extRasterTools-SE/build.number | ||
---|---|---|
1 |
#Build Number for ANT. Do not edit! |
|
2 |
#Fri Jul 08 10:28:50 CEST 2011 |
|
3 |
build.number=1306 |
|
0 | 4 |
tags/v1_11_0_Build_1306/extensions/extRasterTools-SE/src/org/gvsig/fmap/raster/grid/roi/VectorialROIsReader.java | ||
---|---|---|
1 |
package org.gvsig.fmap.raster.grid.roi; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.io.File; |
|
5 |
import java.sql.Types; |
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.HashMap; |
|
8 |
|
|
9 |
import org.cresques.cts.IProjection; |
|
10 |
import org.gvsig.raster.dataset.FileNotExistsException; |
|
11 |
import org.gvsig.raster.grid.Grid; |
|
12 |
|
|
13 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
14 |
import com.hardcode.gdbms.engine.values.NumericValue; |
|
15 |
import com.iver.andami.PluginServices; |
|
16 |
import com.iver.andami.config.generate.Plugin; |
|
17 |
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException; |
|
18 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
|
19 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
20 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
|
21 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
|
22 |
|
|
23 |
|
|
24 |
public class VectorialROIsReader { |
|
25 |
|
|
26 |
private String filename = null; |
|
27 |
private IProjection projection = null; |
|
28 |
private FLyrVect fLyrVect = null; |
|
29 |
private HashMap rois = null; |
|
30 |
private Grid grid = null; |
|
31 |
|
|
32 |
|
|
33 |
public VectorialROIsReader(String filename, Grid grid, IProjection projection) throws LoadLayerException, FileNotExistsException { |
|
34 |
this.filename = filename; |
|
35 |
this.projection = projection; |
|
36 |
this.grid = grid; |
|
37 |
File file = new File(filename); |
|
38 |
if(file.exists()){ |
|
39 |
fLyrVect = (FLyrVect)LayerFactory.createLayer("layer1", "gvSIG shp driver", file, projection); |
|
40 |
}else |
|
41 |
throw new FileNotExistsException("file not found"); |
|
42 |
} |
|
43 |
|
|
44 |
|
|
45 |
public ArrayList read(ArrayList existingROIs) throws ReadDriverException, InvalidROIsShpException{ |
|
46 |
SelectableDataSource dataSource = fLyrVect.getSource().getRecordset(); |
|
47 |
|
|
48 |
// Validaci?n del .shp: |
|
49 |
int nameFieldIndex = dataSource.getFieldIndexByName("name"); |
|
50 |
int rFiledIndex = dataSource.getFieldIndexByName("R"); |
|
51 |
int gFiledIndex = dataSource.getFieldIndexByName("G"); |
|
52 |
int bFiledIndex = dataSource.getFieldIndexByName("B"); |
|
53 |
if (nameFieldIndex < 0 || rFiledIndex < 0 || gFiledIndex < 0 || bFiledIndex < 0){ |
|
54 |
throw new InvalidROIsShpException(""); |
|
55 |
} |
|
56 |
if (dataSource.getFieldType(nameFieldIndex) != Types.VARCHAR || |
|
57 |
dataSource.getFieldType(rFiledIndex) < Types.NUMERIC || dataSource.getFieldType(rFiledIndex) > Types.DOUBLE || |
|
58 |
dataSource.getFieldType(gFiledIndex) < Types.NUMERIC || dataSource.getFieldType(gFiledIndex) > Types.DOUBLE || |
|
59 |
dataSource.getFieldType(bFiledIndex) < Types.NUMERIC || dataSource.getFieldType(bFiledIndex) > Types.DOUBLE ) |
|
60 |
throw new InvalidROIsShpException(""); |
|
61 |
|
|
62 |
|
|
63 |
if (existingROIs != null) |
|
64 |
rois = new HashMap(); |
|
65 |
if (existingROIs != null){ |
|
66 |
for (int i = 0; i < existingROIs.size(); i++) { |
|
67 |
VectorialROI roi = (VectorialROI)existingROIs.get(i); |
|
68 |
rois.put(roi.getName(), roi); |
|
69 |
} |
|
70 |
} |
|
71 |
String roiName; |
|
72 |
int r, g, b; |
|
73 |
for (int i = 0; i<dataSource.getRowCount(); i++) { |
|
74 |
IFeature feature = fLyrVect.getSource().getFeature(i); |
|
75 |
roiName = feature.getAttribute(nameFieldIndex).toString(); |
|
76 |
VectorialROI roi = null; |
|
77 |
if (!rois.containsKey(roiName)){ |
|
78 |
roi = new VectorialROI(grid); |
|
79 |
roi.setName(roiName); |
|
80 |
r = ((NumericValue)feature.getAttribute(rFiledIndex)).intValue(); |
|
81 |
g = ((NumericValue)feature.getAttribute(gFiledIndex)).intValue(); |
|
82 |
b = ((NumericValue)feature.getAttribute(bFiledIndex)).intValue(); |
|
83 |
roi.setColor(new Color(r,g,b)); |
|
84 |
rois.put(roi.getName(), roi); |
|
85 |
} |
|
86 |
else |
|
87 |
roi = (VectorialROI)rois.get(roiName); |
|
88 |
roi.addGeometry(feature.getGeometry()); |
|
89 |
} |
|
90 |
return new ArrayList(rois.values()); |
|
91 |
} |
|
92 |
} |
tags/v1_11_0_Build_1306/extensions/extRasterTools-SE/src/org/gvsig/fmap/raster/grid/roi/InvalidROIsShpException.java | ||
---|---|---|
1 |
package org.gvsig.fmap.raster.grid.roi; |
|
2 |
|
|
3 |
public class InvalidROIsShpException extends Exception { |
|
4 |
|
|
5 |
private static final long serialVersionUID = 5095144339285844477L; |
|
6 |
|
|
7 |
/** |
|
8 |
* Constructor. Asigna el texto de la excepci?n |
|
9 |
* @param msg |
|
10 |
*/ |
|
11 |
public InvalidROIsShpException(String msg){ |
|
12 |
super(msg); |
|
13 |
} |
|
14 |
|
|
15 |
} |
tags/v1_11_0_Build_1306/extensions/extRasterTools-SE/src/org/gvsig/fmap/raster/grid/roi/VectorialROI.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
|
|
20 |
package org.gvsig.fmap.raster.grid.roi; |
|
21 |
|
|
22 |
import java.awt.geom.Rectangle2D; |
|
23 |
import java.util.ArrayList; |
|
24 |
|
|
25 |
import org.gvsig.raster.datastruct.Extent; |
|
26 |
import org.gvsig.raster.grid.Grid; |
|
27 |
import org.gvsig.raster.grid.roi.ROI; |
|
28 |
|
|
29 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
30 |
|
|
31 |
/** |
|
32 |
* Clase que representa una regi?n de interes conformada por |
|
33 |
* elementos vectoriales. |
|
34 |
* |
|
35 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es) |
|
36 |
* |
|
37 |
*/ |
|
38 |
public class VectorialROI extends ROI { |
|
39 |
|
|
40 |
/** |
|
41 |
* Array de geometr?as (IGeometry) que definen el ROI. |
|
42 |
*/ |
|
43 |
private ArrayList geometries = null; |
|
44 |
/** |
|
45 |
* Extent m?ximo de todas las geometrias |
|
46 |
*/ |
|
47 |
private Extent extent = null; |
|
48 |
|
|
49 |
public VectorialROI(Grid grid) { |
|
50 |
super(grid); |
|
51 |
geometries = new ArrayList(); |
|
52 |
} |
|
53 |
|
|
54 |
/* |
|
55 |
* (non-Javadoc) |
|
56 |
* @see org.gvsig.raster.grid.roi.ROI#isInside(double, double, double, double) |
|
57 |
*/ |
|
58 |
public boolean isInside(double x, double y, double w, double h) { |
|
59 |
if((x + w) < extent.minX() || x > extent.maxX() || (y - h) > extent.maxY() || y < extent.minY()) |
|
60 |
return false; |
|
61 |
for (int i = 0; i < geometries.size(); i++) { |
|
62 |
Rectangle2D celda = new Rectangle2D.Double(x, y, w, h); |
|
63 |
if(((IGeometry)geometries.get(i)).intersects(celda)) |
|
64 |
return true; |
|
65 |
} |
|
66 |
return false; |
|
67 |
} |
|
68 |
|
|
69 |
/* |
|
70 |
* (non-Javadoc) |
|
71 |
* @see org.gvsig.raster.grid.roi.ROI#isInGrid(int, int) |
|
72 |
*/ |
|
73 |
public boolean isInGrid(int x, int y) { |
|
74 |
double newX = x - xOffset; |
|
75 |
double newY = y - yOffset; |
|
76 |
//newY = getNY() - (newY + 1); |
|
77 |
if (newX>=0 && newX<=getNX() && newY >=0 && newY<=getNY()){ |
|
78 |
//Cooordendas pixel a coordenadas "reales". |
|
79 |
double cellSize = getCellSize(); |
|
80 |
double mapX = this.getGridExtent().getMin().getX()+newX*cellSize; |
|
81 |
double mapY = this.getGridExtent().getMax().getY()-newY*cellSize; |
|
82 |
for (int i = 0; i < geometries.size(); i++){ |
|
83 |
Rectangle2D celda = new Rectangle2D.Double(mapX, mapY-cellSize, cellSize, cellSize); |
|
84 |
if(((IGeometry)geometries.get(i)).intersects(celda)) |
|
85 |
return true; |
|
86 |
} |
|
87 |
} |
|
88 |
return false; |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* A?ade una geometr?a a la ROI |
|
93 |
* |
|
94 |
* @param geometry |
|
95 |
*/ |
|
96 |
public void addGeometry(IGeometry geometry){ |
|
97 |
|
|
98 |
geometries.add(geometry); |
|
99 |
double cellSize = getGridExtent().getCellSize(); |
|
100 |
|
|
101 |
Rectangle2D geometryBounds = geometry.getBounds(); |
|
102 |
if(extent == null) |
|
103 |
extent = new Extent(geometryBounds.getMinX(), geometryBounds.getMaxY(), geometryBounds.getMaxX(), geometryBounds.getMinY()); |
|
104 |
else |
|
105 |
extent = new Extent(Math.min(geometryBounds.getMinX(), extent.minX()), |
|
106 |
Math.max(geometryBounds.getMaxY(), extent.maxY()), |
|
107 |
Math.max(geometryBounds.getMaxX(), extent.maxX()), |
|
108 |
Math.min(geometryBounds.getMinY(), extent.minY())); |
|
109 |
|
|
110 |
double minX = geometryBounds.getMinX() - Math.abs(geometryBounds.getMinX() - getGrid().getGridExtent().getMin().getX()) % cellSize; |
|
111 |
double minY = (geometryBounds.getMinY()) - (Math.abs(geometryBounds.getMinY() - getGrid().getGridExtent().getMin().getY())) % cellSize; |
|
112 |
double maxX = (geometryBounds.getMaxX() + cellSize) - Math.abs(geometryBounds.getMaxX() - getGrid().getGridExtent().getMin().getX()) % cellSize; |
|
113 |
double maxY = (geometryBounds.getMaxY() + cellSize) - (Math.abs(geometryBounds.getMaxY() - getGrid().getGridExtent().getMin().getY())) % cellSize; |
|
114 |
|
|
115 |
if (geometries.size() > 1){ |
|
116 |
minX = Math.min(minX,getGridExtent().getMin().getX()); |
|
117 |
minY = Math.min(minY,getGridExtent().getMin().getY()); |
|
118 |
maxX = Math.max(maxX,getGridExtent().getMax().getX()); |
|
119 |
maxY = Math.max(maxY,getGridExtent().getMax().getY()); |
|
120 |
} |
|
121 |
|
|
122 |
getGridExtent().setXRange(minX, maxX); |
|
123 |
getGridExtent().setYRange(minY, maxY); |
|
124 |
|
|
125 |
xOffset = (int)((minX - getGrid().getGridExtent().getMin().getX())/cellSize); |
|
126 |
yOffset = (int)((getGrid().getGridExtent().getMax().getY()- maxY)/cellSize); |
|
127 |
getStatistic().setStatisticsCalculated(false); |
|
128 |
getStatistic().setAdvancedStatisticCalculated(false); |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* Eliminar la geometr?a con ?ndice <code>index</code> de la ROI |
|
133 |
* |
|
134 |
* @param index indice de la geometr?a a eliminar |
|
135 |
*/ |
|
136 |
public void deleteGeometry(int index){ |
|
137 |
geometries.remove(index); |
|
138 |
getStatistic().setStatisticsCalculated(false); |
|
139 |
getStatistic().setAdvancedStatisticCalculated(false); |
|
140 |
|
|
141 |
//TODO: Reajustar el Extent. |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* Elimina todas las geometr?as que definen la ROI. |
|
146 |
* |
|
147 |
*/ |
|
148 |
public void clear(){ |
|
149 |
geometries.clear(); |
|
150 |
getStatistic().setStatisticsCalculated(false); |
|
151 |
getStatistic().setAdvancedStatisticCalculated(false); |
|
152 |
|
|
153 |
//TODO: Reajustar el Extent. |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* |
|
158 |
* @return ArryList con las geometr?as que definen la ROI |
|
159 |
*/ |
|
160 |
public ArrayList getGeometries() { |
|
161 |
return geometries; |
|
162 |
} |
|
163 |
} |
|
0 | 164 |
tags/v1_11_0_Build_1306/extensions/extRasterTools-SE/src/org/gvsig/fmap/raster/grid/roi/VectorialROIsWriter.java | ||
---|---|---|
1 |
package org.gvsig.fmap.raster.grid.roi; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.sql.Types; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.Iterator; |
|
7 |
|
|
8 |
import org.cresques.cts.IProjection; |
|
9 |
|
|
10 |
import com.hardcode.gdbms.engine.values.Value; |
|
11 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
|
12 |
import com.iver.cit.gvsig.exceptions.visitors.StopWriterVisitorException; |
|
13 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
|
14 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
15 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
16 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
|
17 |
import com.iver.cit.gvsig.fmap.drivers.LayerDefinition; |
|
18 |
import com.iver.cit.gvsig.fmap.drivers.SHPLayerDefinition; |
|
19 |
import com.iver.cit.gvsig.fmap.edition.DefaultRowEdited; |
|
20 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
|
21 |
import com.iver.cit.gvsig.fmap.edition.IWriter; |
|
22 |
import com.iver.cit.gvsig.fmap.edition.writers.shp.ShpWriter; |
|
23 |
|
|
24 |
/** |
|
25 |
* Clase dedicada a la escritura de ROIs en formato en disco (formato shape). |
|
26 |
* |
|
27 |
* Si las ROIs a escribir incluyen distintos tipos de geometr?as la escritura se |
|
28 |
* realizar? en distintos shape files, uno para poligonos, otro para polil?neas y |
|
29 |
* otro para puntos. |
|
30 |
* |
|
31 |
* @author Diego Guerrero (diego.guerrero@uclm.es) |
|
32 |
* |
|
33 |
*/ |
|
34 |
public class VectorialROIsWriter { |
|
35 |
private String baseFilename = null; |
|
36 |
private IWriter pointsWriter = null; |
|
37 |
private IWriter linesWriter = null; |
|
38 |
private IWriter polygonsWriter = null; |
|
39 |
private IProjection projection = null; |
|
40 |
private int iPolygon; |
|
41 |
private int iPoint; |
|
42 |
private int iPolyline; |
|
43 |
|
|
44 |
|
|
45 |
/** |
|
46 |
* Constructor. |
|
47 |
* |
|
48 |
* @param baseFilename ruta base para formar los nombres de fichero (ruta/prefijo) |
|
49 |
* @param projection CRS de las geometr?as. |
|
50 |
*/ |
|
51 |
public VectorialROIsWriter(String baseFilename, IProjection projection) { |
|
52 |
this.baseFilename = baseFilename; |
|
53 |
this.projection = projection; |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* Escribe el Array de ROIs pasado como par?metro. |
|
58 |
* |
|
59 |
* @param rois Array de VectorialROI |
|
60 |
*/ |
|
61 |
public void write (VectorialROI rois[]){ |
|
62 |
boolean monoType = true; |
|
63 |
int geometryType = -1; |
|
64 |
ArrayList geometries = null; |
|
65 |
|
|
66 |
Value values[] = new Value[4]; |
|
67 |
|
|
68 |
if (baseFilename.endsWith(".shp")) |
|
69 |
baseFilename = baseFilename.replaceAll(".shp", ""); |
|
70 |
|
|
71 |
for (int i = 0; i < rois.length; i++) { |
|
72 |
geometries = rois[i].getGeometries(); |
|
73 |
for (Iterator iterator = geometries.iterator(); iterator.hasNext();) { |
|
74 |
if (geometryType < 0) |
|
75 |
geometryType = ((IGeometry) iterator.next()).getGeometryType(); |
|
76 |
else |
|
77 |
if (geometryType != ((IGeometry) iterator.next()).getGeometryType()){ |
|
78 |
monoType = false; |
|
79 |
break; |
|
80 |
} |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
if (monoType) |
|
85 |
switch (geometryType){ |
|
86 |
case FShape.POLYGON: |
|
87 |
create(baseFilename+".shp", projection, FShape.POLYGON); |
|
88 |
break; |
|
89 |
|
|
90 |
case FShape.POINT: |
|
91 |
create(baseFilename+".shp", projection, FShape.POINT); |
|
92 |
break; |
|
93 |
|
|
94 |
case FShape.LINE: |
|
95 |
create(baseFilename+".shp", projection, FShape.LINE); |
|
96 |
break; |
|
97 |
} |
|
98 |
|
|
99 |
for (int i = 0; i < rois.length; i++) { |
|
100 |
geometries = rois[i].getGeometries(); |
|
101 |
values[0] = ValueFactory.createValue(rois[i].getName()); |
|
102 |
values[1] = ValueFactory.createValue(rois[i].getColor().getRed()); |
|
103 |
values[2] = ValueFactory.createValue(rois[i].getColor().getGreen()); |
|
104 |
values[3] = ValueFactory.createValue(rois[i].getColor().getBlue()); |
|
105 |
|
|
106 |
|
|
107 |
for (Iterator iterator = geometries.iterator(); iterator.hasNext();) { |
|
108 |
IGeometry geometry = (IGeometry) iterator.next(); |
|
109 |
switch (geometry.getGeometryType()) { |
|
110 |
case FShape.POLYGON: |
|
111 |
if (polygonsWriter == null) |
|
112 |
create(baseFilename+"_polygons"+".shp", projection, FShape.POLYGON); |
|
113 |
break; |
|
114 |
|
|
115 |
case FShape.POINT: |
|
116 |
if (pointsWriter == null) |
|
117 |
create(baseFilename+"_points"+".shp", projection, FShape.POINT); |
|
118 |
break; |
|
119 |
|
|
120 |
case FShape.LINE: |
|
121 |
if (linesWriter == null) |
|
122 |
create(baseFilename+"_polylines"+".shp", projection, FShape.LINE); |
|
123 |
break; |
|
124 |
|
|
125 |
default: |
|
126 |
return; |
|
127 |
} |
|
128 |
addFeature(geometry, values); |
|
129 |
} |
|
130 |
} |
|
131 |
try { |
|
132 |
if (polygonsWriter != null) |
|
133 |
polygonsWriter.postProcess(); |
|
134 |
if (pointsWriter != null) |
|
135 |
pointsWriter.postProcess(); |
|
136 |
if (linesWriter != null) |
|
137 |
linesWriter.postProcess(); |
|
138 |
} catch (StopWriterVisitorException e) { |
|
139 |
// TODO Auto-generated catch block |
|
140 |
e.printStackTrace(); |
|
141 |
} |
|
142 |
} |
|
143 |
|
|
144 |
private void addFeature(IGeometry geom, Value[] values) { |
|
145 |
|
|
146 |
DefaultFeature feat = null; |
|
147 |
IRowEdited editFeat = null; |
|
148 |
try { |
|
149 |
switch (geom.getGeometryType()) { |
|
150 |
case FShape.POLYGON: |
|
151 |
if (polygonsWriter != null){ |
|
152 |
feat = new DefaultFeature(geom, values, Integer.toString(iPolygon)); |
|
153 |
editFeat = new DefaultRowEdited(feat, IRowEdited.STATUS_MODIFIED, iPolygon); |
|
154 |
iPolygon++; |
|
155 |
polygonsWriter.process(editFeat); |
|
156 |
} |
|
157 |
break; |
|
158 |
|
|
159 |
case FShape.POINT: |
|
160 |
if (pointsWriter != null){ |
|
161 |
feat = new DefaultFeature(geom, values, Integer.toString(iPoint)); |
|
162 |
editFeat = new DefaultRowEdited(feat, IRowEdited.STATUS_MODIFIED, iPoint); |
|
163 |
iPoint++; |
|
164 |
pointsWriter.process(editFeat); |
|
165 |
} |
|
166 |
break; |
|
167 |
|
|
168 |
case FShape.LINE: |
|
169 |
if (linesWriter != null){ |
|
170 |
feat = new DefaultFeature(geom, values, Integer.toString(iPolyline)); |
|
171 |
editFeat = new DefaultRowEdited(feat, IRowEdited.STATUS_MODIFIED, iPolyline); |
|
172 |
iPolyline++; |
|
173 |
linesWriter.process(editFeat); |
|
174 |
} |
|
175 |
break; |
|
176 |
|
|
177 |
default: |
|
178 |
return; |
|
179 |
} |
|
180 |
} catch (Exception e) { |
|
181 |
e.printStackTrace(); |
|
182 |
} |
|
183 |
|
|
184 |
} |
|
185 |
|
|
186 |
private void create(String filename, IProjection crs, int shapeType) { |
|
187 |
|
|
188 |
LayerDefinition tableDef; |
|
189 |
|
|
190 |
iPoint = 0; |
|
191 |
iPolygon = 0; |
|
192 |
iPolyline = 0; |
|
193 |
projection = (IProjection) crs; |
|
194 |
IWriter writer; |
|
195 |
switch (shapeType) { |
|
196 |
case FShape.POLYGON: |
|
197 |
polygonsWriter = new ShpWriter(); |
|
198 |
writer = polygonsWriter; |
|
199 |
break; |
|
200 |
|
|
201 |
case FShape.POINT: |
|
202 |
pointsWriter = new ShpWriter(); |
|
203 |
writer = pointsWriter; |
|
204 |
break; |
|
205 |
|
|
206 |
case FShape.LINE: |
|
207 |
linesWriter = new ShpWriter(); |
|
208 |
writer = linesWriter; |
|
209 |
break; |
|
210 |
|
|
211 |
default: |
|
212 |
return; |
|
213 |
} |
|
214 |
|
|
215 |
try { |
|
216 |
((ShpWriter)writer).setFile(new File(filename)); |
|
217 |
tableDef = new SHPLayerDefinition(); |
|
218 |
tableDef.setShapeType(shapeType); |
|
219 |
|
|
220 |
tableDef.setFieldsDesc(getFields()); |
|
221 |
tableDef.setName(filename); |
|
222 |
|
|
223 |
writer.initialize(tableDef); |
|
224 |
writer.preProcess(); |
|
225 |
|
|
226 |
} catch (Exception e){ |
|
227 |
e.printStackTrace(); |
|
228 |
} |
|
229 |
|
|
230 |
} |
|
231 |
|
|
232 |
private FieldDescription[] getFields(){ |
|
233 |
FieldDescription[] fields = new FieldDescription[4]; |
|
234 |
|
|
235 |
fields[0] = new FieldDescription(); |
|
236 |
fields[0].setFieldName("name"); |
|
237 |
fields[0].setFieldType(Types.VARCHAR); |
|
238 |
fields[0].setFieldLength(20); |
|
239 |
fields[0].setFieldDecimalCount(5); |
|
240 |
|
|
241 |
fields[1] = new FieldDescription(); |
|
242 |
fields[1].setFieldName("R"); |
|
243 |
fields[1].setFieldType(Types.INTEGER); |
|
244 |
fields[1].setFieldLength(10); |
|
245 |
fields[1].setFieldDecimalCount(5); |
|
246 |
|
|
247 |
fields[2] = new FieldDescription(); |
|
248 |
fields[2].setFieldName("G"); |
|
249 |
fields[2].setFieldType(Types.INTEGER); |
|
250 |
fields[2].setFieldLength(10); |
|
251 |
fields[2].setFieldDecimalCount(5); |
|
252 |
|
|
253 |
fields[3] = new FieldDescription(); |
|
254 |
fields[3].setFieldName("B"); |
|
255 |
fields[3].setFieldType(Types.INTEGER); |
|
256 |
fields[3].setFieldLength(10); |
|
257 |
fields[3].setFieldDecimalCount(5); |
|
258 |
|
|
259 |
return fields; |
|
260 |
} |
|
261 |
} |
tags/v1_11_0_Build_1306/extensions/extRasterTools-SE/src/org/gvsig/fmap/raster/legend/ColorTableLegend.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.fmap.raster.legend; |
|
20 |
|
|
21 |
import java.awt.Color; |
|
22 |
|
|
23 |
import org.gvsig.raster.datastruct.ColorItem; |
|
24 |
import org.gvsig.raster.datastruct.ColorTable; |
|
25 |
import org.gvsig.raster.util.MathUtils; |
|
26 |
|
|
27 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
28 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol; |
|
29 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleLineSymbol; |
|
30 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
|
31 |
import com.iver.cit.gvsig.fmap.rendering.IClassifiedLegend; |
|
32 |
import com.iver.cit.gvsig.fmap.rendering.ILegend; |
|
33 |
import com.iver.cit.gvsig.fmap.rendering.IRasterLegend; |
|
34 |
import com.iver.cit.gvsig.fmap.rendering.LegendContentsChangedListener; |
|
35 |
import com.iver.cit.gvsig.fmap.rendering.SymbolLegendEvent; |
|
36 |
import com.iver.utiles.XMLEntity; |
|
37 |
/** |
|
38 |
* Leyenda para tablas de color aplicadas a un raster. |
|
39 |
* |
|
40 |
* @version 27/06/2007 |
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
42 |
*/ |
|
43 |
public class ColorTableLegend implements IClassifiedLegend, IRasterLegend { |
|
44 |
ISymbol[] symbols = null; |
|
45 |
String[] desc = null; |
|
46 |
|
|
47 |
/** |
|
48 |
* Crea una leyenda de tipo ColorTableLegend a partir de un objeto ColorTable |
|
49 |
* @param colorTable |
|
50 |
* @return ColorTableLegend |
|
51 |
*/ |
|
52 |
public static ColorTableLegend createLegend(ColorTable colorTable) { |
|
53 |
if ((colorTable == null) || (colorTable.getColorItems() == null)) |
|
54 |
return null; |
|
55 |
|
|
56 |
SimpleLineSymbol line = new SimpleLineSymbol(); |
|
57 |
line.setLineColor(Color.BLACK); |
|
58 |
ISymbol[] symbol = new ISymbol[colorTable.getColorItems().size()]; |
|
59 |
String[] desc = new String[colorTable.getColorItems().size()]; |
|
60 |
|
|
61 |
String nameClass = null; |
|
62 |
for (int i = 0; i < colorTable.getColorItems().size(); i++) { |
|
63 |
SimpleFillSymbol s = new SimpleFillSymbol(); |
|
64 |
s.setOutline(line); |
|
65 |
s.setFillColor(((ColorItem) colorTable.getColorItems().get(i)).getColor()); |
|
66 |
nameClass = ((ColorItem) colorTable.getColorItems().get(i)).getNameClass(); |
|
67 |
if ((nameClass == null) || (nameClass.equals(""))){ |
|
68 |
if (i < (colorTable.getColorItems().size() - 1)){ |
|
69 |
desc[i] = "[" + MathUtils.format(((ColorItem) colorTable.getColorItems().get(i)).getValue(), 2) + " , " + MathUtils.format(((ColorItem) colorTable.getColorItems().get(i + 1)).getValue(), 2) + "[ "; |
|
70 |
}else{ |
|
71 |
desc[i] = "[" + MathUtils.format(((ColorItem) colorTable.getColorItems().get(i)).getValue(), 2) + "] "; |
|
72 |
} |
|
73 |
}else{ |
|
74 |
desc[i] = ((ColorItem) colorTable.getColorItems().get(i)).getNameClass(); |
|
75 |
} |
|
76 |
symbol[i] = s; |
|
77 |
} |
|
78 |
|
|
79 |
return new ColorTableLegend(symbol, desc); |
|
80 |
} |
|
81 |
|
|
82 |
/** |
|
83 |
* Leyenda para tablas de color raster. |
|
84 |
* @param s Lista de simbolos |
|
85 |
* @param d Lista de descripciones de simbolos |
|
86 |
*/ |
|
87 |
public ColorTableLegend(ISymbol[] s, String[] d) { |
|
88 |
symbols = s; |
|
89 |
desc = d; |
|
90 |
} |
|
91 |
|
|
92 |
/* |
|
93 |
* (non-Javadoc) |
|
94 |
* @see com.iver.cit.gvsig.fmap.rendering.IClassifiedLegend#getDescriptions() |
|
95 |
*/ |
|
96 |
public String[] getDescriptions() { |
|
97 |
return desc; |
|
98 |
} |
|
99 |
|
|
100 |
/* |
|
101 |
* (non-Javadoc) |
|
102 |
* @see com.iver.cit.gvsig.fmap.rendering.IClassifiedLegend#getSymbols() |
|
103 |
*/ |
|
104 |
public ISymbol[] getSymbols() { |
|
105 |
return symbols; |
|
106 |
} |
|
107 |
|
|
108 |
/* |
|
109 |
* (non-Javadoc) |
|
110 |
* @see com.iver.cit.gvsig.fmap.rendering.IClassifiedLegend#getValues() |
|
111 |
*/ |
|
112 |
public Object[] getValues() { |
|
113 |
return desc; |
|
114 |
} |
|
115 |
|
|
116 |
/* |
|
117 |
* (non-Javadoc) |
|
118 |
* @see com.iver.cit.gvsig.fmap.rendering.ILegend#cloneLegend() |
|
119 |
*/ |
|
120 |
public ILegend cloneLegend() throws XMLException { |
|
121 |
return null; |
|
122 |
} |
|
123 |
|
|
124 |
/* |
|
125 |
* (non-Javadoc) |
|
126 |
* @see com.iver.cit.gvsig.fmap.rendering.ILegend#getDefaultSymbol() |
|
127 |
*/ |
|
128 |
public ISymbol getDefaultSymbol() { |
|
129 |
return null; |
|
130 |
} |
|
131 |
|
|
132 |
/* |
|
133 |
* (non-Javadoc) |
|
134 |
* @see com.iver.cit.gvsig.fmap.rendering.ILegend#getSLDString(java.lang.String) |
|
135 |
*/ |
|
136 |
public String getSLDString(String layerName) { |
|
137 |
return null; |
|
138 |
} |
|
139 |
|
|
140 |
/* |
|
141 |
* (non-Javadoc) |
|
142 |
* @see com.iver.cit.gvsig.fmap.rendering.ILegend#getXMLEntity() |
|
143 |
*/ |
|
144 |
public XMLEntity getXMLEntity() { |
|
145 |
return null; |
|
146 |
} |
|
147 |
|
|
148 |
/* |
|
149 |
* (non-Javadoc) |
|
150 |
* @see com.iver.utiles.IPersistance#getClassName() |
|
151 |
*/ |
|
152 |
public String getClassName() { |
|
153 |
return null; |
|
154 |
} |
|
155 |
|
|
156 |
/* |
|
157 |
* (non-Javadoc) |
|
158 |
* @see com.iver.utiles.IPersistance#setXMLEntity(com.iver.utiles.XMLEntity) |
|
159 |
*/ |
|
160 |
public void setXMLEntity(XMLEntity xml) { |
|
161 |
} |
|
162 |
|
|
163 |
public void addLegendListener(LegendContentsChangedListener listener) { |
|
164 |
// TODO Auto-generated method stub |
|
165 |
} |
|
166 |
|
|
167 |
public void fireDefaultSymbolChangedEvent(SymbolLegendEvent event) { |
|
168 |
// TODO Auto-generated method stub |
|
169 |
|
|
170 |
} |
|
171 |
|
|
172 |
public LegendContentsChangedListener[] getListeners() { |
|
173 |
// TODO Auto-generated method stub |
|
174 |
return null; |
|
175 |
} |
|
176 |
|
|
177 |
|
|
178 |
public void removeLegendListener(LegendContentsChangedListener listener) { |
|
179 |
// TODO Auto-generated method stub |
|
180 |
} |
|
181 |
} |
|
0 | 182 |
tags/v1_11_0_Build_1306/extensions/extRasterTools-SE/src/org/gvsig/fmap/raster/layers/DefaultLayerConfiguration.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.fmap.raster.layers; |
|
20 |
/** |
|
21 |
* DefaultLayerConfiguration sirve para aquellos objetos que no puedan usar la |
|
22 |
* configuracion de PluginServices, devolviendo siempre el valor por defecto. |
|
23 |
* |
|
24 |
* @version 14/01/2008 |
|
25 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
26 |
*/ |
|
27 |
public class DefaultLayerConfiguration implements IConfiguration { |
|
28 |
|
|
29 |
/* |
|
30 |
* (non-Javadoc) |
|
31 |
* @see org.gvsig.fmap.raster.conf.IConfiguration#getValueBoolean(java.lang.String, java.lang.Boolean) |
|
32 |
*/ |
|
33 |
public Boolean getValueBoolean(String name, Boolean defaultValue) { |
|
34 |
return defaultValue; |
|
35 |
} |
|
36 |
|
|
37 |
/* |
|
38 |
* (non-Javadoc) |
|
39 |
* @see org.gvsig.fmap.raster.conf.IConfiguration#getValueDouble(java.lang.String, java.lang.Double) |
|
40 |
*/ |
|
41 |
public Double getValueDouble(String name, Double defaultValue) { |
|
42 |
return defaultValue; |
|
43 |
} |
|
44 |
|
|
45 |
/* |
|
46 |
* (non-Javadoc) |
|
47 |
* @see org.gvsig.fmap.raster.conf.IConfiguration#getValueFloat(java.lang.String, java.lang.Float) |
|
48 |
*/ |
|
49 |
public Float getValueFloat(String name, Float defaultValue) { |
|
50 |
return defaultValue; |
|
51 |
} |
|
52 |
|
|
53 |
/* |
|
54 |
* (non-Javadoc) |
|
55 |
* @see org.gvsig.fmap.raster.conf.IConfiguration#getValueInteger(java.lang.String, java.lang.Integer) |
|
56 |
*/ |
|
57 |
public Integer getValueInteger(String name, Integer defaultValue) { |
|
58 |
return defaultValue; |
|
59 |
} |
|
60 |
|
|
61 |
/* |
|
62 |
* (non-Javadoc) |
|
63 |
* @see org.gvsig.fmap.raster.conf.IConfiguration#getValueLong(java.lang.String, java.lang.Long) |
|
64 |
*/ |
|
65 |
public Long getValueLong(String name, Long defaultValue) { |
|
66 |
return defaultValue; |
|
67 |
} |
|
68 |
|
|
69 |
/* |
|
70 |
* (non-Javadoc) |
|
71 |
* @see org.gvsig.fmap.raster.conf.IConfiguration#getValueString(java.lang.String, java.lang.String) |
|
72 |
*/ |
|
73 |
public String getValueString(String name, String defaultValue) { |
|
74 |
return defaultValue; |
|
75 |
} |
|
76 |
} |
tags/v1_11_0_Build_1306/extensions/extRasterTools-SE/src/org/gvsig/fmap/raster/layers/FLyrState.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.fmap.raster.layers; |
|
20 |
|
|
21 |
|
|
22 |
/** |
|
23 |
* Estados de una capa. Cada capa tiene uno o varios estados activos en cada instante. |
|
24 |
* Hay estados no compatibles entre si, es decir, no pueden estar activos a la vez en cada |
|
25 |
* instante. Por ejemplo, una capa no puede estar cerrada y renderizando ya que sus datos no |
|
26 |
* est?n accesibles para esa operaci?n. Los estados de una capa sir |
|
27 |
* @version 13/09/2007 |
|
28 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
29 |
* |
|
30 |
*/ |
|
31 |
public class FLyrState implements ILayerState { |
|
32 |
private boolean open = false; |
|
33 |
private boolean closed = true; |
|
34 |
private boolean awake = false; |
|
35 |
private boolean stopped = false; |
|
36 |
//private boolean renderizing = false; |
|
37 |
|
|
38 |
private int lastBeforeStop = UNDEFINED; |
|
39 |
|
|
40 |
|
|
41 |
/* |
|
42 |
* (non-Javadoc) |
|
43 |
* @see org.gvsig.fmap.raster.layers.IState#isAwake() |
|
44 |
*/ |
|
45 |
public boolean isAwake() { |
|
46 |
return awake; |
|
47 |
} |
|
48 |
|
|
49 |
/* |
|
50 |
* (non-Javadoc) |
|
51 |
* @see org.gvsig.fmap.raster.layers.IState#enableAwake() |
|
52 |
*/ |
|
53 |
public void enableAwake() throws NotAvailableStateException { |
|
54 |
if(open == true || closed == true || stopped == true) { |
|
55 |
this.awake = true; |
|
56 |
stopped = closed = open = false; |
|
57 |
lastBeforeStop = UNDEFINED; |
|
58 |
} else |
|
59 |
throw new NotAvailableStateException("Awake state not available"); |
|
60 |
} |
|
61 |
|
|
62 |
/* |
|
63 |
* (non-Javadoc) |
|
64 |
* @see org.gvsig.fmap.raster.layers.IState#isOpen() |
|
65 |
*/ |
|
66 |
public boolean isOpen() { |
|
67 |
return open; |
|
68 |
} |
|
69 |
|
|
70 |
/* |
|
71 |
* (non-Javadoc) |
|
72 |
* @see org.gvsig.fmap.raster.layers.IState#enableOpen() |
|
73 |
*/ |
|
74 |
public void enableOpen() throws NotAvailableStateException { |
|
75 |
if(stopped == true || awake == true) { |
|
76 |
this.open = true; |
|
77 |
stopped = closed = awake = false; |
|
78 |
lastBeforeStop = UNDEFINED; |
|
79 |
} else |
|
80 |
throw new NotAvailableStateException("Open state not available"); |
|
81 |
} |
|
82 |
|
|
83 |
|
|
84 |
/* |
|
85 |
* (non-Javadoc) |
|
86 |
* @see org.gvsig.fmap.raster.layers.IState#isClosed() |
|
87 |
*/ |
|
88 |
public boolean isClosed() { |
|
89 |
return closed; |
|
90 |
} |
|
91 |
|
|
92 |
/* |
|
93 |
* (non-Javadoc) |
|
94 |
* @see org.gvsig.fmap.raster.layers.IState#enableClosed() |
|
95 |
*/ |
|
96 |
public void enableClosed() throws NotAvailableStateException { |
|
97 |
if(open == true || awake == true || stopped == true) { |
|
98 |
this.closed = true; |
|
99 |
stopped = open = awake = false; |
|
100 |
lastBeforeStop = UNDEFINED; |
|
101 |
} else |
|
102 |
throw new NotAvailableStateException("Closed state not available"); |
|
103 |
} |
|
104 |
|
|
105 |
/* |
|
106 |
* (non-Javadoc) |
|
107 |
* @see org.gvsig.fmap.raster.layers.IState#isStopped() |
|
108 |
*/ |
|
109 |
public boolean isStopped() { |
|
110 |
return stopped; |
|
111 |
} |
|
112 |
|
|
113 |
/* |
|
114 |
* (non-Javadoc) |
|
115 |
* @see org.gvsig.fmap.raster.layers.IState#enableStopped() |
|
116 |
*/ |
|
117 |
public void enableStopped() { |
|
118 |
if(open == true || awake == true || closed == true) { |
|
119 |
lastBeforeStop = (open == true) ? OPEN : ((closed == true) ? CLOSED : ((awake == true) ? AWAKE : UNDEFINED)); |
|
120 |
if(lastBeforeStop != UNDEFINED) { |
|
121 |
stopped = true; |
|
122 |
closed = open = awake = false; |
|
123 |
} |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 |
/* |
|
128 |
* (non-Javadoc) |
|
129 |
* @see org.gvsig.fmap.raster.layers.IState#disableStopped() |
|
130 |
*/ |
|
131 |
public void disableStopped() { |
|
132 |
if(stopped == true && lastBeforeStop != UNDEFINED) { |
|
133 |
switch(lastBeforeStop) { |
|
134 |
case OPEN: open = true; closed = awake = false; break; |
|
135 |
case CLOSED: closed = true; awake = open = false; break; |
|
136 |
case AWAKE: awake = true; closed = open = false; break; |
|
137 |
} |
|
138 |
stopped = false; |
|
139 |
lastBeforeStop = UNDEFINED; |
|
140 |
} |
|
141 |
} |
|
142 |
|
|
143 |
} |
|
0 | 144 |
tags/v1_11_0_Build_1306/extensions/extRasterTools-SE/src/org/gvsig/fmap/raster/layers/IStatusRaster.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.fmap.raster.layers; |
|
20 |
|
|
21 |
import java.util.ArrayList; |
|
22 |
|
|
23 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
|
24 |
import org.gvsig.raster.dataset.io.RasterDriverException; |
|
25 |
import org.gvsig.raster.datastruct.ColorTable; |
|
26 |
import org.gvsig.raster.grid.GridTransparency; |
|
27 |
import org.gvsig.raster.grid.filter.FilterTypeException; |
|
28 |
import org.gvsig.raster.grid.filter.RasterFilterList; |
|
29 |
import org.gvsig.raster.hierarchy.IRasterProperties; |
|
30 |
|
|
31 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
|
32 |
import com.iver.utiles.XMLEntity; |
|
33 |
|
|
34 |
public interface IStatusRaster{ |
|
35 |
|
|
36 |
/** |
|
37 |
* Recupera en fichero XML algunas propiedades y filtros del raster |
|
38 |
* @param xml |
|
39 |
* @throws XMLException |
|
40 |
*/ |
|
41 |
public void setXMLEntity(XMLEntity xml, IRasterProperties layer)throws XMLException; |
|
42 |
|
|
43 |
/** |
|
44 |
* Salva en fichero XML algunas propiedades y filtros de raster |
|
45 |
* @param xml |
|
46 |
* @throws XMLException |
|
47 |
*/ |
|
48 |
public void getXMLEntity(XMLEntity xml, boolean loadClass, IRasterProperties layer)throws XMLException; |
|
49 |
|
|
50 |
/** |
|
51 |
* Aplica el estado almacenado al FLyrRaster pasado por par?metro |
|
52 |
* @param adapter |
|
53 |
* @throws NotSupportedExtensionException Cuando la extensi?n no est? soportada |
|
54 |
* @throws RasterDriverException Cuando se produce un error en la lectura del fichero |
|
55 |
*/ |
|
56 |
public void applyStatus(FLyrRasterSE layer) throws NotSupportedExtensionException, RasterDriverException, FilterTypeException ; |
|
57 |
|
|
58 |
/** |
|
59 |
* Obtiene el listado de filtros para poder montar una pila |
|
60 |
* despu?s de la recuperaci?n desde el XML |
|
61 |
* @return |
|
62 |
*/ |
|
63 |
public ArrayList getFilters(); |
|
64 |
|
|
65 |
/** |
|
66 |
* Obtiene el orden de renderizado de bandas cargado desde el proyecto |
|
67 |
* despu?s de hacer un setXMLEntity |
|
68 |
* @return Lista de enteros con el orden de renderizado |
|
69 |
*/ |
|
70 |
public int[] getRenderBands(); |
|
71 |
|
|
72 |
/** |
|
73 |
* Obtiene la lista de filtros cargada desde el proyecto despu?s de hacer un |
|
74 |
* setXMLEntity |
|
75 |
* @return RasterFilterList |
|
76 |
* @throws FilterTypeException |
|
77 |
*/ |
|
78 |
public RasterFilterList getFilterList() throws FilterTypeException; |
|
79 |
|
|
80 |
/** |
|
81 |
* Obtiene el objeto de transparencia cargado desde el proyecto despu?s de hacer un |
|
82 |
* setXMLEntity |
|
83 |
* @return la lista de filtros |
|
84 |
*/ |
|
85 |
public GridTransparency getTransparency(); |
|
86 |
|
|
87 |
/** |
|
88 |
* Obtiene la lista de filtros cargada desde el proyecto despu?s de hacer un |
|
89 |
* setXMLEntity. No construye los filtros sino que devuelve una lista de par?metros |
|
90 |
* @return RasterFilterList |
|
91 |
*/ |
|
92 |
public ArrayList getFilterArguments(); |
|
93 |
|
|
94 |
/** |
|
95 |
* Obtiene el ColorTable si hay un filtro de tabla de color en la lista |
|
96 |
* @return ColorTable |
|
97 |
* @throws FilterTypeException |
|
98 |
*/ |
|
99 |
public ColorTable getColorTable() throws FilterTypeException; |
|
100 |
} |
|
0 | 101 |
tags/v1_11_0_Build_1306/extensions/extRasterTools-SE/src/org/gvsig/fmap/raster/layers/GeorefPanListenerImpl.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.fmap.raster.layers; |
|
20 |
|
|
21 |
import java.awt.Cursor; |
|
22 |
import java.awt.Image; |
|
23 |
import java.awt.Point; |
|
24 |
import java.awt.Toolkit; |
|
25 |
import java.awt.geom.Point2D; |
|
26 |
import java.awt.geom.Rectangle2D; |
|
27 |
|
|
28 |
import com.iver.andami.PluginServices; |
|
29 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
30 |
import com.iver.cit.gvsig.fmap.ViewPort; |
|
31 |
import com.iver.cit.gvsig.fmap.tools.Events.MoveEvent; |
|
32 |
import com.iver.cit.gvsig.fmap.tools.Listeners.PanListener; |
|
33 |
|
|
34 |
|
|
35 |
/** |
|
36 |
* Implementaci?n de la interfaz PanListener como herramienta para realizar el |
|
37 |
* Pan. |
|
38 |
* |
|
39 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
40 |
*/ |
|
41 |
public class GeorefPanListenerImpl implements PanListener { |
|
42 |
// private final Image ipan = new ImageIcon(MapControl.class.getResource( |
|
43 |
// "images/CruxCursor.png")).getImage(); |
|
44 |
private final Image ipan = PluginServices.getIconTheme().get("crux-cursor").getImage(); |
|
45 |
private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(ipan, |
Also available in: Unified diff