svn-gvsig-desktop / trunk / extensions / extCAD / src / com / iver / cit / gvsig / project / documents / table / operators / PointY.java @ 10254
History | View | Annotate | Download (1.54 KB)
1 |
package com.iver.cit.gvsig.project.documents.table.operators; |
---|---|
2 |
|
3 |
import org.apache.bsf.BSFException; |
4 |
import org.apache.bsf.BSFManager; |
5 |
|
6 |
import com.iver.cit.gvsig.ExpresionFieldExtension; |
7 |
import com.iver.cit.gvsig.fmap.core.FShape; |
8 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
9 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
10 |
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial; |
11 |
import com.iver.cit.gvsig.project.documents.table.GraphicOperator; |
12 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
13 |
import com.iver.cit.gvsig.project.documents.table.Index; |
14 |
/**
|
15 |
* @author Vicente Caballero Navarro
|
16 |
*/
|
17 |
public class PointY extends GraphicOperator{ |
18 |
|
19 |
public String addText(String s) { |
20 |
return s.concat(toString()+"()"); |
21 |
} |
22 |
public double process(Index index) throws DriverIOException { |
23 |
ReadableVectorial adapter = getLayer().getSource(); |
24 |
IGeometry geom=adapter.getShape(index.get()); |
25 |
Double[][] xsys=getXY(geom); |
26 |
return xsys[1][0].doubleValue(); |
27 |
} |
28 |
public void eval(BSFManager interpreter) throws BSFException { |
29 |
interpreter.declareBean("pointY",this,PointY.class); |
30 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"double y(){return pointY.process(indexRow);};"); |
31 |
} |
32 |
public String toString() { |
33 |
return "y"; |
34 |
} |
35 |
public boolean isEnable() { |
36 |
if (getLayer()==null) |
37 |
return false; |
38 |
ReadableVectorial adapter = getLayer().getSource(); |
39 |
int type=FShape.POINT;
|
40 |
try {
|
41 |
type=adapter.getShapeType(); |
42 |
} catch (DriverIOException e) {
|
43 |
e.printStackTrace(); |
44 |
} |
45 |
return (getType()==IOperator.NUMBER && type==FShape.POINT);
|
46 |
} |
47 |
} |