Revision 158

View differences:

org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4

  
5
    <modelVersion>4.0.0</modelVersion>
6
    <artifactId>org.gvsig.expressionfield</artifactId>
7
    <name>${project.artifactId}</name>
8
    <version>2.0.26</version>
9
    <description>Field calculator (Expression from assistant or from text file)</description>
10

  
11
    <parent>
12
        <groupId>org.gvsig</groupId>
13
        <artifactId>org.gvsig.desktop</artifactId>
14
        <version>2.0.124</version>
15
    </parent>
16

  
17
    <url>https://devel.gvsig.org/redmine/projects/gvsig-expression-field</url>
18

  
19
    <scm>
20
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-expression-field/org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26</connection>
21
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-expression-field/org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26</developerConnection>
22
        <url>scm:svn:https://devel.gvsig.org/svn/gvsig-expression-field/org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26</url>
23
    </scm>
24

  
25
  <repositories>
26
    <repository>
27
      <id>gvsig-public-http-repository</id>
28
      <name>gvSIG maven public HTTP repository</name>
29
      <url>http://devel.gvsig.org/m2repo/j2se</url>
30
      <releases>
31
        <enabled>true</enabled>
32
        <updatePolicy>daily</updatePolicy>
33
        <checksumPolicy>warn</checksumPolicy>
34
      </releases>
35
      <snapshots>
36
        <enabled>true</enabled>
37
        <updatePolicy>daily</updatePolicy>
38
        <checksumPolicy>warn</checksumPolicy>
39
      </snapshots>
40
    </repository>
41
  </repositories>
42

  
43
    <dependencyManagement>
44
        <dependencies>
45
            <!-- Adding this dependency because this project is using a jython version
46
            different to the version defined by the parent pom  -->
47
            <dependency>
48
                <groupId>org.python</groupId>
49
                <artifactId>jython</artifactId>
50
                <version>2.2.1</version>
51
            </dependency>
52
        </dependencies>
53
    </dependencyManagement>
54

  
55
    <dependencies>
56
        <dependency>
57
            <groupId>org.gvsig</groupId>
58
            <artifactId>org.gvsig.app.mainplugin</artifactId>
59
            <scope>compile</scope>
60
        </dependency>
61
        <dependency>
62
            <groupId>org.gvsig</groupId>
63
            <artifactId>org.gvsig.app.document.table.app.mainplugin</artifactId>
64
            <scope>compile</scope>
65
        </dependency>
66
        <dependency>
67
            <groupId>bsf</groupId>
68
            <artifactId>bsf</artifactId>
69
            <scope>compile</scope>
70
        </dependency>
71

  
72
        <dependency>
73
            <groupId>bsh</groupId>
74
            <artifactId>bsh</artifactId>
75
            <scope>compile</scope>
76
        </dependency>
77

  
78
        <dependency>
79
            <groupId>org.gvsig</groupId>
80
            <artifactId>org.gvsig.about.api</artifactId>
81
            <scope>compile</scope>
82
        </dependency>
83
        <dependency>
84
            <groupId>org.gvsig</groupId>
85
            <artifactId>org.gvsig.andami</artifactId>
86
            <scope>compile</scope>
87
        </dependency>
88
        <dependency>
89
            <groupId>org.gvsig</groupId>
90
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
91
            <scope>compile</scope>
92
        </dependency>
93
        <dependency>
94
            <groupId>org.gvsig</groupId>
95
            <artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
96
            <scope>compile</scope>
97
        </dependency>
98
        <dependency>
99
            <groupId>org.gvsig</groupId>
100
            <artifactId>org.gvsig.tools.lib</artifactId>
101
            <scope>compile</scope>
102
        </dependency>
103
        <dependency>
104
            <groupId>org.gvsig</groupId>
105
            <artifactId>org.gvsig.tools.swing.api</artifactId>
106
            <scope>compile</scope>
107
        </dependency>
108
        <dependency>
109
            <groupId>org.gvsig</groupId>
110
            <artifactId>org.gvsig.fmap.geometry.api</artifactId>
111
            <scope>compile</scope>
112
        </dependency>
113
        <dependency>
114
            <groupId>org.gvsig</groupId>
115
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
116
            <scope>compile</scope>
117
        </dependency>
118
        <dependency>
119
            <groupId>org.gvsig</groupId>
120
            <artifactId>org.gvsig.ui</artifactId>
121
            <scope>compile</scope>
122
        </dependency>
123
        <dependency>
124
            <groupId>org.gvsig</groupId>
125
            <artifactId>org.gvsig.projection.api</artifactId>
126
            <scope>compile</scope>
127
        </dependency>
128
        <dependency>
129
            <groupId>org.gvsig</groupId>
