Revision 34068
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/gui/FieldExpressionPage.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 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id: FieldExpressionPage.java 14822 2007-10-22 12:15:32Z jmvivo $ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2007-09-03 10:28:47 caballero |
|
47 |
* prepare head |
|
48 |
* |
|
49 |
* Revision 1.1 2007/02/09 10:49:36 caballero |
|
50 |
* expression field |
|
51 |
* |
|
52 |
* Revision 1.4 2006/09/06 15:29:59 caballero |
|
53 |
* initialize flatness |
|
54 |
* |
|
55 |
* Revision 1.3 2006/08/22 12:27:53 jaume |
|
56 |
* improved performances when saving |
|
57 |
* |
|
58 |
* Revision 1.2 2006/08/22 07:37:32 jaume |
|
59 |
* *** empty log message *** |
|
60 |
* |
|
61 |
* Revision 1.1 2006/08/10 08:18:35 caballero |
|
62 |
* configurar grid |
|
63 |
* |
|
64 |
* Revision 1.1 2006/08/04 11:41:05 caballero |
|
65 |
* poder especificar el zoom a aplicar en las vistas |
|
66 |
* |
|
67 |
* Revision 1.3 2006/07/31 10:02:31 jaume |
|
68 |
* *** empty log message *** |
|
69 |
* |
|
70 |
* Revision 1.2 2006/06/13 07:43:08 fjp |
|
71 |
* Ajustes sobre los cuadros de dialogos de preferencias |
|
72 |
* |
|
73 |
* Revision 1.1 2006/06/12 16:04:28 caballero |
|
74 |
* Preferencias |
|
75 |
* |
|
76 |
* Revision 1.11 2006/06/06 10:26:31 jaume |
|
77 |
* *** empty log message *** |
|
78 |
* |
|
79 |
* Revision 1.10 2006/06/05 17:07:17 jaume |
|
80 |
* *** empty log message *** |
|
81 |
* |
|
82 |
* Revision 1.9 2006/06/05 17:00:44 jaume |
|
83 |
* *** empty log message *** |
|
84 |
* |
|
85 |
* Revision 1.8 2006/06/05 16:57:59 jaume |
|
86 |
* *** empty log message *** |
|
87 |
* |
|
88 |
* Revision 1.7 2006/06/05 14:45:06 jaume |
|
89 |
* *** empty log message *** |
|
90 |
* |
|
91 |
* Revision 1.6 2006/06/05 11:00:09 jaume |
|
92 |
* *** empty log message *** |
|
93 |
* |
|
94 |
* Revision 1.5 2006/06/05 10:39:02 jaume |
|
95 |
* *** empty log message *** |
|
96 |
* |
|
97 |
* Revision 1.4 2006/06/05 10:13:40 jaume |
|
98 |
* *** empty log message *** |
|
99 |
* |
|
100 |
* Revision 1.3 2006/06/05 10:06:08 jaume |
|
101 |
* *** empty log message *** |
|
102 |
* |
|
103 |
* Revision 1.2 2006/06/05 09:51:56 jaume |
|
104 |
* *** empty log message *** |
|
105 |
* |
|
106 |
* Revision 1.1 2006/06/02 10:50:18 jaume |
|
107 |
* *** empty log message *** |
|
108 |
* |
|
109 |
* |
|
110 |
*/ |
|
111 |
package org.gvsig.expressionfield.gui; |
|
112 |
|
|
113 |
import java.awt.event.MouseEvent; |
|
114 |
import java.awt.event.MouseListener; |
|
115 |
import java.util.prefs.Preferences; |
|
116 |
|
|
117 |
import javax.swing.ImageIcon; |
|
118 |
import javax.swing.JCheckBox; |
|
119 |
import javax.swing.JPanel; |
|
120 |
import javax.swing.JTextArea; |
|
121 |
import javax.swing.JTextField; |
|
122 |
|
|
123 |
import org.gvsig.andami.PluginServices; |
|
124 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
|
125 |
import org.gvsig.andami.preferences.StoreException; |
|
126 |
|
|
127 |
|
|
128 |
/** |
|
129 |
* @author Vicente Caballero Navarro |
|
130 |
*/ |
|
131 |
public class FieldExpressionPage extends AbstractPreferencePage { |
|
132 |
private static Preferences prefs = Preferences.userRoot().node( "fieldExpressionOptions" ); |
|
133 |
private JTextArea jTextArea = null; |
|
134 |
private JTextField txtLimit; |
|
135 |
private JCheckBox ckLimit=null; |
|
136 |
private ImageIcon icon; |
|
137 |
|
|
138 |
public FieldExpressionPage() { |
|
139 |
super(); |
|
140 |
icon=PluginServices.getIconTheme().get("field-expression-kcalc"); |
|
141 |
addComponent(getJTextArea()); |
|
142 |
|
|
143 |
addComponent(PluginServices.getText(this, "limit_rows_in_memory") + ":", |
|
144 |
txtLimit = new JTextField("", 15)); |
|
145 |
addComponent(ckLimit = new JCheckBox(PluginServices.getText(this, "without_limit"))); |
|
146 |
ckLimit.addMouseListener(new MouseListener() { |
|
147 |
public void mouseClicked(MouseEvent e) { |
|
148 |
if (ckLimit.isSelected()) { |
|
149 |
txtLimit.setText(PluginServices.getText(this, "without_limit")); |
|
150 |
}else { |
|
151 |
if (txtLimit.getText().equals(PluginServices.getText(this, "without_limit"))) |
|
152 |
txtLimit.setText("500000"); |
|
153 |
} |
|
154 |
|
|
155 |
} |
|
156 |
public void mouseEntered(MouseEvent e) { |
|
157 |
} |
|
158 |
public void mouseExited(MouseEvent e) { |
|
159 |
} |
|
160 |
public void mousePressed(MouseEvent e) { |
|
161 |
} |
|
162 |
public void mouseReleased(MouseEvent e) { |
|
163 |
} |
|
164 |
|
|
165 |
}); |
|
166 |
} |
|
167 |
|
|
168 |
public void initializeValues() { |
|
169 |
int limit = prefs.getInt("limit_rows_in_memory",-1); |
|
170 |
if (limit==-1) { |
|
171 |
ckLimit.setSelected(true); |
|
172 |
txtLimit.setText(PluginServices.getText(this,"without_limit")); |
|
173 |
}else { |
|
174 |
ckLimit.setSelected(false); |
|
175 |
txtLimit.setText(String.valueOf(limit)); |
|
176 |
} |
|
177 |
} |
|
178 |
|
|
179 |
public String getID() { |
|
180 |
return this.getClass().getName(); |
|
181 |
} |
|
182 |
|
|
183 |
public String getTitle() { |
|
184 |
return PluginServices.getText(this, "limit_rows_in_memory"); |
|
185 |
} |
|
186 |
|
|
187 |
public JPanel getPanel() { |
|
188 |
return this; |
|
189 |
} |
|
190 |
|
|
191 |
public void storeValues() throws StoreException { |
|
192 |
int limit; |
|
193 |
try{ |
|
194 |
if (ckLimit.isSelected()) { |
|
195 |
limit=-1; |
|
196 |
}else { |
|
197 |
// if (txtLimit.getText().equals(PluginServices.getText(this,"without_limit"))) { |
|
198 |
// limit=-1; |
|
199 |
// }else { |
|
200 |
limit=Integer.parseInt(txtLimit.getText()); |
|
201 |
} |
|
202 |
}catch (Exception e) { |
|
203 |
throw new StoreException(PluginServices.getText(this,"limit_rows_in_memory")+PluginServices.getText(this,"error")); |
|
204 |
} |
|
205 |
prefs.putInt("limit_rows_in_memory", limit); |
|
206 |
} |
|
207 |
|
|
208 |
public void initializeDefaults() { |
|
209 |
int limit=prefs.getInt("limit_rows_in_memory",-1); |
|
210 |
if (limit==-1) { |
|
211 |
ckLimit.setSelected(true); |
|
212 |
txtLimit.setText(PluginServices.getText(this,"without_limit")); |
|
213 |
}else { |
|
214 |
ckLimit.setSelected(false); |
|
215 |
txtLimit.setText(String.valueOf(limit)); |
|
216 |
} |
|
217 |
} |
|
218 |
|
|
219 |
public ImageIcon getIcon() { |
|
220 |
return icon; |
|
221 |
} |
|
222 |
/** |
|
223 |
* This method initializes jTextArea |
|
224 |
* |
|
225 |
* @return javax.swing.JTextArea |
|
226 |
*/ |
|
227 |
private JTextArea getJTextArea() { |
|
228 |
if (jTextArea == null) { |
|
229 |
jTextArea = new JTextArea(); |
|
230 |
jTextArea.setBounds(new java.awt.Rectangle(13,7,285,57)); |
|
231 |
jTextArea.setForeground(java.awt.Color.black); |
|
232 |
jTextArea.setBackground(java.awt.SystemColor.control); |
|
233 |
jTextArea.setRows(3); |
|
234 |
jTextArea.setWrapStyleWord(true); |
|
235 |
jTextArea.setLineWrap(true); |
|
236 |
jTextArea.setEditable(false); |
|
237 |
jTextArea.setText(PluginServices.getText(this,"specifies_the_limit_rows_in_memory_when_the_program_eval_the_expression")); |
|
238 |
} |
|
239 |
return jTextArea; |
|
240 |
} |
|
241 |
|
|
242 |
public boolean isValueChanged() { |
|
243 |
return super.hasChanged(); |
|
244 |
} |
|
245 |
|
|
246 |
public void setChangesApplied() { |
|
247 |
setChanged(false); |
|
248 |
} |
|
249 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Before.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class Before extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+",)"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "before"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"boolean before(java.lang.Object value1,java.lang.Object value2){return value1.before(value2);};"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def before(value1, value2):\n" + |
|
25 |
" return value1.before(value2)"); |
|
26 |
} |
|
27 |
public boolean isEnable() { |
|
28 |
return (getType()==IOperator.DATE); |
|
29 |
} |
|
30 |
public String getTooltip(){ |
|
31 |
return PluginServices.getText(this,"operator")+": "+toString()+"("+PluginServices.getText(this,"parameter")+"1,"+PluginServices.getText(this,"parameter")+"2"+")"+"\n"+getDescription(); |
|
32 |
} |
|
33 |
public String getDescription() { |
|
34 |
return PluginServices.getText(this, "parameter") + "1"+": " + |
|
35 |
PluginServices.getText(this, "date_value") + "\n"+ |
|
36 |
PluginServices.getText(this, "parameter") + "2"+": " + |
|
37 |
PluginServices.getText(this, "date_value") + "\n"+ |
|
38 |
PluginServices.getText(this, "returns") + ": " + |
|
39 |
PluginServices.getText(this, "boolean_value") + "\n" + |
|
40 |
PluginServices.getText(this, "description") + ": " + |
|
41 |
"Tests if parameter1 date is before the parameter2 date."; |
|
42 |
} |
|
43 |
|
|
44 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Pow.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class Pow extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+", )"; |
|
18 |
} |
|
19 |
|
|
20 |
public void eval(BSFManager interpreter) throws BSFException { |
|
21 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double pow(double value1,double value2){return java.lang.Math.pow(value1,value2);};"); |
|
22 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def pow(value1, value2):\n" + |
|
23 |
" import java.lang.Math\n" + |
|
24 |
" return java.lang.Math.pow(value1,value2)"); |
|
25 |
} |
|
26 |
public String toString() { |
|
27 |
return "pow"; |
|
28 |
} |
|
29 |
public boolean isEnable() { |
|
30 |
return (getType()==IOperator.NUMBER); |
|
31 |
} |
|
32 |
public String getTooltip(){ |
|
33 |
return PluginServices.getText(this,"operator")+": "+ toString()+ "(" +PluginServices.getText(this,"parameter")+"1,"+PluginServices.getText(this,"parameter")+"2"+")\n"+getDescription(); |
|
34 |
} |
|
35 |
public String getDescription() { |
|
36 |
return PluginServices.getText(this, "parameter") + "1"+": " + |
|
37 |
PluginServices.getText(this, "numeric_value") + "\n"+ |
|
38 |
PluginServices.getText(this, "parameter") + "2"+": " + |
|
39 |
PluginServices.getText(this, "numeric_value") + "\n"+ |
|
40 |
PluginServices.getText(this, "returns") + ": " + |
|
41 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
42 |
PluginServices.getText(this, "description") + ": " + |
|
43 |
"Returns the value of the first argument raised to the power of the second argument. Special cases:\n" + |
|
44 |
"* If the second argument is positive or negative zero, then the result is 1.0.\n" + |
|
45 |
"* If the second argument is 1.0, then the result is the same as the first argument.\n" + |
|
46 |
"* If the second argument is NaN, then the result is NaN.\n" + |
|
47 |
"* If the first argument is NaN and the second argument is nonzero, then the result is NaN.\n" + |
|
48 |
"* If\n" + |
|
49 |
" - the absolute value of the first argument is greater than 1 and the second argument is positive infinity, or\n" + |
|
50 |
" - the absolute value of the first argument is less than 1 and the second argument is negative infinity,\n" + |
|
51 |
"then the result is positive infinity.\n" + |
|
52 |
"* If\n" + |
|
53 |
" - the absolute value of the first argument is greater than 1 and the second argument is negative infinity, or\n" + |
|
54 |
" - the absolute value of the first argument is less than 1 and the second argument is positive infinity,\n" + |
|
55 |
"then the result is positive zero.\n" + |
|
56 |
"* If the absolute value of the first argument equals 1 and the second argument is infinite, then the result is NaN.\n" + |
|
57 |
"* If\n" + |
|
58 |
" - the first argument is positive zero and the second argument is greater than zero, or\n" + |
|
59 |
" - the first argument is positive infinity and the second argument is less than zero,\n" + |
|
60 |
"then the result is positive zero.\n" + |
|
61 |
"* If\n" + |
|
62 |
" - the first argument is positive zero and the second argument is less than zero, or\n" + |
|
63 |
" - the first argument is positive infinity and the second argument is greater than zero,\n" + |
|
64 |
"then the result is positive infinity.\n" + |
|
65 |
"* If\n" + |
|
66 |
" - the first argument is negative zero and the second argument is greater than zero but not a finite odd integer, or\n" + |
|
67 |
" - the first argument is negative infinity and the second argument is less than zero but not a finite odd integer,\n" + |
|
68 |
"then the result is positive zero.\n" + |
|
69 |
"* If\n" + |
|
70 |
" - the first argument is negative zero and the second argument is a positive finite odd integer, or\n" + |
|
71 |
" - the first argument is negative infinity and the second argument is a negative finite odd integer,\n" + |
|
72 |
"then the result is negative zero.\n" + |
|
73 |
"* If\n" + |
|
74 |
" - the first argument is negative zero and the second argument is less than zero but not a finite odd integer, or\n" + |
|
75 |
" - the first argument is negative infinity and the second argument is greater than zero but not a finite odd integer,\n" + |
|
76 |
"then the result is positive infinity.\n" + |
|
77 |
"* If\n" + |
|
78 |
" - the first argument is negative zero and the second argument is a negative finite odd integer, or\n" + |
|
79 |
" - the first argument is negative infinity and the second argument is a positive finite odd integer,\n" + |
|
80 |
"then the result is negative infinity.\n" + |
|
81 |
"* If the first argument is finite and less than zero\n" + |
|
82 |
" - if the second argument is a finite even integer, the result is equal to the result of raising the absolute value of the first argument to the power of the second argument\n" + |
|
83 |
" - if the second argument is a finite odd integer, the result is equal to the negative of the result of raising the absolute value of the first argument to the power of the second argument\n" + |
|
84 |
" - if the second argument is finite and not an integer, then the result is NaN.\n" + |
|
85 |
"* If both arguments are integers, then the result is exactly equal to the mathematical result of raising the first argument to the power of the second argument if that result can in fact be represented exactly as a double value."; |
|
86 |
} |
|
87 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Abs.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
/** |
|
13 |
* |
|
14 |
* @author Vicente Caballero Navarro |
|
15 |
*/ |
|
16 |
public class Abs extends AbstractOperator { |
|
17 |
public String addText(String s) { |
|
18 |
return toString() + "(" + s + ")"; |
|
19 |
} |
|
20 |
|
|
21 |
public String toString() { |
|
22 |
return "abs"; |
|
23 |
} |
|
24 |
|
|
25 |
public void eval(BSFManager interpreter) throws BSFException { |
|
26 |
interpreter.exec(ExpressionFieldExtension.JYTHON, null, -1, -1, |
|
27 |
"def abs(value):\n" + |
|
28 |
" import java.lang.Math\n"+ |
|
29 |
" return java.lang.Math.abs(value)\n"); |
|
30 |
} |
|
31 |
|
|
32 |
public boolean isEnable() { |
|
33 |
return (getType() == IOperator.NUMBER); |
|
34 |
} |
|
35 |
|
|
36 |
public double abs(double value) { |
|
37 |
return java.lang.Math.abs(value); |
|
38 |
} |
|
39 |
|
|
40 |
public String getDescription() { |
|
41 |
return PluginServices.getText(this, "parameter") + ": " + |
|
42 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
43 |
PluginServices.getText(this, "returns") + ": " + |
|
44 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
45 |
PluginServices.getText(this, "description") + ": " + |
|
46 |
"Returns the absolute value of a double value. If the argument is not negative, the argument is returned. " + |
|
47 |
"If the argument is negative, the negation of the argument is returned.\n " + |
|
48 |
"Special cases:\n" + |
|
49 |
"* If the argument is positive zero or negative zero, the result is positive zero.\n" + |
|
50 |
"* If the argument is infinite, the result is positive infinity.\n" + |
|
51 |
"* If the argument is NaN, the result is NaN."; |
|
52 |
} |
|
53 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/AbstractField.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
6 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
7 |
import org.gvsig.fmap.dal.feature.Feature; |
|
8 |
|
|
9 |
|
|
10 |
public abstract class AbstractField extends AbstractOperator{ |
|
11 |
private boolean isEval=false; |
|
12 |
public Object getValue(Feature feature, String nameField){ |
|
13 |
if (feature != null) |
|
14 |
return feature.get(nameField); |
|
15 |
return null; |
|
16 |
} |
|
17 |
// public Object getValue(String nameField,Index indexRow,SelectableDataSource sds) { |
|
18 |
// try { |
|
19 |
// int index=sds.getFieldIndexByName(nameField); |
|
20 |
// Value value=sds.getFieldValue(indexRow.get(),index); |
|
21 |
// if (value instanceof NumericValue) { |
|
22 |
// double dv=((NumericValue)value).doubleValue(); |
|
23 |
// return new Double(dv); |
|
24 |
// }else if (value instanceof DateValue) { |
|
25 |
// Date date=((DateValue)value).getValue(); |
|
26 |
// return date; |
|
27 |
// }else if (value instanceof BooleanValue){ |
|
28 |
// boolean b=((BooleanValue)value).getValue(); |
|
29 |
// return new Boolean(b); |
|
30 |
// }else { |
|
31 |
// return value.toString(); |
|
32 |
// } |
|
33 |
// } catch (ReadDriverException e) { |
|
34 |
// throw new RuntimeException(e.getMessage()); |
|
35 |
// } |
|
36 |
// } |
|
37 |
public void eval(BSFManager interpreter) throws BSFException { |
|
38 |
if (!isEval){ |
|
39 |
interpreter.declareBean("jfield",this,Field.class); |
|
40 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def field(nameField):\n" + |
|
41 |
" return jfield.getValue(featureContainer.getFeature(), nameField)"); |
|
42 |
isEval=true; |
|
43 |
} |
|
44 |
} |
|
45 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/SetTimeDate.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class SetTimeDate extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "setTimeDate"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"java.util.Date setTimeDate(java.lang.Object value1,double value2){value1.setTime((long)value2);return value1;};"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1, |
|
25 |
"import java.util.Date as jDate\n"+ |
|
26 |
"def setTimeDate(value):\n"+ |
|
27 |
" aux = jDate()\n"+ |
|
28 |
" aux.setTime(long(value))\n"+ |
|
29 |
" return aux"); |
|
30 |
} |
|
31 |
public boolean isEnable() { |
|
32 |
return (getType()==IOperator.DATE); |
|
33 |
} |
|
34 |
|
|
35 |
public String getDescription() { |
|
36 |
return PluginServices.getText(this, "parameter") + ": " + |
|
37 |
PluginServices.getText(this, "numeric_value") + "\n"+ |
|
38 |
PluginServices.getText(this, "returns") + ": " + |
|
39 |
PluginServices.getText(this, "date_value") + "\n" + |
|
40 |
PluginServices.getText(this, "description") + ": " + |
|
41 |
"Returns a date object to represent a point in time that is 'parameter' milliseconds after January 1, 1970 00:00:00 GMT."; |
|
42 |
} |
|
43 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Trim.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class Trim extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "trim"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"String trim(String value){return value.trim();};"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def trim(value):\n" + |
|
25 |
" return value.strip()"); |
|
26 |
} |
|
27 |
public boolean isEnable() { |
|
28 |
return (getType()==IOperator.STRING); |
|
29 |
} |
|
30 |
public String getDescription() { |
|
31 |
return PluginServices.getText(this, "parameter") + ": " + |
|
32 |
PluginServices.getText(this, "string_value") + "\n" + |
|
33 |
PluginServices.getText(this, "returns") + ": " + |
|
34 |
PluginServices.getText(this, "string_value") + "\n" + |
|
35 |
PluginServices.getText(this, "description") + ": " + |
|
36 |
"Returns a copy of the string, with leading and trailing whitespace omitted."; |
|
37 |
} |
|
38 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/FieldCopy.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
6 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
7 |
import org.gvsig.fmap.dal.feature.Feature; |
|
8 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class FieldCopy extends AbstractOperator{ |
|
14 |
private FeatureAttributeDescriptor fd; |
|
15 |
public FieldCopy() { |
|
16 |
} |
|
17 |
public void setFieldDescription(FeatureAttributeDescriptor fd) { |
|
18 |
this.fd=fd; |
|
19 |
} |
|
20 |
public String addText(String s) { |
|
21 |
return s.concat(toString()); |
|
22 |
} |
|
23 |
|
|
24 |
public void eval(BSFManager interpreter) throws BSFException { |
|
25 |
interpreter.declareBean(fd.getName(),this,FieldCopy.class); |
|
26 |
interpreter.eval(ExpressionFieldExtension.JYTHON,null,-1,-1,"java.lang.Object "+ fd.getName()+ "(){return "+fd.getName()+".getValue(feature);};"); |
|
27 |
} |
|
28 |
public Object getValue(Feature feature){ |
|
29 |
return feature.get(fd.getName()); |
|
30 |
} |
|
31 |
// public Object getValue(Index indexRow,FeatureStore sds) { |
|
32 |
// try { |
|
33 |
// int index=sds.getFieldIndexByName(fd.getName()); |
|
34 |
// Value value=sds.getFieldValue(indexRow.get(),index); |
|
35 |
// if (value instanceof NumericValue) { |
|
36 |
// double dv=((NumericValue)value).doubleValue(); |
|
37 |
// return new Double(dv); |
|
38 |
// }else if (value instanceof DateValue) { |
|
39 |
// Date date=((DateValue)value).getValue(); |
|
40 |
// return date; |
|
41 |
// }else if (value instanceof BooleanValue){ |
|
42 |
// boolean b=((BooleanValue)value).getValue(); |
|
43 |
// return new Boolean(b); |
|
44 |
// }else { |
|
45 |
// return value.toString(); |
|
46 |
// } |
|
47 |
// } catch (ReadDriverException e) { |
|
48 |
// throw new RuntimeException(e.getMessage()); |
|
49 |
// } |
|
50 |
// } |
|
51 |
public String toString() { |
|
52 |
return "["+fd.getName()+"]"; |
|
53 |
} |
|
54 |
public boolean isEnable() { |
|
55 |
return true; |
|
56 |
} |
|
57 |
public String getDescription() { |
|
58 |
// TODO Auto-generated method stub |
|
59 |
return null; |
|
60 |
} |
|
61 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/PointX.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
|
|
5 |
import org.apache.bsf.BSFException; |
|
6 |
import org.apache.bsf.BSFManager; |
|
7 |
import org.gvsig.andami.PluginServices; |
|
8 |
import org.gvsig.andami.messages.NotificationManager; |
|
9 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
10 |
import org.gvsig.expressionfield.project.documents.table.GraphicOperator; |
|
11 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
12 |
import org.gvsig.fmap.dal.exception.DataException; |
|
13 |
import org.gvsig.fmap.dal.feature.Feature; |
|
14 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
15 |
|
|
16 |
/** |
|
17 |
* @author Vicente Caballero Navarro |
|
18 |
*/ |
|
19 |
public class PointX extends GraphicOperator{ |
|
20 |
|
|
21 |
public String addText(String s) { |
|
22 |
return s.concat(toString()+"()"); |
|
23 |
} |
|
24 |
public double process(Feature feature){ |
|
25 |
// ReadableVectorial adapter = getLayer().getSource(); |
|
26 |
org.gvsig.fmap.geom.Geometry geom=null; |
|
27 |
// try { |
|
28 |
geom = feature.getDefaultGeometry();//adapter.getShape(index.get()); |
|
29 |
// } catch (ExpansionFileReadException e) { |
|
30 |
// throw new DriverIOException(e); |
|
31 |
// } catch (ReadDriverException e) { |
|
32 |
// throw new DriverIOException(e); |
|
33 |
// } |
|
34 |
ArrayList parts=getXY(geom); |
|
35 |
Double[][] xsys=(Double[][])parts.get(0);//getXY(geom); |
|
36 |
return xsys[0][0].doubleValue(); |
|
37 |
} |
|
38 |
public void eval(BSFManager interpreter) throws BSFException { |
|
39 |
interpreter.declareBean("pointX",this,PointX.class); |
|
40 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double x(){return pointX.process(indexRow);};"); |
|
41 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def x():\n" + |
|
42 |
" return pointX.process(featureContainer.getFeature())"); |
|
43 |
} |
|
44 |
public String toString() { |
|
45 |
return "x"; |
|
46 |
} |
|
47 |
public boolean isEnable() { |
|
48 |
if (getLayer()==null) |
|
49 |
return false; |
|
50 |
int geomType=org.gvsig.fmap.geom.Geometry.TYPES.POINT; |
|
51 |
try { |
|
52 |
FeatureStore store = getLayer().getFeatureStore(); |
|
53 |
geomType = store.getDefaultFeatureType().getAttributeDescriptor(store.getDefaultFeatureType().getDefaultGeometryAttributeIndex()).getGeometryType(); |
|
54 |
} catch (DataException e) { |
|
55 |
NotificationManager.addError(e); |
|
56 |
} |
|
57 |
return (getType()==IOperator.NUMBER && geomType==org.gvsig.fmap.geom.Geometry.TYPES.POINT); |
|
58 |
} |
|
59 |
public String getTooltip(){ |
|
60 |
return PluginServices.getText(this,"operator")+": "+addText("")+"\n"+getDescription(); |
|
61 |
} |
|
62 |
public String getDescription() { |
|
63 |
return PluginServices.getText(this, "returns") + ": " + |
|
64 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
65 |
PluginServices.getText(this, "description") + ": " + |
|
66 |
"Returns the X coordenate of point geometry of this row."; |
|
67 |
} |
|
68 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Floor.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class Floor extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "floor"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def floor(value):\n" + |
|
24 |
" import java.lang.Math\n" + |
|
25 |
" return java.lang.Math.floor(value)"); |
|
26 |
} |
|
27 |
public boolean isEnable() { |
|
28 |
return (getType()==IOperator.NUMBER); |
|
29 |
} |
|
30 |
public String getDescription() { |
|
31 |
return PluginServices.getText(this, "parameter") + ": " + |
|
32 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
33 |
PluginServices.getText(this, "returns") + ": " + |
|
34 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
35 |
PluginServices.getText(this, "description") + ": " + |
|
36 |
"Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer. Special cases:\n" + |
|
37 |
"* If the argument value is already equal to a mathematical integer, then the result is the same as the argument.\n" + |
|
38 |
"* If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.\n"; |
|
39 |
} |
|
40 |
|
|
41 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/ToDegrees.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class ToDegrees extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "toDegrees"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double toDegrees(double value){return java.lang.Math.toDegrees(value);};"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def toDegrees(value):\n" + |
|
25 |
" import java.lang.Math\n" + |
|
26 |
" return java.lang.Math.toDegrees(value)"); |
|
27 |
} |
|
28 |
public boolean isEnable() { |
|
29 |
return (getType()==IOperator.NUMBER); |
|
30 |
} |
|
31 |
public String getDescription() { |
|
32 |
return PluginServices.getText(this, "parameter") + ": " + |
|
33 |
PluginServices.getText(this, "double_value") + "\n" + |
|
34 |
PluginServices.getText(this, "returns") + ": " + |
|
35 |
PluginServices.getText(this, "double_value") + "\n" + |
|
36 |
PluginServices.getText(this, "description") + ": " + |
|
37 |
"Converts an angle measured in radians to an approximately equivalent angle measured in degrees.\n" + |
|
38 |
"The conversion from radians to degrees is generally inexact; users should not expect cos(toRadians(90.0)) to exactly equal 0.0."; |
|
39 |
} |
|
40 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Tan.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class Tan extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "tan"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double tan(double value){return java.lang.Math.tan(value);};"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def tan(value):\n" + |
|
25 |
" import java.lang.Math\n" + |
|
26 |
" return java.lang.Math.tan(value)"); |
|
27 |
} |
|
28 |
public boolean isEnable() { |
|
29 |
return (getType()==IOperator.NUMBER); |
|
30 |
} |
|
31 |
public String getDescription() { |
|
32 |
return PluginServices.getText(this, "parameter") + ": " + |
|
33 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
34 |
PluginServices.getText(this, "returns") + ": " + |
|
35 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
36 |
PluginServices.getText(this, "description") + ": " + |
|
37 |
"Returns the trigonometric tangent of an angle. Special cases:\n" + |
|
38 |
"* If the argument is NaN or an infinity, then the result is NaN.\n" + |
|
39 |
"* If the argument is zero, then the result is a zero with the same sign as the argument."; |
|
40 |
} |
|
41 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Atan.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class Atan extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "atan"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double atan(double value){return java.lang.Math.atan(value);};"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def atan(value):\n" + |
|
25 |
" import java.lang.Math\n" + |
|
26 |
" return java.lang.Math.atan(value)"); |
|
27 |
} |
|
28 |
public boolean isEnable() { |
|
29 |
return (getType()==IOperator.NUMBER); |
|
30 |
} |
|
31 |
public String getDescription() { |
|
32 |
return PluginServices.getText(this, "parameter") + ": " + |
|
33 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
34 |
PluginServices.getText(this, "returns") + ": " + |
|
35 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
36 |
PluginServices.getText(this, "description") + ": " + |
|
37 |
"Returns the arc tangent of an angle, in the range of -pi/2 through pi/2. Special cases:\n" + |
|
38 |
"* If the argument is NaN, then the result is NaN.\n" + |
|
39 |
"* If the argument is zero, then the result is a zero with the same sign as the argument.\n"; |
|
40 |
} |
|
41 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Plus.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
8 |
|
|
9 |
/** |
|
10 |
* @author Vicente Caballero Navarro |
|
11 |
*/ |
|
12 |
public class Plus extends AbstractOperator{ |
|
13 |
|
|
14 |
public String addText(String s) { |
|
15 |
return s.concat(toString()); |
|
16 |
} |
|
17 |
public String toString() { |
|
18 |
return "+"; |
|
19 |
} |
|
20 |
public void eval(BSFManager interpreter) throws BSFException { |
|
21 |
} |
|
22 |
public boolean isEnable() { |
|
23 |
return (getType()==IOperator.NUMBER || getType()==IOperator.STRING); |
|
24 |
} |
|
25 |
public String getTooltip(){ |
|
26 |
return PluginServices.getText(this,"operator")+": "+addText("")+"\n"+getDescription(); |
|
27 |
} |
|
28 |
public String getDescription() { |
|
29 |
return PluginServices.getText(this, "returns") + ": " + |
|
30 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
31 |
PluginServices.getText(this, "description") + ": " + |
|
32 |
"Returns the result of sum."; |
|
33 |
} |
|
34 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Cos.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class Cos extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "cos"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double cos(double value){return java.lang.Math.cos(value);};"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def cos(value):\n" + |
|
25 |
" import java.lang.Math\n" + |
|
26 |
" return java.lang.Math.cos(value)"); |
|
27 |
} |
|
28 |
public boolean isEnable() { |
|
29 |
return (getType()==IOperator.NUMBER); |
|
30 |
} |
|
31 |
public String getDescription() { |
|
32 |
return PluginServices.getText(this, "parameter") + ": " + |
|
33 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
34 |
PluginServices.getText(this, "returns") + ": " + |
|
35 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
36 |
PluginServices.getText(this, "description") + ": " + |
|
37 |
"Returns the trigonometric cosine of an angle. Special cases:\n" + |
|
38 |
"* If the argument is NaN or an infinity, then the result is NaN."; |
|
39 |
} |
|
40 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/E.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class E extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return s.concat(toString()+"()"); |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "e"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double e(){return java.lang.Math.E;};"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def e():\n" + |
|
25 |
" import java.lang.Math\n" + |
|
26 |
" return java.lang.Math.E"); |
|
27 |
} |
|
28 |
public boolean isEnable() { |
|
29 |
return (getType()==IOperator.NUMBER); |
|
30 |
} |
|
31 |
public String getTooltip(){ |
|
32 |
return PluginServices.getText(this,"operator")+": "+addText("")+"\n"+getDescription(); |
|
33 |
} |
|
34 |
public String getDescription() { |
|
35 |
return PluginServices.getText(this, "returns") + ": " + |
|
36 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
37 |
PluginServices.getText(this, "description") + ": " + |
|
38 |
"The double value that is closer than any other to e, the base of the natural logarithms."; |
|
39 |
} |
|
40 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Acos.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class Acos extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "acos"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
interpreter.exec(ExpressionFieldExtension.JYTHON, null, -1, -1, |
|
24 |
"def acos(value):\n" + |
|
25 |
" import java.lang.Math\n"+ |
|
26 |
" return java.lang.Math.acos(value)\n"); |
|
27 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double acos(double value){return java.lang.Math.acos(value);};"); |
|
28 |
} |
|
29 |
public boolean isEnable() { |
|
30 |
return (getType()==IOperator.NUMBER); |
|
31 |
} |
|
32 |
public String getDescription() { |
|
33 |
return PluginServices.getText(this, "parameter") + ": " + |
|
34 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
35 |
PluginServices.getText(this, "returns") + ": " + |
|
36 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
37 |
PluginServices.getText(this, "description") + ": " + |
|
38 |
"Returns the arc cosine of an angle, in the range of 0.0 through pi. Special case:\n" + |
|
39 |
"* If the argument is NaN or its absolute value is greater than 1, then the result is NaN."; |
|
40 |
} |
|
41 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Round.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class Round extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "round"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double round(double value){return java.lang.Math.round(value);};"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def round(value):\n" + |
|
25 |
" import java.lang.Math\n" + |
|
26 |
" return java.lang.Math.round(value)"); |
|
27 |
} |
|
28 |
public boolean isEnable() { |
|
29 |
return (getType()==IOperator.NUMBER); |
|
30 |
} |
|
31 |
public String getDescription() { |
|
32 |
return PluginServices.getText(this, "parameter") + ": " + |
|
33 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
34 |
PluginServices.getText(this, "returns") + ": " + |
|
35 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
36 |
PluginServices.getText(this, "description") + ": " + |
|
37 |
"Returns the closest long to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type long."; |
|
38 |
} |
|
39 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/ToLowerCase.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class ToLowerCase extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "toLowerCase"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"String toLowerCase(String value){return value.toLowerCase();};"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def toLowerCase(value):\n" + |
|
25 |
" return value.lower()"); |
|
26 |
} |
|
27 |
public boolean isEnable() { |
|
28 |
return (getType()==IOperator.STRING); |
|
29 |
} |
|
30 |
public String getDescription() { |
|
31 |
return PluginServices.getText(this, "parameter") + ": " + |
|
32 |
PluginServices.getText(this, "string_value") + "\n" + |
|
33 |
PluginServices.getText(this, "returns") + ": " + |
|
34 |
PluginServices.getText(this, "string_value") + "\n" + |
|
35 |
PluginServices.getText(this, "description") + ": " + |
|
36 |
"Converts all of the characters in this String to lower case using the rules of the default locale."; |
|
37 |
} |
|
38 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Sqrt.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class Sqrt extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "sqrt"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double sqrt(double value){return java.lang.Math.sqrt(value);};"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def sqrt(value):\n" + |
|
25 |
" import java.lang.Math\n" + |
|
26 |
" return java.lang.Math.sqrt(value)"); |
|
27 |
} |
|
28 |
public boolean isEnable() { |
|
29 |
return (getType()==IOperator.NUMBER); |
|
30 |
} |
|
31 |
public String getDescription() { |
|
32 |
return PluginServices.getText(this, "parameter") + ": " + |
|
33 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
34 |
PluginServices.getText(this, "returns") + ": " + |
|
35 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
36 |
PluginServices.getText(this, "description") + ": " + |
|
37 |
"Returns the correctly rounded positive square root of a double value. Special cases:\n" + |
|
38 |
"* If the argument is NaN or less than zero, then the result is NaN.\n" + |
|
39 |
"* If the argument is positive infinity, then the result is positive infinity.\n" + |
|
40 |
"* If the argument is positive zero or negative zero, then the result is the same as the argument."; |
|
41 |
} |
|
42 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Equals.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class Equals extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "equals"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"boolean equals(java.lang.Object value1,java.lang.Object value2){return value1.equals(value2);};"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1, |
|
25 |
"def equals(value1,value2):\n" + |
|
26 |
" return value1 == value2"); |
|
27 |
} |
|
28 |
public boolean isEnable() { |
|
29 |
return (getType()==IOperator.STRING || getType()==IOperator.DATE); |
|
30 |
} |
|
31 |
public String getTooltip(){ |
|
32 |
return PluginServices.getText(this,"operator")+": "+toString()+"("+PluginServices.getText(this,"parameter")+"1,"+PluginServices.getText(this,"parameter")+"2"+")"+"\n"+getDescription(); |
|
33 |
} |
|
34 |
public String getDescription() { |
|
35 |
return PluginServices.getText(this, "parameter") + "1"+": " + |
|
36 |
// PluginServices.getText(this, "string_value") + "\n"+ |
|
37 |
PluginServices.getText(this, "parameter") + "2"+": " + |
|
38 |
// PluginServices.getText(this, "string_value") + "\n"+ |
|
39 |
PluginServices.getText(this, "returns") + ": " + |
|
40 |
PluginServices.getText(this, "boolean_value") + "\n" + |
|
41 |
PluginServices.getText(this, "description") + ": " + |
|
42 |
"Compares the parameter1 to the parameter2. The result is true if and only if the arguments are not null and represents the same object."; |
|
43 |
} |
|
44 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/ToUpperCase.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class ToUpperCase extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "toUpperCase"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"String toUpperCase(String value){return value.toUpperCase();};"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def toUpperCase(value):\n" + |
|
25 |
" return value.upper()"); |
|
26 |
} |
|
27 |
public boolean isEnable() { |
|
28 |
return (getType()==IOperator.STRING); |
|
29 |
} |
|
30 |
public String getDescription() { |
|
31 |
return PluginServices.getText(this, "parameter") + ": " + |
|
32 |
PluginServices.getText(this, "string_value") + "\n" + |
|
33 |
PluginServices.getText(this, "returns") + ": " + |
|
34 |
PluginServices.getText(this, "string_value") + "\n" + |
|
35 |
PluginServices.getText(this, "description") + ": " + |
|
36 |
"Converts all of the characters in this String to upper case using the rules of the given Locale.\n" + |
|
37 |
"Case mappings rely heavily on the Unicode specification's character data.\n" + |
|
38 |
"Since case mappings are not always 1:1 char mappings, the resulting String may be a different length than the original String."; |
|
39 |
} |
|
40 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/DateToString.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author fdiaz |
|
13 |
*/ |
|
14 |
public class DateToString extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return toString()+"("+s+")"; |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "dateToString"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"String toString(java.lang.Object value){" + |
|
24 |
// "if (value instanceof java.util.Date)" + |
|
25 |
// "return ((java.util.Date)value).toString();" + |
|
26 |
// "return String.valueOf(value);};"); |
|
27 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1, |
|
28 |
"import java.util.Date as Date\n"+ |
|
29 |
"import java.text.DateFormat as DateFormat\n"+ |
|
30 |
"import java.text.SimpleDateFormat as SimpleDateFormat\n" + |
|
31 |
"import java.text.NumberFormat as NumberFormat\n"+ |
|
32 |
"dateFormat = DateFormat.getInstance()\n"+ |
|
33 |
"myDateFormat = SimpleDateFormat()\n" + |
|
34 |
"def dateToString(value, format=None):\n" + |
|
35 |
" if value == None:\n"+ |
|
36 |
" return None\n"+ |
|
37 |
" if value == '':\n"+ |
|
38 |
" return ''\n"+ |
|
39 |
" if isinstance(value,Date):\n"+ |
|
40 |
" if format != None:\n"+ |
|
41 |
" myDateFormat.applyPattern(format)\n"+ |
|
42 |
" return myDateFormat.format(value)\n"+ |
|
43 |
" else:\n"+ |
|
44 |
" return dateFormat.format(value)\n"+ |
|
45 |
" else:\n"+ |
|
46 |
" raise InputError\n"+ |
|
47 |
" return str(value)"); |
|
48 |
} |
|
49 |
public boolean isEnable() { |
|
50 |
return (getType()==IOperator.DATE); |
|
51 |
} |
|
52 |
|
|
53 |
public String getTooltip(){ |
|
54 |
return PluginServices.getText(this,"operator")+": "+toString()+"("+PluginServices.getText(this,"parameter")+"[,"+PluginServices.getText(this,"format")+"])"+"\n"+getDescription(); |
|
55 |
} |
|
56 |
|
|
57 |
public String getDescription() { |
|
58 |
return PluginServices.getText(this, "parameter") + ": " + |
|
59 |
PluginServices.getText(this, "date_value") + "\n" + |
|
60 |
PluginServices.getText(this, "format") + " ("+PluginServices.getText(this, "optional")+"): " + |
|
61 |
PluginServices.getText(this, "string_value") + "\n" + |
|
62 |
PluginServices.getText(this, "returns") + ": " + |
|
63 |
PluginServices.getText(this, "string_value") + "\n" + |
|
64 |
PluginServices.getText(this, "description") + ": " + |
|
65 |
"Returns the string representation of the Object date parameter\n" + |
|
66 |
"formatted according to the parameter format, if it is supplied.\n\n"+ |
|
67 |
"The format should follow the specifications of\n" + |
|
68 |
"'http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html'.\n\n"+ |
|
69 |
"Examples: (for the date of December 23, 2008)\n"+ |
|
70 |
" 'dd/MM/yy' 23/12/08\n"+ |
|
71 |
" 'dd/MM/yyyy' 23/12/2008\n"+ |
|
72 |
" 'dd/MMM/yyyy' 23/dec/2008\n"+ |
|
73 |
" 'dd/MMMM/yyyy' 23/december/2008\n"; |
|
74 |
} |
|
75 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Equal.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
8 |
|
|
9 |
|
|
10 |
/** |
|
11 |
* @author Vicente Caballero Navarro |
|
12 |
*/ |
|
13 |
public class Equal extends AbstractOperator{ |
|
14 |
|
|
15 |
public String addText(String s) { |
|
16 |
return s.concat(toString()); |
|
17 |
} |
|
18 |
|
|
19 |
public void eval(BSFManager interpreter) throws BSFException { |
|
20 |
|
|
21 |
} |
|
22 |
public String toString() { |
|
23 |
return " == "; |
|
24 |
} |
|
25 |
public boolean isEnable() { |
|
26 |
return (getType()==IOperator.DATE || getType()==IOperator.NUMBER || getType()==IOperator.STRING); |
|
27 |
} |
|
28 |
public String getTooltip(){ |
|
29 |
return PluginServices.getText(this,"operator")+": "+addText("")+"\n"+getDescription(); |
|
30 |
} |
|
31 |
public String getDescription() { |
|
32 |
return PluginServices.getText(this, "returns") + ": " + |
|
33 |
PluginServices.getText(this, "boolean_value") + "\n" + |
|
34 |
PluginServices.getText(this, "description") + ": " + |
|
35 |
"Returns true if the first object value is equals than the second value."; |
|
36 |
} |
|
37 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Pi.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import org.apache.bsf.BSFException; |
|
4 |
import org.apache.bsf.BSFManager; |
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.expressionfield.ExpressionFieldExtension; |
|
7 |
import org.gvsig.expressionfield.project.documents.table.AbstractOperator; |
|
8 |
import org.gvsig.expressionfield.project.documents.table.IOperator; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @author Vicente Caballero Navarro |
|
13 |
*/ |
|
14 |
public class Pi extends AbstractOperator{ |
|
15 |
|
|
16 |
public String addText(String s) { |
|
17 |
return s.concat(toString()+"()"); |
|
18 |
} |
|
19 |
public String toString() { |
|
20 |
return "pi"; |
|
21 |
} |
|
22 |
public void eval(BSFManager interpreter) throws BSFException { |
|
23 |
// interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double pi(){return java.lang.Math.PI;};"); |
|
24 |
interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def pi():\n" + |
|
25 |
" import java.lang.Math\n" + |
|
26 |
" return java.lang.Math.PI"); |
|
27 |
} |
|
28 |
public boolean isEnable() { |
|
29 |
return (getType()==IOperator.NUMBER); |
|
30 |
} |
|
31 |
public String getTooltip(){ |
|
32 |
return PluginServices.getText(this,"operator")+": "+addText("")+"\n"+getDescription(); |
|
33 |
} |
|
34 |
public String getDescription() { |
|
35 |
return PluginServices.getText(this, "returns") + ": " + |
|
36 |
PluginServices.getText(this, "numeric_value") + "\n" + |
|
37 |
PluginServices.getText(this, "description") + ": " + |
|
38 |
"The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter."; |
|
39 |
} |
|
40 |
} |
tags/v2_0_0_Build_2021/extensions/extExpressionField/src/org/gvsig/expressionfield/project/documents/table/operators/Area.java | ||
---|---|---|
1 |
package org.gvsig.expressionfield.project.documents.table.operators; |
|
2 |
|
|
3 |
import java.awt.geom.Point2D; |
|
4 |
import java.util.ArrayList; |
|
5 |
|
|
6 |
import org.apache.bsf.BSFException; |
|
7 |
import org.apache.bsf.BSFManager; |
|
8 |
import org.cresques.cts.IProjection; |
|
9 |
import org.gvsig.andami.PluginServices; |
|
10 |
import org.gvsig.andami.messages.NotificationManager; |
Also available in: Unified diff