Statistics
| Revision:

root / org.gvsig.expressionfield / trunk / org.gvsig.expressionfield / src / main / java / org / gvsig / expressionfield / project / documents / table / operators / Geometry.java @ 24

History | View | Annotate | Download (2.91 KB)

1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.expressionfield.project.documents.table.operators;
27

    
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.ExpressionFieldExtension;
32
import org.gvsig.expressionfield.project.documents.table.GraphicOperator;
33
import org.gvsig.fmap.dal.feature.Feature;
34

    
35
/**
36
 * @author Vicente Caballero Navarro
37
 */
38
public class Geometry extends GraphicOperator{
39

    
40
        public String addText(String s) {
41
                return s.concat(toString()+"()");
42
        }
43
        public double process(Feature feature) {
44
                return 0;
45
        }
46
        public org.gvsig.fmap.geom.Geometry getGeometry(Feature feature) {
47
//                ReadableVectorial adapter = getLayer().getSource();
48
                   org.gvsig.fmap.geom.Geometry geom=feature.getDefaultGeometry();//adapter.getShape(index.get());
49
                   return geom;
50
        }
51
        public void eval(BSFManager interpreter) throws BSFException {
52
                interpreter.declareBean("jgeometry",this,Geometry.class);
53
//                interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"java.lang.Object geometry(){return geometry.getGeometry(indexRow);};");
54
                interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def geometry():\n" +
55
                                "  return jgeometry.getGeometry(featureContainer.getFeature())");
56
        }
57
        public String toString() {
58
                return "geometry";
59
        }
60
        public boolean isEnable() {
61
                return false;
62
        }
63
        public String getTooltip(){
64
                return PluginServices.getText(this,"operator")+":  "+addText("")+"\n"+getDescription();
65
        }
66
        public String getDescription() {
67
        return PluginServices.getText(this, "returns") + ": " +
68
        PluginServices.getText(this, "numeric_value") + "\n" +
69
        PluginServices.getText(this, "description") + ": " +
70
        "Returns the geometry of this row.";
71
    }
72
}