130
            <artifactId>org.gvsig.fmap.control</artifactId>
131
            <scope>compile</scope>
132
        </dependency>
133
        <dependency>
134
            <groupId>org.gvsig</groupId>
135
            <artifactId>org.gvsig.utils</artifactId>
136
            <scope>compile</scope>
137
        </dependency>
138
        <dependency>
139
            <groupId>org.gvsig</groupId>
140
            <artifactId>org.gvsig.timesupport.lib.api</artifactId>
141
            <scope>compile</scope>
142
        </dependency>
143
        <dependency>
144
            <groupId>com.fifesoft</groupId>
145
            <artifactId>rsyntaxtextarea</artifactId>
146
            <scope>compile</scope>
147
        </dependency>
148
        <dependency>
149
            <groupId>org.python</groupId>
150
            <artifactId>jython</artifactId>
151
            <scope>runtime</scope>
152
        </dependency>
153
    </dependencies>
154

  
155

  
156
    <build>
157

  
158
        <plugins>
159
            <plugin>
160
                <groupId>org.apache.maven.plugins</groupId>
161
                <artifactId>maven-surefire-plugin</artifactId>
162
                <configuration>
163
                    <skipTests>true</skipTests>
164
                </configuration>
165
            </plugin>
166

  
167
            <plugin>
168
                <artifactId>maven-release-plugin</artifactId>
169
                <version>2.0</version>
170
                <configuration>
171
                    <tagBase>https://devel.gvsig.org/svn/gvsig-expression-field/org.gvsig.expressionfield/tags</tagBase>
172
                </configuration>
173
            </plugin>
174

  
175
        </plugins>
176

  
177
    </build>
178

  
179

  
180
    <properties>
181
        <gvsig.package.info.name>Tools: Field calculator</gvsig.package.info.name>
182
        <gvsig.package.info.dependencies>required: org.gvsig.app.document.table.app.mainplugin -ge 2</gvsig.package.info.dependencies>
183
        <gvsig.package.info.javaVM>j1_6</gvsig.package.info.javaVM>
184
        <gvsig.package.info.state>testing</gvsig.package.info.state>
185
        <gvsig.package.info.official>true</gvsig.package.info.official>
186
        <!-- alpha-devel -->
187
        <gvsig.package.info.categories>Table</gvsig.package.info.categories>
188
        <gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-expression-field/pool</gvsig.package.info.poolURL>
189

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

  
28
import java.awt.event.MouseEvent;
29
import java.awt.event.MouseListener;
30
import java.util.prefs.Preferences;
31

  
32
import javax.swing.ImageIcon;
33
import javax.swing.JCheckBox;
34
import javax.swing.JPanel;
35
import javax.swing.JTextArea;
36
import javax.swing.JTextField;
37

  
38
import org.gvsig.andami.IconThemeHelper;
39
import org.gvsig.andami.PluginServices;
40
import org.gvsig.andami.preferences.AbstractPreferencePage;
41
import org.gvsig.andami.preferences.StoreException;
42

  
43

  
44
/**
45
 * @author Vicente Caballero Navarro
46
 */
