Revision 47790 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/MapContext.java
MapContext.java | ||
---|---|---|
29 | 29 |
import java.awt.image.BufferedImage; |
30 | 30 |
import java.util.ArrayList; |
31 | 31 |
import java.util.Collection; |
32 |
import java.util.HashSet; |
|
33 | 32 |
import java.util.Iterator; |
34 | 33 |
import java.util.LinkedHashMap; |
35 | 34 |
import java.util.List; |
36 | 35 |
import java.util.Map; |
37 | 36 |
import java.util.Set; |
38 |
import java.util.function.Predicate; |
|
39 | 37 |
import org.apache.commons.lang3.ArrayUtils; |
40 |
|
|
41 | 38 |
import org.cresques.cts.ICoordTrans; |
42 | 39 |
import org.cresques.cts.IProjection; |
43 | 40 |
import org.cresques.geo.Projected; |
44 |
import org.slf4j.Logger; |
|
45 |
import org.slf4j.LoggerFactory; |
|
46 |
|
|
47 | 41 |
import org.gvsig.compat.CompatLocator; |
48 | 42 |
import org.gvsig.compat.print.PrintAttributes; |
49 | 43 |
import org.gvsig.fmap.dal.DataStore; |
... | ... | |
101 | 95 |
import org.gvsig.tools.task.Cancellable; |
102 | 96 |
import org.gvsig.tools.util.Callable; |
103 | 97 |
import org.gvsig.tools.visitor.Visitor; |
98 |
import org.slf4j.Logger; |
|
99 |
import org.slf4j.LoggerFactory; |
|
104 | 100 |
|
105 | 101 |
/** |
106 | 102 |
* <p> |
... | ... | |
144 | 140 |
public static ArrayList DISTANCEABBR = new ArrayList(); |
145 | 141 |
public static ArrayList DISTANCETRANS2METER = new ArrayList(); |
146 | 142 |
|
143 |
public static final Color DEFAULT_SELECTION_COLOR = new Color(Color.YELLOW.getRed(), Color.YELLOW.getGreen(), Color.YELLOW.getBlue(), 127); |
|
144 |
|
|
147 | 145 |
static { |
148 | 146 |
MapContext.addDistanceUnit("Kilometros", "Km", 1000); |
149 | 147 |
MapContext.addDistanceUnit("Metros", "m", 1); |
... | ... | |
496 | 494 |
* <p> |
497 | 495 |
* Color used to represent the selections.</p> |
498 | 496 |
*/ |
499 |
private static Color selectionColor = new Color(Color.YELLOW.getRed(), Color.YELLOW.getGreen(), Color.YELLOW.getBlue(), 127);
|
|
497 |
// private Color selectionColor = DEFAULT_SELECTION_COLOR;
|
|
500 | 498 |
private Set<FLyrVect> layersToSnap = new LayersToSnap(); |
501 | 499 |
|
502 | 500 |
/** |
... | ... | |
505 | 503 |
* |
506 | 504 |
* @return color used to represent the selections |
507 | 505 |
*/ |
508 |
public static Color getSelectionColor() { |
|
509 |
return selectionColor; |
|
506 |
public Color getSelectionColor() { |
|
507 |
if(this.viewPort == null) { |
|
508 |
return MapContext.DEFAULT_SELECTION_COLOR; |
|
509 |
} |
|
510 |
return this.viewPort.getSelectionColor(); |
|
510 | 511 |
} |
511 | 512 |
|
512 | 513 |
/** |
... | ... | |
515 | 516 |
* |
516 | 517 |
* @param selectionColor color used to represent the selections |
517 | 518 |
*/ |
518 |
public static void setSelectionColor(Color selectionColor) { |
|
519 |
MapContext.selectionColor = selectionColor; |
|
519 |
public void setSelectionColor(Color selectionColor) { |
|
520 |
if(this.viewPort == null){ |
|
521 |
return; |
|
522 |
} |
|
523 |
this.viewPort.setSelectionColor(selectionColor); |
|
520 | 524 |
} |
521 | 525 |
|
522 | 526 |
/** |
... | ... | |
1174 | 1178 |
/** |
1175 | 1179 |
* @see org.gvsig.utils.swing.threads.Cancellable#isCanceled() |
1176 | 1180 |
*/ |
1181 |
@Override |
|
1177 | 1182 |
public boolean isCanceled() { |
1178 | 1183 |
return false; |
1179 | 1184 |
} |
1180 | 1185 |
|
1186 |
@Override |
|
1181 | 1187 |
public void setCanceled(boolean canceled) { |
1182 | 1188 |
// Do nothing |
1183 | 1189 |
} |
... | ... | |
1482 | 1488 |
* |
1483 | 1489 |
* @see Object#equals(Object) |
1484 | 1490 |
*/ |
1491 |
@Override |
|
1485 | 1492 |
public boolean equals(Object arg0) { |
1486 | 1493 |
if (!(arg0 instanceof MapContext)) { |
1487 | 1494 |
return false; |
... | ... | |
1582 | 1589 |
|
1583 | 1590 |
} |
1584 | 1591 |
|
1592 |
@Override |
|
1585 | 1593 |
public void update(Observable observable, Object notification) { |
1586 | 1594 |
// TODO REVISAR ESTO!!! |
1587 | 1595 |
String ntype = null; |
... | ... | |
1650 | 1658 |
} |
1651 | 1659 |
} |
1652 | 1660 |
|
1661 |
@Override |
|
1653 | 1662 |
public void loadFromState(PersistentState state) |
1654 | 1663 |
throws PersistenceException { |
1655 | 1664 |
|
1656 | 1665 |
ViewPort vp = (ViewPort) state.get("ViewPort"); |
1657 | 1666 |
setViewPort(vp); |
1658 |
|
|
1667 |
|
|
1659 | 1668 |
layers = (FLayers) state.get("layers"); |
1660 | 1669 |
layers.setName("root layer"); |
1661 | 1670 |
loadLayers(layers); |
... | ... | |
1691 | 1700 |
} |
1692 | 1701 |
} |
1693 | 1702 |
|
1703 |
@Override |
|
1694 | 1704 |
public void saveToState(PersistentState state) throws PersistenceException { |
1695 | 1705 |
state.set("ViewPort", viewPort); |
1696 | 1706 |
state.set("layers", (Persistent)layers); |
... | ... | |
1699 | 1709 |
|
1700 | 1710 |
public static class RegisterPersistence implements Callable { |
1701 | 1711 |
|
1712 |
@Override |
|
1702 | 1713 |
public Object call() { |
1703 | 1714 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
1704 | 1715 |
DynStruct definition = manager.addDefinition( |
... | ... | |
1724 | 1735 |
} |
1725 | 1736 |
} |
1726 | 1737 |
|
1738 |
@Override |
|
1727 | 1739 |
protected void doDispose() throws BaseException { |
1728 | 1740 |
dispose(layers); |
1729 | 1741 |
for (VectorLayer tracLayer : this.tracLayers.values()) { |
... | ... | |
1784 | 1796 |
|
1785 | 1797 |
public boolean hasActiveVectorLayers() { |
1786 | 1798 |
FLayer[] layers = this.getLayers().getActives(); |
1787 |
for (int i = 0; i < layers.length; i++) { |
|
1788 |
FLayer layer = layers[i]; |
|
1799 |
for (FLayer layer : layers) { |
|
1789 | 1800 |
if (layer.isAvailable() && layer instanceof FLyrVect) { |
1790 | 1801 |
return true; |
1791 | 1802 |
} |
Also available in: Unified diff