svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / expressionevaluator / ViewTakeProjectionCodeElement.java @ 44262
History | View | Annotate | Download (1.52 KB)
1 | 44006 | jjdelcerro | package org.gvsig.app.project.documents.view.expressionevaluator; |
---|---|---|---|
2 | |||
3 | import org.cresques.cts.IProjection; |
||
4 | import org.gvsig.app.ApplicationLocator; |
||
5 | import org.gvsig.app.ApplicationManager; |
||
6 | import org.gvsig.app.project.documents.view.ViewDocument; |
||
7 | import org.gvsig.app.project.documents.view.ViewManager; |
||
8 | import org.gvsig.expressionevaluator.swing.Element.SimpleElement; |
||
9 | import org.gvsig.expressionevaluator.swing.Element.ConstantElement; |
||
10 | import org.gvsig.expressionevaluator.swing.spi.AbstractElement; |
||
11 | 44012 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
12 | 44006 | jjdelcerro | |
13 | /**
|
||
14 | *
|
||
15 | * @author jjdelcerro
|
||
16 | */
|
||
17 | @SuppressWarnings("UseSpecificCatch") |
||
18 | public class ViewTakeProjectionCodeElement |
||
19 | extends AbstractElement
|
||
20 | implements SimpleElement, ConstantElement
|
||
21 | { |
||
22 | public ViewTakeProjectionCodeElement() {
|
||
23 | 44012 | jjdelcerro | super(
|
24 | ToolsLocator.getI18nManager().getTranslation("_Take_projection_code"),
|
||
25 | "expressionbuilder-element-view-projection-code"
|
||
26 | ); |
||
27 | 44006 | jjdelcerro | } |
28 | |||
29 | @Override
|
||
30 | public Object getValue() { |
||
31 | ApplicationManager application = ApplicationLocator.getManager(); |
||
32 | ViewDocument viewDoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
||
33 | if( viewDoc == null ) { |
||
34 | return null; |
||
35 | } |
||
36 | IProjection proj = viewDoc.getMapContext().getProjection(); |
||
37 | String[] proj_s = proj.getAbrev().split(":"); |
||
38 | try {
|
||
39 | int code = Integer.parseInt(proj_s[1]); |
||
40 | return code;
|
||
41 | } catch(Exception ex) { |
||
42 | return proj_s[1]; |
||
43 | } |
||
44 | } |
||
45 | |||
46 | |||
47 | |||
48 | } |