47
public class FieldExpressionPage extends AbstractPreferencePage {
48
	private static Preferences prefs = Preferences.userRoot().node( "fieldExpressionOptions" );
49
	private JTextArea jTextArea = null;
50
	private JTextField txtLimit;
51
	private JCheckBox ckLimit=null;
52
	private ImageIcon icon;
53

  
54
	public FieldExpressionPage() {
55
		super();
56
		
57
		icon = IconThemeHelper.getImageIcon("expression-field-preferences");
58
		
59
		addComponent(getJTextArea());
60

  
61
		addComponent(PluginServices.getText(this, "limit_rows_in_memory") + ":",
62
			txtLimit = new JTextField("", 15));
63
		addComponent(ckLimit = new JCheckBox(PluginServices.getText(this, "without_limit")));
64
		ckLimit.addMouseListener(new MouseListener() {
65
			public void mouseClicked(MouseEvent e) {
66
				if (ckLimit.isSelected()) {
67
					txtLimit.setText(PluginServices.getText(this, "without_limit"));
68
				}else {
69
					if (txtLimit.getText().equals(PluginServices.getText(this, "without_limit")))
70
					txtLimit.setText("500000");
71
				}
72

  
73
			}
74
			public void mouseEntered(MouseEvent e) {
75
			}
76
			public void mouseExited(MouseEvent e) {
77
			}
78
			public void mousePressed(MouseEvent e) {
79
			}
80
			public void mouseReleased(MouseEvent e) {
81
			}
82

  
83
		});
84
	}
85

  
86
	public void initializeValues() {
87
		int limit = prefs.getInt("limit_rows_in_memory",-1);
88
		if (limit==-1) {
89
			ckLimit.setSelected(true);
90
			txtLimit.setText(PluginServices.getText(this,"without_limit"));
91
		}else {
92
			ckLimit.setSelected(false);
93
			txtLimit.setText(String.valueOf(limit));
94
		}
95
	}
96

  
97
	public String getID() {
98
		return this.getClass().getName();
99
	}
100

  
101
	public String getTitle() {
102
		return PluginServices.getText(this, "limit_rows_in_memory");
103
	}
104

  
105
	public JPanel getPanel() {
106
		return this;
107
	}
108

  
109
	public void storeValues() throws StoreException {
110
		int limit;
111
		try{
112
			if (ckLimit.isSelected()) {
113
				limit=-1;
114
			}else {
115
//			if (txtLimit.getText().equals(PluginServices.getText(this,"without_limit"))) {
116
//				limit=-1;
117
//			}else {
118
				limit=Integer.parseInt(txtLimit.getText());
119
			}
120
		}catch (Exception e) {
121
			throw new StoreException(PluginServices.getText(this,"limit_rows_in_memory")+PluginServices.getText(this,"error"));
122
		}
123
		prefs.putInt("limit_rows_in_memory", limit);
124
	}
125

  
126
	public void initializeDefaults() {
127
		int limit=prefs.getInt("limit_rows_in_memory",-1);
128
		if (limit==-1) {
129
			ckLimit.setSelected(true);
130
			txtLimit.setText(PluginServices.getText(this,"without_limit"));
131
		}else {
132
			ckLimit.setSelected(false);
133
			txtLimit.setText(String.valueOf(limit));
134
		}
135
	}
136

  
137
	public ImageIcon getIcon() {
138
		return icon;
139
	}
140
	/**
141
	 * This method initializes jTextArea
142
	 *
143
	 * @return javax.swing.JTextArea
144
	 */
145
	private JTextArea getJTextArea() {
146
		if (jTextArea == null) {
147
			jTextArea = new JTextArea();
148
			jTextArea.setBounds(new java.awt.Rectangle(13,7,285,57));
149
			jTextArea.setForeground(java.awt.Color.black);
150
			jTextArea.setBackground(java.awt.SystemColor.control);
151
			jTextArea.setRows(3);
152
			jTextArea.setWrapStyleWord(true);
153
			jTextArea.setLineWrap(true);
154
			jTextArea.setEditable(false);
155
			jTextArea.setText(PluginServices.getText(this,"specifies_the_limit_rows_in_memory_when_the_program_eval_the_expression"));
156
		}
157
		return jTextArea;
158
	}
159

  
160
	public boolean isValueChanged() {
161
		return super.hasChanged();
162
	}
163

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

  
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.ExpressionFieldExtension;
32
import org.gvsig.expressionfield.project.documents.table.AbstractOperator;
33
import org.gvsig.expressionfield.project.documents.table.IOperator;
34

  
35

  
36
/**
37
 * @author Vicente Caballero Navarro
38
 */
39
public class ToDate extends AbstractOperator{
40

  
41
	public String addText(String s) {
42
		return toString()+"("+s+")";
43
	}
44
	public String toString() {
45
		return "toDate";
46
	}
47
	public void eval(BSFManager interpreter) throws BSFException {
48
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"java.util.Date toDate(String value){return new java.text.SimpleDateFormat().parse(value);};");
49
		interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,
50
				"import java.text.DateFormat as DateFormat\n" +
51
				"import java.text.SimpleDateFormat as SimpleDateFormat\n" +
52
				"dateFormat = DateFormat.getInstance()\n" +
53
				"myDateFormat = SimpleDateFormat()\n" +
54
				"def toDate(value, format=None):\n" +
55
				"  if format != None:\n"+
56
				"    myDateFormat.applyPattern(format)\n"+
57
				"    return myDateFormat.parse(value)\n"+
58
				"  return dateFormat.parse(value)");
59
	}
60
	public boolean isEnable() {
61
		return (getType()==IOperator.DATE);
62
	}
63

  
64
	public String getTooltip(){
65
		return PluginServices.getText(this,"operator")+":  "+toString()+"("+PluginServices.getText(this,"parameter")+"[,"+PluginServices.getText(this,"format")+"])"+"\n"+getDescription();
66
	}
