Revision 21155
branches/v2_0_0_prep/libraries/libFMap/src/com/vividsolutions/jts/geomgraph/SnapEdgeList.java | ||
---|---|---|
67 | 67 |
import java.util.Iterator; |
68 | 68 |
import java.util.List; |
69 | 69 |
|
70 |
import org.gvsig.fmap.drivers.iterators.spatialindex.RTreeJsi; |
|
71 |
|
|
72 | 70 |
import com.vividsolutions.jts.geom.Envelope; |
73 | 71 |
/** |
74 | 72 |
* Overwrites jts' EdgeList to allow spatial queries |
75 | 73 |
* consideering snap. |
76 |
*
|
|
74 |
* |
|
77 | 75 |
* (for example, (0 0, 5 0) and (0.01 0.01, 5.01 0.02) |
78 | 76 |
* arent equivalent in findEqualEdge, even thought with a |
79 | 77 |
* snap distance of 0.1 |
80 |
*
|
|
81 |
*
|
|
82 |
*
|
|
78 |
* |
|
79 |
* |
|
80 |
* |
|
83 | 81 |
* */ |
84 | 82 |
public class SnapEdgeList extends EdgeList { |
85 | 83 |
private List edges = new ArrayList(); |
86 |
|
|
84 |
|
|
87 | 85 |
// private SpatialIndex index = new Quadtree(); |
88 |
|
|
86 |
|
|
89 | 87 |
//El quadtree no funciona bien para indexar dimensiones |
90 | 88 |
//lineales o lineas. |
91 |
|
|
92 |
private RTreeJsi spatialIndex = new RTreeJsi(); |
|
89 |
|
|
90 |
// private RTreeJsi spatialIndex = new RTreeJsi();
|
|
93 | 91 |
private double snapTolerance; |
94 |
|
|
95 |
|
|
96 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
97 | 95 |
public SnapEdgeList(double snapTolerance) { |
98 | 96 |
this.snapTolerance = snapTolerance; |
99 | 97 |
} |
... | ... | |
103 | 101 |
*/ |
104 | 102 |
public void add(Edge e) |
105 | 103 |
{ |
106 |
// int position = edges.size();
|
|
104 |
// int position = edges.size(); |
|
107 | 105 |
edges.add(e); |
108 | 106 |
//TODO me peta el indice espacial |
109 | 107 |
// Envelope oldEnvelope = e.getEnvelope(); |
... | ... | |
116 | 114 |
double ymin = oldEnvelope.getMinY() - snapTolerance; |
117 | 115 |
double width = oldEnvelope.getWidth() + snapTolerance; |
118 | 116 |
double height = oldEnvelope.getHeight() + snapTolerance; |
119 |
|
|
117 |
|
|
120 | 118 |
return new Rectangle2D.Double(xmin, ymin, width, height); |
121 | 119 |
} |
122 | 120 |
|
... | ... | |
135 | 133 |
// query(getEnvelopeForSnap(e.getEnvelope())); |
136 | 134 |
//PETA CON QUADTREE Y CON RTREE DE JSI |
137 | 135 |
|
138 |
Collection testEdges = edges;
|
|
139 |
|
|
136 |
Collection testEdges = edges; |
|
137 |
|
|
140 | 138 |
for (Iterator i = testEdges.iterator(); i.hasNext(); ) { |
141 | 139 |
//TODO me peta el indice espacial |
142 | 140 |
// int index = ((Integer)i.next()).intValue(); |
143 |
Edge testEdge = (Edge) i.next();
|
|
144 |
|
|
141 |
Edge testEdge = (Edge) i.next(); |
|
142 |
|
|
145 | 143 |
// Edge testEdge = (Edge) edges.get(index); |
146 | 144 |
if (testEdge.equals(e) ) return testEdge; |
147 | 145 |
} |
148 | 146 |
return null; |
149 | 147 |
} |
150 |
|
|
148 |
|
|
151 | 149 |
public void addAll(Collection edgeColl) |
152 | 150 |
{ |
153 | 151 |
for (Iterator i = edgeColl.iterator(); i.hasNext(); ) { |
154 | 152 |
add((Edge) i.next()); |
155 | 153 |
} |
156 | 154 |
} |
157 |
|
|
155 |
|
|
158 | 156 |
public Iterator iterator() { return edges.iterator(); } |
159 | 157 |
|
160 | 158 |
public Edge get(int i) { return (Edge) edges.get(i); } |
... | ... | |
172 | 170 |
return -1; |
173 | 171 |
} |
174 | 172 |
|
175 |
|
|
173 |
|
|
176 | 174 |
public List getEdges() { return edges; } |
177 | 175 |
|
178 | 176 |
} |
branches/v2_0_0_prep/libraries/libFMap/src/org/gvsig/fmap/mapcontext/layers/FLyrGT2.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 20-sep-2005 |
|
3 |
* |
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
21 |
* |
|
22 |
* For more information, contact: |
|
23 |
* |
|
24 |
* Generalitat Valenciana |
|
25 |
* Conselleria d'Infraestructures i Transport |
|
26 |
* Av. Blasco Ib??ez, 50 |
|
27 |
* 46010 VALENCIA |
|
28 |
* SPAIN |
|
29 |
* |
|
30 |
* +34 963862235 |
|
31 |
* gvsig@gva.es |
|
32 |
* www.gvsig.gva.es |
|
33 |
* |
|
34 |
* or |
|
35 |
* |
|
36 |
* IVER T.I. S.A |
|
37 |
* Salamanca 50 |
|
38 |
* 46005 Valencia |
|
39 |
* Spain |
|
40 |
* |
|
41 |
* +34 963163400 |
|
42 |
* dac@iver.es |
|
43 |
*/ |
|
44 |
package org.gvsig.fmap.mapcontext.layers; |
|
45 |
|
|
46 |
import java.awt.Graphics2D; |
|
47 |
import java.awt.geom.Rectangle2D; |
|
48 |
import java.awt.image.BufferedImage; |
|
49 |
import java.io.IOException; |
|
50 |
import java.util.NoSuchElementException; |
|
51 |
|
|
52 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
53 |
|
|
54 |
import org.geotools.data.DataStore; |
|
55 |
import org.geotools.data.DefaultQuery; |
|
56 |
import org.geotools.data.DefaultTransaction; |
|
57 |
import org.geotools.data.FeatureReader; |
|
58 |
import org.geotools.data.FeatureSource; |
|
59 |
import org.geotools.data.Query; |
|
60 |
import org.geotools.data.Transaction; |
|
61 |
import org.geotools.feature.Feature; |
|
62 |
import org.geotools.feature.IllegalAttributeException; |
|
63 |
import org.geotools.filter.AbstractFilter; |
|
64 |
import org.geotools.filter.BBoxExpression; |
|
65 |
import org.geotools.filter.FilterFactory; |
|
66 |
import org.geotools.filter.FilterType; |
|
67 |
import org.geotools.filter.GeometryFilter; |
|
68 |
import org.geotools.filter.IllegalFilterException; |
|
69 |
import org.gvsig.fmap.core.geometries.IGeometry; |
|
70 |
import org.gvsig.fmap.core.geometries.utils.FConverter; |
|
71 |
import org.gvsig.fmap.core.shapes.ShapeFactory; |
|
72 |
import org.gvsig.fmap.core.shapes.gt2.FLiteShape; |
|
73 |
import org.gvsig.fmap.datasources.SelectableDataSource; |
|
74 |
import org.gvsig.fmap.drivers.exceptions.VisitorException; |
|
75 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
76 |
import org.gvsig.fmap.mapcontext.rendering.strategies.FeatureVisitor; |
|
77 |
import org.gvsig.fmap.mapcontext.rendering.symbols.IMarkerSymbol; |
|
78 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory; |
|
79 |
|
|
80 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
81 |
import com.iver.utiles.swing.threads.Cancellable; |
|
82 |
import com.vividsolutions.jts.geom.Envelope; |
|
83 |
import com.vividsolutions.jts.geom.Geometry; |
|
84 |
|
|
85 |
public class FLyrGT2 extends FLyrSecuential { |
|
86 |
|
|
87 |
DataStore dataStore; |
|
88 |
String typeName; |
|
89 |
String tableName; |
|
90 |
static FilterFactory ff = FilterFactory.createFilterFactory(); |
|
91 |
|
|
92 |
public Rectangle2D getFullExtent() throws ReadDriverException { |
|
93 |
Rectangle2D r; |
|
94 |
Envelope jtsR = null; |
|
95 |
try { |
|
96 |
jtsR = dataStore.getFeatureSource(tableName).getBounds(); |
|
97 |
} catch (IOException e) { |
|
98 |
throw new ReadDriverException(getName(),e); |
|
99 |
} |
|
100 |
r = FConverter.convertEnvelopeToRectangle2D(jtsR); |
|
101 |
return r; |
|
102 |
} |
|
103 |
|
|
104 |
private void prepareDrawing() |
|
105 |
{ |
|
106 |
|
|
107 |
} |
|
108 |
private void drawSelectedFeatures() |
|
109 |
{ |
|
110 |
|
|
111 |
} |
|
112 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
113 |
Cancellable cancel, double scale) throws ReadDriverException { |
|
114 |
if (!isWithinScale(scale)) return; |
|
115 |
try { |
|
116 |
prepareDrawing(); |
|
117 |
FeatureSource featSource = dataStore.getFeatureSource(tableName); |
|
118 |
|
|
119 |
Envelope env = new Envelope(viewPort.getExtent().getMinX(), |
|
120 |
viewPort.getExtent().getMinY(), viewPort.getExtent().getMaxX(), |
|
121 |
viewPort.getExtent().getMaxY()); |
|
122 |
|
|
123 |
// create filter to select only features that satify 300000 >= "field" >= 100000 |
|
124 |
|
|
125 |
BBoxExpression bb = ff.createBBoxExpression(env); |
|
126 |
GeometryFilter bboxFilter = |
|
127 |
ff.createGeometryFilter(AbstractFilter.GEOMETRY_BBOX); |
|
128 |
bboxFilter.addRightGeometry(bb); |
|
129 |
String strGeom = dataStore.getSchema(tableName).getDefaultGeometry().getName(); |
|
130 |
bboxFilter.addLeftGeometry( |
|
131 |
ff.createAttributeExpression(dataStore.getSchema(tableName),strGeom)); |
|
132 |
|
|
133 |
Query theQuery = new DefaultQuery(tableName, bboxFilter); |
|
134 |
// Query theQuery = new DefaultQuery(tableName, Filter.NONE); |
|
135 |
Transaction t = new DefaultTransaction(); |
|
136 |
FeatureReader reader = dataStore.getFeatureReader(theQuery, t); |
|
137 |
Feature f = null; |
|
138 |
IMarkerSymbol sym = SymbologyFactory.createDefaultMarkerSymbol(); |
|
139 |
while ( reader.hasNext() ) { |
|
140 |
if (cancel.isCanceled()) { |
|
141 |
reader.close(); |
|
142 |
break; |
|
143 |
} |
|
144 |
|
|
145 |
f = reader.next(); |
|
146 |
Geometry geom = f.getDefaultGeometry(); |
|
147 |
FLiteShape shpLite = new FLiteShape(geom); |
|
148 |
IGeometry gAux = ShapeFactory.createGeometry(shpLite); |
|
149 |
gAux.draw(g,viewPort,sym, cancel); |
|
150 |
} |
|
151 |
|
|
152 |
reader.close(); |
|
153 |
|
|
154 |
} catch (IOException e) { |
|
155 |
throw new ReadDriverException(getName(),e); |
|
156 |
} catch (IllegalFilterException e) { |
|
157 |
throw new ReadDriverException(getName(),e); |
|
158 |
} catch (NoSuchElementException e) { |
|
159 |
throw new ReadDriverException(getName(),e); |
|
160 |
} catch (IllegalAttributeException e) { |
|
161 |
throw new ReadDriverException(getName(),e); |
|
162 |
} |
|
163 |
|
|
164 |
} |
|
165 |
|
|
166 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
|
167 |
double scale, PrintRequestAttributeSet properties) throws ReadDriverException { |
|
168 |
// TODO Auto-generated method stub |
|
169 |
|
|
170 |
} |
|
171 |
|
|
172 |
/** |
|
173 |
* @return Returns the dataStore. |
|
174 |
*/ |
|
175 |
public DataStore getDataStore() { |
|
176 |
return dataStore; |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* @param dataStore The dataStore to set. |
|
181 |
* @throws IOException |
|
182 |
*/ |
|
183 |
public void setDataStore(DataStore dataStore) throws IOException { |
|
184 |
this.dataStore = dataStore; |
|
185 |
// feature type name is defaulted to the name of shapefile (without extension) |
|
186 |
typeName = dataStore.getTypeNames()[0]; |
|
187 |
} |
|
188 |
|
|
189 |
/** |
|
190 |
* @param tableName The tableName to set. |
|
191 |
*/ |
|
192 |
public void setTableName(String tableName) { |
|
193 |
this.tableName = tableName; |
|
194 |
} |
|
195 |
|
|
196 |
public void process(FeatureVisitor visitor, FBitSet subset) throws ReadDriverException, VisitorException { |
|
197 |
// TODO Auto-generated method stub |
|
198 |
|
|
199 |
} |
|
200 |
|
|
201 |
public void process(FeatureVisitor visitor, Rectangle2D rect) throws ReadDriverException, VisitorException { |
|
202 |
try |
|
203 |
{ |
|
204 |
|
|
205 |
Envelope env = FConverter.convertRectangle2DtoEnvelope(rect); |
|
206 |
|
|
207 |
|
|
208 |
BBoxExpression bb = ff.createBBoxExpression(env); |
|
209 |
GeometryFilter bboxFilter = |
|
210 |
ff.createGeometryFilter(FilterType.GEOMETRY_BBOX); |
|
211 |
bboxFilter.addRightGeometry(bb); |
|
212 |
String strGeom = dataStore.getSchema(tableName).getDefaultGeometry().getName(); |
|
213 |
bboxFilter.addLeftGeometry( |
|
214 |
ff.createAttributeExpression(dataStore.getSchema(tableName),strGeom)); |
|
215 |
|
|
216 |
Query theQuery = new DefaultQuery(tableName, bboxFilter); |
|
217 |
// Query theQuery = new DefaultQuery(tableName, Filter.NONE); |
|
218 |
Transaction t = new DefaultTransaction(); |
|
219 |
FeatureReader reader = dataStore.getFeatureReader(theQuery, t); |
|
220 |
Feature f = null; |
|
221 |
while ( reader.hasNext() ) { |
|
222 |
f = reader.next(); |
|
223 |
Geometry geom = f.getDefaultGeometry(); |
|
224 |
FLiteShape shpLite = new FLiteShape(geom); |
|
225 |
IGeometry gAux = ShapeFactory.createGeometry(shpLite); |
|
226 |
visitor.visit(gAux, -1); |
|
227 |
} |
|
228 |
|
|
229 |
reader.close(); |
|
230 |
|
|
231 |
} catch (IOException e) { |
|
232 |
throw new ReadDriverException(getName(),e); |
|
233 |
} catch (IllegalFilterException e) { |
|
234 |
throw new ReadDriverException(getName(),e); |
|
235 |
} catch (NoSuchElementException e) { |
|
236 |
throw new ReadDriverException(getName(),e); |
|
237 |
} catch (IllegalAttributeException e) { |
|
238 |
throw new ReadDriverException(getName(),e); |
|
239 |
} |
|
240 |
|
|
241 |
|
|
242 |
} |
|
243 |
|
|
244 |
public void process(FeatureVisitor visitor) throws ReadDriverException, VisitorException { |
|
245 |
// TODO Auto-generated method stub |
|
246 |
|
|
247 |
} |
|
248 |
|
|
249 |
public SelectableDataSource getRecordset() { |
|
250 |
// TODO Auto-generated method stub |
|
251 |
// fjp: simplificar SelectableDataSource y quitar los m?todos que no |
|
252 |
// necesitamos. (getPrimeryKeys, getDataWare, getDataFactory... etc) |
|
253 |
return null; |
|
254 |
} |
|
255 |
|
|
256 |
} |
branches/v2_0_0_prep/libraries/libFMap/src/org/gvsig/fmap/mapcontext/layers/FLayers.java | ||
---|---|---|
45 | 45 |
import java.awt.geom.Rectangle2D; |
46 | 46 |
import java.awt.image.BufferedImage; |
47 | 47 |
import java.awt.image.WritableRaster; |
48 |
import java.io.File; |
|
49 | 48 |
import java.util.ArrayList; |
50 | 49 |
import java.util.Collections; |
51 | 50 |
import java.util.Iterator; |
... | ... | |
62 | 61 |
import org.gvsig.data.ReadException; |
63 | 62 |
import org.gvsig.data.vectorial.FeatureCollection; |
64 | 63 |
import org.gvsig.data.vectorial.visitor.FeaturesVisitor; |
65 |
import org.gvsig.fmap.crs.CRSFactory; |
|
66 | 64 |
import org.gvsig.fmap.mapcontext.MapContext; |
67 | 65 |
import org.gvsig.fmap.mapcontext.Messages; |
68 | 66 |
import org.gvsig.fmap.mapcontext.ViewPort; |
69 |
import org.gvsig.fmap.mapcontext.exceptions.DriverLayerException; |
|
70 | 67 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
71 | 68 |
import org.gvsig.fmap.mapcontext.layers.operations.ComposedLayer; |
72 | 69 |
import org.gvsig.fmap.mapcontext.layers.operations.ILabelable; |
... | ... | |
74 | 71 |
import org.gvsig.fmap.mapcontext.layers.operations.LayerCollection; |
75 | 72 |
import org.gvsig.fmap.mapcontext.layers.operations.VectorialData; |
76 | 73 |
import org.gvsig.fmap.mapcontext.layers.operations.XMLItem; |
77 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLayerFileVectorial; |
|
78 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLayerGenericVectorial; |
|
79 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrAnnotation; |
|
80 | 74 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
81 | 75 |
import org.gvsig.fmap.mapcontrol.MapControl; |
82 | 76 |
|
83 |
import com.iver.utiles.IPersistence; |
|
84 | 77 |
import com.iver.utiles.XMLEntity; |
85 | 78 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
86 | 79 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
... | ... | |
1514 | 1507 |
* @param name name of the layer to add |
1515 | 1508 |
*/ |
1516 | 1509 |
private void addLayerFromXMLNew(XMLEntity xml, String name) { |
1517 |
FLayer layer = null; |
|
1518 |
|
|
1519 |
|
|
1520 |
try { |
|
1521 |
String className = xml.getStringProperty("className"); |
|
1522 |
Class clazz = Class.forName(className); |
|
1523 |
if (clazz.isAssignableFrom(FLayers.class)) { |
|
1524 |
layer = (FLayer) clazz.newInstance(); |
|
1525 |
((FLayers)layer).setMapContext(getMapContext()); |
|
1526 |
((FLayers)layer).setParentLayer(this); |
|
1527 |
// if (className.equals((FLayers.class.getName()))){ |
|
1528 |
// layer = new FLayers(getMapContext(),this); |
|
1529 |
} else { |
|
1530 |
// Por compatibilidad |
|
1531 |
if (className.equals(FLyrVect.class.getName())) { |
|
1532 |
if (xml.contains("file")) { |
|
1533 |
layer = new FLayerFileVectorial(); |
|
1534 |
} else if (xml.contains("db")) { |
|
1535 |
try { |
|
1536 |
layer = (FLayer)((ExtensionPoint)ExtensionPointsSingleton.getInstance().get("Layers")).create("com.iver.cit.gvsig.fmap.layers.FLayerJDBCVectorial"); |
|
1537 |
} catch (Exception e) { |
|
1538 |
throw new XMLException(new Exception("No se tiene registrada la capa de tipo JDBC")); |
|
1539 |
} |
|
1540 |
//className = FLayerJDBCVectorial.class.getName(); |
|
1541 |
} else if (xml.contains("other")){ |
|
1542 |
layer = new FLayerGenericVectorial(); |
|
1543 |
} else { |
|
1544 |
throw new XMLException(new Exception("Capa vectorial de tipo no reconocido")); |
|
1545 |
} |
|
1546 |
// Fin por compatibilidad |
|
1547 |
} else { |
|
1548 |
try { |
|
1549 |
layer = (FLayer)(((ExtensionPoint)ExtensionPointsSingleton.getInstance().get("Layers")).create(className)); |
|
1550 |
} catch (Exception e) { |
|
1551 |
//puende que no este registrada como punto de extension |
|
1552 |
Class clase = Class.forName(className); |
|
1553 |
layer = (FLayer) clase.newInstance(); |
|
1554 |
// FIXME: Hacemos algo aqui o dejamos que suba el error? |
|
1555 |
} |
|
1556 |
} |
|
1557 |
|
|
1558 |
} |
|
1559 |
layer.setXMLEntity(xml); |
|
1560 |
if (name != null) layer.setName(name); |
|
1561 |
layer.load(); |
|
1562 |
|
|
1563 |
this.addLayer(layer); |
|
1564 |
logger.debug("layer: "+ layer.getName() +" loaded"); |
|
1565 |
// Comprobar que la proyecci?n es la misma que la de FMap |
|
1566 |
// Si no lo es, es una capa que est? reproyectada al vuelo |
|
1567 |
IProjection proj = layer.getProjection(); |
|
1568 |
if ((proj != null)) |
|
1569 |
if (proj != getMapContext().getProjection()) |
|
1570 |
{ |
|
1571 |
ICoordTrans ct = proj.getCT(getMapContext().getProjection()); |
|
1572 |
// TODO: REVISAR CON LUIS |
|
1573 |
// Se lo fijamos a todas, luego cada una que se reproyecte |
|
1574 |
// si puede, o que no haga nada |
|
1575 |
layer.setCoordTrans(ct); |
|
1576 |
|
|
1577 |
} |
|
1578 |
}catch (Exception e) { |
|
1579 |
fmap.addLayerError(xml.getStringProperty("name")); |
|
1580 |
logger.debug(Messages.getString("could_not_load_layer")+": "+xml.getStringProperty("name") + ".\n" |
|
1581 |
+Messages.getString("reason")+":", e); |
|
1582 |
} |
|
1510 |
// FLayer layer = null;
|
|
1511 |
// |
|
1512 |
// |
|
1513 |
// try {
|
|
1514 |
// String className = xml.getStringProperty("className");
|
|
1515 |
// Class clazz = Class.forName(className);
|
|
1516 |
// if (clazz.isAssignableFrom(FLayers.class)) {
|
|
1517 |
// layer = (FLayer) clazz.newInstance();
|
|
1518 |
// ((FLayers)layer).setMapContext(getMapContext());
|
|
1519 |
// ((FLayers)layer).setParentLayer(this);
|
|
1520 |
// // if (className.equals((FLayers.class.getName()))){
|
|
1521 |
// // layer = new FLayers(getMapContext(),this);
|
|
1522 |
// } else {
|
|
1523 |
// // Por compatibilidad
|
|
1524 |
// if (className.equals(FLyrVect.class.getName())) {
|
|
1525 |
// if (xml.contains("file")) {
|
|
1526 |
// layer = new FLayerFileVectorial();
|
|
1527 |
// } else if (xml.contains("db")) {
|
|
1528 |
// try {
|
|
1529 |
// layer = (FLayer)((ExtensionPoint)ExtensionPointsSingleton.getInstance().get("Layers")).create("com.iver.cit.gvsig.fmap.layers.FLayerJDBCVectorial");
|
|
1530 |
// } catch (Exception e) {
|
|
1531 |
// throw new XMLException(new Exception("No se tiene registrada la capa de tipo JDBC"));
|
|
1532 |
// }
|
|
1533 |
// //className = FLayerJDBCVectorial.class.getName();
|
|
1534 |
// } else if (xml.contains("other")){
|
|
1535 |
// layer = new FLayerGenericVectorial();
|
|
1536 |
// } else {
|
|
1537 |
// throw new XMLException(new Exception("Capa vectorial de tipo no reconocido"));
|
|
1538 |
// }
|
|
1539 |
// // Fin por compatibilidad
|
|
1540 |
// } else {
|
|
1541 |
// try {
|
|
1542 |
// layer = (FLayer)(((ExtensionPoint)ExtensionPointsSingleton.getInstance().get("Layers")).create(className));
|
|
1543 |
// } catch (Exception e) {
|
|
1544 |
// //puende que no este registrada como punto de extension
|
|
1545 |
// Class clase = Class.forName(className);
|
|
1546 |
// layer = (FLayer) clase.newInstance();
|
|
1547 |
// // FIXME: Hacemos algo aqui o dejamos que suba el error?
|
|
1548 |
// }
|
|
1549 |
// }
|
|
1550 |
// |
|
1551 |
// }
|
|
1552 |
// layer.setXMLEntity(xml);
|
|
1553 |
// if (name != null) layer.setName(name);
|
|
1554 |
// layer.load();
|
|
1555 |
// |
|
1556 |
// this.addLayer(layer);
|
|
1557 |
// logger.debug("layer: "+ layer.getName() +" loaded");
|
|
1558 |
// // Comprobar que la proyecci?n es la misma que la de FMap
|
|
1559 |
// // Si no lo es, es una capa que est? reproyectada al vuelo
|
|
1560 |
// IProjection proj = layer.getProjection();
|
|
1561 |
// if ((proj != null))
|
|
1562 |
// if (proj != getMapContext().getProjection())
|
|
1563 |
// {
|
|
1564 |
// ICoordTrans ct = proj.getCT(getMapContext().getProjection());
|
|
1565 |
// // TODO: REVISAR CON LUIS
|
|
1566 |
// // Se lo fijamos a todas, luego cada una que se reproyecte
|
|
1567 |
// // si puede, o que no haga nada
|
|
1568 |
// layer.setCoordTrans(ct);
|
|
1569 |
// |
|
1570 |
// }
|
|
1571 |
// }catch (Exception e) {
|
|
1572 |
// fmap.addLayerError(xml.getStringProperty("name"));
|
|
1573 |
// logger.debug(Messages.getString("could_not_load_layer")+": "+xml.getStringProperty("name") + ".\n"
|
|
1574 |
// +Messages.getString("reason")+":", e);
|
|
1575 |
// }
|
|
1583 | 1576 |
} |
1584 | 1577 |
} |
branches/v2_0_0_prep/libraries/libFMap/src/org/gvsig/fmap/mapcontext/layers/vectorial/FLyrAnnotation.java | ||
---|---|---|
1 |
package org.gvsig.fmap.mapcontext.layers.vectorial; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.Font; |
|
5 |
import java.awt.Graphics2D; |
|
6 |
import java.awt.geom.Point2D; |
|
7 |
import java.awt.geom.Rectangle2D; |
|
8 |
import java.awt.image.BufferedImage; |
|
9 |
import java.util.ArrayList; |
|
10 |
import java.util.Iterator; |
|
11 |
|
|
12 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
13 |
|
|
14 |
import org.cresques.cts.ICoordTrans; |
|
15 |
import org.cresques.cts.IProjection; |
|
16 |
import org.gvsig.fmap.core.geometries.IGeometry; |
|
17 |
import org.gvsig.fmap.core.geometries.utils.FLabel; |
|
18 |
import org.gvsig.fmap.crs.CRSFactory; |
|
19 |
import org.gvsig.fmap.datasources.SelectableDataSource; |
|
20 |
import org.gvsig.fmap.drivers.exceptions.ExpansionFileReadException; |
|
21 |
import org.gvsig.fmap.drivers.exceptions.VisitorException; |
|
22 |
import org.gvsig.fmap.drivers.iterators.spatialindex.QuadtreeJts; |
|
23 |
import org.gvsig.fmap.drivers.reading.BoundedShapes; |
|
24 |
import org.gvsig.fmap.drivers.reading.DriverAttributes; |
|
25 |
import org.gvsig.fmap.drivers.writing.adapters.AnnotationEditableAdapter; |
|
26 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
27 |
import org.gvsig.fmap.mapcontext.exceptions.LegendLayerException; |
|
28 |
import org.gvsig.fmap.mapcontext.exceptions.StartEditionLayerException; |
|
29 |
import org.gvsig.fmap.mapcontext.layers.FBitSet; |
|
30 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
31 |
import org.gvsig.fmap.mapcontext.layers.FLyrDefault; |
|
32 |
import org.gvsig.fmap.mapcontext.layers.MappingAnnotation; |
|
33 |
import org.gvsig.fmap.mapcontext.layers.ReadableVectorial; |
|
34 |
import org.gvsig.fmap.mapcontext.layers.XMLException; |
|
35 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
36 |
import org.gvsig.fmap.mapcontext.rendering.legend.VectorialUniqueValueLegend; |
|
37 |
import org.gvsig.fmap.mapcontext.rendering.strategies.AnnotationStrategy; |
|
38 |
import org.gvsig.fmap.mapcontext.rendering.strategies.Strategy; |
|
39 |
import org.gvsig.fmap.mapcontext.rendering.strategies.StrategyManager; |
|
40 |
import org.gvsig.fmap.mapcontext.rendering.symbols.FSymbol; |
|
41 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
42 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ITextSymbol; |
|
43 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory; |
|
44 |
|
|
45 |
import com.hardcode.gdbms.driver.exceptions.InitializeDriverException; |
|
46 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
47 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
|
48 |
import com.hardcode.gdbms.engine.values.IntValue; |
|
49 |
import com.hardcode.gdbms.engine.values.NullValue; |
|
50 |
import com.hardcode.gdbms.engine.values.NumericValue; |
|
51 |
import com.hardcode.gdbms.engine.values.StringValue; |
|
52 |
import com.hardcode.gdbms.engine.values.Value; |
|
53 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
|
54 |
import com.iver.utiles.XMLEntity; |
|
55 |
import com.iver.utiles.swing.threads.Cancellable; |
|
56 |
|
|
57 |
/** |
|
58 |
* DOCUMENT ME! |
|
59 |
* |
|
60 |
* @author Vicente Caballero Navarro |
|
61 |
*/ |
|
62 |
public class FLyrAnnotation extends FLyrVect { |
|
63 |
private MappingAnnotation mapping = null; |
|
64 |
|
|
65 |
private ArrayList m_labels; |
|
66 |
|
|
67 |
private int indexEditing = -1; |
|
68 |
|
|
69 |
private boolean inPixels; |
|
70 |
private VectorialUniqueValueLegend vuvl=new VectorialUniqueValueLegend(); |
|
71 |
private Strategy strategy=null; |
|
72 |
/** |
|
73 |
* Crea un nuevo FLyrAnnotation. |
|
74 |
*/ |
|
75 |
public FLyrAnnotation() { |
|
76 |
super(); |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* DOCUMENT ME! |
|
81 |
* |
|
82 |
* @param mapping |
|
83 |
* DOCUMENT ME! |
|
84 |
*/ |
|
85 |
public void setMapping(MappingAnnotation mapping) { |
|
86 |
this.mapping = mapping; |
|
87 |
try { |
|
88 |
setLegend(); |
|
89 |
createLabels(); |
|
90 |
} catch (ReadDriverException e) { |
|
91 |
e.printStackTrace(); |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
95 |
/** |
|
96 |
* DOCUMENT ME! |
|
97 |
* |
|
98 |
* @return DOCUMENT ME! |
|
99 |
*/ |
|
100 |
public MappingAnnotation getMapping() { |
|
101 |
return mapping; |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* @see com.iver.cit.gvsig.fmap.layers.LayerOperations#draw(java.awt.image.BufferedImage, |
|
106 |
* ISymbol) |
|
107 |
*/ |
|
108 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
109 |
Cancellable cancel, double scale) throws ReadDriverException { |
|
110 |
if (isWithinScale(scale)) { |
|
111 |
// Las que solo tienen etiquetado sin pintar el shape, |
|
112 |
// no pasamos por ellas |
|
113 |
boolean bDrawShapes = true; |
|
114 |
|
|
115 |
if (bDrawShapes) { |
|
116 |
if (strategy == null){ |
|
117 |
strategy = (AnnotationStrategy) StrategyManager |
|
118 |
.getStrategy(this); |
|
119 |
} |
|
120 |
try { |
|
121 |
g.setColor(Color.black); |
|
122 |
strategy.draw(image, g, viewPort, cancel); |
|
123 |
if (getISpatialIndex()==null && !isEditing()) { |
|
124 |
createSpatialIndex(); |
|
125 |
} |
|
126 |
} catch (ReadDriverException e) { |
|
127 |
this.setVisible(false); |
|
128 |
this.setActive(false); |
|
129 |
throw e; |
|
130 |
} |
|
131 |
} |
|
132 |
|
|
133 |
if (getVirtualLayers() != null) { |
|
134 |
getVirtualLayers().draw(image, g, viewPort, cancel, scale); |
|
135 |
} |
|
136 |
} |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* @throws ReadDriverException |
|
141 |
* @throws ExpansionFileReadException |
|
142 |
* @see com.iver.cit.gvsig.fmap.layers.LayerOperations#getFullExtent() |
|
143 |
*/ |
|
144 |
public Rectangle2D getFullExtent() throws ReadDriverException, ExpansionFileReadException { |
|
145 |
Rectangle2D rAux; |
|
146 |
// logger.debug("source.start()"); |
|
147 |
try { |
|
148 |
getSource().start(); |
|
149 |
} catch (InitializeDriverException e) { |
|
150 |
throw new ReadDriverException(getName(),e); |
|
151 |
} |
|
152 |
rAux = getSource().getFullExtent(); |
|
153 |
// logger.debug("source.stop()"); |
|
154 |
getSource().stop(); |
|
155 |
// Si existe reproyecci?n, reproyectar el extent |
|
156 |
ICoordTrans ct = getCoordTrans(); |
|
157 |
if (ct != null) { |
|
158 |
Point2D pt1 = new Point2D.Double(rAux.getMinX(), rAux.getMinY()); |
|
159 |
Point2D pt2 = new Point2D.Double(rAux.getMaxX(), rAux.getMaxY()); |
|
160 |
pt1 = ct.convert(pt1, null); |
|
161 |
pt2 = ct.convert(pt2, null); |
|
162 |
rAux = new Rectangle2D.Double(); |
|
163 |
rAux.setFrameFromDiagonal(pt1, pt2); |
|
164 |
} |
|
165 |
return rAux; |
|
166 |
} |
|
167 |
|
|
168 |
/** |
|
169 |
* @see org.gvsig.fmap.mapcontext.layers.FLayer#print(java.awt.Graphics2D, |
|
170 |
* org.gvsig.fmap.mapcontext.ViewPort, |
|
171 |
* com.iver.utiles.swing.threads.Cancellable) |
|
172 |
*/ |
|
173 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
|
174 |
double scale, PrintRequestAttributeSet properties) throws ReadDriverException { |
|
175 |
if (isVisible() && isWithinScale(scale)) { |
|
176 |
Strategy strategy = StrategyManager.getStrategy(this); |
|
177 |
strategy.print(g, viewPort, cancel, properties); |
|
178 |
} |
|
179 |
} |
|
180 |
|
|
181 |
/* |
|
182 |
* (non-Javadoc) |
|
183 |
* |
|
184 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.RandomVectorialData#queryByRect(java.awt.geom.Rectangle2D) |
|
185 |
*/ |
|
186 |
public FBitSet queryByRect(Rectangle2D rect) throws ReadDriverException, VisitorException { |
|
187 |
Strategy s = StrategyManager.getStrategy(this); |
|
188 |
|
|
189 |
return s.queryByRect(rect); |
|
190 |
} |
|
191 |
|
|
192 |
/** |
|
193 |
* DOCUMENT ME! |
|
194 |
* |
|
195 |
* @param p |
|
196 |
* DOCUMENT ME! |
|
197 |
* @param tolerance |
|
198 |
* DOCUMENT ME! |
|
199 |
* |
|
200 |
* @return DOCUMENT ME! |
|
201 |
* @throws DriverException |
|
202 |
* DOCUMENT ME! |
|
203 |
*/ |
|
204 |
public FBitSet queryByPoint(Point2D p, double tolerance) |
|
205 |
throws ReadDriverException, VisitorException { |
|
206 |
Strategy s = StrategyManager.getStrategy(this); |
|
207 |
|
|
208 |
return s.queryByPoint(p, tolerance); |
|
209 |
} |
|
210 |
|
|
211 |
/** |
|
212 |
* DOCUMENT ME! |
|
213 |
* |
|
214 |
* @param g |
|
215 |
* DOCUMENT ME! |
|
216 |
* @param relationship |
|
217 |
* DOCUMENT ME! |
|
218 |
* |
|
219 |
* @return FBitset |
|
220 |
*/ |
|
221 |
public FBitSet queryByShape(IGeometry g, int relationship) |
|
222 |
throws ReadDriverException, VisitorException { |
|
223 |
Strategy s = StrategyManager.getStrategy(this); |
|
224 |
|
|
225 |
return s.queryByShape(g, relationship); |
|
226 |
} |
|
227 |
|
|
228 |
/** |
|
229 |
* DOCUMENT ME! |
|
230 |
* |
|
231 |
* @return DOCUMENT ME! |
|
232 |
* |
|
233 |
* @throws XMLException |
|
234 |
* |
|
235 |
* @see org.gvsig.fmap.mapcontext.layers.FLayer#getProperties() |
|
236 |
*/ |
|
237 |
public XMLEntity getXMLEntity() throws XMLException { |
|
238 |
XMLEntity xml = super.getXMLEntity(); |
|
239 |
xml.addChild(mapping.getXMLEntity()); |
|
240 |
xml.putProperty("isInPixels", isInPixels()); |
|
241 |
|
|
242 |
return xml; |
|
243 |
} |
|
244 |
|
|
245 |
/** |
|
246 |
* @see org.gvsig.fmap.mapcontext.layers.FLyrDefault#setXMLEntity(com.iver.utiles.XMLEntity) |
|
247 |
*/ |
|
248 |
public void setXMLEntity(XMLEntity xml) throws XMLException { |
|
249 |
Iterator iter=xml.findChildren("className",MappingAnnotation.class.getName()); |
|
250 |
if (iter.hasNext()) |
|
251 |
mapping = MappingAnnotation.createFromXML((XMLEntity)iter.next()); |
|
252 |
else{ |
|
253 |
//Este else para versiones anteriores a la 1.0.2.(908) |
|
254 |
if (xml.getChildrenCount()==3) |
|
255 |
mapping = MappingAnnotation.createFromXML(xml.getChild(2)); |
|
256 |
else |
|
257 |
mapping = MappingAnnotation.createFromXML(xml.getChild(3)); |
|
258 |
} |
|
259 |
setInPixels(xml.getBooleanProperty("isInPixels")); |
|
260 |
|
|
261 |
IProjection proj = null; |
|
262 |
|
|
263 |
if (xml.contains("proj")) { |
|
264 |
proj = CRSFactory.getCRS(xml.getStringProperty("proj")); |
|
265 |
} |
|
266 |
|
|
267 |
// VectorialAdapter adapter=null; |
|
268 |
// if (xml.contains("file")){ |
|
269 |
// adapter = new VectorialFileAdapter(new File(xml |
|
270 |
// .getStringProperty("file"))); |
|
271 |
// }else if (xml.contains("db")){ |
|
272 |
// adapter = new VectorialDBAdapter(); |
|
273 |
// } |
|
274 |
// Driver d; |
|
275 |
// |
|
276 |
// try { |
|
277 |
// d = LayerFactory.getDM().getDriver( |
|
278 |
// xml.getStringProperty("driverName")); |
|
279 |
// } catch (DriverLoadException e1) { |
|
280 |
// throw new XMLException(e1); |
|
281 |
// } |
|
282 |
// |
|
283 |
// adapter.setDriver((VectorialDriver) d); |
|
284 |
// // TODO Meter esto dentro de la comprobaci?n de si hay memoria |
|
285 |
// if (false) { |
|
286 |
// } else { |
|
287 |
// setSource(adapter); |
|
288 |
// setProjection(proj); |
|
289 |
// } |
|
290 |
|
|
291 |
// Le asignamos tambi?n una legenda por defecto acorde con |
|
292 |
// el tipo de shape que tenga. Tampoco s? si es aqu? el |
|
293 |
// sitio adecuado, pero en fin.... |
|
294 |
/* |
|
295 |
* if (d instanceof WithDefaultLegend) { WithDefaultLegend aux = |
|
296 |
* (WithDefaultLegend) d; adapter.start(); setLegend((VectorialLegend) |
|
297 |
* aux.getDefaultLegend()); adapter.stop(); } else { |
|
298 |
* setLegend(LegendFactory.createSingleSymbolLegend(getShapeType())); } |
|
299 |
*/ |
|
300 |
|
|
301 |
super.setXMLEntity(xml); |
|
302 |
try { |
|
303 |
createLabels(); |
|
304 |
} catch (ReadDriverException e) { |
|
305 |
e.printStackTrace(); |
|
306 |
} |
|
307 |
} |
|
308 |
|
|
309 |
/** |
|
310 |
* Esto tiene el fallo de que obligas a una etiqueta por entidad, para poder |
|
311 |
* evitar esto, una posible soluci?n ser?a que un FLabel pudiera ser una |
|
312 |
* colecci?n de FLabel (Patr?n Composite) |
|
313 |
* |
|
314 |
* @param lyrVect |
|
315 |
* @throws ReadDriverException |
|
316 |
* @throws DriverException |
|
317 |
*/ |
|
318 |
private void createLabels() throws ReadDriverException{ |
|
319 |
SelectableDataSource ds = getRecordset(); |
|
320 |
try { |
|
321 |
ReadableVectorial adapter = getSource(); |
|
322 |
adapter.start(); |
|
323 |
ds.start(); |
|
324 |
int sc; |
|
325 |
// El mapping[0] es el text |
|
326 |
int fieldId = mapping.getColumnText(); |
|
327 |
// El mapping[1] es el ?ngulo |
|
328 |
int idFieldRotationText = mapping.getColumnRotate(); |
|
329 |
// El mapping[2] es el color |
|
330 |
int idFieldColorText = mapping.getColumnColor(); |
|
331 |
// El mapping[3] es el alto |
|
332 |
int idFieldHeightText = mapping.getColumnHeight(); |
|
333 |
// El mapping[4] es el tipo de fuente |
|
334 |
int idFieldTypeFontText = mapping.getColumnTypeFont(); |
|
335 |
// El mapping[5] es el estilo de fuente |
|
336 |
int idFieldStyleFontText = mapping.getColumnStyleFont(); |
|
337 |
|
|
338 |
sc = (int) ds.getRowCount(); |
|
339 |
m_labels = new ArrayList(sc); |
|
340 |
DriverAttributes attr = adapter.getDriverAttributes(); |
|
341 |
boolean bMustClone = false; |
|
342 |
if (attr != null) { |
|
343 |
if (attr.isLoadedInMemory()) { |
|
344 |
bMustClone = attr.isLoadedInMemory(); |
|
345 |
} |
|
346 |
} |
|
347 |
ICoordTrans ct = getCoordTrans(); |
|
348 |
FSymbol defaultSym = (FSymbol) getLegend().getDefaultSymbol(); |
|
349 |
for (int i = 0; i < sc; i++) { |
|
350 |
IGeometry geom = adapter.getGeometry(i); |
|
351 |
|
|
352 |
if (geom == null) { |
|
353 |
m_labels.add(null); |
|
354 |
continue; |
|
355 |
} |
|
356 |
if (ct != null) { |
|
357 |
if (bMustClone) |
|
358 |
geom = geom.cloneGeometry(); |
|
359 |
geom.reProject(ct); |
|
360 |
} |
|
361 |
|
|
362 |
// TODO: El m?todo contenedor (createLabelLayer) debe recoger |
|
363 |
// los par?metros de posicionamiento y de allowDuplicates |
|
364 |
// if (i >= 328) |
|
365 |
// System.out.println("i= " + i + " " + val.toString()); |
|
366 |
//ArrayList values=new ArrayList(4); |
|
367 |
String t=new String(); |
|
368 |
Value val = ds.getFieldValue(i, fieldId); |
|
369 |
t=val.toString(); |
|
370 |
//values.add(val); |
|
371 |
if (idFieldColorText!=-1){ |
|
372 |
Value valColor=ds.getFieldValue(i,idFieldColorText); |
|
373 |
t=t.concat(valColor.toString()); |
|
374 |
//values.add(valColor); |
|
375 |
} |
|
376 |
if (idFieldTypeFontText!=-1){ |
|
377 |
Value valTypeFont=ds.getFieldValue(i,idFieldTypeFontText); |
|
378 |
t=t.concat(valTypeFont.toString()); |
|
379 |
//values.add(valTypeFont); |
|
380 |
} |
|
381 |
|
|
382 |
if (idFieldStyleFontText!=-1){ |
|
383 |
Value valStyleFont=ds.getFieldValue(i,idFieldStyleFontText); |
|
384 |
t=t.concat(valStyleFont.toString()); |
|
385 |
//values.add(valStyleFont); |
|
386 |
} |
|
387 |
//Value total=ValueFactory.createValue((Value[])values.toArray(new Value[0])); |
|
388 |
Value total=ValueFactory.createValue(t); |
|
389 |
if ((val instanceof NullValue) || (val == null)) { |
|
390 |
m_labels.add(null); |
|
391 |
continue; |
|
392 |
} |
|
393 |
FLabel[] lbls = geom.createLabels(0, true); |
|
394 |
for (int j = 0; j < lbls.length; j++) { |
|
395 |
if (lbls[j] != null) { |
|
396 |
lbls[j].setString(val.toString()); |
|
397 |
if (idFieldRotationText != -1) { |
|
398 |
NumericValue rotation = (NumericValue) ds |
|
399 |
.getFieldValue(i, idFieldRotationText); |
|
400 |
lbls[j].setRotation(rotation.doubleValue()); |
|
401 |
} else { |
|
402 |
lbls[j].setRotation(defaultSym.getRotation()); |
|
403 |
} |
|
404 |
|
|
405 |
float height; |
|
406 |
if (idFieldHeightText != -1) { |
|
407 |
NumericValue h = (NumericValue) ds |
|
408 |
.getFieldValue(i, idFieldHeightText); |
|
409 |
height=h.floatValue(); |
|
410 |
lbls[j].setHeight(height); |
|
411 |
} else { |
|
412 |
height=defaultSym.getFontSize(); |
|
413 |
lbls[j].setHeight(height); |
|
414 |
} |
|
415 |
|
|
416 |
|
|
417 |
|
|
418 |
if (vuvl.getSymbolByValue(total)==null){ |
|
419 |
Color color; |
|
420 |
if (idFieldColorText != -1) { |
|
421 |
NumericValue c = (NumericValue) ds.getFieldValue( |
|
422 |
i, idFieldColorText); |
|
423 |
color=new Color(c.intValue()); |
|
424 |
} else { |
|
425 |
color=defaultSym.getFontColor(); |
|
426 |
} |
|
427 |
String typeFont; |
|
428 |
if (idFieldTypeFontText != -1) { |
|
429 |
StringValue tf = (StringValue) ds |
|
430 |
.getFieldValue(i, idFieldTypeFontText); |
|
431 |
typeFont=tf.getValue(); |
|
432 |
} else { |
|
433 |
typeFont=defaultSym.getFont().getFontName(); |
|
434 |
} |
|
435 |
int style; |
|
436 |
if (idFieldStyleFontText != -1) { |
|
437 |
IntValue sf = (IntValue) ds |
|
438 |
.getFieldValue(i, idFieldStyleFontText); |
|
439 |
style = sf.getValue(); |
|
440 |
} else { |
|
441 |
style = defaultSym.getFont().getStyle(); |
|
442 |
} |
|
443 |
//FSymbol symbol=new FSymbol(FConstant.SYMBOL_TYPE_TEXT); |
|
444 |
|
|
445 |
ITextSymbol symbol; |
|
446 |
|
|
447 |
symbol = SymbologyFactory.createDefaultTextSymbol(); |
|
448 |
|
|
449 |
// casca perque ara ?s un ITextSymbol |
|
450 |
// symbol.setFontSizeInPixels(isInPixels()); |
|
451 |
symbol.setFont(new Font(typeFont, style, (int)height)); |
|
452 |
symbol.setDescription(lbls[j].getString()); |
|
453 |
//symbol.setFontColor(color); |
|
454 |
symbol.setTextColor(color); |
|
455 |
vuvl.addSymbol(total,symbol); |
|
456 |
} |
|
457 |
|
|
458 |
} |
|
459 |
m_labels.add(lbls[j]); |
|
460 |
|
|
461 |
} |
|
462 |
} |
|
463 |
|
|
464 |
ds.stop(); |
|
465 |
adapter.stop(); |
|
466 |
} catch (ExpansionFileReadException e) { |
|
467 |
throw new ReadDriverException(getName(),e); |
|
468 |
} catch (InitializeDriverException e) { |
|
469 |
throw new ReadDriverException(getName(),e); |
|
470 |
} |
|
471 |
|
|
472 |
} |
|
473 |
|
|
474 |
public FLabel getLabel(int numReg) { |
|
475 |
if (m_labels == null || numReg == -1) |
|
476 |
return null; |
|
477 |
if (getSource() instanceof AnnotationEditableAdapter){ |
|
478 |
AnnotationEditableAdapter aea=((AnnotationEditableAdapter)getSource()); |
|
479 |
return aea.getLabel(numReg,false); |
|
480 |
} |
|
481 |
return (FLabel)m_labels.get(numReg); |
|
482 |
} |
|
483 |
|
|
484 |
/* |
|
485 |
* (non-Javadoc) |
|
486 |
* |
|
487 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.RandomVectorialData#createIndex() |
|
488 |
*/ |
|
489 |
public void createSpatialIndex() { |
|
490 |
// FJP: ESTO HABR? QUE CAMBIARLO. PARA LAS CAPAS SECUENCIALES, TENDREMOS |
|
491 |
// QUE ACCEDER CON UN WHILE NEXT. (O mejorar lo de los FeatureVisitor |
|
492 |
// para que acepten recorrer sin geometria, solo con rectangulos. |
|
493 |
|
|
494 |
//AZABALA: Como no tengo claro de donde se crean las capas de textos |
|
495 |
//el ?ndice espacial creado seguir? siendo el Quadtree en memoria |
|
496 |
//de JTS (QuadtreeJts es un adapter a nuestra api de indices) |
|
497 |
spatialIndex = new QuadtreeJts(); |
|
498 |
ReadableVectorial va = getSource(); |
|
499 |
ICoordTrans ct = getCoordTrans(); |
|
500 |
BoundedShapes shapeBounds = (BoundedShapes) va.getDriver(); |
|
501 |
try { |
|
502 |
va.start(); |
|
503 |
|
|
504 |
for (int i = 0; i < va.getShapeCount(); i++) { |
|
505 |
Rectangle2D r = null; |
|
506 |
FLabel label=getLabel(i); |
|
507 |
if (label != null) { |
|
508 |
r = label.getBoundBox(); |
|
509 |
} else { |
|
510 |
r = shapeBounds.getShapeBounds(i); |
|
511 |
} |
|
512 |
// TODO: MIRAR COMO SE TRAGAR?A ESTO LO DE LAS REPROYECCIONES |
|
513 |
if (ct != null) { |
|
514 |
r = ct.convert(r); |
|
515 |
} |
|
516 |
if (r != null) { |
|
517 |
// Coordinate c1 = new Coordinate(r.getMinX(), r.getMinY()); |
|
518 |
// Coordinate c2 = new Coordinate(r.getMaxX(), r.getMaxY()); |
|
519 |
// Envelope env = new Envelope(c1, c2); |
|
520 |
// spatialIndex.insert(env, new Integer(i)); |
|
521 |
spatialIndex.insert(r, i); |
|
522 |
} |
|
523 |
} // for |
|
524 |
va.stop(); |
|
525 |
} catch (ReadDriverException e) { |
|
526 |
e.printStackTrace(); |
|
527 |
} |
|
528 |
} |
|
529 |
|
|
530 |
public void setSelectedEditing() throws ReadDriverException { |
|
531 |
FBitSet bitSet = getRecordset().getSelection(); |
|
532 |
if (bitSet.cardinality() == 0) |
|
533 |
return; |
|
534 |
indexEditing = bitSet.nextSetBit(0); |
|
535 |
} |
|
536 |
|
|
537 |
public void setInPixels(boolean b) { |
|
538 |
inPixels = b; |
|
539 |
} |
|
540 |
|
|
541 |
public boolean isInPixels() { |
|
542 |
return inPixels; |
|
543 |
} |
|
544 |
|
|
545 |
public void setInEdition(int i) { |
|
546 |
indexEditing = i; |
|
547 |
|
|
548 |
} |
|
549 |
|
|
550 |
public int getInEdition() { |
|
551 |
return indexEditing; |
|
552 |
} |
|
553 |
|
|
554 |
public ArrayList getLabels() { |
|
555 |
return m_labels; |
|
556 |
} |
|
557 |
|
|
558 |
|
|
559 |
public void setLegend() { |
|
560 |
try { |
|
561 |
getSource().getRecordset().start(); |
|
562 |
vuvl.setClassifyingFieldNames( |
|
563 |
new String[] { |
|
564 |
getSource().getRecordset().getFieldName(mapping.getColumnText()) |
|
565 |
} |
|
566 |
); |
|
567 |
|
|
568 |
// vuvl.setDefaultSymbol(new FSymbol(FConstant.SYMBOL_TYPE_TEXT)); |
|
569 |
vuvl.setDefaultSymbol(SymbologyFactory.createDefaultTextSymbol()); |
|
570 |
setLegend((IVectorLegend) vuvl); |
|
571 |
getSource().getRecordset().stop(); |
|
572 |
} catch (LegendLayerException e) { |
|
573 |
e.printStackTrace(); |
|
574 |
} catch (ReadDriverException e) { |
|
575 |
e.printStackTrace(); |
|
576 |
} |
|
577 |
|
|
578 |
} |
|
579 |
|
|
580 |
public Strategy getStrategy() { |
|
581 |
return strategy; |
|
582 |
} |
|
583 |
public void setEditing(boolean b) throws StartEditionLayerException { |
|
584 |
super.setEditing(b); |
|
585 |
deleteSpatialIndex(); |
|
586 |
} |
|
587 |
|
|
588 |
public static FLayer createLayerFromVect(FLyrVect layer) throws ReadDriverException, LegendLayerException{ |
|
589 |
FLyrAnnotation la=new FLyrAnnotation(); |
|
590 |
la.setSource(layer.getSource()); |
|
591 |
la.setRecordset(layer.getRecordset()); |
|
592 |
la.setProjection(layer.getProjection()); |
|
593 |
la.setLegend((IVectorLegend)layer.getLegend()); |
|
594 |
return la; |
|
595 |
} |
|
596 |
} |
branches/v2_0_0_prep/libraries/libFMap/src/org/gvsig/fmap/mapcontext/layers/vectorial/FLayerGenericVectorial.java | ||
---|---|---|
1 |
package org.gvsig.fmap.mapcontext.layers.vectorial; |
|
2 |
|
|
3 |
import org.cresques.cts.IProjection; |
|
4 |
import org.gvsig.fmap.crs.CRSFactory; |
|
5 |
import org.gvsig.fmap.drivers.reading.VectorialDriver; |
|
6 |
import org.gvsig.fmap.drivers.reading.WithDefaultLegend; |
|
7 |
import org.gvsig.fmap.drivers.reading.adapters.VectorialAdapter; |
|
8 |
import org.gvsig.fmap.drivers.reading.adapters.VectorialDefaultAdapter; |
|
9 |
import org.gvsig.fmap.mapcontext.exceptions.DriverLayerException; |
|
10 |
import org.gvsig.fmap.mapcontext.exceptions.LegendLayerException; |
|
11 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
12 |
import org.gvsig.fmap.mapcontext.exceptions.NameLayerException; |
|
13 |
import org.gvsig.fmap.mapcontext.exceptions.ProjectionLayerException; |
|
14 |
import org.gvsig.fmap.mapcontext.exceptions.XMLLayerException; |
|
15 |
import org.gvsig.fmap.mapcontext.layers.LayerFactory; |
|
16 |
import org.gvsig.fmap.mapcontext.layers.XMLException; |
|
17 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
18 |
import org.gvsig.fmap.mapcontext.rendering.legend.LegendFactory; |
|
19 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.AttrInTableLabelingStrategy; |
|
20 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingStrategy; |
|
21 |
|
|
22 |
import com.hardcode.driverManager.DriverLoadException; |
|
23 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
24 |
import com.iver.utiles.IPersistence; |
|
25 |
import com.iver.utiles.XMLEntity; |
|
26 |
|
|
27 |
public class FLayerGenericVectorial extends FLyrVect { |
|
28 |
private boolean loaded = false; |
|
29 |
|
|
30 |
private VectorialDriver vDriver = null; |
|
31 |
|
|
32 |
|
|
33 |
/* Esto deberia ir en el FLyrDefault */ |
|
34 |
public void setProjectionByName(String projectionName) throws Exception{ |
|
35 |
IProjection proj = CRSFactory.getCRS(projectionName); |
|
36 |
if (proj == null) { |
|
37 |
throw new Exception("No se ha encontrado la proyeccion: "+ projectionName); |
|
38 |
} |
|
39 |
this.setProjection(proj); |
|
40 |
|
|
41 |
} |
|
42 |
|
|
43 |
|
|
44 |
public void setDriver(VectorialDriver vDriver) { |
|
45 |
this.vDriver = vDriver; |
|
46 |
} |
|
47 |
|
|
48 |
public VectorialDriver getDriver() { |
|
49 |
return this.vDriver ; |
|
50 |
} |
|
51 |
|
|
52 |
public void setDriverByName(String driverName) throws DriverLoadException { |
|
53 |
this.setDriver( |
|
54 |
(VectorialDriver)LayerFactory.getDM().getDriver(driverName) |
|
55 |
); |
|
56 |
} |
|
57 |
|
|
58 |
|
|
59 |
/* Esto deberia ir en FLyrVect */ |
|
60 |
private void initializeLegendDefault() throws LegendLayerException, ReadDriverException { |
|
61 |
if (this.getLegend() == null) { |
|
62 |
if (this.getRecordset().getDriver() instanceof WithDefaultLegend) { |
|
63 |
WithDefaultLegend aux = (WithDefaultLegend) this.getRecordset().getDriver(); |
|
64 |
this.setLegend((IVectorLegend) aux.getDefaultLegend()); |
|
65 |
|
|
66 |
ILabelingStrategy labeler = aux.getDefaultLabelingStrategy(); |
|
67 |
if (labeler instanceof AttrInTableLabelingStrategy) { |
|
68 |
((AttrInTableLabelingStrategy) labeler).setLayer(this); |
|
69 |
} |
|
70 |
|
|
71 |
this.setLabelingStrategy(labeler); |
|
72 |
} else { |
|
73 |
this.setLegend(LegendFactory.createSingleSymbolLegend( |
|
74 |
this.getShapeType())); |
|
75 |
} |
|
76 |
} |
|
77 |
} |
|
78 |
/* FIXME: esto tendria que tener declarado un throws de algo*/ |
|
79 |
public void wakeUp() throws LoadLayerException { |
|
80 |
if (!loaded) { |
|
81 |
this.load(); |
|
82 |
} |
|
83 |
|
|
84 |
} |
|
85 |
|
|
86 |
|
|
87 |
public void load() throws LoadLayerException { |
|
88 |
if (this.getName() == null || this.getName().length() == 0) { |
|
89 |
this.setAvailable(false); |
|
90 |
throw new NameLayerException(getName(),null); |
|
91 |
} |
|
92 |
if (this.vDriver == null) { |
|
93 |
this.setAvailable(false); |
|
94 |
throw new DriverLayerException(getName(),null); |
|
95 |
} |
|
96 |
if (this.getProjection() == null) { |
|
97 |
this.setAvailable(false); |
|
98 |
throw new ProjectionLayerException(getName(),null); |
|
99 |
} |
|
100 |
|
|
101 |
VectorialAdapter adapter = null; |
|
102 |
adapter = new VectorialDefaultAdapter(); |
|
103 |
adapter.setDriver(this.vDriver); |
|
104 |
this.setSource(adapter); |
|
105 |
|
|
106 |
try { |
|
107 |
this.putLoadSelection(); |
|
108 |
this.putLoadLegend(); |
|
109 |
this.initializeLegendDefault(); |
|
110 |
|
|
111 |
} catch (LegendLayerException e) { |
|
112 |
this.setAvailable(false); |
|
113 |
throw new LegendLayerException(getName(),e); |
|
114 |
} catch (XMLException e) { |
|
115 |
this.setAvailable(false); |
|
116 |
throw new XMLLayerException(getName(),e); |
|
117 |
} catch (ReadDriverException e) { |
|
118 |
this.setAvailable(false); |
|
119 |
throw new LoadLayerException(getName(),e); |
|
120 |
} |
|
121 |
this.cleanLoadOptions(); |
|
122 |
} |
|
123 |
|
|
124 |
public void setXMLEntity(XMLEntity xml) throws XMLException { |
|
125 |
IProjection proj = null; |
|
126 |
if (xml.contains("proj")) { |
|
127 |
proj = CRSFactory.getCRS(xml.getStringProperty("proj")); |
|
128 |
} |
|
129 |
else |
|
130 |
{ |
|
131 |
proj = this.getMapContext().getViewPort().getProjection(); |
|
132 |
} |
|
133 |
this.setName(xml.getName()); |
|
134 |
this.setProjection(proj); |
|
135 |
|
|
136 |
String driverName = xml.getStringProperty("other"); |
|
137 |
VectorialDriver driver = null; |
|
138 |
try { |
|
139 |
driver = (VectorialDriver) LayerFactory.getDM().getDriver(driverName); |
|
140 |
} catch (DriverLoadException e) { |
|
141 |
// Si no existe ese driver, no pasa nada. |
|
142 |
// Puede que el desarrollador no quiera que |
|
143 |
// aparezca en el cuadro de di?logo y ha metido |
|
144 |
// el jar con sus clases en nuestro directorio lib. |
|
145 |
// Intentamos cargar esa clase "a pelo". |
|
146 |
if (xml.getChild(2).contains("className")) |
|
147 |
{ |
|
148 |
String className2 = xml.getChild(2).getStringProperty("className"); |
|
149 |
try { |
|
150 |
driver = (VectorialDriver) Class.forName(className2).newInstance(); |
|
151 |
} catch (Exception e1) { |
|
152 |
throw new XMLException(e1); |
|
153 |
} |
|
154 |
} |
|
155 |
} catch (NullPointerException npe) { |
|
156 |
// Si no existe ese driver, no pasa nada. |
|
157 |
// Puede que el desarrollador no quiera que |
|
158 |
// aparezca en el cuadro de di?logo y ha metido |
|
159 |
// el jar con sus clases en nuestro directorio lib. |
|
160 |
// Intentamos cargar esa clase "a pelo". |
|
161 |
if (xml.getChild(2).contains("className")) |
|
162 |
{ |
|
163 |
String className2 = xml.getChild(2).getStringProperty("className"); |
|
164 |
try { |
|
165 |
driver = (VectorialDriver) Class.forName(className2).newInstance(); |
|
166 |
} catch (Exception e1) { |
|
167 |
throw new XMLException(e1); |
|
168 |
} |
|
169 |
} |
|
170 |
} |
|
171 |
if (driver == null) { |
|
172 |
throw new XMLException(new Exception("Error al cargar el driver")); |
|
173 |
} |
|
174 |
if (driver instanceof IPersistence) |
|
175 |
{ |
|
176 |
IPersistence persist = (IPersistence) driver; |
|
177 |
persist.setXMLEntity(xml.getChild(2)); |
|
178 |
} |
|
179 |
this.setDriver(driver); |
|
180 |
super.setXMLEntityNew(xml); |
|
181 |
} |
|
182 |
} |
branches/v2_0_0_prep/libraries/libFMap/src/org/gvsig/fmap/mapcontext/layers/vectorial/FLayerFileVectorial.java | ||
---|---|---|
1 |
package org.gvsig.fmap.mapcontext.layers.vectorial; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.FileNotFoundException; |
|
5 |
|
|
6 |
import org.cresques.cts.IProjection; |
|
7 |
import org.gvsig.fmap.crs.CRSFactory; |
|
8 |
import org.gvsig.fmap.drivers.reading.VectorialFileDriver; |
|
9 |
import org.gvsig.fmap.drivers.reading.WithDefaultLegend; |
|
10 |
import org.gvsig.fmap.drivers.reading.adapters.VectorialFileAdapter; |
|
11 |
import org.gvsig.fmap.mapcontext.exceptions.DriverLayerException; |
|
12 |
import org.gvsig.fmap.mapcontext.exceptions.FileLayerException; |
|
13 |
import org.gvsig.fmap.mapcontext.exceptions.LegendLayerException; |
|
14 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
15 |
import org.gvsig.fmap.mapcontext.exceptions.NameLayerException; |
|
16 |
import org.gvsig.fmap.mapcontext.exceptions.ProjectionLayerException; |
|
17 |
import org.gvsig.fmap.mapcontext.exceptions.XMLLayerException; |
|
18 |
import org.gvsig.fmap.mapcontext.layers.LayerFactory; |
|
19 |
import org.gvsig.fmap.mapcontext.layers.XMLException; |
|
20 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
21 |
import org.gvsig.fmap.mapcontext.rendering.legend.LegendFactory; |
|
22 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.AttrInTableLabelingStrategy; |
|
23 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingStrategy; |
|
24 |
|
|
25 |
import com.hardcode.driverManager.DriverLoadException; |
|
26 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
27 |
import com.iver.utiles.XMLEntity; |
|
28 |
|
|
29 |
public class FLayerFileVectorial extends FLyrVect{ |
|
30 |
private boolean loaded = false; |
|
31 |
private File dataFile = null; |
|
32 |
private VectorialFileDriver fileDriver = null; |
|
33 |
|
|
34 |
public FLayerFileVectorial() { |
|
35 |
super(); |
|
36 |
} |
|
37 |
|
|
38 |
public FLayerFileVectorial(String name, String fileName,String driverName,String projectionName) throws Exception { |
|
39 |
super(); |
|
40 |
|
|
41 |
this.setName(name); |
|
42 |
|
|
43 |
this.setFileName(fileName); |
|
44 |
|
|
45 |
this.setDriverByName(driverName); |
|
46 |
|
|
47 |
this.setProjectionByName(projectionName); |
|
48 |
} |
|
49 |
|
|
50 |
/* Esto deberia ir en el FLyrDefault */ |
|
51 |
public void setProjectionByName(String projectionName) throws Exception{ |
|
52 |
IProjection proj = CRSFactory.getCRS(projectionName); |
|
53 |
if (proj == null) { |
|
54 |
throw new Exception("No se ha encontrado la proyeccion: "+ projectionName); |
|
55 |
} |
|
56 |
this.setProjection(proj); |
|
57 |
|
|
58 |
} |
|
59 |
|
|
60 |
public void setFileName(String filePath) throws FileNotFoundException{ |
|
61 |
if (dataFile != null) { |
|
62 |
//TODO: que excepcion lanzar??? |
|
63 |
return; |
|
64 |
} |
|
65 |
File file = new File(filePath); |
|
66 |
if (!file.exists()) { |
|
67 |
throw new FileNotFoundException(filePath); |
|
68 |
} |
|
69 |
this.dataFile = file; |
|
70 |
} |
|
71 |
|
|
72 |
public void setFile(File file) throws FileNotFoundException { |
|
73 |
if (dataFile != null) { |
|
74 |
//TODO: que excepcion lanzar??? |
|
75 |
return; |
|
76 |
} |
|
77 |
if (!file.exists()) { |
|
78 |
throw new FileNotFoundException(file.getAbsolutePath()); |
|
79 |
} |
|
80 |
this.dataFile = new File(file.getAbsolutePath()); |
|
81 |
} |
|
82 |
|
|
83 |
public String getFileName() { |
|
84 |
if (this.dataFile == null) { |
|
85 |
return null; |
|
86 |
} |
|
87 |
return this.dataFile.getAbsolutePath(); |
|
88 |
} |
|
89 |
|
|
90 |
|
|
91 |
public void setDriver(VectorialFileDriver driver) { |
|
92 |
this.fileDriver = driver; |
|
93 |
} |
|
94 |
|
|
95 |
public void setDriverByName(String driverName) throws DriverLoadException { |
|
96 |
this.setDriver( |
|
97 |
(VectorialFileDriver)LayerFactory.getDM().getDriver(driverName) |
|
98 |
); |
|
99 |
} |
|
100 |
|
|
101 |
public VectorialFileDriver getDriver() { |
|
102 |
return this.fileDriver; |
|
103 |
} |
|
104 |
|
|
105 |
/* FIXME: esto tendria que tener declarado un throws de algo*/ |
|
106 |
public void wakeUp() throws LoadLayerException { |
|
107 |
if (!loaded) { |
|
108 |
this.load(); |
|
109 |
} |
|
110 |
|
|
111 |
} |
|
112 |
|
|
113 |
|
|
114 |
public void load() throws LoadLayerException { |
|
115 |
if (this.dataFile == null) { |
|
116 |
this.setAvailable(false); |
|
117 |
throw new FileLayerException(getName(),null); |
|
118 |
} |
|
119 |
if (this.getName() == null || this.getName().length() == 0) { |
|
120 |
this.setAvailable(false); |
|
121 |
throw new NameLayerException(getName(),null); |
|
122 |
} |
|
123 |
if (this.fileDriver == null) { |
|
124 |
this.setAvailable(false); |
|
125 |
throw new DriverLayerException(getName(),null); |
|
126 |
} |
|
127 |
if (this.getProjection() == null) { |
|
128 |
this.setAvailable(false); |
|
129 |
throw new ProjectionLayerException(getName(),null); |
|
130 |
} |
|
131 |
|
|
132 |
VectorialFileAdapter adapter = new VectorialFileAdapter(this.dataFile); |
|
133 |
adapter.setDriver(this.fileDriver); |
|
134 |
|
|
135 |
this.setSource(adapter); |
|
136 |
|
|
137 |
try { |
|
138 |
this.putLoadSelection(); |
|
139 |
this.putLoadLegend(); |
|
140 |
this.initializeLegendDefault(); |
|
141 |
} catch (LegendLayerException e) { |
|
142 |
this.setAvailable(false); |
|
143 |
throw new LegendLayerException(getName(),e); |
|
144 |
} catch (XMLException e) { |
|
145 |
this.setAvailable(false); |
|
146 |
throw new XMLLayerException(getName(),e); |
|
147 |
} catch (ReadDriverException e) { |
|
148 |
this.setAvailable(false); |
|
149 |
throw new LoadLayerException(getName(),e); |
|
150 |
} |
|
151 |
this.cleanLoadOptions(); |
|
152 |
this.loaded = true; |
|
153 |
} |
|
154 |
|
|
155 |
/* Esto deberia ir en FLyrVect */ |
|
156 |
private void initializeLegendDefault() throws LegendLayerException, ReadDriverException { |
|
157 |
if (this.getLegend() == null) { |
|
158 |
if (this.getRecordset().getDriver() instanceof WithDefaultLegend) { |
|
159 |
WithDefaultLegend aux = (WithDefaultLegend) this.getRecordset().getDriver(); |
|
160 |
this.setLegend((IVectorLegend) aux.getDefaultLegend()); |
|
161 |
|
|
162 |
ILabelingStrategy labeler = aux.getDefaultLabelingStrategy(); |
Also available in: Unified diff