Revision 42293 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/FLayers.java
FLayers.java | ||
---|---|---|
26 | 26 |
import java.awt.Point; |
27 | 27 |
import java.awt.image.BufferedImage; |
28 | 28 |
import java.util.ArrayList; |
29 |
import java.util.Collection; |
|
29 | 30 |
import java.util.Collections; |
30 | 31 |
import java.util.Iterator; |
31 | 32 |
import java.util.List; |
33 |
import java.util.ListIterator; |
|
32 | 34 |
import java.util.Set; |
33 | 35 |
import java.util.TreeSet; |
34 | 36 |
|
... | ... | |
65 | 67 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
66 | 68 |
import org.gvsig.tools.task.Cancellable; |
67 | 69 |
import org.gvsig.tools.util.Callable; |
68 |
import org.gvsig.tools.visitor.NotSupportedOperationException; |
|
69 | 70 |
import org.gvsig.tools.visitor.VisitCanceledException; |
70 | 71 |
import org.gvsig.tools.visitor.Visitor; |
71 | 72 |
|
... | ... | |
84 | 85 |
* @see FLyrDefault |
85 | 86 |
*/ |
86 | 87 |
public class FLayers extends FLyrDefault implements LayerCollection, |
87 |
InfoByPoint { |
|
88 |
InfoByPoint, List {
|
|
88 | 89 |
|
89 | 90 |
/** |
90 | 91 |
* List with all listeners registered for this kind of node. |
... | ... | |
187 | 188 |
IProjection layerProj = layer.getProjection(); |
188 | 189 |
if (layerProj != null && fmap != null) { |
189 | 190 |
IProjection mapContextProj = fmap.getProjection(); |
190 |
// TODO REVISAR ESTO !!!!
|
|
191 |
// TODO REVISAR ESTO !!!!
|
|
191 | 192 |
// Esta condici?n puede que no fuese exacta para todos los casos |
192 | 193 |
if (!layerProj.getAbrev().equals(mapContextProj.getAbrev())) { |
193 | 194 |
ICoordTrans ct = layerProj.getCT(mapContextProj); |
... | ... | |
400 | 401 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.LayerCollection#getLayer(java.lang.String) |
401 | 402 |
*/ |
402 | 403 |
public FLayer getLayer(String layerName) { |
403 |
FLayer lyr; |
|
404 |
FLayer lyr2; |
|
405 |
ArrayList layerList; |
|
406 |
|
|
407 | 404 |
for (int i = 0; i < layers.size(); i++) { |
408 |
lyr = ((FLayer) layers.get(i)); |
|
409 |
|
|
405 |
FLayer lyr = ((FLayer) layers.get(i)); |
|
410 | 406 |
if (lyr.getName().compareToIgnoreCase(layerName) == 0) { |
411 | 407 |
return lyr; |
412 | 408 |
} |
413 |
|
|
414 |
layerList = new ArrayList();
|
|
415 |
splitLayerGroup(lyr, layerList);
|
|
416 |
for (int j = 0; j < layerList.size(); j++) {
|
|
417 |
lyr2 = ((FLayer) layerList.get(j));
|
|
418 |
if (lyr2.getName().compareToIgnoreCase(layerName) == 0) {
|
|
419 |
return lyr2;
|
|
409 |
if (lyr instanceof FLayers) { |
|
410 |
List layerList = toPlainList(lyr);
|
|
411 |
for (int j = 0; j < layerList.size(); j++) {
|
|
412 |
FLayer lyr2 = ((FLayer) layerList.get(j));
|
|
413 |
if (lyr2.getName().compareToIgnoreCase(layerName) == 0) {
|
|
414 |
return lyr2;
|
|
415 |
}
|
|
420 | 416 |
} |
421 | 417 |
} |
422 | 418 |
} |
423 |
|
|
424 | 419 |
return null; |
425 | 420 |
} |
426 | 421 |
|
427 |
/** |
|
428 |
* <p> |
|
429 |
* Splits up a layer group in order to get a layer by name when there are |
|
430 |
* layer groups</p> |
|
431 |
* |
|
432 |
* <p> |
|
433 |
* In <code>result</code> always will be at least one layer.</p> |
|
434 |
* |
|
435 |
* @param layer the layer we are looking for |
|
436 |
* @param result an array list that will have the results of the search |
|
437 |
*/ |
|
438 |
private void splitLayerGroup(FLayer layer, ArrayList result) { |
|
439 |
int i; |
|
440 |
FLayers layerGroup; |
|
422 |
private List toPlainList(FLayer layer) { |
|
423 |
return toPlainList(layer, new ArrayList()); |
|
424 |
} |
|
425 |
|
|
426 |
private List toPlainList(FLayer layer, List result) { |
|
441 | 427 |
if (layer instanceof FLayers) { |
442 |
layerGroup = (FLayers) layer; |
|
443 |
for (i = 0; i < layerGroup.getLayersCount(); i++) { |
|
444 |
splitLayerGroup(layerGroup.getLayer(i), result);
|
|
428 |
FLayers layerGroup = (FLayers) layer;
|
|
429 |
for (int i = 0; i < layerGroup.getLayersCount(); i++) {
|
|
430 |
toPlainList(layerGroup.getLayer(i), result);
|
|
445 | 431 |
} |
446 | 432 |
} else { |
447 | 433 |
result.add(layer); |
448 | 434 |
} |
435 |
return result; |
|
449 | 436 |
} |
450 | 437 |
|
451 | 438 |
/* |
... | ... | |
546 | 533 |
dpi = 72; |
547 | 534 |
} |
548 | 535 |
|
549 |
// TODO: A la hora de imprimir, isWithinScale falla, porque est?
|
|
536 |
// TODO: A la hora de imprimir, isWithinScale falla, porque est?
|
|
550 | 537 |
// calculando la escala en pantalla, no para el layout. |
551 | 538 |
// Revisar esto. |
552 | 539 |
// TODO: We have to check when we have to call the drawLabels method when exists a ComposedLayer group. |
... | ... | |
558 | 545 |
|
559 | 546 |
try { |
560 | 547 |
|
561 |
///// CHEMA ComposedLayer
|
|
548 |
///// CHEMA ComposedLayer
|
|
562 | 549 |
// Checks for draw group (ComposedLayer) |
563 | 550 |
if (group != null) { |
564 | 551 |
if (lyr instanceof FLayers) { |
... | ... | |
647 | 634 |
} |
648 | 635 |
///// CHEMA ComposedLayer |
649 | 636 |
|
650 |
// if (getVirtualLayers() != null) {
|
|
637 |
// if (getVirtualLayers() != null) {
|
|
651 | 638 |
// getVirtualLayers().print( g, viewPort, cancel, scale, properties); |
652 | 639 |
// } |
653 | 640 |
///// CHEMA ComposedLayer |
... | ... | |
843 | 830 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.LayerCollection#getActives() |
844 | 831 |
*/ |
845 | 832 |
public FLayer[] getActives() { |
846 |
ArrayList ret = new ArrayList();
|
|
833 |
List ret = new ArrayList(); |
|
847 | 834 |
LayersIterator it = new LayersIterator(this) { |
848 | 835 |
|
849 | 836 |
public boolean evaluate(FLayer layer) { |
... | ... | |
968 | 955 |
* |
969 | 956 |
* @throws LoadLayerException if fails loading this layer. |
970 | 957 |
*/ |
971 |
// public boolean addLayerFromXMLEntity(XMLEntity xml, String name) throws LoadLayerException {
|
|
958 |
// public boolean addLayerFromXMLEntity(XMLEntity xml, String name) throws LoadLayerException {
|
|
972 | 959 |
// fmap.clearErrors(); |
973 | 960 |
// this.addLayerFromXML(xml,name); |
974 | 961 |
// |
... | ... | |
1453 | 1440 |
|
1454 | 1441 |
} |
1455 | 1442 |
|
1443 |
public FLayer getFirstActiveLayer() { |
|
1444 |
LayersIterator it = new LayersIterator(this) { |
|
1445 |
public boolean evaluate(FLayer layer) { |
|
1446 |
return layer.isActive(); |
|
1447 |
} |
|
1448 |
}; |
|
1449 |
if( it.hasNext() ) { |
|
1450 |
return (FLayer) it.next(); |
|
1451 |
} |
|
1452 |
return null; |
|
1453 |
} |
|
1454 |
|
|
1455 |
public Iterator iterator() { |
|
1456 |
return this.layers.iterator(); |
|
1457 |
} |
|
1458 |
|
|
1459 |
public Iterator deepiterator() { |
|
1460 |
List layers = toPlainList(this); |
|
1461 |
return layers.iterator(); |
|
1462 |
} |
|
1463 |
|
|
1464 |
public int size() { |
|
1465 |
return this.layers.size(); |
|
1466 |
} |
|
1467 |
|
|
1468 |
public Object get(int index) { |
|
1469 |
return this.layers.get(index); |
|
1470 |
} |
|
1471 |
|
|
1472 |
public boolean isEmpty() { |
|
1473 |
return this.layers.isEmpty(); |
|
1474 |
} |
|
1475 |
|
|
1476 |
public boolean contains(Object o) { |
|
1477 |
return this.layers.contains(o); |
|
1478 |
} |
|
1479 |
|
|
1480 |
public Object[] toArray() { |
|
1481 |
return this.layers.toArray(); |
|
1482 |
} |
|
1483 |
|
|
1484 |
public Object[] toArray(Object[] ts) { |
|
1485 |
return this.layers.toArray(ts); |
|
1486 |
} |
|
1487 |
|
|
1488 |
public boolean add(Object e) { |
|
1489 |
this.addLayer((FLayer) e); |
|
1490 |
return true; |
|
1491 |
} |
|
1492 |
|
|
1493 |
public boolean remove(Object o) { |
|
1494 |
this.removeLayer((FLayer) o); |
|
1495 |
return true; |
|
1496 |
} |
|
1497 |
|
|
1498 |
public boolean containsAll(Collection clctn) { |
|
1499 |
return this.layers.containsAll(clctn); |
|
1500 |
} |
|
1501 |
|
|
1502 |
public void add(int i, Object e) { |
|
1503 |
this.addLayer(i, (FLayer) e); |
|
1504 |
} |
|
1505 |
|
|
1506 |
public Object remove(int i) { |
|
1507 |
FLayer o = this.getLayer(i); |
|
1508 |
this.removeLayer(i); |
|
1509 |
return o; |
|
1510 |
} |
|
1511 |
|
|
1512 |
public int indexOf(Object o) { |
|
1513 |
return this.layers.indexOf(o); |
|
1514 |
} |
|
1515 |
|
|
1516 |
public int lastIndexOf(Object o) { |
|
1517 |
return this.layers.lastIndexOf(o); |
|
1518 |
} |
|
1519 |
|
|
1520 |
public ListIterator listIterator() { |
|
1521 |
return this.layers.listIterator(); |
|
1522 |
} |
|
1523 |
|
|
1524 |
public ListIterator listIterator(int i) { |
|
1525 |
return this.layers.listIterator(i); |
|
1526 |
} |
|
1527 |
|
|
1528 |
public List subList(int i, int i1) { |
|
1529 |
return this.layers.subList(i, i1); |
|
1530 |
} |
|
1531 |
|
|
1532 |
public boolean addAll(Collection clctn) { |
|
1533 |
Iterator it = clctn.iterator(); |
|
1534 |
while( it.hasNext() ) { |
|
1535 |
this.add(it.next()); |
|
1536 |
} |
|
1537 |
return true; |
|
1538 |
} |
|
1539 |
|
|
1540 |
public boolean addAll(int i, Collection clctn) { |
|
1541 |
Iterator it = clctn.iterator(); |
|
1542 |
while( it.hasNext() ) { |
|
1543 |
this.add(i,it.next()); |
|
1544 |
} |
|
1545 |
return true; |
|
1546 |
} |
|
1547 |
|
|
1548 |
public boolean removeAll(Collection clctn) { |
|
1549 |
Iterator it = clctn.iterator(); |
|
1550 |
while( it.hasNext() ) { |
|
1551 |
this.remove(it.next()); |
|
1552 |
} |
|
1553 |
return true; |
|
1554 |
} |
|
1555 |
|
|
1556 |
public boolean retainAll(Collection clctn) { |
|
1557 |
Iterator it = this.layers.iterator(); |
|
1558 |
while( it.hasNext() ) { |
|
1559 |
Object o = it.next(); |
|
1560 |
if( !clctn.contains(o) ) { |
|
1561 |
this.remove(o); |
|
1562 |
} |
|
1563 |
} |
|
1564 |
return true; |
|
1565 |
} |
|
1566 |
|
|
1567 |
public Object set(int i, Object e) { |
|
1568 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
1569 |
} |
|
1570 |
|
|
1456 | 1571 |
} |
Also available in: Unified diff