Revision 10254
trunk/extensions/extCAD/config/config.xml | ||
---|---|---|
3 | 3 |
<libraries library-dir="./"/> |
4 | 4 |
<depends plugin-name="com.iver.cit.gvsig" /> |
5 | 5 |
<depends plugin-name="com.iver.cit.gvsig.jdbc_spatial" /> |
6 |
<depends plugin-name="com.iver.cit.gvsig.scripting" /> |
|
6 | 7 |
<resourceBundle name="text"/> |
7 | 8 |
<extensions> |
8 | 9 |
<extension class-name="com.iver.cit.gvsig.CreateNewLayer" |
... | ... | |
240 | 241 |
<action-tool icon="images/previousSel.png" action-command="previous_selection" tooltip="previous_selection" group="vista" position="19"/> |
241 | 242 |
</tool-bar> |
242 | 243 |
</extension> |
243 |
|
|
244 | 244 |
|
245 |
|
|
245 | 246 |
<extension class-name="com.iver.cit.gvsig.LayerPropertiesExtension" |
246 | 247 |
description="Abre el di?logo de propiedades de la capa." |
247 | 248 |
active="true" > |
248 | 249 |
<menu text="Capa/Propiedades" action-command="PROPERTIES"/> |
249 | 250 |
</extension> |
251 |
<extension class-name="com.iver.cit.gvsig.ExpresionFieldExtension" |
|
252 |
description="Extension that evaluate the expresion to a column." |
|
253 |
active="true"> |
|
254 |
<menu text="field/expresion" tooltip="expresion" |
|
255 |
action-command="EXPRESION" |
|
256 |
icon="images/expresion.png" /> |
|
257 |
<tool-bar name="field_toolbar"> |
|
258 |
<action-tool icon="images/expresion.png" |
|
259 |
action-command="EXPRESION" tooltip="expresion" |
|
260 |
last="true"/> |
|
261 |
</tool-bar> |
|
262 |
</extension> |
|
250 | 263 |
</extensions> |
251 | 264 |
</plugin-config> |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/preferences/EditionPreferencePage.java | ||
---|---|---|
61 | 61 |
import com.iver.cit.gvsig.CADExtension; |
62 | 62 |
import com.iver.cit.gvsig.EditionManager; |
63 | 63 |
import com.iver.cit.gvsig.fmap.MapContext; |
64 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
65 | 64 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
66 | 65 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
67 | 66 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/preferences/FieldExpresionPage.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
|
|
42 |
|
|
43 |
package com.iver.cit.gvsig.gui.preferences; |
|
44 |
|
|
45 |
import java.awt.event.MouseEvent; |
|
46 |
import java.awt.event.MouseListener; |
|
47 |
import java.util.prefs.Preferences; |
|
48 |
|
|
49 |
import javax.swing.ImageIcon; |
|
50 |
import javax.swing.JCheckBox; |
|
51 |
import javax.swing.JPanel; |
|
52 |
import javax.swing.JTextArea; |
|
53 |
import javax.swing.JTextField; |
|
54 |
import javax.swing.event.ChangeEvent; |
|
55 |
import javax.swing.event.ChangeListener; |
|
56 |
|
|
57 |
import com.iver.andami.PluginServices; |
|
58 |
import com.iver.andami.preferences.AbstractPreferencePage; |
|
59 |
import com.iver.andami.preferences.StoreException; |
|
60 |
/** |
|
61 |
* @author Vicente Caballero Navarro |
|
62 |
**/ |
|
63 |
public class FieldExpresionPage extends AbstractPreferencePage { |
|
64 |
private static Preferences prefs = Preferences.userRoot().node( "fieldExpresionOptions" ); |
|
65 |
private JTextArea jTextArea = null; |
|
66 |
private JTextField txtLimit; |
|
67 |
private JCheckBox ckLimit=null; |
|
68 |
private ImageIcon icon; |
|
69 |
|
|
70 |
public FieldExpresionPage() { |
|
71 |
super(); |
|
72 |
icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/FieldExpresion.png")); |
|
73 |
addComponent(getJTextArea()); |
|
74 |
|
|
75 |
addComponent(PluginServices.getText(this, "limit_rows_in_memory") + ":", |
|
76 |
txtLimit = new JTextField("", 15)); |
|
77 |
addComponent(ckLimit = new JCheckBox(PluginServices.getText(this, "without_limit"))); |
|
78 |
ckLimit.addMouseListener(new MouseListener() { |
|
79 |
public void mouseClicked(MouseEvent e) { |
|
80 |
if (ckLimit.isSelected()) { |
|
81 |
txtLimit.setText(PluginServices.getText(this, "without_limit")); |
|
82 |
}else { |
|
83 |
if (txtLimit.getText().equals(PluginServices.getText(this, "without_limit"))) |
|
84 |
txtLimit.setText("500000"); |
|
85 |
} |
|
86 |
|
|
87 |
} |
|
88 |
public void mouseEntered(MouseEvent e) { |
|
89 |
} |
|
90 |
public void mouseExited(MouseEvent e) { |
|
91 |
} |
|
92 |
public void mousePressed(MouseEvent e) { |
|
93 |
} |
|
94 |
public void mouseReleased(MouseEvent e) { |
|
95 |
} |
|
96 |
|
|
97 |
}); |
|
98 |
} |
|
99 |
|
|
100 |
public void initializeValues() { |
|
101 |
int limit = prefs.getInt("limit_rows_in_memory",-1); |
|
102 |
if (limit==-1) { |
|
103 |
ckLimit.setSelected(true); |
|
104 |
txtLimit.setText(PluginServices.getText(this,"without_limit")); |
|
105 |
}else { |
|
106 |
ckLimit.setSelected(false); |
|
107 |
txtLimit.setText(String.valueOf(limit)); |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
public String getID() { |
|
112 |
return this.getClass().getName(); |
|
113 |
} |
|
114 |
|
|
115 |
public String getTitle() { |
|
116 |
return PluginServices.getText(this, "limit_rows_in_memory"); |
|
117 |
} |
|
118 |
|
|
119 |
public JPanel getPanel() { |
|
120 |
return this; |
|
121 |
} |
|
122 |
|
|
123 |
public void storeValues() throws StoreException { |
|
124 |
int limit; |
|
125 |
try{ |
|
126 |
if (ckLimit.isSelected()) { |
|
127 |
limit=-1; |
|
128 |
}else { |
|
129 |
// if (txtLimit.getText().equals(PluginServices.getText(this,"without_limit"))) { |
|
130 |
// limit=-1; |
|
131 |
// }else { |
|
132 |
limit=Integer.parseInt(txtLimit.getText()); |
|
133 |
} |
|
134 |
}catch (Exception e) { |
|
135 |
throw new StoreException(PluginServices.getText(this,"limit_rows_in_memory")+PluginServices.getText(this,"error")); |
|
136 |
} |
|
137 |
prefs.putInt("limit_rows_in_memory", limit); |
|
138 |
} |
|
139 |
|
|
140 |
public void initializeDefaults() { |
|
141 |
int limit=prefs.getInt("limit_rows_in_memory",-1); |
|
142 |
if (limit==-1) { |
|
143 |
ckLimit.setSelected(true); |
|
144 |
txtLimit.setText(PluginServices.getText(this,"without_limit")); |
|
145 |
}else { |
|
146 |
ckLimit.setSelected(false); |
|
147 |
txtLimit.setText(String.valueOf(limit)); |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
public ImageIcon getIcon() { |
|
152 |
return icon; |
|
153 |
} |
|
154 |
/** |
|
155 |
* This method initializes jTextArea |
|
156 |
* |
|
157 |
* @return javax.swing.JTextArea |
|
158 |
*/ |
|
159 |
private JTextArea getJTextArea() { |
|
160 |
if (jTextArea == null) { |
|
161 |
jTextArea = new JTextArea(); |
|
162 |
jTextArea.setBounds(new java.awt.Rectangle(13,7,285,57)); |
|
163 |
jTextArea.setForeground(java.awt.Color.black); |
|
164 |
jTextArea.setBackground(java.awt.SystemColor.control); |
|
165 |
jTextArea.setRows(3); |
|
166 |
jTextArea.setWrapStyleWord(true); |
|
167 |
jTextArea.setLineWrap(true); |
|
168 |
jTextArea.setEditable(false); |
|
169 |
jTextArea.setText(PluginServices.getText(this,"specifies_the_limit_rows_in_memory_when_the_program_eval_the_expresion")); |
|
170 |
} |
|
171 |
return jTextArea; |
|
172 |
} |
|
173 |
|
|
174 |
public boolean isValueChanged() { |
|
175 |
return super.hasChanged(); |
|
176 |
} |
|
177 |
|
|
178 |
public void setChangesApplied() { |
|
179 |
setChanged(false); |
|
180 |
} |
|
181 |
} |
|
0 | 182 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/ExpresionFieldExtension.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig; |
|
2 |
|
|
3 |
import java.util.BitSet; |
|
4 |
|
|
5 |
import org.apache.bsf.BSFManager; |
|
6 |
|
|
7 |
import com.iver.andami.PluginServices; |
|
8 |
import com.iver.andami.plugins.Extension; |
|
9 |
import com.iver.cit.gvsig.gui.preferences.FieldExpresionPage; |
|
10 |
import com.iver.cit.gvsig.project.documents.table.gui.EvalExpresionDialog; |
|
11 |
import com.iver.cit.gvsig.project.documents.table.gui.Table; |
|
12 |
import com.iver.cit.gvsig.project.documents.table.operators.Abs; |
|
13 |
import com.iver.cit.gvsig.project.documents.table.operators.Acos; |
|
14 |
import com.iver.cit.gvsig.project.documents.table.operators.Area; |
|
15 |
import com.iver.cit.gvsig.project.documents.table.operators.Asin; |
|
16 |
import com.iver.cit.gvsig.project.documents.table.operators.Atan; |
|
17 |
import com.iver.cit.gvsig.project.documents.table.operators.Ceil; |
|
18 |
import com.iver.cit.gvsig.project.documents.table.operators.Cos; |
|
19 |
import com.iver.cit.gvsig.project.documents.table.operators.Distinct; |
|
20 |
import com.iver.cit.gvsig.project.documents.table.operators.Division; |
|
21 |
import com.iver.cit.gvsig.project.documents.table.operators.E; |
|
22 |
import com.iver.cit.gvsig.project.documents.table.operators.EndsWith; |
|
23 |
import com.iver.cit.gvsig.project.documents.table.operators.Equal; |
|
24 |
import com.iver.cit.gvsig.project.documents.table.operators.Equals; |
|
25 |
import com.iver.cit.gvsig.project.documents.table.operators.Exp; |
|
26 |
import com.iver.cit.gvsig.project.documents.table.operators.IndexOf; |
|
27 |
import com.iver.cit.gvsig.project.documents.table.operators.IsNumber; |
|
28 |
import com.iver.cit.gvsig.project.documents.table.operators.LastIndexOf; |
|
29 |
import com.iver.cit.gvsig.project.documents.table.operators.Length; |
|
30 |
import com.iver.cit.gvsig.project.documents.table.operators.LessEquals; |
|
31 |
import com.iver.cit.gvsig.project.documents.table.operators.LessThan; |
|
32 |
import com.iver.cit.gvsig.project.documents.table.operators.Log; |
|
33 |
import com.iver.cit.gvsig.project.documents.table.operators.Minus; |
|
34 |
import com.iver.cit.gvsig.project.documents.table.operators.MoreEquals; |
|
35 |
import com.iver.cit.gvsig.project.documents.table.operators.MoreThan; |
|
36 |
import com.iver.cit.gvsig.project.documents.table.operators.Perimeter; |
|
37 |
import com.iver.cit.gvsig.project.documents.table.operators.Pi; |
|
38 |
import com.iver.cit.gvsig.project.documents.table.operators.Plus; |
|
39 |
import com.iver.cit.gvsig.project.documents.table.operators.PointX; |
|
40 |
import com.iver.cit.gvsig.project.documents.table.operators.PointY; |
|
41 |
import com.iver.cit.gvsig.project.documents.table.operators.Pow; |
|
42 |
import com.iver.cit.gvsig.project.documents.table.operators.Random; |
|
43 |
import com.iver.cit.gvsig.project.documents.table.operators.Replace; |
|
44 |
import com.iver.cit.gvsig.project.documents.table.operators.Round; |
|
45 |
import com.iver.cit.gvsig.project.documents.table.operators.Sin; |
|
46 |
import com.iver.cit.gvsig.project.documents.table.operators.Sqrt; |
|
47 |
import com.iver.cit.gvsig.project.documents.table.operators.StartsWith; |
|
48 |
import com.iver.cit.gvsig.project.documents.table.operators.SubString; |
|
49 |
import com.iver.cit.gvsig.project.documents.table.operators.Tan; |
|
50 |
import com.iver.cit.gvsig.project.documents.table.operators.Times; |
|
51 |
import com.iver.cit.gvsig.project.documents.table.operators.ToDate; |
|
52 |
import com.iver.cit.gvsig.project.documents.table.operators.ToDegrees; |
|
53 |
import com.iver.cit.gvsig.project.documents.table.operators.ToLowerCase; |
|
54 |
import com.iver.cit.gvsig.project.documents.table.operators.ToNumber; |
|
55 |
import com.iver.cit.gvsig.project.documents.table.operators.ToRadians; |
|
56 |
import com.iver.cit.gvsig.project.documents.table.operators.ToString; |
|
57 |
import com.iver.cit.gvsig.project.documents.table.operators.ToUpperCase; |
|
58 |
import com.iver.cit.gvsig.project.documents.table.operators.Trim; |
|
59 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
|
60 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
|
61 |
/** |
|
62 |
* |
|
63 |
* @author Vicente Caballero Navarro |
|
64 |
* |
|
65 |
*/ |
|
66 |
public class ExpresionFieldExtension extends Extension{ |
|
67 |
//private static Interpreter interpreter=new Interpreter(); |
|
68 |
public static final String BEANSHELL="beanshell"; |
|
69 |
private static BSFManager interpreter=new BSFManager(); |
|
70 |
private Table table=null; |
|
71 |
public void initialize() { |
|
72 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
73 |
extensionPoints.add("cad_editing_properties_pages","fieldExpresion",FieldExpresionPage.class); |
|
74 |
registerOperations(); |
|
75 |
} |
|
76 |
|
|
77 |
public void execute(String actionCommand) { |
|
78 |
com.iver.andami.ui.mdiManager.IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
79 |
table=(Table)window; |
|
80 |
EvalExpresionDialog eed=new EvalExpresionDialog(table,interpreter); |
|
81 |
PluginServices.getMDIManager().addWindow(eed); |
|
82 |
} |
|
83 |
public void postInitialize() { |
|
84 |
|
|
85 |
} |
|
86 |
|
|
87 |
public boolean isEnabled() { |
|
88 |
com.iver.andami.ui.mdiManager.IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
89 |
if (window instanceof Table) { |
|
90 |
Table table=(Table)window; |
|
91 |
BitSet columnSelected = table.getSelectedFieldIndices(); |
|
92 |
if (!columnSelected.isEmpty() && table.isEditing()) { |
|
93 |
return true; |
|
94 |
} |
|
95 |
} |
|
96 |
return false; |
|
97 |
} |
|
98 |
|
|
99 |
public boolean isVisible() { |
|
100 |
com.iver.andami.ui.mdiManager.IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
101 |
if (window instanceof Table) { |
|
102 |
return true; |
|
103 |
} |
|
104 |
return false; |
|
105 |
} |
|
106 |
private void registerOperations() { |
|
107 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
108 |
extensionPoints.add("ColumnOperators",Abs.class.toString(),Abs.class); |
|
109 |
extensionPoints.add("ColumnOperators",Acos.class.toString(),Acos.class); |
|
110 |
extensionPoints.add("ColumnOperators",Area.class.toString(),Area.class); |
|
111 |
extensionPoints.add("ColumnOperators",Asin.class.toString(),Asin.class); |
|
112 |
extensionPoints.add("ColumnOperators",Atan.class.toString(),Atan.class); |
|
113 |
extensionPoints.add("ColumnOperators",Ceil.class.toString(),Ceil.class); |
|
114 |
extensionPoints.add("ColumnOperators",Cos.class.toString(),Cos.class); |
|
115 |
extensionPoints.add("ColumnOperators",Distinct.class.toString(),Distinct.class); |
|
116 |
extensionPoints.add("ColumnOperators",Division.class.toString(),Division.class); |
|
117 |
extensionPoints.add("ColumnOperators",E.class.toString(),E.class); |
|
118 |
extensionPoints.add("ColumnOperators",EndsWith.class.toString(),EndsWith.class); |
|
119 |
extensionPoints.add("ColumnOperators",Equal.class.toString(),Equal.class); |
|
120 |
extensionPoints.add("ColumnOperators",Equals.class.toString(),Equals.class); |
|
121 |
extensionPoints.add("ColumnOperators",Exp.class.toString(),Exp.class); |
|
122 |
extensionPoints.add("ColumnOperators",IndexOf.class.toString(),IndexOf.class); |
|
123 |
extensionPoints.add("ColumnOperators",IsNumber.class.toString(),IsNumber.class); |
|
124 |
extensionPoints.add("ColumnOperators",LastIndexOf.class.toString(),LastIndexOf.class); |
|
125 |
extensionPoints.add("ColumnOperators",Length.class.toString(),Length.class); |
|
126 |
extensionPoints.add("ColumnOperators",LessEquals.class.toString(),LessEquals.class); |
|
127 |
extensionPoints.add("ColumnOperators",LessThan.class.toString(),LessThan.class); |
|
128 |
extensionPoints.add("ColumnOperators",Log.class.toString(),Log.class); |
|
129 |
extensionPoints.add("ColumnOperators",Minus.class.toString(),Minus.class); |
|
130 |
extensionPoints.add("ColumnOperators",MoreEquals.class.toString(),MoreEquals.class); |
|
131 |
extensionPoints.add("ColumnOperators",MoreThan.class.toString(),MoreThan.class); |
|
132 |
extensionPoints.add("ColumnOperators",Perimeter.class.toString(),Perimeter.class); |
|
133 |
extensionPoints.add("ColumnOperators",Pi.class.toString(),Pi.class); |
|
134 |
extensionPoints.add("ColumnOperators",Plus.class.toString(),Plus.class); |
|
135 |
extensionPoints.add("ColumnOperators",PointX.class.toString(),PointX.class); |
|
136 |
extensionPoints.add("ColumnOperators",PointY.class.toString(),PointY.class); |
|
137 |
extensionPoints.add("ColumnOperators",Pow.class.toString(),Pow.class); |
|
138 |
extensionPoints.add("ColumnOperators",Random.class.toString(),Random.class); |
|
139 |
extensionPoints.add("ColumnOperators",Replace.class.toString(),Replace.class); |
|
140 |
extensionPoints.add("ColumnOperators",Round.class.toString(),Round.class); |
|
141 |
extensionPoints.add("ColumnOperators",Sin.class.toString(),Sin.class); |
|
142 |
extensionPoints.add("ColumnOperators",Sqrt.class.toString(),Sqrt.class); |
|
143 |
extensionPoints.add("ColumnOperators",StartsWith.class.toString(),StartsWith.class); |
|
144 |
extensionPoints.add("ColumnOperators",SubString.class.toString(),SubString.class); |
|
145 |
extensionPoints.add("ColumnOperators",Tan.class.toString(),Tan.class); |
|
146 |
extensionPoints.add("ColumnOperators",Times.class.toString(),Times.class); |
|
147 |
extensionPoints.add("ColumnOperators",ToDate.class.toString(),ToDate.class); |
|
148 |
extensionPoints.add("ColumnOperators",ToDegrees.class.toString(),ToDegrees.class); |
|
149 |
extensionPoints.add("ColumnOperators",ToLowerCase.class.toString(),ToLowerCase.class); |
|
150 |
extensionPoints.add("ColumnOperators",ToNumber.class.toString(),ToNumber.class); |
|
151 |
extensionPoints.add("ColumnOperators",ToRadians.class.toString(),ToRadians.class); |
|
152 |
extensionPoints.add("ColumnOperators",ToString.class.toString(),ToString.class); |
|
153 |
extensionPoints.add("ColumnOperators",ToUpperCase.class.toString(),ToUpperCase.class); |
|
154 |
extensionPoints.add("ColumnOperators",Trim.class.toString(),Trim.class); |
|
155 |
} |
|
156 |
|
|
157 |
} |
|
0 | 158 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/Pow.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class Pow extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return toString()+"("+s+", \"\")"; |
|
17 |
} |
|
18 |
|
|
19 |
public void eval(BSFManager interpreter) throws BSFException { |
|
20 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"double pow(double value1,double value2){return java.lang.Math.pow(value1,value2);};"); |
|
21 |
} |
|
22 |
public String toString() { |
|
23 |
return "pow"; |
|
24 |
} |
|
25 |
public boolean isEnable() { |
|
26 |
return (getType()==IOperator.NUMBER); |
|
27 |
} |
|
28 |
} |
|
0 | 29 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/Abs.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
/** |
|
10 |
* @author Vicente Caballero Navarro |
|
11 |
*/ |
|
12 |
public class Abs extends AbstractOperator{ |
|
13 |
|
|
14 |
public String addText(String s) { |
|
15 |
return toString()+"("+s+")"; |
|
16 |
} |
|
17 |
public String toString() { |
|
18 |
return "abs"; |
|
19 |
} |
|
20 |
public void eval(BSFManager interpreter) throws BSFException { |
|
21 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"double abs(double value){return java.lang.Math.abs(value);};"); |
|
22 |
} |
|
23 |
public boolean isEnable() { |
|
24 |
return (getType()==IOperator.NUMBER); |
|
25 |
} |
|
26 |
public double abs(double value) { |
|
27 |
return java.lang.Math.abs(value); |
|
28 |
} |
|
29 |
} |
|
0 | 30 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/Pi.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class Pi extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return s.concat(toString()+"()"); |
|
17 |
} |
|
18 |
public String toString() { |
|
19 |
return "pi"; |
|
20 |
} |
|
21 |
public void eval(BSFManager interpreter) throws BSFException { |
|
22 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"double pi(){return java.lang.Math.PI;};"); |
|
23 |
} |
|
24 |
public boolean isEnable() { |
|
25 |
return (getType()==IOperator.NUMBER); |
|
26 |
} |
|
27 |
|
|
28 |
} |
|
0 | 29 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/Area.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.project.documents.table.operators; |
|
2 |
|
|
3 |
import java.awt.geom.Point2D; |
|
4 |
|
|
5 |
import org.apache.bsf.BSFException; |
|
6 |
import org.apache.bsf.BSFManager; |
|
7 |
import org.cresques.cts.IProjection; |
|
8 |
|
|
9 |
import com.iver.cit.gvsig.ExpresionFieldExtension; |
|
10 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
11 |
import com.iver.cit.gvsig.fmap.ViewPort; |
|
12 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
13 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
14 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
15 |
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial; |
|
16 |
import com.iver.cit.gvsig.fmap.tools.geo.Geo; |
|
17 |
import com.iver.cit.gvsig.project.documents.table.GraphicOperator; |
|
18 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
19 |
import com.iver.cit.gvsig.project.documents.table.Index; |
|
20 |
/** |
|
21 |
* @author Vicente Caballero Navarro |
|
22 |
*/ |
|
23 |
public class Area extends GraphicOperator{ |
|
24 |
|
|
25 |
public String addText(String s) { |
|
26 |
return s.concat(toString()+"()"); |
|
27 |
} |
|
28 |
public double process(Index index) throws DriverIOException { |
|
29 |
ReadableVectorial adapter = getLayer().getSource(); |
|
30 |
IGeometry geom=adapter.getShape(index.get()); |
|
31 |
int distanceUnits=getLayer().getMapContext().getViewPort().getDistanceUnits(); |
|
32 |
return returnArea(geom)/Math.pow(MapContext.CHANGEM[distanceUnits],2); |
|
33 |
} |
|
34 |
public void eval(BSFManager interpreter) throws BSFException { |
|
35 |
interpreter.declareBean("area",this,Area.class); |
|
36 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"double area(){return area.process(indexRow);};"); |
|
37 |
} |
|
38 |
public String toString() { |
|
39 |
return "area"; |
|
40 |
} |
|
41 |
public boolean isEnable() { |
|
42 |
if (getLayer()==null) |
|
43 |
return false; |
|
44 |
ReadableVectorial adapter = getLayer().getSource(); |
|
45 |
int type=FShape.POINT; |
|
46 |
try { |
|
47 |
type=adapter.getShapeType(); |
|
48 |
} catch (DriverIOException e) { |
|
49 |
e.printStackTrace(); |
|
50 |
} |
|
51 |
return (getType()==IOperator.NUMBER && type==FShape.POLYGON); |
|
52 |
} |
|
53 |
|
|
54 |
private double returnArea(IGeometry geom) { |
|
55 |
Double[][] xsys=getXY(geom); |
|
56 |
Double[] xs=xsys[0]; |
|
57 |
Double[] ys=xsys[1]; |
|
58 |
IProjection proj=getLayer().getMapContext().getProjection(); |
|
59 |
if (proj.isProjected()) { |
|
60 |
return returnCoordsArea(xs,ys,new Point2D.Double(xs[xs.length-1].doubleValue(),ys[ys.length-1].doubleValue())); |
|
61 |
} |
|
62 |
return returnGeoCArea(xs,ys); |
|
63 |
} |
|
64 |
private double returnGeoCArea(Double[] xs,Double[] ys) { |
|
65 |
double[] lat=new double[xs.length]; |
|
66 |
double[] lon=new double[xs.length]; |
|
67 |
for (int K= 0; K < xs.length; K++){ |
|
68 |
lon[K]= xs[K].doubleValue()/Geo.Degree; |
|
69 |
lat[K]= ys[K].doubleValue()/Geo.Degree; |
|
70 |
} |
|
71 |
return (Geo.sphericalPolyArea(lat,lon,xs.length-1)*Geo.SqM); |
|
72 |
} |
|
73 |
/** |
|
74 |
* Calcula el ?rea. |
|
75 |
* |
|
76 |
* @param aux ?ltimo punto. |
|
77 |
* |
|
78 |
* @return ?rea. |
|
79 |
*/ |
|
80 |
public double returnCoordsArea(Double[] xs,Double[] ys, Point2D point) { |
|
81 |
Point2D aux=point; |
|
82 |
double elArea = 0.0; |
|
83 |
Point2D pPixel; |
|
84 |
Point2D p = new Point2D.Double(); |
|
85 |
Point2D.Double pAnt = new Point2D.Double(); |
|
86 |
ViewPort vp = getLayer().getMapContext().getViewPort(); |
|
87 |
for (int pos = 0; pos < xs.length-1; pos++) { |
|
88 |
pPixel = new Point2D.Double(xs[pos].doubleValue(), |
|
89 |
ys[pos].doubleValue()); |
|
90 |
p = pPixel; |
|
91 |
if (pos == 0) { |
|
92 |
pAnt.x = aux.getX(); |
|
93 |
pAnt.y = aux.getY(); |
|
94 |
} |
|
95 |
elArea = elArea + ((pAnt.x - p.getX()) * (pAnt.y + p.getY())); |
|
96 |
pAnt.setLocation(p); |
|
97 |
} |
|
98 |
|
|
99 |
elArea = elArea + ((pAnt.x - aux.getX()) * (pAnt.y + aux.getY())); |
|
100 |
elArea = Math.abs(elArea / 2.0); |
|
101 |
return (elArea*(Math.pow(MapContext.CHANGEM[vp.getMapUnits()],2))); |
|
102 |
} |
|
103 |
} |
|
0 | 104 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/ToString.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class ToString extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return toString()+"("+s+")"; |
|
17 |
} |
|
18 |
public String toString() { |
|
19 |
return "toString"; |
|
20 |
} |
|
21 |
public void eval(BSFManager interpreter) throws BSFException { |
|
22 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"String toString(java.lang.Object value){return String.valueOf(value);};"); |
|
23 |
} |
|
24 |
public boolean isEnable() { |
|
25 |
return (getType()==IOperator.NUMBER || getType()==IOperator.DATE); |
|
26 |
} |
|
27 |
|
|
28 |
} |
|
0 | 29 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/Ceil.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class Ceil extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return toString()+"("+s+")"; |
|
17 |
} |
|
18 |
public String toString() { |
|
19 |
return "ceil"; |
|
20 |
} |
|
21 |
public void eval(BSFManager interpreter) throws BSFException { |
|
22 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"double ceil(double value){return java.lang.Math.ceil(value);};"); |
|
23 |
} |
|
24 |
public boolean isEnable() { |
|
25 |
return (getType()==IOperator.NUMBER); |
|
26 |
} |
|
27 |
|
|
28 |
} |
|
0 | 29 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/StartsWith.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class StartsWith extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return toString()+"("+s+",\"\")"; |
|
17 |
} |
|
18 |
public String toString() { |
|
19 |
return "startsWith"; |
|
20 |
} |
|
21 |
public void eval(BSFManager interpreter) throws BSFException { |
|
22 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"boolean startsWith(String value1,String value2){return value1.startsWith(value2);};"); |
|
23 |
} |
|
24 |
public boolean isEnable() { |
|
25 |
return (getType()==IOperator.STRING); |
|
26 |
} |
|
27 |
|
|
28 |
} |
|
0 | 29 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/MoreEquals.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
7 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
8 |
|
|
9 |
/** |
|
10 |
* @author Vicente Caballero Navarro |
|
11 |
*/ |
|
12 |
public class MoreEquals extends AbstractOperator{ |
|
13 |
|
|
14 |
public String addText(String s) { |
|
15 |
return s.concat(toString()); |
|
16 |
} |
|
17 |
|
|
18 |
public void eval(BSFManager interpreter) throws BSFException { |
|
19 |
} |
|
20 |
public String toString() { |
|
21 |
return ">="; |
|
22 |
} |
|
23 |
public boolean isEnable() { |
|
24 |
return (getType()==IOperator.DATE || getType()==IOperator.NUMBER); |
|
25 |
} |
|
26 |
} |
|
0 | 27 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/MoreThan.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
7 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
8 |
|
|
9 |
/** |
|
10 |
* @author Vicente Caballero Navarro |
|
11 |
*/ |
|
12 |
public class MoreThan extends AbstractOperator{ |
|
13 |
|
|
14 |
public String addText(String s) { |
|
15 |
return s.concat(toString()); |
|
16 |
} |
|
17 |
public void eval(BSFManager interpreter) throws BSFException { |
|
18 |
|
|
19 |
} |
|
20 |
public String toString() { |
|
21 |
return ">"; |
|
22 |
} |
|
23 |
public boolean isEnable() { |
|
24 |
return (getType()==IOperator.DATE || getType()==IOperator.NUMBER); |
|
25 |
} |
|
26 |
} |
|
0 | 27 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/ToDate.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class ToDate extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return toString()+"("+s+")"; |
|
17 |
} |
|
18 |
public String toString() { |
|
19 |
return "toDate"; |
|
20 |
} |
|
21 |
public void eval(BSFManager interpreter) throws BSFException { |
|
22 |
|
|
23 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"java.util.Date toDate(String value){return java.util.Date.parse(value);};"); |
|
24 |
} |
|
25 |
public boolean isEnable() { |
|
26 |
return (getType()==IOperator.STRING); |
|
27 |
} |
|
28 |
|
|
29 |
} |
|
0 | 30 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/Random.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class Random extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return s.concat(toString()+"()"); |
|
17 |
} |
|
18 |
public String toString() { |
|
19 |
return "random"; |
|
20 |
} |
|
21 |
public void eval(BSFManager interpreter) throws BSFException { |
|
22 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"double random(){return java.lang.Math.random();};"); |
|
23 |
} |
|
24 |
public boolean isEnable() { |
|
25 |
return (getType()==IOperator.NUMBER); |
|
26 |
} |
|
27 |
|
|
28 |
} |
|
0 | 29 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/Distinct.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
7 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
8 |
|
|
9 |
/** |
|
10 |
* @author Vicente Caballero Navarro |
|
11 |
*/ |
|
12 |
public class Distinct extends AbstractOperator{ |
|
13 |
|
|
14 |
public String addText(String s) { |
|
15 |
return s.concat(toString()); |
|
16 |
} |
|
17 |
public void eval(BSFManager interpreter) throws BSFException { |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "<>"; |
|
21 |
} |
|
22 |
public boolean isEnable() { |
|
23 |
return (getType()==IOperator.DATE || getType()==IOperator.NUMBER || getType()==IOperator.STRING); |
|
24 |
} |
|
25 |
} |
|
0 | 26 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/Length.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class Length extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return toString()+"("+s+")"; |
|
17 |
} |
|
18 |
public String toString() { |
|
19 |
return "length"; |
|
20 |
} |
|
21 |
public void eval(BSFManager interpreter) throws BSFException { |
|
22 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"int length(String value){return value.length();};"); |
|
23 |
} |
|
24 |
public boolean isEnable() { |
|
25 |
return (getType()==IOperator.STRING); |
|
26 |
} |
|
27 |
|
|
28 |
} |
|
0 | 29 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/LessEquals.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
7 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
8 |
|
|
9 |
/** |
|
10 |
* @author Vicente Caballero Navarro |
|
11 |
*/ |
|
12 |
public class LessEquals extends AbstractOperator { |
|
13 |
|
|
14 |
public String addText(String s) { |
|
15 |
return s.concat(toString()); |
|
16 |
} |
|
17 |
|
|
18 |
public void eval(BSFManager interpreter) throws BSFException { |
|
19 |
} |
|
20 |
public String toString() { |
|
21 |
return "<="; |
|
22 |
} |
|
23 |
public boolean isEnable() { |
|
24 |
return (getType()==IOperator.DATE || getType()==IOperator.NUMBER); |
|
25 |
} |
|
26 |
} |
|
0 | 27 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/LessThan.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
7 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
8 |
|
|
9 |
/** |
|
10 |
* @author Vicente Caballero Navarro |
|
11 |
*/ |
|
12 |
public class LessThan extends AbstractOperator{ |
|
13 |
|
|
14 |
public String addText(String s) { |
|
15 |
return s.concat(toString()); |
|
16 |
} |
|
17 |
|
|
18 |
public void eval(BSFManager interpreter) throws BSFException { |
|
19 |
} |
|
20 |
public String toString() { |
|
21 |
return "<"; |
|
22 |
} |
|
23 |
public boolean isEnable() { |
|
24 |
return (getType()==IOperator.DATE || getType()==IOperator.NUMBER); |
|
25 |
} |
|
26 |
} |
|
0 | 27 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/ToDegrees.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class ToDegrees extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return toString()+"("+s+")"; |
|
17 |
} |
|
18 |
public String toString() { |
|
19 |
return "toDegrees"; |
|
20 |
} |
|
21 |
public void eval(BSFManager interpreter) throws BSFException { |
|
22 |
|
|
23 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"double toDegrees(double value){return java.lang.Math.toDegrees(value);};"); |
|
24 |
} |
|
25 |
public boolean isEnable() { |
|
26 |
return (getType()==IOperator.NUMBER); |
|
27 |
} |
|
28 |
|
|
29 |
} |
|
0 | 30 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/PointY.java | ||
---|---|---|
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 |
} |
|
0 | 48 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/Tan.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class Tan extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return toString()+"("+s+")"; |
|
17 |
} |
|
18 |
public String toString() { |
|
19 |
return "tan"; |
|
20 |
} |
|
21 |
public void eval(BSFManager interpreter) throws BSFException { |
|
22 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"double tan(double value){return java.lang.Math.tan(value);};"); |
|
23 |
} |
|
24 |
public boolean isEnable() { |
|
25 |
return (getType()==IOperator.NUMBER); |
|
26 |
} |
|
27 |
|
|
28 |
} |
|
0 | 29 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/Division.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
7 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
8 |
|
|
9 |
/** |
|
10 |
* @author Vicente Caballero Navarro |
|
11 |
*/ |
|
12 |
public class Division extends AbstractOperator{ |
|
13 |
|
|
14 |
public String addText(String s) { |
|
15 |
return s.concat(toString()); |
|
16 |
} |
|
17 |
|
|
18 |
public void eval(BSFManager interpreter) throws BSFException { |
|
19 |
} |
|
20 |
public String toString() { |
|
21 |
return "/"; |
|
22 |
} |
|
23 |
public boolean isEnable() { |
|
24 |
return (getType()==IOperator.NUMBER); |
|
25 |
} |
|
26 |
|
|
27 |
} |
|
0 | 28 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/IsNumber.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class IsNumber extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return toString()+"("+s+")"; |
|
17 |
} |
|
18 |
public String toString() { |
|
19 |
return "isNumber"; |
|
20 |
} |
|
21 |
public void eval(BSFManager interpreter) throws BSFException { |
|
22 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"boolean isNumber (String value){try{java.lang.Double.parseDouble(value);}catch(java.lang.NumberFormatException e){return false;}return true;};"); |
|
23 |
} |
|
24 |
public boolean isEnable() { |
|
25 |
return (getType()==IOperator.STRING); |
|
26 |
} |
|
27 |
|
|
28 |
} |
|
0 | 29 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/Cos.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class Cos extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return toString()+"("+s+")"; |
|
17 |
} |
|
18 |
public String toString() { |
|
19 |
return "cos"; |
|
20 |
} |
|
21 |
public void eval(BSFManager interpreter) throws BSFException { |
|
22 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"double cos(double value){return java.lang.Math.cos(value);};"); |
|
23 |
} |
|
24 |
public boolean isEnable() { |
|
25 |
return (getType()==IOperator.NUMBER); |
|
26 |
} |
|
27 |
|
|
28 |
} |
|
0 | 29 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/E.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class E extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return s.concat(toString()+"()"); |
|
17 |
} |
|
18 |
public String toString() { |
|
19 |
return "e"; |
|
20 |
} |
|
21 |
public void eval(BSFManager interpreter) throws BSFException { |
|
22 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"double e(){return java.lang.Math.E;};"); |
|
23 |
} |
|
24 |
public boolean isEnable() { |
|
25 |
return (getType()==IOperator.NUMBER); |
|
26 |
} |
|
27 |
|
|
28 |
} |
|
0 | 29 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/EndsWith.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class EndsWith extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return toString()+"("+s+",\"\")"; |
|
17 |
} |
|
18 |
public String toString() { |
|
19 |
return "endsWith"; |
|
20 |
} |
|
21 |
public void eval(BSFManager interpreter) throws BSFException { |
|
22 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"boolean endsWith(String value1,String value2){return value1.endsWith(value2);};"); |
|
23 |
} |
|
24 |
public boolean isEnable() { |
|
25 |
return (getType()==IOperator.STRING); |
|
26 |
} |
|
27 |
|
|
28 |
} |
|
0 | 29 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/table/operators/Round.java | ||
---|---|---|
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.project.documents.table.AbstractOperator; |
|
8 |
import com.iver.cit.gvsig.project.documents.table.IOperator; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class Round extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return toString()+"("+s+")"; |
|
17 |
} |
|
18 |
public String toString() { |
|
19 |
return "round"; |
|
20 |
} |
|
21 |
public void eval(BSFManager interpreter) throws BSFException { |
|
22 |
interpreter.eval(ExpresionFieldExtension.BEANSHELL,null,-1,-1,"double round(double value){return java.lang.Math.round(value);};"); |
|
23 |
} |
|
24 |
public boolean isEnable() { |
|
25 |
return (getType()==IOperator.NUMBER); |
|
26 |
} |
|
27 |
|
|
28 |
} |
|
0 | 29 |
Also available in: Unified diff