/[schmitzm]/trunk/src/skrueger/geotools/CrsLabel.java
ViewVC logotype

Annotation of /trunk/src/skrueger/geotools/CrsLabel.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1222 - (hide annotations)
Wed Nov 3 14:07:08 2010 UTC (14 years, 3 months ago) by alfonx
File MIME type: text/plain
File size: 1120 byte(s)
Added a label for the CRS to the MapPaneStatusBar
1 alfonx 1220 package skrueger.geotools;
2    
3     import javax.swing.JLabel;
4    
5 alfonx 1222 import schmitzm.geotools.gui.GeotoolsGUIUtil;
6 alfonx 1220 import schmitzm.geotools.gui.SelectableXMapPane;
7     import schmitzm.geotools.gui.XMapPaneEvent;
8     import schmitzm.geotools.map.event.JMapPaneListener;
9    
10     public class CrsLabel extends JLabel {
11    
12     private JMapPaneListener listenForCrsChange = new JMapPaneListener() {
13    
14     @Override
15     public void performMapPaneEvent(XMapPaneEvent e) {
16     updateCrs();
17     }
18     };
19 alfonx 1221
20 alfonx 1220 private final SelectableXMapPane mapPane;
21    
22 alfonx 1222 public CrsLabel(SelectableXMapPane mapPane) {
23 alfonx 1220 super();
24     this.mapPane = mapPane;
25    
26     mapPane.addMapPaneListener(listenForCrsChange);
27    
28     updateCrs();
29 alfonx 1222
30     setToolTipText(GeotoolsGUIUtil.R("CRSLabel.TT"));
31 alfonx 1220 }
32    
33     public void updateCrs() {
34 alfonx 1222 String crsName = "";
35 alfonx 1220 try {
36 alfonx 1222 crsName = mapPane.getMapContext().getCoordinateReferenceSystem()
37     .getName().toString();
38     setText(GeotoolsGUIUtil.R("CRSLabel", crsName));
39 alfonx 1220 } catch (Exception e) {
40 alfonx 1222 setText("");
41 alfonx 1220 }
42     }
43    
44     @Override
45     protected void finalize() throws Throwable {
46     super.finalize();
47     if (mapPane != null)
48     mapPane.removeMapPaneListener(listenForCrsChange);
49     }
50    
51     }

Properties

Name Value
svn:eol-style native
svn:keywords Id URL
svn:mime-type text/plain

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26