Revision 11613 branches/v10/extensions/extAnnotations/src/com/iver/cit/gvsig/fmap/layers/Annotation_Layer.java
Annotation_Layer.java | ||
---|---|---|
51 | 51 |
|
52 | 52 |
/** |
53 | 53 |
* Annotation's layer. |
54 |
* |
|
54 |
*
|
|
55 | 55 |
* @author Vicente Caballero Navarro |
56 | 56 |
*/ |
57 | 57 |
public class Annotation_Layer extends FLyrVect { |
58 | 58 |
private Annotation_Mapping mapping = null; |
59 | 59 |
|
60 |
// private ArrayList m_labels;
|
|
60 |
// private ArrayList m_labels;
|
|
61 | 61 |
|
62 | 62 |
private int indexEditing = -1; |
63 | 63 |
|
64 |
private boolean inPixels=false; |
|
64 |
private boolean inPixels = false; |
|
65 |
|
|
65 | 66 |
private Annotation_Legend aLegend; |
66 |
private Strategy strategy=null; |
|
67 |
|
|
68 |
private Strategy strategy = null; |
|
69 |
|
|
67 | 70 |
/** |
68 | 71 |
* Crea un nuevo FLyrAnnotation. |
69 | 72 |
*/ |
... | ... | |
74 | 77 |
|
75 | 78 |
/** |
76 | 79 |
* DOCUMENT ME! |
77 |
* |
|
80 |
*
|
|
78 | 81 |
* @param mapping |
79 | 82 |
* DOCUMENT ME! |
80 | 83 |
*/ |
81 | 84 |
public void setMapping(Annotation_Mapping mapping) { |
82 | 85 |
this.mapping = mapping; |
83 |
aLegend=new Annotation_Legend(); |
|
84 |
// try { |
|
85 |
setLegend(); |
|
86 |
// createLabels(); |
|
87 |
// } catch (DriverException e) { |
|
88 |
// e.printStackTrace(); |
|
89 |
// JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
|
90 |
// PluginServices.getText(this,"Este fichero no es posible abirlo como capa de anotaciones")); |
|
91 |
// } |
|
86 |
aLegend = new Annotation_Legend(); |
|
87 |
// try { |
|
88 |
setLegend(); |
|
89 |
// createLabels(); |
|
90 |
// } catch (DriverException e) { |
|
91 |
// e.printStackTrace(); |
|
92 |
// JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
|
93 |
// PluginServices.getText(this,"Este fichero no es posible abirlo como |
|
94 |
// capa de anotaciones")); |
|
95 |
// } |
|
92 | 96 |
} |
93 | 97 |
|
94 | 98 |
/** |
95 | 99 |
* DOCUMENT ME! |
96 |
* |
|
100 |
*
|
|
97 | 101 |
* @return DOCUMENT ME! |
98 | 102 |
*/ |
99 | 103 |
public Annotation_Mapping getAnnotatonMapping() { |
... | ... | |
107 | 111 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
108 | 112 |
Cancellable cancel, double scale) throws DriverException { |
109 | 113 |
|
110 |
|
|
111 | 114 |
if (isWithinScale(scale)) { |
112 | 115 |
// Las que solo tienen etiquetado sin pintar el shape, |
113 | 116 |
// no pasamos por ellas |
114 | 117 |
boolean bDrawShapes = true; |
115 | 118 |
|
116 | 119 |
if (bDrawShapes) { |
117 |
if (strategy == null){ |
|
120 |
if (strategy == null) {
|
|
118 | 121 |
strategy = new Annotation_Strategy(this); |
119 | 122 |
} |
120 | 123 |
try { |
... | ... | |
124 | 127 |
|
125 | 128 |
strategy.draw(image, g, viewPort, cancel); |
126 | 129 |
adapter.stop(); |
127 |
// if (getISpatialIndex()==null && !isEditing()) {
|
|
128 |
// createSpatialIndex();
|
|
129 |
// }
|
|
130 |
// if (getISpatialIndex()==null && !isEditing()) {
|
|
131 |
// createSpatialIndex();
|
|
132 |
// }
|
|
130 | 133 |
} catch (DriverException e) { |
131 | 134 |
this.setVisible(false); |
132 | 135 |
this.setActive(false); |
... | ... | |
182 | 185 |
* com.iver.utiles.swing.threads.Cancellable) |
183 | 186 |
*/ |
184 | 187 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
185 |
double scale, PrintRequestAttributeSet properties) throws DriverException { |
|
188 |
double scale, PrintRequestAttributeSet properties) |
|
189 |
throws DriverException { |
|
186 | 190 |
if (isVisible() && isWithinScale(scale)) { |
187 | 191 |
Strategy strategy = StrategyManager.getStrategy(this); |
188 | 192 |
strategy.print(g, viewPort, cancel, properties); |
... | ... | |
191 | 195 |
|
192 | 196 |
/* |
193 | 197 |
* (non-Javadoc) |
194 |
* |
|
198 |
*
|
|
195 | 199 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.RandomVectorialData#queryByRect(java.awt.geom.Rectangle2D) |
196 | 200 |
*/ |
197 | 201 |
public FBitSet queryByRect(Rectangle2D rect) throws DriverException { |
... | ... | |
202 | 206 |
|
203 | 207 |
/** |
204 | 208 |
* DOCUMENT ME! |
205 |
* |
|
209 |
*
|
|
206 | 210 |
* @param p |
207 | 211 |
* DOCUMENT ME! |
208 | 212 |
* @param tolerance |
209 | 213 |
* DOCUMENT ME! |
210 |
* |
|
214 |
*
|
|
211 | 215 |
* @return DOCUMENT ME! |
212 |
* |
|
216 |
*
|
|
213 | 217 |
* @throws DriverException |
214 | 218 |
* DOCUMENT ME! |
215 | 219 |
*/ |
... | ... | |
222 | 226 |
|
223 | 227 |
/** |
224 | 228 |
* DOCUMENT ME! |
225 |
* |
|
229 |
*
|
|
226 | 230 |
* @param g |
227 | 231 |
* DOCUMENT ME! |
228 | 232 |
* @param relationship |
229 | 233 |
* DOCUMENT ME! |
230 |
* |
|
234 |
*
|
|
231 | 235 |
* @return DOCUMENT ME! |
232 |
* |
|
236 |
*
|
|
233 | 237 |
* @throws DriverException |
234 | 238 |
* DOCUMENT ME! |
235 | 239 |
* @throws VisitException |
... | ... | |
244 | 248 |
|
245 | 249 |
/** |
246 | 250 |
* DOCUMENT ME! |
247 |
* |
|
251 |
*
|
|
248 | 252 |
* @return DOCUMENT ME! |
249 |
* |
|
253 |
*
|
|
250 | 254 |
* @throws XMLException |
251 |
* |
|
255 |
*
|
|
252 | 256 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#getProperties() |
253 | 257 |
*/ |
254 | 258 |
public XMLEntity getXMLEntity() throws XMLException { |
255 | 259 |
XMLEntity xml = super.getXMLEntity(); |
256 |
// xml.addChild(mapping.getXMLEntity());
|
|
260 |
// xml.addChild(mapping.getXMLEntity());
|
|
257 | 261 |
xml.putProperty("isInPixels", isInPixels()); |
258 | 262 |
|
259 | 263 |
return xml; |
... | ... | |
263 | 267 |
* @see com.iver.cit.gvsig.fmap.layers.FLyrDefault#setXMLEntity(com.iver.utiles.XMLEntity) |
264 | 268 |
*/ |
265 | 269 |
public void setXMLEntity(XMLEntity xml) throws XMLException { |
266 |
// Iterator iter=xml.findChildren("className",Annotation_Mapping.class.getName()); |
|
267 |
// if (iter.hasNext()) |
|
268 |
// mapping = Annotation_Mapping.createFromXML((XMLEntity)iter.next()); |
|
269 |
// else{ |
|
270 |
// //Este else para versiones anteriores a la 1.0.2.(908) |
|
271 |
// if (xml.getChildrenCount()==3) |
|
272 |
// mapping = Annotation_Mapping.createFromXML(xml.getChild(2)); |
|
273 |
// else |
|
274 |
// mapping = Annotation_Mapping.createFromXML(xml.getChild(3)); |
|
275 |
// } |
|
270 |
// Iterator |
|
271 |
// iter=xml.findChildren("className",Annotation_Mapping.class.getName()); |
|
272 |
// if (iter.hasNext()) |
|
273 |
// mapping = Annotation_Mapping.createFromXML((XMLEntity)iter.next()); |
|
274 |
// else{ |
|
275 |
// //Este else para versiones anteriores a la 1.0.2.(908) |
|
276 |
// if (xml.getChildrenCount()==3) |
|
277 |
// mapping = Annotation_Mapping.createFromXML(xml.getChild(2)); |
|
278 |
// else |
|
279 |
// mapping = Annotation_Mapping.createFromXML(xml.getChild(3)); |
|
280 |
// } |
|
276 | 281 |
IProjection proj = null; |
277 |
if (xml.contains("proj")) { |
|
278 |
proj = CRSFactory.getCRS(xml.getStringProperty("proj")); |
|
279 |
} |
|
280 |
else |
|
281 |
{ |
|
282 |
proj = this.getMapContext().getViewPort().getProjection(); |
|
283 |
} |
|
282 |
if (xml.contains("proj")) { |
|
283 |
proj = CRSFactory.getCRS(xml.getStringProperty("proj")); |
|
284 |
} else { |
|
285 |
proj = this.getMapContext().getViewPort().getProjection(); |
|
286 |
} |
|
284 | 287 |
if (xml.contains("file")) { |
285 | 288 |
Driver d; |
286 | 289 |
try { |
287 |
d = LayerFactory.getDM().getDriver(xml.getStringProperty("driverName")); |
|
290 |
d = LayerFactory.getDM().getDriver( |
|
291 |
xml.getStringProperty("driverName")); |
|
288 | 292 |
} catch (DriverLoadException e1) { |
289 | 293 |
throw new XMLException(e1); |
290 | 294 |
} |
291 |
FLyrVect lv = (FLyrVect)LayerFactory.createLayer(xml.getName(), (VectorialFileDriver) d,
|
|
292 |
new File(xml.getStringProperty("file")),
|
|
293 |
proj);
|
|
295 |
FLyrVect lv = (FLyrVect) LayerFactory.createLayer(xml.getName(),
|
|
296 |
(VectorialFileDriver) d, new File(xml
|
|
297 |
.getStringProperty("file")), proj);
|
|
294 | 298 |
try { |
295 | 299 |
this.setSource(lv.getSource()); |
296 | 300 |
this.setRecordset(lv.getRecordset()); |
297 | 301 |
this.setProjection(lv.getProjection()); |
298 |
this.setLegend((VectorialLegend)lv.getLegend()); |
|
302 |
this.setLegend((VectorialLegend) lv.getLegend());
|
|
299 | 303 |
Annotation_Mapping.addAnnotationMapping(this); |
300 | 304 |
} catch (DriverException e) { |
301 | 305 |
// TODO Auto-generated catch block |
... | ... | |
310 | 314 |
} |
311 | 315 |
setInPixels(xml.getBooleanProperty("isInPixels")); |
312 | 316 |
|
313 |
// IProjection proj = null;
|
|
314 |
// |
|
315 |
// if (xml.contains("proj")) {
|
|
316 |
// proj = CRSFactory.getCRS(xml.getStringProperty("proj"));
|
|
317 |
// }
|
|
317 |
// IProjection proj = null;
|
|
318 |
//
|
|
319 |
// if (xml.contains("proj")) {
|
|
320 |
// proj = CRSFactory.getCRS(xml.getStringProperty("proj"));
|
|
321 |
// }
|
|
318 | 322 |
|
319 |
// VectorialAdapter adapter=null;
|
|
320 |
// if (xml.contains("file")){
|
|
321 |
// adapter = new VectorialFileAdapter(new File(xml
|
|
322 |
// .getStringProperty("file")));
|
|
323 |
// }else if (xml.contains("db")){
|
|
324 |
// adapter = new VectorialDBAdapter();
|
|
325 |
// }
|
|
326 |
// Driver d;
|
|
327 |
// |
|
328 |
// try {
|
|
329 |
// d = LayerFactory.getDM().getDriver(
|
|
330 |
// xml.getStringProperty("driverName"));
|
|
331 |
// } catch (DriverLoadException e1) {
|
|
332 |
// throw new XMLException(e1);
|
|
333 |
// }
|
|
334 |
// |
|
335 |
// adapter.setDriver((VectorialDriver) d);
|
|
336 |
// // TODO Meter esto dentro de la comprobaci?n de si hay memoria
|
|
337 |
// if (false) {
|
|
338 |
// } else {
|
|
339 |
// setSource(adapter);
|
|
340 |
// setProjection(proj);
|
|
341 |
// }
|
|
323 |
// VectorialAdapter adapter=null;
|
|
324 |
// if (xml.contains("file")){
|
|
325 |
// adapter = new VectorialFileAdapter(new File(xml
|
|
326 |
// .getStringProperty("file")));
|
|
327 |
// }else if (xml.contains("db")){
|
|
328 |
// adapter = new VectorialDBAdapter();
|
|
329 |
// }
|
|
330 |
// Driver d;
|
|
331 |
//
|
|
332 |
// try {
|
|
333 |
// d = LayerFactory.getDM().getDriver(
|
|
334 |
// xml.getStringProperty("driverName"));
|
|
335 |
// } catch (DriverLoadException e1) {
|
|
336 |
// throw new XMLException(e1);
|
|
337 |
// }
|
|
338 |
//
|
|
339 |
// adapter.setDriver((VectorialDriver) d);
|
|
340 |
// // TODO Meter esto dentro de la comprobaci?n de si hay memoria
|
|
341 |
// if (false) {
|
|
342 |
// } else {
|
|
343 |
// setSource(adapter);
|
|
344 |
// setProjection(proj);
|
|
345 |
// }
|
|
342 | 346 |
|
343 | 347 |
// Le asignamos tambi?n una legenda por defecto acorde con |
344 | 348 |
// el tipo de shape que tenga. Tampoco s? si es aqu? el |
... | ... | |
351 | 355 |
*/ |
352 | 356 |
|
353 | 357 |
super.setXMLEntity(xml); |
354 |
// try {
|
|
355 |
// createLabels();
|
|
356 |
// } catch (DriverException e) {
|
|
357 |
// // TODO Auto-generated catch block
|
|
358 |
// e.printStackTrace();
|
|
359 |
// }
|
|
358 |
// try {
|
|
359 |
// createLabels();
|
|
360 |
// } catch (DriverException e) {
|
|
361 |
// // TODO Auto-generated catch block
|
|
362 |
// e.printStackTrace();
|
|
363 |
// }
|
|
360 | 364 |
} |
361 | 365 |
|
362 | 366 |
/** |
363 | 367 |
* Esto tiene el fallo de que obligas a una etiqueta por entidad, para poder |
364 | 368 |
* evitar esto, una posible soluci?n ser?a que un FLabel pudiera ser una |
365 | 369 |
* colecci?n de FLabel (Patr?n Composite) |
366 |
* |
|
370 |
*
|
|
367 | 371 |
* @param lyrVect |
368 | 372 |
* @throws DriverException |
369 | 373 |
*/ |
370 |
// private void createLabels() throws DriverException { |
|
371 |
// SelectableDataSource ds = getRecordset(); |
|
372 |
// FSymbol symbol; |
|
373 |
// try { |
|
374 |
// ReadableVectorial adapter = getSource(); |
|
375 |
// adapter.start(); |
|
376 |
// if (isJoined()){ |
|
377 |
// ds.start(); |
|
378 |
// } |
|
379 |
// int sc; |
|
380 |
// // El mapping[0] es el text |
|
381 |
// int fieldId = mapping.getColumnText(); |
|
382 |
// // El mapping[1] es el ?ngulo |
|
383 |
// int idFieldRotationText = mapping.getColumnRotate(); |
|
384 |
// // El mapping[2] es el color |
|
385 |
// int idFieldColorText = mapping.getColumnColor(); |
|
386 |
// // El mapping[3] es el alto |
|
387 |
// int idFieldHeightText = mapping.getColumnHeight(); |
|
388 |
// // El mapping[4] es el tipo de fuente |
|
389 |
// int idFieldTypeFontText = mapping.getColumnTypeFont(); |
|
390 |
// // El mapping[5] es el estilo de fuente |
|
391 |
// int idFieldStyleFontText = mapping.getColumnStyleFont(); |
|
392 |
// |
|
393 |
// sc = (int) ds.getRowCount(); |
|
394 |
// m_labels = new ArrayList(sc); |
|
395 |
// DriverAttributes attr = adapter.getDriverAttributes(); |
|
396 |
// boolean bMustClone = false; |
|
397 |
// if (attr != null) { |
|
398 |
// if (attr.isLoadedInMemory()) { |
|
399 |
// bMustClone = attr.isLoadedInMemory(); |
|
400 |
// } |
|
401 |
// } |
|
402 |
// ICoordTrans ct = getCoordTrans(); |
|
403 |
// FSymbol defaultSym = (FSymbol) getLegend().getDefaultSymbol(); |
|
404 |
// for (int i = 0; i < sc; i++) { |
|
405 |
// IGeometry geom = adapter.getShape(i); |
|
406 |
// |
|
407 |
// if (geom == null) { |
|
408 |
// m_labels.add(null); |
|
409 |
// continue; |
|
410 |
// } |
|
411 |
// if (ct != null) { |
|
412 |
// if (bMustClone) |
|
413 |
// geom = geom.cloneGeometry(); |
|
414 |
// geom.reProject(ct); |
|
415 |
// } |
|
416 |
// |
|
417 |
// // TODO: El m?todo contenedor (createLabelLayer) debe recoger |
|
418 |
// // los par?metros de posicionamiento y de allowDuplicates |
|
419 |
// // if (i >= 328) |
|
420 |
// // System.out.println("i= " + i + " " + val.toString()); |
|
421 |
// //ArrayList values=new ArrayList(4); |
|
422 |
//// String t=new String(); |
|
423 |
// Value val = ds.getFieldValue(i, fieldId); |
|
424 |
// |
|
425 |
// //Value total=ValueFactory.createValue((Value[])values.toArray(new Value[0])); |
|
426 |
// Value total=getSymbolKey(i);//ValueFactory.createValue(t); |
|
427 |
// if ((val instanceof NullValue) || (val == null)) { |
|
428 |
// m_labels.add(null); |
|
429 |
// continue; |
|
430 |
// } |
|
431 |
// FLabel[] lbls = geom.createLabels(0, true); |
|
432 |
// for (int j = 0; j < lbls.length; j++) { |
|
433 |
// if (lbls[j] != null) { |
|
434 |
// lbls[j].setString(val.toString()); |
|
435 |
// if (idFieldRotationText != -1) { |
|
436 |
// NumericValue rotation = (NumericValue) ds |
|
437 |
// .getFieldValue(i, idFieldRotationText); |
|
438 |
// lbls[j].setRotation(rotation.doubleValue()); |
|
439 |
// } else { |
|
440 |
// lbls[j].setRotation(defaultSym.getRotation()); |
|
441 |
// } |
|
442 |
// |
|
443 |
// float height; |
|
444 |
// if (idFieldHeightText != -1) { |
|
445 |
// NumericValue h = (NumericValue) ds |
|
446 |
// .getFieldValue(i, idFieldHeightText); |
|
447 |
// height=h.floatValue(); |
|
448 |
// lbls[j].setHeight(height); |
|
449 |
// } else { |
|
450 |
// height=defaultSym.getFontSize(); |
|
451 |
// lbls[j].setHeight(height); |
|
452 |
// } |
|
453 |
// |
|
454 |
// |
|
455 |
// |
|
456 |
// if (aLegend.getSymbolByValue(total)==null){ |
|
457 |
// Color color; |
|
458 |
// if (idFieldColorText != -1) { |
|
459 |
// NumericValue c = (NumericValue) ds.getFieldValue( |
|
460 |
// i, idFieldColorText); |
|
461 |
// color=new Color(c.intValue()); |
|
462 |
// } else { |
|
463 |
// color=defaultSym.getFontColor(); |
|
464 |
// } |
|
465 |
// String typeFont; |
|
466 |
// if (idFieldTypeFontText != -1) { |
|
467 |
// StringValue tf = (StringValue) ds |
|
468 |
// .getFieldValue(i, idFieldTypeFontText); |
|
469 |
// typeFont=tf.getValue(); |
|
470 |
// } else { |
|
471 |
// typeFont=defaultSym.getFont().getFontName(); |
|
472 |
// } |
|
473 |
// int style; |
|
474 |
// if (idFieldStyleFontText != -1) { |
|
475 |
// NumericValue sf = (NumericValue) ds |
|
476 |
// .getFieldValue(i, idFieldStyleFontText); |
|
477 |
// style=sf.intValue(); |
|
478 |
// } else { |
|
479 |
// style=defaultSym.getFont().getStyle(); |
|
480 |
// } |
|
481 |
// symbol=new FSymbol(FConstant.SYMBOL_TYPE_TEXT); |
|
482 |
// symbol.setFontSizeInPixels(isInPixels()); |
|
483 |
// symbol.setFont(new Font(typeFont,style,(int)height)); |
|
484 |
// symbol.setDescription(lbls[j].getString()); |
|
485 |
// symbol.setFontColor(color); |
|
486 |
// aLegend.addSymbol(total,symbol); |
|
487 |
// } |
|
488 |
// |
|
489 |
// } |
|
490 |
// m_labels.add(lbls[j]); |
|
491 |
// |
|
492 |
// } |
|
493 |
// } |
|
494 |
// |
|
495 |
// if (this.isJoined()){ |
|
496 |
// ds.stop(); |
|
497 |
// } |
|
498 |
// adapter.stop(); |
|
499 |
// } catch (DriverIOException e) { |
|
500 |
// e.printStackTrace(); |
|
501 |
// throw new DriverException(e); |
|
502 |
// } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
503 |
// e.printStackTrace(); |
|
504 |
// throw new DriverException(e); |
|
505 |
// } |
|
506 |
// |
|
507 |
// } |
|
508 |
|
|
509 |
public Value getSymbolKey(int i) throws com.hardcode.gdbms.engine.data.driver.DriverException, DriverException { |
|
374 |
// private void createLabels() throws DriverException { |
|
375 |
// SelectableDataSource ds = getRecordset(); |
|
376 |
// FSymbol symbol; |
|
377 |
// try { |
|
378 |
// ReadableVectorial adapter = getSource(); |
|
379 |
// adapter.start(); |
|
380 |
// if (isJoined()){ |
|
381 |
// ds.start(); |
|
382 |
// } |
|
383 |
// int sc; |
|
384 |
// // El mapping[0] es el text |
|
385 |
// int fieldId = mapping.getColumnText(); |
|
386 |
// // El mapping[1] es el ?ngulo |
|
387 |
// int idFieldRotationText = mapping.getColumnRotate(); |
|
388 |
// // El mapping[2] es el color |
|
389 |
// int idFieldColorText = mapping.getColumnColor(); |
|
390 |
// // El mapping[3] es el alto |
|
391 |
// int idFieldHeightText = mapping.getColumnHeight(); |
|
392 |
// // El mapping[4] es el tipo de fuente |
|
393 |
// int idFieldTypeFontText = mapping.getColumnTypeFont(); |
|
394 |
// // El mapping[5] es el estilo de fuente |
|
395 |
// int idFieldStyleFontText = mapping.getColumnStyleFont(); |
|
396 |
// |
|
397 |
// sc = (int) ds.getRowCount(); |
|
398 |
// m_labels = new ArrayList(sc); |
|
399 |
// DriverAttributes attr = adapter.getDriverAttributes(); |
|
400 |
// boolean bMustClone = false; |
|
401 |
// if (attr != null) { |
|
402 |
// if (attr.isLoadedInMemory()) { |
|
403 |
// bMustClone = attr.isLoadedInMemory(); |
|
404 |
// } |
|
405 |
// } |
|
406 |
// ICoordTrans ct = getCoordTrans(); |
|
407 |
// FSymbol defaultSym = (FSymbol) getLegend().getDefaultSymbol(); |
|
408 |
// for (int i = 0; i < sc; i++) { |
|
409 |
// IGeometry geom = adapter.getShape(i); |
|
410 |
// |
|
411 |
// if (geom == null) { |
|
412 |
// m_labels.add(null); |
|
413 |
// continue; |
|
414 |
// } |
|
415 |
// if (ct != null) { |
|
416 |
// if (bMustClone) |
|
417 |
// geom = geom.cloneGeometry(); |
|
418 |
// geom.reProject(ct); |
|
419 |
// } |
|
420 |
// |
|
421 |
// // TODO: El m?todo contenedor (createLabelLayer) debe recoger |
|
422 |
// // los par?metros de posicionamiento y de allowDuplicates |
|
423 |
// // if (i >= 328) |
|
424 |
// // System.out.println("i= " + i + " " + val.toString()); |
|
425 |
// //ArrayList values=new ArrayList(4); |
|
426 |
// // String t=new String(); |
|
427 |
// Value val = ds.getFieldValue(i, fieldId); |
|
428 |
// |
|
429 |
// //Value total=ValueFactory.createValue((Value[])values.toArray(new |
|
430 |
// Value[0])); |
|
431 |
// Value total=getSymbolKey(i);//ValueFactory.createValue(t); |
|
432 |
// if ((val instanceof NullValue) || (val == null)) { |
|
433 |
// m_labels.add(null); |
|
434 |
// continue; |
|
435 |
// } |
|
436 |
// FLabel[] lbls = geom.createLabels(0, true); |
|
437 |
// for (int j = 0; j < lbls.length; j++) { |
|
438 |
// if (lbls[j] != null) { |
|
439 |
// lbls[j].setString(val.toString()); |
|
440 |
// if (idFieldRotationText != -1) { |
|
441 |
// NumericValue rotation = (NumericValue) ds |
|
442 |
// .getFieldValue(i, idFieldRotationText); |
|
443 |
// lbls[j].setRotation(rotation.doubleValue()); |
|
444 |
// } else { |
|
445 |
// lbls[j].setRotation(defaultSym.getRotation()); |
|
446 |
// } |
|
447 |
// |
|
448 |
// float height; |
|
449 |
// if (idFieldHeightText != -1) { |
|
450 |
// NumericValue h = (NumericValue) ds |
|
451 |
// .getFieldValue(i, idFieldHeightText); |
|
452 |
// height=h.floatValue(); |
|
453 |
// lbls[j].setHeight(height); |
|
454 |
// } else { |
|
455 |
// height=defaultSym.getFontSize(); |
|
456 |
// lbls[j].setHeight(height); |
|
457 |
// } |
|
458 |
// |
|
459 |
// |
|
460 |
// |
|
461 |
// if (aLegend.getSymbolByValue(total)==null){ |
|
462 |
// Color color; |
|
463 |
// if (idFieldColorText != -1) { |
|
464 |
// NumericValue c = (NumericValue) ds.getFieldValue( |
|
465 |
// i, idFieldColorText); |
|
466 |
// color=new Color(c.intValue()); |
|
467 |
// } else { |
|
468 |
// color=defaultSym.getFontColor(); |
|
469 |
// } |
|
470 |
// String typeFont; |
|
471 |
// if (idFieldTypeFontText != -1) { |
|
472 |
// StringValue tf = (StringValue) ds |
|
473 |
// .getFieldValue(i, idFieldTypeFontText); |
|
474 |
// typeFont=tf.getValue(); |
|
475 |
// } else { |
|
476 |
// typeFont=defaultSym.getFont().getFontName(); |
|
477 |
// } |
|
478 |
// int style; |
|
479 |
// if (idFieldStyleFontText != -1) { |
|
480 |
// NumericValue sf = (NumericValue) ds |
|
481 |
// .getFieldValue(i, idFieldStyleFontText); |
|
482 |
// style=sf.intValue(); |
|
483 |
// } else { |
|
484 |
// style=defaultSym.getFont().getStyle(); |
|
485 |
// } |
|
486 |
// symbol=new FSymbol(FConstant.SYMBOL_TYPE_TEXT); |
|
487 |
// symbol.setFontSizeInPixels(isInPixels()); |
|
488 |
// symbol.setFont(new Font(typeFont,style,(int)height)); |
|
489 |
// symbol.setDescription(lbls[j].getString()); |
|
490 |
// symbol.setFontColor(color); |
|
491 |
// aLegend.addSymbol(total,symbol); |
|
492 |
// } |
|
493 |
// |
|
494 |
// } |
|
495 |
// m_labels.add(lbls[j]); |
|
496 |
// |
|
497 |
// } |
|
498 |
// } |
|
499 |
// |
|
500 |
// if (this.isJoined()){ |
|
501 |
// ds.stop(); |
|
502 |
// } |
|
503 |
// adapter.stop(); |
|
504 |
// } catch (DriverIOException e) { |
|
505 |
// e.printStackTrace(); |
|
506 |
// throw new DriverException(e); |
|
507 |
// } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
508 |
// e.printStackTrace(); |
|
509 |
// throw new DriverException(e); |
|
510 |
// } |
|
511 |
// |
|
512 |
// } |
|
513 |
public Value getSymbolKey(int i) |
|
514 |
throws com.hardcode.gdbms.engine.data.driver.DriverException, |
|
515 |
DriverException { |
|
510 | 516 |
SelectableDataSource ds = getRecordset(); |
511 |
String t=new String();
|
|
517 |
String t = new String();
|
|
512 | 518 |
Value val = ds.getFieldValue(i, mapping.getColumnText()); |
513 |
t=val.toString();
|
|
514 |
//values.add(val); |
|
515 |
if (mapping.getColumnColor()!=-1){
|
|
516 |
Value valColor=ds.getFieldValue(i,mapping.getColumnColor());
|
|
517 |
t=t.concat(valColor.toString());
|
|
518 |
//values.add(valColor); |
|
519 |
t = val.toString();
|
|
520 |
// values.add(val);
|
|
521 |
if (mapping.getColumnColor() != -1) {
|
|
522 |
Value valColor = ds.getFieldValue(i, mapping.getColumnColor());
|
|
523 |
t = t.concat(valColor.toString());
|
|
524 |
// values.add(valColor);
|
|
519 | 525 |
} |
520 |
if (mapping.getColumnTypeFont()!=-1){ |
|
521 |
Value valTypeFont=ds.getFieldValue(i,mapping.getColumnTypeFont()); |
|
522 |
t=t.concat(valTypeFont.toString()); |
|
523 |
//values.add(valTypeFont); |
|
526 |
if (mapping.getColumnTypeFont() != -1) { |
|
527 |
Value valTypeFont = ds |
|
528 |
.getFieldValue(i, mapping.getColumnTypeFont()); |
|
529 |
t = t.concat(valTypeFont.toString()); |
|
530 |
// values.add(valTypeFont); |
|
524 | 531 |
} |
525 | 532 |
|
526 |
if (mapping.getColumnStyleFont()!=-1){ |
|
527 |
Value valStyleFont=ds.getFieldValue(i,mapping.getColumnStyleFont()); |
|
528 |
t=t.concat(valStyleFont.toString()); |
|
529 |
//values.add(valStyleFont); |
|
533 |
if (mapping.getColumnStyleFont() != -1) { |
|
534 |
Value valStyleFont = ds.getFieldValue(i, mapping |
|
535 |
.getColumnStyleFont()); |
|
536 |
t = t.concat(valStyleFont.toString()); |
|
537 |
// values.add(valStyleFont); |
|
530 | 538 |
} |
531 |
//Value total=ValueFactory.createValue((Value[])values.toArray(new Value[0])); |
|
532 |
Value total=ValueFactory.createValue(t); |
|
539 |
// Value total=ValueFactory.createValue((Value[])values.toArray(new |
|
540 |
// Value[0])); |
|
541 |
Value total = ValueFactory.createValue(t); |
|
533 | 542 |
return total; |
534 | 543 |
} |
535 | 544 |
|
536 |
// public FLabel getLabel(int numReg) { |
|
537 |
// if (m_labels == null || numReg == -1) |
|
538 |
// return null; |
|
539 |
// if (getSource() instanceof Annotation_EditableAdapter){ |
|
540 |
// Annotation_EditableAdapter aea=((Annotation_EditableAdapter)getSource()); |
|
541 |
// return aea.getLabel(numReg,false); |
|
542 |
// } |
|
543 |
// return (FLabel)m_labels.get(numReg); |
|
544 |
// } |
|
545 |
// private FLabel getLabelNew(int numReg) throws DriverException{ |
|
546 |
// SelectableDataSource ds = getRecordset(); |
|
547 |
// FSymbol symbol; |
|
548 |
// try { |
|
549 |
// ReadableVectorial adapter = getSource(); |
|
550 |
// adapter.start(); |
|
551 |
// if (isJoined()){ |
|
552 |
// ds.start(); |
|
553 |
// } |
|
554 |
// int sc; |
|
555 |
// // El mapping[0] es el text |
|
556 |
// int fieldId = mapping.getColumnText(); |
|
557 |
// // El mapping[1] es el ?ngulo |
|
558 |
// int idFieldRotationText = mapping.getColumnRotate(); |
|
559 |
// // El mapping[2] es el color |
|
560 |
// int idFieldColorText = mapping.getColumnColor(); |
|
561 |
// // El mapping[3] es el alto |
|
562 |
// int idFieldHeightText = mapping.getColumnHeight(); |
|
563 |
// // El mapping[4] es el tipo de fuente |
|
564 |
// int idFieldTypeFontText = mapping.getColumnTypeFont(); |
|
565 |
// // El mapping[5] es el estilo de fuente |
|
566 |
// int idFieldStyleFontText = mapping.getColumnStyleFont(); |
|
567 |
// |
|
568 |
//// sc = (int) ds.getRowCount(); |
|
569 |
//// m_labels = new ArrayList(sc); |
|
570 |
//// DriverAttributes attr = adapter.getDriverAttributes(); |
|
571 |
// boolean bMustClone = false; |
|
572 |
//// if (attr != null) { |
|
573 |
//// if (attr.isLoadedInMemory()) { |
|
574 |
//// bMustClone = attr.isLoadedInMemory(); |
|
575 |
//// } |
|
576 |
//// } |
|
577 |
// ICoordTrans ct = getCoordTrans(); |
|
578 |
// FSymbol defaultSym = (FSymbol) getLegend().getDefaultSymbol(); |
|
579 |
//// for (int i = 0; i < sc; i++) { |
|
580 |
// IGeometry geom = adapter.getShape(numReg); |
|
581 |
// |
|
582 |
// if (geom == null) { |
|
583 |
//// m_labels.add(null); |
|
584 |
// return null; |
|
585 |
// } |
|
586 |
// if (ct != null) { |
|
587 |
// if (bMustClone) |
|
588 |
// geom = geom.cloneGeometry(); |
|
589 |
// geom.reProject(ct); |
|
590 |
// } |
|
591 |
// |
|
592 |
// // TODO: El m?todo contenedor (createLabelLayer) debe recoger |
|
593 |
// // los par?metros de posicionamiento y de allowDuplicates |
|
594 |
// // if (i >= 328) |
|
595 |
// // System.out.println("i= " + i + " " + val.toString()); |
|
596 |
// //ArrayList values=new ArrayList(4); |
|
597 |
// String t=new String(); |
|
598 |
// Value val = ds.getFieldValue(numReg, fieldId); |
|
599 |
// t=val.toString(); |
|
600 |
// //values.add(val); |
|
601 |
// if (idFieldColorText!=-1){ |
|
602 |
// Value valColor=ds.getFieldValue(numReg,idFieldColorText); |
|
603 |
// t=t.concat(valColor.toString()); |
|
604 |
// //values.add(valColor); |
|
605 |
// } |
|
606 |
// if (idFieldTypeFontText!=-1){ |
|
607 |
// Value valTypeFont=ds.getFieldValue(numReg,idFieldTypeFontText); |
|
608 |
// t=t.concat(valTypeFont.toString()); |
|
609 |
// //values.add(valTypeFont); |
|
610 |
// } |
|
611 |
// |
|
612 |
// if (idFieldStyleFontText!=-1){ |
|
613 |
// Value valStyleFont=ds.getFieldValue(numReg,idFieldStyleFontText); |
|
614 |
// t=t.concat(valStyleFont.toString()); |
|
615 |
// //values.add(valStyleFont); |
|
616 |
// } |
|
617 |
// //Value total=ValueFactory.createValue((Value[])values.toArray(new Value[0])); |
|
618 |
// Value total=ValueFactory.createValue(t); |
|
619 |
// if ((val instanceof NullValue) || (val == null)) { |
|
620 |
// return null; |
|
621 |
// } |
|
622 |
// FLabel[] lbls = geom.createLabels(0, true); |
|
623 |
// for (int j = 0; j < lbls.length; j++) { |
|
624 |
// if (lbls[j] != null) { |
|
625 |
// lbls[j].setString(val.toString()); |
|
626 |
// if (idFieldRotationText != -1) { |
|
627 |
// NumericValue rotation = (NumericValue) ds |
|
628 |
// .getFieldValue(numReg, idFieldRotationText); |
|
629 |
// lbls[j].setRotation(rotation.doubleValue()); |
|
630 |
// } else { |
|
631 |
// lbls[j].setRotation(defaultSym.getRotation()); |
|
632 |
// } |
|
633 |
// |
|
634 |
// float height; |
|
635 |
// if (idFieldHeightText != -1) { |
|
636 |
// NumericValue h = (NumericValue) ds |
|
637 |
// .getFieldValue(numReg, idFieldHeightText); |
|
638 |
// height=h.floatValue(); |
|
639 |
// lbls[j].setHeight(height); |
|
640 |
// } else { |
|
641 |
// height=defaultSym.getFontSize(); |
|
642 |
// lbls[j].setHeight(height); |
|
643 |
// } |
|
644 |
// |
|
645 |
// |
|
646 |
// |
|
647 |
// if (aLegend.getSymbolByValue(total)==null){ |
|
648 |
// Color color; |
|
649 |
// if (idFieldColorText != -1) { |
|
650 |
// NumericValue c = (NumericValue) ds.getFieldValue( |
|
651 |
// numReg, idFieldColorText); |
|
652 |
// color=new Color(c.intValue()); |
|
653 |
// } else { |
|
654 |
// color=defaultSym.getFontColor(); |
|
655 |
// } |
|
656 |
// String typeFont; |
|
657 |
// if (idFieldTypeFontText != -1) { |
|
658 |
// StringValue tf = (StringValue) ds |
|
659 |
// .getFieldValue(numReg, idFieldTypeFontText); |
|
660 |
// typeFont=tf.getValue(); |
|
661 |
// } else { |
|
662 |
// typeFont=defaultSym.getFont().getFontName(); |
|
663 |
// } |
|
664 |
// int style; |
|
665 |
// if (idFieldStyleFontText != -1) { |
|
666 |
// NumericValue sf = (NumericValue) ds |
|
667 |
// .getFieldValue(numReg, idFieldStyleFontText); |
|
668 |
// style=sf.intValue(); |
|
669 |
// } else { |
|
670 |
// style=defaultSym.getFont().getStyle(); |
|
671 |
// } |
|
672 |
// symbol=new FSymbol(FConstant.SYMBOL_TYPE_TEXT); |
|
673 |
// symbol.setFontSizeInPixels(isInPixels()); |
|
674 |
// symbol.setFont(new Font(typeFont,style,(int)height)); |
|
675 |
// symbol.setDescription(lbls[j].getString()); |
|
676 |
// symbol.setFontColor(color); |
|
677 |
// aLegend.addSymbol(total,symbol); |
|
678 |
// } |
|
679 |
// |
|
680 |
// } |
|
681 |
// return lbls[j]; |
|
682 |
// |
|
683 |
// } |
|
684 |
//// } |
|
685 |
// |
|
686 |
// if (this.isJoined()){ |
|
687 |
// ds.stop(); |
|
688 |
// } |
|
689 |
// adapter.stop(); |
|
690 |
// } catch (DriverIOException e) { |
|
691 |
// e.printStackTrace(); |
|
692 |
// throw new DriverException(e); |
|
693 |
// } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
694 |
// e.printStackTrace(); |
|
695 |
// throw new DriverException(e); |
|
696 |
// } |
|
697 |
// return null; |
|
698 |
// } |
|
545 |
// public FLabel getLabel(int numReg) { |
|
546 |
// if (m_labels == null || numReg == -1) |
|
547 |
// return null; |
|
548 |
// if (getSource() instanceof Annotation_EditableAdapter){ |
|
549 |
// Annotation_EditableAdapter aea=((Annotation_EditableAdapter)getSource()); |
|
550 |
// return aea.getLabel(numReg,false); |
|
551 |
// } |
|
552 |
// return (FLabel)m_labels.get(numReg); |
|
553 |
// } |
|
554 |
// private FLabel getLabelNew(int numReg) throws DriverException{ |
|
555 |
// SelectableDataSource ds = getRecordset(); |
|
556 |
// FSymbol symbol; |
|
557 |
// try { |
|
558 |
// ReadableVectorial adapter = getSource(); |
|
559 |
// adapter.start(); |
|
560 |
// if (isJoined()){ |
|
561 |
// ds.start(); |
|
562 |
// } |
|
563 |
// int sc; |
|
564 |
// // El mapping[0] es el text |
|
565 |
// int fieldId = mapping.getColumnText(); |
|
566 |
// // El mapping[1] es el ?ngulo |
|
567 |
// int idFieldRotationText = mapping.getColumnRotate(); |
|
568 |
// // El mapping[2] es el color |
|
569 |
// int idFieldColorText = mapping.getColumnColor(); |
|
570 |
// // El mapping[3] es el alto |
|
571 |
// int idFieldHeightText = mapping.getColumnHeight(); |
|
572 |
// // El mapping[4] es el tipo de fuente |
|
573 |
// int idFieldTypeFontText = mapping.getColumnTypeFont(); |
|
574 |
// // El mapping[5] es el estilo de fuente |
|
575 |
// int idFieldStyleFontText = mapping.getColumnStyleFont(); |
|
576 |
// |
|
577 |
// // sc = (int) ds.getRowCount(); |
|
578 |
// // m_labels = new ArrayList(sc); |
|
579 |
// // DriverAttributes attr = adapter.getDriverAttributes(); |
|
580 |
// boolean bMustClone = false; |
|
581 |
// // if (attr != null) { |
|
582 |
// // if (attr.isLoadedInMemory()) { |
|
583 |
// // bMustClone = attr.isLoadedInMemory(); |
|
584 |
// // } |
|
585 |
// // } |
|
586 |
// ICoordTrans ct = getCoordTrans(); |
|
587 |
// FSymbol defaultSym = (FSymbol) getLegend().getDefaultSymbol(); |
|
588 |
// // for (int i = 0; i < sc; i++) { |
|
589 |
// IGeometry geom = adapter.getShape(numReg); |
|
590 |
// |
|
591 |
// if (geom == null) { |
|
592 |
// // m_labels.add(null); |
|
593 |
// return null; |
|
594 |
// } |
|
595 |
// if (ct != null) { |
|
596 |
// if (bMustClone) |
|
597 |
// geom = geom.cloneGeometry(); |
|
598 |
// geom.reProject(ct); |
|
599 |
// } |
|
600 |
// |
|
601 |
// // TODO: El m?todo contenedor (createLabelLayer) debe recoger |
|
602 |
// // los par?metros de posicionamiento y de allowDuplicates |
|
603 |
// // if (i >= 328) |
|
604 |
// // System.out.println("i= " + i + " " + val.toString()); |
|
605 |
// //ArrayList values=new ArrayList(4); |
|
606 |
// String t=new String(); |
|
607 |
// Value val = ds.getFieldValue(numReg, fieldId); |
|
608 |
// t=val.toString(); |
|
609 |
// //values.add(val); |
|
610 |
// if (idFieldColorText!=-1){ |
|
611 |
// Value valColor=ds.getFieldValue(numReg,idFieldColorText); |
|
612 |
// t=t.concat(valColor.toString()); |
|
613 |
// //values.add(valColor); |
|
614 |
// } |
|
615 |
// if (idFieldTypeFontText!=-1){ |
|
616 |
// Value valTypeFont=ds.getFieldValue(numReg,idFieldTypeFontText); |
|
617 |
// t=t.concat(valTypeFont.toString()); |
|
618 |
// //values.add(valTypeFont); |
|
619 |
// } |
|
620 |
// |
|
621 |
// if (idFieldStyleFontText!=-1){ |
|
622 |
// Value valStyleFont=ds.getFieldValue(numReg,idFieldStyleFontText); |
|
623 |
// t=t.concat(valStyleFont.toString()); |
|
624 |
// //values.add(valStyleFont); |
|
625 |
// } |
|
626 |
// //Value total=ValueFactory.createValue((Value[])values.toArray(new |
|
627 |
// Value[0])); |
|
628 |
// Value total=ValueFactory.createValue(t); |
|
629 |
// if ((val instanceof NullValue) || (val == null)) { |
|
630 |
// return null; |
|
631 |
// } |
|
632 |
// FLabel[] lbls = geom.createLabels(0, true); |
|
633 |
// for (int j = 0; j < lbls.length; j++) { |
|
634 |
// if (lbls[j] != null) { |
|
635 |
// lbls[j].setString(val.toString()); |
|
636 |
// if (idFieldRotationText != -1) { |
|
637 |
// NumericValue rotation = (NumericValue) ds |
|
638 |
// .getFieldValue(numReg, idFieldRotationText); |
|
639 |
// lbls[j].setRotation(rotation.doubleValue()); |
|
640 |
// } else { |
|
641 |
// lbls[j].setRotation(defaultSym.getRotation()); |
|
642 |
// } |
|
643 |
// |
|
644 |
// float height; |
|
645 |
// if (idFieldHeightText != -1) { |
|
646 |
// NumericValue h = (NumericValue) ds |
|
647 |
// .getFieldValue(numReg, idFieldHeightText); |
|
648 |
// height=h.floatValue(); |
|
649 |
// lbls[j].setHeight(height); |
|
650 |
// } else { |
|
651 |
// height=defaultSym.getFontSize(); |
|
652 |
// lbls[j].setHeight(height); |
|
653 |
// } |
|
654 |
// |
|
655 |
// |
|
656 |
// |
|
657 |
// if (aLegend.getSymbolByValue(total)==null){ |
|
658 |
// Color color; |
|
659 |
// if (idFieldColorText != -1) { |
|
660 |
// NumericValue c = (NumericValue) ds.getFieldValue( |
|
661 |
// numReg, idFieldColorText); |
|
662 |
// color=new Color(c.intValue()); |
|
663 |
// } else { |
|
664 |
// color=defaultSym.getFontColor(); |
|
665 |
// } |
|
666 |
// String typeFont; |
|
667 |
// if (idFieldTypeFontText != -1) { |
|
668 |
// StringValue tf = (StringValue) ds |
|
669 |
// .getFieldValue(numReg, idFieldTypeFontText); |
|
670 |
// typeFont=tf.getValue(); |
|
671 |
// } else { |
|
672 |
// typeFont=defaultSym.getFont().getFontName(); |
|
673 |
// } |
|
674 |
// int style; |
|
675 |
// if (idFieldStyleFontText != -1) { |
|
676 |
// NumericValue sf = (NumericValue) ds |
|
677 |
// .getFieldValue(numReg, idFieldStyleFontText); |
|
678 |
// style=sf.intValue(); |
|
679 |
// } else { |
|
680 |
// style=defaultSym.getFont().getStyle(); |
|
681 |
// } |
|
682 |
// symbol=new FSymbol(FConstant.SYMBOL_TYPE_TEXT); |
|
683 |
// symbol.setFontSizeInPixels(isInPixels()); |
|
684 |
// symbol.setFont(new Font(typeFont,style,(int)height)); |
|
685 |
// symbol.setDescription(lbls[j].getString()); |
|
686 |
// symbol.setFontColor(color); |
|
687 |
// aLegend.addSymbol(total,symbol); |
|
688 |
// } |
|
689 |
// |
|
690 |
// } |
|
691 |
// return lbls[j]; |
|
692 |
// |
|
693 |
// } |
|
694 |
// // } |
|
695 |
// |
|
696 |
// if (this.isJoined()){ |
|
697 |
// ds.stop(); |
|
698 |
// } |
|
699 |
// adapter.stop(); |
|
700 |
// } catch (DriverIOException e) { |
|
701 |
// e.printStackTrace(); |
|
702 |
// throw new DriverException(e); |
|
703 |
// } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
704 |
// e.printStackTrace(); |
|
705 |
// throw new DriverException(e); |
|
706 |
// } |
|
707 |
// return null; |
|
708 |
// } |
|
699 | 709 |
/* |
700 | 710 |
* (non-Javadoc) |
701 |
* |
|
711 |
*
|
|
702 | 712 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.RandomVectorialData#createIndex() |
703 | 713 |
*/ |
704 | 714 |
public void createSpatialIndex() { |
... | ... | |
706 | 716 |
// QUE ACCEDER CON UN WHILE NEXT. (O mejorar lo de los FeatureVisitor |
707 | 717 |
// para que acepten recorrer sin geometria, solo con rectangulos. |
708 | 718 |
|
709 |
//AZABALA: Como no tengo claro de donde se crean las capas de textos |
|
710 |
//el ?ndice espacial creado seguir? siendo el Quadtree en memoria |
|
711 |
//de JTS (QuadtreeJts es un adapter a nuestra api de indices) |
|
719 |
// AZABALA: Como no tengo claro de donde se crean las capas de textos
|
|
720 |
// el ?ndice espacial creado seguir? siendo el Quadtree en memoria
|
|
721 |
// de JTS (QuadtreeJts es un adapter a nuestra api de indices)
|
|
712 | 722 |
spatialIndex = new QuadtreeJts(); |
713 | 723 |
ReadableVectorial va = getSource(); |
714 | 724 |
ICoordTrans ct = getCoordTrans(); |
... | ... | |
717 | 727 |
va.start(); |
718 | 728 |
for (int i = 0; i < va.getShapeCount(); i++) { |
719 | 729 |
Rectangle2D r = null; |
720 |
IGeometry geom=va.getShape(i);
|
|
721 |
// FSymbol symbol=(FSymbol)aLegend.getSymbol(i);
|
|
722 |
// IGeometry geom=aLegend.getTextWrappingGeometry(symbol,i);
|
|
723 |
// FLabel label=getLabel(i);
|
|
730 |
IGeometry geom = va.getShape(i);
|
|
731 |
// FSymbol symbol=(FSymbol)aLegend.getSymbol(i);
|
|
732 |
// IGeometry geom=aLegend.getTextWrappingGeometry(symbol,i);
|
|
733 |
// FLabel label=getLabel(i);
|
|
724 | 734 |
if (geom != null) { |
725 | 735 |
r = geom.getBounds2D(); |
726 | 736 |
} else { |
... | ... | |
731 | 741 |
r = ct.convert(r); |
732 | 742 |
} |
733 | 743 |
if (r != null) { |
734 |
// Coordinate c1 = new Coordinate(r.getMinX(), r.getMinY());
|
|
735 |
// Coordinate c2 = new Coordinate(r.getMaxX(), r.getMaxY());
|
|
736 |
// Envelope env = new Envelope(c1, c2);
|
|
737 |
// spatialIndex.insert(env, new Integer(i));
|
|
744 |
// Coordinate c1 = new Coordinate(r.getMinX(), r.getMinY());
|
|
745 |
// Coordinate c2 = new Coordinate(r.getMaxX(), r.getMaxY());
|
|
746 |
// Envelope env = new Envelope(c1, c2);
|
|
747 |
// spatialIndex.insert(env, new Integer(i));
|
|
738 | 748 |
spatialIndex.insert(r, i); |
739 | 749 |
} |
740 | 750 |
} // for |
... | ... | |
755 | 765 |
|
756 | 766 |
public void setInPixels(boolean b) { |
757 | 767 |
inPixels = b; |
758 |
if (aLegend!=null)
|
|
768 |
if (aLegend != null)
|
|
759 | 769 |
aLegend.setInPixels(b); |
760 | 770 |
} |
761 | 771 |
|
... | ... | |
772 | 782 |
return indexEditing; |
773 | 783 |
} |
774 | 784 |
|
775 |
// public ArrayList getLabels() {
|
|
776 |
// return m_labels;
|
|
777 |
// }
|
|
785 |
// public ArrayList getLabels() {
|
|
786 |
// return m_labels;
|
|
787 |
// }
|
|
778 | 788 |
|
779 |
|
|
780 | 789 |
public void setLegend() { |
781 | 790 |
try { |
782 | 791 |
getSource().getRecordset().start(); |
783 |
aLegend.setFieldName(getSource().getRecordset().getFieldName(mapping.getColumnText())); |
|
784 |
//aLegend.setDefaultSymbol(new FSymbol(FConstant.SYMBOL_TYPE_TEXT)); |
|
792 |
aLegend.setFieldName(getSource().getRecordset().getFieldName( |
|
793 |
mapping.getColumnText())); |
|
794 |
// aLegend.setDefaultSymbol(new |
|
795 |
// FSymbol(FConstant.SYMBOL_TYPE_TEXT)); |
|
785 | 796 |
setLegend(aLegend); |
786 | 797 |
getSource().getRecordset().stop(); |
787 | 798 |
} catch (FieldNotFoundException e) { |
... | ... | |
803 | 814 |
public void setEditing(boolean b) throws EditionException { |
804 | 815 |
super.setEditing(b); |
805 | 816 |
try { |
806 |
if (b) { |
|
817 |
if (b) {
|
|
807 | 818 |
Annotation_EditableAdapter aea = new Annotation_EditableAdapter( |
808 | 819 |
this); |
809 |
aea.setOriginalVectorialAdapter(((VectorialEditableAdapter)super.getSource()).getOriginalAdapter()); |
|
810 |
((VectorialEditableAdapter)super.getSource()).cancelEdition(EditionEvent.GRAPHIC); |
|
820 |
aea |
|
821 |
.setOriginalVectorialAdapter(((VectorialEditableAdapter) super |
|
822 |
.getSource()).getOriginalAdapter()); |
|
823 |
((VectorialEditableAdapter) super.getSource()) |
|
824 |
.cancelEdition(EditionEvent.GRAPHIC); |
|
811 | 825 |
aea.start(); |
812 | 826 |
// CHEMA |
813 | 827 |
aea.startEdition(EditionEvent.GRAPHIC); |
... | ... | |
815 | 829 |
getRecordset().setSelectionSupport( |
816 | 830 |
aea.getOriginalAdapter().getRecordset() |
817 | 831 |
.getSelectionSupport()); |
818 |
}else{
|
|
819 |
// createLabels();
|
|
832 |
} else {
|
|
833 |
// createLabels();
|
|
820 | 834 |
} |
821 | 835 |
} catch (DriverIOException e) { |
822 | 836 |
throw new EditionException(); |
... | ... | |
831 | 845 |
|
832 | 846 |
} |
833 | 847 |
|
834 |
public static FLayer createLayerFromVect(FLyrVect layer) throws DriverException, FieldNotFoundException { |
|
835 |
Annotation_Layer la=new Annotation_Layer(); |
|
848 |
public static FLayer createLayerFromVect(FLyrVect layer) |
|
849 |
throws DriverException, FieldNotFoundException { |
|
850 |
Annotation_Layer la = new Annotation_Layer(); |
|
836 | 851 |
la.setSource(layer.getSource()); |
837 | 852 |
la.setRecordset(layer.getRecordset()); |
838 | 853 |
la.setProjection(layer.getProjection()); |
839 |
la.setLegend((VectorialLegend)layer.getLegend()); |
|
854 |
la.setLegend((VectorialLegend) layer.getLegend());
|
|
840 | 855 |
return la; |
841 | 856 |
} |
842 | 857 |
|
843 | 858 |
public void removingThisLayer() { |
844 | 859 |
super.removingThisLayer(); |
845 |
// m_labels.clear();
|
|
846 |
spatialIndex=null;
|
|
847 |
aLegend=null;
|
|
848 |
strategy=null;
|
|
860 |
// m_labels.clear();
|
|
861 |
spatialIndex = null;
|
|
862 |
aLegend = null;
|
|
863 |
strategy = null;
|
|
849 | 864 |
System.gc(); |
850 | 865 |
} |
851 |
public IGeometry getTextWrappingGeometry(float height, String description, |
|
852 |
double rotation, int numReg) throws DriverIOException { |
|
853 |
ReadableVectorial adapter = getSource(); |
|
854 |
// adapter.start(); |
|
855 |
ICoordTrans ct = getCoordTrans(); |
|
856 |
IGeometry geom = adapter.getShape(numReg); |
|
857 |
boolean bMustClone = false; |
|
858 |
if (geom == null) { |
|
859 |
return null; |
|
860 |
} |
|
861 |
if (ct != null) { |
|
862 |
if (bMustClone) |
|
863 |
geom = geom.cloneGeometry(); |
|
864 |
geom.reProject(ct); |
|
865 |
} |
|
866 |
// FLabel[] lbls = geom.createLabels(0, true); |
|
867 |
FPoint2D p = ((FPoint2D) geom.getInternalShape()); |
|
868 |
// assuming FShape is a point with the starting position of the text |
|
869 |
// Font font = symbol.getFont(); |
|
870 |
double h = height; |
|
871 |
if (isInPixels()) |
|
872 |
h=getMapContext().getViewPort().toMapDistance( |
|
873 |
(int) (height)); |
|
874 |
// else |
|
875 |
// h=h*FConstant.FONT_HEIGHT_SCALE_FACTOR; |
|
876 | 866 |
|
877 |
Font font = new Font("Arial", 0, |
|
878 |
(int) (h* FConstant.FONT_HEIGHT_SCALE_FACTOR)); |
|
879 |
FontRenderContext frc = new FontRenderContext(new AffineTransform(), |
|
880 |
false, true);// g.getFontRenderContext(); |
|
881 |
GlyphVector gv = font.createGlyphVector(frc, description); |
|
867 |
public IGeometry getTextWrappingGeometry(float height, String description, |
|
868 |
double rotation, int numReg) throws DriverIOException { |
|
869 |
ReadableVectorial adapter = getSource(); |
|
870 |
// adapter.start(); |
|
871 |
ICoordTrans ct = getCoordTrans(); |
|
872 |
IGeometry geom = adapter.getShape(numReg); |
|
873 |
boolean bMustClone = false; |
|
874 |
if (geom == null) { |
|
875 |
return null; |
|
876 |
} |
|
877 |
if (ct != null) { |
|
878 |
if (bMustClone) |
|
879 |
geom = geom.cloneGeometry(); |
|
880 |
geom.reProject(ct); |
|
881 |
} |
|
882 |
// FLabel[] lbls = geom.createLabels(0, true); |
|
883 |
FPoint2D p = ((FPoint2D) geom.getInternalShape()); |
|
884 |
// assuming FShape is a point with the starting position of the text |
|
885 |
// Font font = symbol.getFont(); |
|
886 |
double h = height; |
|
887 |
if (isInPixels()) |
|
888 |
h = getMapContext().getViewPort().toMapDistance((int) (height)); |
|
889 |
// else |
|
890 |
// h=h*FConstant.FONT_HEIGHT_SCALE_FACTOR; |
|
882 | 891 |
|
883 |
/* p.transform(affineTransform); */ |
|
884 |
Shape shape = gv.getOutline((float) p.getX(), (float) (p.getY() + h)); |
|
892 |
Font font = new Font("Arial", 0, |
|
893 |
(int) (h * FConstant.FONT_HEIGHT_SCALE_FACTOR)); |
|
894 |
FontRenderContext frc = new FontRenderContext(new AffineTransform(), |
|
895 |
false, true);// g.getFontRenderContext(); |
|
896 |
GlyphVector gv = font.createGlyphVector(frc, description); |
|
885 | 897 |
|
886 |
IGeometry geomResult = ShapeFactory.createPolygon2D(new GeneralPathX(
|
|
887 |
shape.getBounds2D()));
|
|
888 |
// IGeometry geomResult2 = ShapeFactory.createPolygon2D(new GeneralPathX( |
|
889 |
// shape.getBounds2D()));
|
|
890 |
// geomResult2.transform(layer.getMapContext().getViewPort().getAffineTransform());
|
|
891 |
// Rectangle r = geomResult2.getBounds();
|
|
892 |
if (rotation != 0) {
|
|
893 |
geomResult.transform(AffineTransform.getRotateInstance(rotation, p
|
|
894 |
.getX(), p.getY()));
|
|
895 |
}
|
|
896 |
// adapter.stop();
|
|
897 |
// geomResult.transform(layer.getMapContext().getViewPort().getAffineTransform());
|
|
898 |
return geomResult;
|
|
898 |
/* p.transform(affineTransform); */
|
|
899 |
Shape shape = gv.getOutline((float) p.getX(), (float) (p.getY() + h));
|
|
900 |
|
|
901 |
IGeometry geomResult = ShapeFactory.createPolygon2D(new GeneralPathX(
|
|
902 |
shape.getBounds2D()));
|
|
903 |
// IGeometry geomResult2 = ShapeFactory.createPolygon2D(new
|
|
904 |
// GeneralPathX(
|
|
905 |
// shape.getBounds2D()));
|
|
906 |
// geomResult2.transform(layer.getMapContext().getViewPort().getAffineTransform());
|
|
907 |
// Rectangle r = geomResult2.getBounds();
|
|
908 |
if (rotation != 0) {
|
|
909 |
geomResult.transform(AffineTransform.getRotateInstance(rotation, p
|
|
910 |
.getX(), p.getY()));
|
|
899 | 911 |
} |
912 |
// adapter.stop(); |
|
913 |
// geomResult.transform(layer.getMapContext().getViewPort().getAffineTransform()); |
|
914 |
return geomResult; |
|
915 |
} |
|
900 | 916 |
} |
Also available in: Unified diff