67

  
68
	public String getDescription() {
69
		return PluginServices.getText(this, "parameter") + "1: " +
70
	    PluginServices.getText(this, "string_value") + "\n" +
71
		PluginServices.getText(this, "format") + " ("+PluginServices.getText(this, "optional")+"): " +
72
	    PluginServices.getText(this, "string_value") + "\n" +
73
	    PluginServices.getText(this, "returns") + ": " +
74
	    PluginServices.getText(this, "date_value") + "\n" +
75
	    PluginServices.getText(this, "description") + ": " +
76
	    "Returns a date object from string parameter formatted according to\nthe parameter format if it is supplied.\n\n"+
77
	    "The format should follow the specifications of\n" +
78
	    "'http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html'.\n\n"+
79
	    "Examples: (for the date of December 23, 2008)\n"+
80
	    "  'dd/MM/yy'  23/12/08\n"+
81
	    "  'dd/MM/yyyy'  23/12/2008\n"+
82
	    "  'dd/MMM/yyyy'  23/dec/2008\n"+
83
	    "  'dd/MMMM/yyyy'  23/december/2008\n";
84

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

  
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.ExpressionFieldExtension;
32
import org.gvsig.expressionfield.project.documents.table.AbstractOperator;
33
import org.gvsig.expressionfield.project.documents.table.IOperator;
34

  
35

  
36
/**
37
 * @author Vicente Caballero Navarro
38
 */
39
public class Random extends AbstractOperator{
40

  
41
	public String addText(String s) {
42
		return s.concat(toString()+"()");
43
	}
44
	public String toString() {
45
		return "random";
46
	}
47
	public void eval(BSFManager interpreter) throws BSFException {
48
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double random(){return java.lang.Math.random();};");
49
		interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def random():\n" +
50
				"  import java.lang.Math\n" +
51
				"  return java.lang.Math.random()");
52
	}
53
	public boolean isEnable() {
54
		return (getType()==IOperator.NUMBER);
55
	}
56
	public String getTooltip(){
57
		return PluginServices.getText(this,"operator")+":  "+addText("")+"\n"+getDescription();
58
	}
59
	public String getDescription() {
60
        return PluginServices.getText(this, "returns") + ": " +
61
        PluginServices.getText(this, "numeric_value") + "\n" +
62
        PluginServices.getText(this, "description") + ": " +
63
        "Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range.";
64
    }
65
}
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26/src/main/java/org/gvsig/expressionfield/project/documents/table/operators/LessThan.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.expressionfield.project.documents.table.operators;
27

  
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.project.documents.table.AbstractOperator;
32
import org.gvsig.expressionfield.project.documents.table.IOperator;
33

  
34

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

  
40
	public String addText(String s) {
41
		return s.concat(toString());
42
	}
43

  
44
	public void eval(BSFManager interpreter) throws BSFException {
45
	}
46
	public String toString() {
47
		return "<";
48
	}
49
	public boolean isEnable() {
50
		return (getType()==IOperator.NUMBER);
51
	}
52
	public String getTooltip(){
53
		return PluginServices.getText(this,"operator")+":  "+addText("")+"\n"+getDescription();
54
	}
55
	public String getDescription() {
56
        return PluginServices.getText(this, "returns") + ": " +
57
        PluginServices.getText(this, "boolean_value") + "\n" +
58
        PluginServices.getText(this, "description") + ": " +
59
        "Returns true if the first object value is less than the second value.";
60
    }
61
}
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26/src/main/java/org/gvsig/expressionfield/project/documents/table/operators/LessEquals.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.expressionfield.project.documents.table.operators;
27

  
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.project.documents.table.AbstractOperator;
32
import org.gvsig.expressionfield.project.documents.table.IOperator;
33

  
34

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

  
40
	public String addText(String s) {
41
		return s.concat(toString());
42
	}
43

  
44
	public void eval(BSFManager interpreter) throws BSFException {
45
	}
46
	public String toString() {
47
		return "<=";
48
	}
49
	public boolean isEnable() {
50
		return (getType()==IOperator.NUMBER);
51
	}
52
	public String getTooltip(){
53
		return PluginServices.getText(this,"operator")+":  "+addText("")+"\n"+getDescription();
54
	}
55
	public String getDescription() {
56
        return PluginServices.getText(this, "returns") + ": " +
57
        PluginServices.getText(this, "boolean_value") + "\n" +
58
        PluginServices.getText(this, "description") + ": " +
59
        "Returns true if the first object value is less or equals than the second value.";
60
    }
61
}
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26/src/main/java/org/gvsig/expressionfield/project/documents/table/operators/Length.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.expressionfield.project.documents.table.operators;
27

  
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.ExpressionFieldExtension;
32
import org.gvsig.expressionfield.project.documents.table.AbstractOperator;
33
import org.gvsig.expressionfield.project.documents.table.IOperator;
34

  
35

  
36
/**
37
 * @author Vicente Caballero Navarro
38
 */
39
public class Length extends AbstractOperator{
40

  
41
	public String addText(String s) {
42
		return toString()+"("+s+")";
43
	}
44
	public String toString() {
45
		return "length";
46
	}
47
	public void eval(BSFManager interpreter) throws BSFException {
48
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"int length(String value){return value.length();};");
49
		interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def length(value):\n" +
50
				"  return len(value)");
