1 |
alfonx |
1220 |
package skrueger.geotools; |
2 |
|
|
|
3 |
|
|
import javax.swing.JLabel; |
4 |
|
|
|
5 |
|
|
import schmitzm.geotools.gui.SelectableXMapPane; |
6 |
|
|
import schmitzm.geotools.gui.XMapPaneEvent; |
7 |
|
|
import schmitzm.geotools.map.event.JMapPaneListener; |
8 |
|
|
|
9 |
|
|
public class CrsLabel extends JLabel { |
10 |
|
|
|
11 |
|
|
private JMapPaneListener listenForCrsChange = new JMapPaneListener() { |
12 |
|
|
|
13 |
|
|
@Override |
14 |
|
|
public void performMapPaneEvent(XMapPaneEvent e) { |
15 |
|
|
updateCrs(); |
16 |
|
|
} |
17 |
|
|
}; |
18 |
|
|
|
19 |
|
|
private final SelectableXMapPane mapPane; |
20 |
|
|
|
21 |
|
|
CrsLabel(SelectableXMapPane mapPane) { |
22 |
|
|
super(); |
23 |
|
|
this.mapPane = mapPane; |
24 |
|
|
|
25 |
|
|
mapPane.addMapPaneListener(listenForCrsChange); |
26 |
|
|
|
27 |
|
|
updateCrs(); |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
public void updateCrs() { |
31 |
|
|
try { |
32 |
|
|
setText(mapPane.getMapContext().getCoordinateReferenceSystem() |
33 |
|
|
.getName().toString()); |
34 |
|
|
} catch (Exception e) { |
35 |
|
|
setText(""); |
36 |
|
|
} |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
@Override |
40 |
|
|
protected void finalize() throws Throwable { |
41 |
|
|
super.finalize(); |
42 |
|
|
if (mapPane != null) |
43 |
|
|
mapPane.removeMapPaneListener(listenForCrsChange); |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
} |