Revision 13444 trunk/extensions/extExpressionField/src/com/iver/cit/gvsig/project/documents/table/operators/Perimeter.java
Perimeter.java | ||
---|---|---|
5 | 5 |
import org.apache.bsf.BSFException; |
6 | 6 |
import org.apache.bsf.BSFManager; |
7 | 7 |
|
8 |
import com.iver.cit.gvsig.ExpresionFieldExtension; |
|
8 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
9 |
import com.iver.andami.PluginServices; |
|
10 |
import com.iver.andami.messages.NotificationManager; |
|
11 |
import com.iver.cit.gvsig.ExpressionFieldExtension; |
|
12 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
|
9 | 13 |
import com.iver.cit.gvsig.fmap.MapContext; |
10 | 14 |
import com.iver.cit.gvsig.fmap.ViewPort; |
11 | 15 |
import com.iver.cit.gvsig.fmap.core.FShape; |
... | ... | |
25 | 29 |
} |
26 | 30 |
public double process(Index index) throws DriverIOException { |
27 | 31 |
ReadableVectorial adapter = getLayer().getSource(); |
28 |
IGeometry geom=adapter.getShape(index.get()); |
|
32 |
IGeometry geom=null; |
|
33 |
try { |
|
34 |
geom = adapter.getShape(index.get()); |
|
35 |
} catch (ExpansionFileReadException e) { |
|
36 |
throw new DriverIOException(e); |
|
37 |
} catch (ReadDriverException e) { |
|
38 |
throw new DriverIOException(e); |
|
39 |
} |
|
29 | 40 |
Double[][] xsys=getXY(geom); |
30 | 41 |
double dist = 0; |
31 | 42 |
double distAll = 0; |
... | ... | |
44 | 55 |
return distAll/MapContext.CHANGEM[distanceUnits]; |
45 | 56 |
} |
46 | 57 |
public void eval(BSFManager interpreter) throws BSFException { |
47 |
interpreter.declareBean("perimeter",this,Perimeter.class); |
|
48 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"double perimeter(){return perimeter.process(indexRow);};"); |
|
58 |
interpreter.declareBean("jperimeter",this,Perimeter.class); |
|
59 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double perimeter(){return jperimeter.process(indexRow);};"); |
|
60 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def perimeter():\n" + |
|
61 |
" return jperimeter.process(indexRow)"); |
|
49 | 62 |
} |
50 | 63 |
public String toString() { |
51 | 64 |
return "perimeter"; |
... | ... | |
57 | 70 |
int type=FShape.POINT; |
58 | 71 |
try { |
59 | 72 |
type=adapter.getShapeType(); |
60 |
} catch (DriverIOException e) {
|
|
61 |
e.printStackTrace();
|
|
73 |
} catch (ReadDriverException e) {
|
|
74 |
NotificationManager.addError(e);
|
|
62 | 75 |
} |
63 | 76 |
return (getType()==IOperator.NUMBER && (type==FShape.POLYGON || type==FShape.LINE)); |
64 | 77 |
} |
78 |
public String getTooltip(){ |
|
79 |
return PluginServices.getText(this,"operator")+": "+addText("")+"\n"+getDescription(); |
|
80 |
} |
|
81 |
public String getDescription() { |
|
82 |
return PluginServices.getText(this, "returns") + ": " + |
|
83 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
84 |
PluginServices.getText(this, "description") + ": " + |
|
85 |
"Returns the perimeter of polygon or line geometry of this row."; |
|
86 |
} |
|
65 | 87 |
} |
Also available in: Unified diff