51
	}
52
	public boolean isEnable() {
53
		return (getType()==IOperator.STRING);
54
	}
55
	public String getDescription() {
56
	    return PluginServices.getText(this, "parameter") + ": " +
57
	    PluginServices.getText(this, "string_value") + "\n" +
58
	    PluginServices.getText(this, "returns") + ": " +
59
	    PluginServices.getText(this, "numeric_value") + "\n" +
60
	    PluginServices.getText(this, "description") + ": " +
61
	    "Returns the length of string parameter.";
62
	}
63
}
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26/src/main/java/org/gvsig/expressionfield/project/documents/table/operators/Floor.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.expressionfield.project.documents.table.operators;
27

  
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.ExpressionFieldExtension;
32
import org.gvsig.expressionfield.project.documents.table.AbstractOperator;
33
import org.gvsig.expressionfield.project.documents.table.IOperator;
34

  
35

  
36
/**
37
 * @author Vicente Caballero Navarro
38
 */
39
public class Floor extends AbstractOperator{
40

  
41
	public String addText(String s) {
42
		return toString()+"("+s+")";
43
	}
44
	public String toString() {
45
		return "floor";
46
	}
47
	public void eval(BSFManager interpreter) throws BSFException {
48
		interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def floor(value):\n" +
49
				"  import java.lang.Math\n" +
50
				"  return java.lang.Math.floor(value)");
51
	}
52
	public boolean isEnable() {
53
		return (getType()==IOperator.NUMBER);
54
	}
55
	public String getDescription() {
56
        return PluginServices.getText(this, "parameter") + ": " +
57
        PluginServices.getText(this, "numeric_value") + "\n" +
58
        PluginServices.getText(this, "returns") + ": " +
59
        PluginServices.getText(this, "numeric_value") + "\n" +
60
        PluginServices.getText(this, "description") + ": " +
61
        "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" +
62
        "* If the argument value is already equal to a mathematical integer, then the result is the same as the argument.\n" +
63
        "* If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.\n";
64
    }
65

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

  
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.project.documents.table.AbstractOperator;
32
import org.gvsig.expressionfield.project.documents.table.IOperator;
33

  
34

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

  
40
	public String addText(String s) {
41
		return s.concat(toString());
42
	}
43
	public void eval(BSFManager interpreter) throws BSFException {
44
	}
45
	public String toString() {
46
		return "<>";
47
	}
48
	public boolean isEnable() {
49
		return (getType()==IOperator.DATE || getType()==IOperator.NUMBER || getType()==IOperator.STRING);
50
	}
51
	public String getTooltip(){
52
		return PluginServices.getText(this,"operator")+":  "+addText("")+"\n"+getDescription();
53
	}
54
	public String getDescription() {
55
        return PluginServices.getText(this, "returns") + ": " +
56
        PluginServices.getText(this, "boolean_value") + "\n" +
57
        PluginServices.getText(this, "description") + ": " +
58
        "Returns true if the objects are diferents.";
59
    }
60
}
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26/src/main/java/org/gvsig/expressionfield/project/documents/table/operators/ToDegrees.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.expressionfield.project.documents.table.operators;
27

  
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.ExpressionFieldExtension;
32
import org.gvsig.expressionfield.project.documents.table.AbstractOperator;
33
import org.gvsig.expressionfield.project.documents.table.IOperator;
34

  
35

  
36
/**
37
 * @author Vicente Caballero Navarro
38
 */
39
public class ToDegrees extends AbstractOperator{
40

  
41
	public String addText(String s) {
42
		return toString()+"("+s+")";
43
	}
44
	public String toString() {
45
		return "toDegrees";
46
	}
47
	public void eval(BSFManager interpreter) throws BSFException {
48
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double toDegrees(double value){return java.lang.Math.toDegrees(value);};");
49
		interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def toDegrees(value):\n" +
50
				"  import java.lang.Math\n" +
51
				"  return java.lang.Math.toDegrees(value)");
52
	}
53
	public boolean isEnable() {
54
		return (getType()==IOperator.NUMBER);
55
	}
56
	public String getDescription() {
57
	    return PluginServices.getText(this, "parameter") + ": " +
58
	    PluginServices.getText(this, "double_value") + "\n" +
59
	    PluginServices.getText(this, "returns") + ": " +
60
	    PluginServices.getText(this, "double_value") + "\n" +
61
	    PluginServices.getText(this, "description") + ": " +
62
	    "Converts an angle measured in radians to an approximately equivalent angle measured in degrees.\n" +
63
	    "The conversion from radians to degrees is generally inexact; users should not expect cos(toRadians(90.0)) to exactly equal 0.0.";
64
	}
