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 @ 44006
History | View | Annotate | Download (1.49 KB)
1 |
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.Document; |
7 |
import org.gvsig.app.project.documents.view.ViewDocument; |
8 |
import org.gvsig.app.project.documents.view.ViewManager; |
9 |
import org.gvsig.expressionevaluator.swing.Element.SimpleElement; |
10 |
import org.gvsig.expressionevaluator.swing.Element.ConstantElement; |
11 |
import org.gvsig.expressionevaluator.swing.spi.AbstractElement; |
12 |
|
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 |
super("Take projection code", "Take the projection code of the current view", "expressionbuilder-element-view-projection-code"); |
24 |
} |
25 |
|
26 |
@Override
|
27 |
public Object getValue() { |
28 |
ApplicationManager application = ApplicationLocator.getManager(); |
29 |
ViewDocument viewDoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
30 |
if( viewDoc == null ) { |
31 |
return null; |
32 |
} |
33 |
IProjection proj = viewDoc.getMapContext().getProjection(); |
34 |
String[] proj_s = proj.getAbrev().split(":"); |
35 |
try {
|
36 |
int code = Integer.parseInt(proj_s[1]); |
37 |
return code;
|
38 |
} catch(Exception ex) { |
39 |
return proj_s[1]; |
40 |
} |
41 |
} |
42 |
|
43 |
|
44 |
|
45 |
} |