65
}
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26/src/main/java/org/gvsig/expressionfield/project/documents/table/operators/PointY.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.expressionfield.project.documents.table.operators;
27

  
28
import java.util.ArrayList;
29

  
30
import org.apache.bsf.BSFException;
31
import org.apache.bsf.BSFManager;
32
import org.gvsig.andami.PluginServices;
33
import org.gvsig.andami.messages.NotificationManager;
34
import org.gvsig.expressionfield.ExpressionFieldExtension;
35
import org.gvsig.expressionfield.project.documents.table.GraphicOperator;
36
import org.gvsig.expressionfield.project.documents.table.IOperator;
37
import org.gvsig.fmap.dal.exception.DataException;
38
import org.gvsig.fmap.dal.feature.Feature;
39
import org.gvsig.fmap.dal.feature.FeatureStore;
40

  
41
/**
42
 * @author Vicente Caballero Navarro
43
 */
44
public class PointY extends GraphicOperator{
45

  
46
	public String addText(String s) {
47
		return s.concat(toString()+"()");
48
	}
49
	public double process(Feature feature) {
50
//		ReadableVectorial adapter = getLayer().getSource();
51
		org.gvsig.fmap.geom.Geometry geom=null;
52
//		try {
53
			geom = feature.getDefaultGeometry();//adapter.getShape(index.get());
54
//		} catch (ExpansionFileReadException e) {
55
//			throw new DriverIOException(e);
56
//		} catch (ReadDriverException e) {
57
//			throw new DriverIOException(e);
58
//		}
59
		ArrayList parts=getXY(geom);
60
		Double[][] xsys=(Double[][])parts.get(0);//getXY(geom);
61
		return xsys[1][0].doubleValue();
62
	}
63
	public void eval(BSFManager interpreter) throws BSFException {
64
		interpreter.declareBean("pointY",this,PointY.class);
65
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double y(){return pointY.process(indexRow);};");
66
		interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def y():\n" +
67
				"  return pointY.process(featureContainer.getFeature())");
68
	}
69
	public String toString() {
70
		return "y";
71
	}
72
	public boolean isEnable() {
73
		if (getLayer()==null)
74
			return false;
75
		int geomType=org.gvsig.fmap.geom.Geometry.TYPES.POINT;
76
		try {
77
			FeatureStore store = getLayer().getFeatureStore();
78
			geomType = store.getDefaultFeatureType().getAttributeDescriptor(store.getDefaultFeatureType().getDefaultGeometryAttributeIndex()).getGeometryType();
79
		} catch (DataException e) {
80
			NotificationManager.addError(e);
81
		}
82
		return (getType()==IOperator.NUMBER && geomType==org.gvsig.fmap.geom.Geometry.TYPES.POINT);
83
	}
84
	public String getTooltip(){
85
		return PluginServices.getText(this,"operator")+":  "+addText("")+"\n"+getDescription();
86
	}
87
	public String getDescription() {
88
        return PluginServices.getText(this, "returns") + ": " +
89
        PluginServices.getText(this, "numeric_value") + "\n" +
90
        PluginServices.getText(this, "description") + ": " +
91
        "Returns the Y coordenate of point geometry of this row.";
92
    }
93
}
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26/src/main/java/org/gvsig/expressionfield/project/documents/table/operators/Tan.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.expressionfield.project.documents.table.operators;
27

  
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.ExpressionFieldExtension;
32
import org.gvsig.expressionfield.project.documents.table.AbstractOperator;
33
import org.gvsig.expressionfield.project.documents.table.IOperator;
34

  
35

  
36
/**
37
 * @author Vicente Caballero Navarro
38
 */
39
public class Tan extends AbstractOperator{
40

  
41
	public String addText(String s) {
42
		return toString()+"("+s+")";
43
	}
44
	public String toString() {
45
		return "tan";
46
	}
47
	public void eval(BSFManager interpreter) throws BSFException {
48
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double tan(double value){return java.lang.Math.tan(value);};");
49
		interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def tan(value):\n" +
50
				"  import java.lang.Math\n" +
51
				"  return java.lang.Math.tan(value)");
52
	}
53
	public boolean isEnable() {
54
		return (getType()==IOperator.NUMBER);
55
	}
56
	public String getDescription() {
57
        return PluginServices.getText(this, "parameter") + ": " +
58
        PluginServices.getText(this, "numeric_value") + "\n" +
59
        PluginServices.getText(this, "returns") + ": " +
60
        PluginServices.getText(this, "numeric_value") + "\n" +
61
        PluginServices.getText(this, "description") + ": " +
62
        "Returns the trigonometric tangent of an angle. Special cases:\n" +
63
        "* If the argument is NaN or an infinity, then the result is NaN.\n" +
64
        "* If the argument is zero, then the result is a zero with the same sign as the argument.";
65
    }
66
}
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26/src/main/java/org/gvsig/expressionfield/project/documents/table/operators/IsNumber.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.expressionfield.project.documents.table.operators;
27

  
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.ExpressionFieldExtension;
32
import org.gvsig.expressionfield.project.documents.table.AbstractOperator;
33
import org.gvsig.expressionfield.project.documents.table.IOperator;
34

  
35

  
36
/**
37
 * @author Vicente Caballero Navarro
38
 */
39
public class IsNumber extends AbstractOperator{
40

  
41
	public String addText(String s) {
42
		return toString()+"("+s+")";
43
	}
44
	public String toString() {
45
		return "isNumber";
46
	}
47
	public void eval(BSFManager interpreter) throws BSFException {
48
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"boolean isNumber (String value){try{java.lang.Double.parseDouble(value);}catch(java.lang.NumberFormatException e){return false;}return true;};");
49
		interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def isNumber(value):\n" +
50
				"  import java.lang.Double\n" +
51
				"  import java.lang.NumberFormatException\n" +
52
				"  try:\n" +
53
				"    java.lang.Double.parseDouble(value)\n" +
54
				"  except java.lang.NumberFormatException:\n" +
55
				"    return 0==1 #false\n" +
56
				"  return 1==1 #true\n");
57
	}
58
	public boolean isEnable() {
59
		return (getType()==IOperator.STRING);
60
	}
61
	public String getDescription() {
62
	    return PluginServices.getText(this, "parameter") + ": " +
63
	    PluginServices.getText(this, "string_value") + "\n" +
64
	    PluginServices.getText(this, "returns") + ": " +
65
	    PluginServices.getText(this, "boolean_value") + "\n" +
66
	    PluginServices.getText(this, "description") + ": " +
67
	    "Returns true if the string parameter is a number.";
68
	}
69
}
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26/src/main/java/org/gvsig/expressionfield/project/documents/table/operators/Cos.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.expressionfield.project.documents.table.operators;
27

  
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.ExpressionFieldExtension;
32
import org.gvsig.expressionfield.project.documents.table.AbstractOperator;
33
import org.gvsig.expressionfield.project.documents.table.IOperator;
34

  
35

  
36
/**
37
 * @author Vicente Caballero Navarro
38
 */
39
public class Cos extends AbstractOperator{
40

  
41
	public String addText(String s) {
42
		return toString()+"("+s+")";
43
	}
44
	public String toString() {
45
		return "cos";
46
	}
47
	public void eval(BSFManager interpreter) throws BSFException {
48
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double cos(double value){return java.lang.Math.cos(value);};");
49
		interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def cos(value):\n" +
50
				"  import java.lang.Math\n" +
51
				"  return java.lang.Math.cos(value)");
52
	}
53
	public boolean isEnable() {
54
		return (getType()==IOperator.NUMBER);
55
	}
56
	public String getDescription() {
57
        return PluginServices.getText(this, "parameter") + ": " +
58
        PluginServices.getText(this, "numeric_value") + "\n" +
59
        PluginServices.getText(this, "returns") + ": " +
60
        PluginServices.getText(this, "numeric_value") + "\n" +
61
        PluginServices.getText(this, "description") + ": " +
62
        "Returns the trigonometric cosine of an angle. Special cases:\n" +
63
        "* If the argument is NaN or an infinity, then the result is NaN.";
64
    }
65
}
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26/src/main/java/org/gvsig/expressionfield/project/documents/table/operators/Division.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.expressionfield.project.documents.table.operators;
27

  
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.project.documents.table.AbstractOperator;
32
import org.gvsig.expressionfield.project.documents.table.IOperator;
33

  
34

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

  
40
	public String addText(String s) {
41
		return s.concat(toString());
42
	}
43

  
44
	public void eval(BSFManager interpreter) throws BSFException {
45
	}
46
	public String toString() {
47
		return "/";
48
	}
49
	public boolean isEnable() {
50
		return (getType()==IOperator.NUMBER);
51
	}
52
	public String getTooltip(){
53
		return PluginServices.getText(this,"operator")+":  "+addText("")+"\n"+getDescription();
54
	}
55
	public String getDescription() {
56
        return PluginServices.getText(this, "returns") + ": " +
57
        PluginServices.getText(this, "numeric_value") + "\n" +
58
        PluginServices.getText(this, "description") + ": " +
59
        "Returns the result of division.";
60
    }
61
}
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26/src/main/java/org/gvsig/expressionfield/project/documents/table/operators/E.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.expressionfield.project.documents.table.operators;
27

  
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.ExpressionFieldExtension;
32
import org.gvsig.expressionfield.project.documents.table.AbstractOperator;
33
import org.gvsig.expressionfield.project.documents.table.IOperator;
34

  
35

  
36
/**
37
 * @author Vicente Caballero Navarro
38
 */
39
public class E extends AbstractOperator{
40

  
41
	public String addText(String s) {
42
		return s.concat(toString()+"()");
43
	}
44
	public String toString() {
45
		return "e";
46
	}
47
	public void eval(BSFManager interpreter) throws BSFException {
48
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"double e(){return java.lang.Math.E;};");
49
		interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def e():\n" +
50
				"  import java.lang.Math\n" +
51
				"  return java.lang.Math.E");
52
	}
53
	public boolean isEnable() {
54
		return (getType()==IOperator.NUMBER);
55
	}
56
	public String getTooltip(){
57
		return PluginServices.getText(this,"operator")+":  "+addText("")+"\n"+getDescription();
58
	}
59
	public String getDescription() {
60
        return PluginServices.getText(this, "returns") + ": " +
61
        PluginServices.getText(this, "numeric_value") + "\n" +
62
        PluginServices.getText(this, "description") + ": " +
63
        "The double value that is closer than any other to e, the base of the natural logarithms.";
64
    }
65
}
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26/src/main/java/org/gvsig/expressionfield/project/documents/table/operators/EndsWith.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.expressionfield.project.documents.table.operators;
27

  
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.ExpressionFieldExtension;
32
import org.gvsig.expressionfield.project.documents.table.AbstractOperator;
33
import org.gvsig.expressionfield.project.documents.table.IOperator;
34

  
35

  
36
/**
37
 * @author Vicente Caballero Navarro
38
 */
39
public class EndsWith extends AbstractOperator{
40

  
41
	public String addText(String s) {
42
		return toString()+"("+s+",\"\")";
43
	}
44
	public String toString() {
45
		return "endsWith";
46
	}
47
	public void eval(BSFManager interpreter) throws BSFException {
48
//		interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"boolean endsWith(String value1,String value2){return value1.endsWith(value2);};");
49
		interpreter.exec(ExpressionFieldExtension.JYTHON,null,-1,-1,"def endsWith(value1,value2):\n" +
50
				"  return value1.endswith(value2)");
51
	}
52
	public boolean isEnable() {
53
		return (getType()==IOperator.STRING);
54
	}
55
	public String getTooltip(){
56
		return PluginServices.getText(this,"operator")+":  "+toString()+ "("+ PluginServices.getText(this,"parameter")+"1,"+PluginServices.getText(this,"parameter")+"2"+")\n"+getDescription();
57
	}
58
	public String getDescription() {
59
        return PluginServices.getText(this, "parameter") + "1"+": " +
60
        PluginServices.getText(this, "string_value") + "\n"+
61
        PluginServices.getText(this, "parameter") + "2"+": " +
62
        PluginServices.getText(this, "string_value") + "\n"+
63
        PluginServices.getText(this, "returns") + ": " +
64
        PluginServices.getText(this, "boolean_value") + "\n" +
65
        PluginServices.getText(this, "description") + ": " +
66
        "Tests if this parameter1 ends with the specified parameter2.";
67
    }
68
}
org.gvsig.expressionfield/tags/org.gvsig.expressionfield-2.0.26/src/main/java/org/gvsig/expressionfield/project/documents/table/operators/Round.java
1
/*******************************************************************************
2
 *
3
 *   gvSIG. Desktop Geographic Information System.
4
 *  
5
 *   Copyright (C) 2007-2013 gvSIG Association.
6
 *  
7
 *   This program is free software; you can redistribute it and/or
8
 *   modify it under the terms of the GNU General Public License
9
 *   as published by the Free Software Foundation; either version 3
10
 *   of the License, or (at your option) any later version.
11
 *  
12
 *   This program is distributed in the hope that it will be useful,
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *   GNU General Public License for more details.
16
 *  
17
 *   You should have received a copy of the GNU General Public License
18
 *   along with this program; if not, write to the Free Software
19
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 *   MA  02110-1301, USA.
21
 *  
22
 *   For any additional information, do not hesitate to contact us
23
 *   at info AT gvsig.com, or visit our website www.gvsig.com.
24
 *   
25
 *******************************************************************************/
26
package org.gvsig.expressionfield.project.documents.table.operators;
27

  
28
import org.apache.bsf.BSFException;
29
import org.apache.bsf.BSFManager;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.expressionfield.ExpressionFieldExtension;
32
import org.gvsig.expressionfield.project.documents.table.AbstractOperator;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff