Author: ruschein
Date: 2010-07-08 14:13:33 -0700 (Thu, 08 Jul 2010)
New Revision: 20859
Modified:
csplugins/trunk/ucsd/ruschein/tutorial23/build.xml
csplugins/trunk/ucsd/ruschein/tutorial23/src/cytoscape/tutorial23/IXor.java
csplugins/trunk/ucsd/ruschein/tutorial23/src/cytoscape/tutorial23/Tutorial23.java
Log:
Updated to relect the state of Cytoscape 2.8.
Modified: csplugins/trunk/ucsd/ruschein/tutorial23/build.xml
===================================================================
--- csplugins/trunk/ucsd/ruschein/tutorial23/build.xml 2010-07-08 21:04:07 UTC
(rev 20858)
+++ csplugins/trunk/ucsd/ruschein/tutorial23/build.xml 2010-07-08 21:13:33 UTC
(rev 20859)
@@ -25,7 +25,7 @@
<property name="lib.dir" value="${root.dir}/lib"/>
<!-- Define the Cytoscape directories -->
- <property name="cytoscape.dir" value="../../../../eqn_attribs"/>
+ <property name="cytoscape.dir" value="../../../../cytoscape"/>
<property name="cytoscape.lib.dir" value="${cytoscape.dir}/lib"/>
<property name="cytoscape.plugin.dir" value="${cytoscape.dir}/plugins"/>
Modified:
csplugins/trunk/ucsd/ruschein/tutorial23/src/cytoscape/tutorial23/IXor.java
===================================================================
--- csplugins/trunk/ucsd/ruschein/tutorial23/src/cytoscape/tutorial23/IXor.java
2010-07-08 21:04:07 UTC (rev 20858)
+++ csplugins/trunk/ucsd/ruschein/tutorial23/src/cytoscape/tutorial23/IXor.java
2010-07-08 21:13:33 UTC (rev 20859)
@@ -1,13 +1,20 @@
package cytoscape.tutorial23;
-import java.util.ArrayList;
-import java.util.List;
-import cytoscape.data.eqn_attribs.AttribFunction;
-import cytoscape.data.eqn_attribs.EquationUtil;
+import org.cytoscape.equations.AbstractFunction;
+import org.cytoscape.equations.ArgDescriptor;
+import org.cytoscape.equations.ArgType;
+import org.cytoscape.equations.FunctionUtil;
-public class IXor implements AttribFunction {
+public class IXor extends AbstractFunction {
+ public IXor() {
+ super(new ArgDescriptor[] {
+ new ArgDescriptor(ArgType.INT, "arg1", "A
quantity that can be converted to an integer."),
+ new ArgDescriptor(ArgType.INT, "arg2", "A
quantity that can be converted to an integer."),
+ });
+ }
+
/**
* Used to parse the function string. This name is treated in a
case-insensitive manner!
* @returns the name by which you must call the function when used in
an attribute equation.
@@ -20,62 +27,28 @@
*/
public String getFunctionSummary() { return "Returns an integer value
that is the exclusive-or of 2 other integer values."; }
- /**
- * Used to provide help for users.
- * @returns a description of how to use this function
- */
- public String getUsageDescription() { return "Call this with
\"IXOR(integer1,integer2)\""; }
-
public Class getReturnType() { return Long.class; }
/**
- * @returns Long.class or null if there are not exactly 2 args or the
args are not both of type Long or Double
- */
- public Class validateArgTypes(final Class[] argTypes) {
- if (argTypes.length != 2 || (argTypes[0] != Long.class &&
argTypes[0] != Double.class)
- || (argTypes[1] != Long.class && argTypes[1] !=
Double.class))
- return null;
-
- return Long.class;
- }
-
- /**
* @param args the function arguments which must be two objects of
type Long
* @returns the result of the function evaluation which is the
exclusive-or of the bits of the 2 arguments
*/
public Object evaluateFunction(final Object[] args) {
long arg1;
- if (args[0].getClass() == Long.class)
- arg1 = (Long)args[0];
- else
- arg1 = EquationUtil.doubleToLong((Double)args[0]);
+ try {
+ arg1 = FunctionUtil.getArgAsLong(args[0]);
+ } catch (final Exception e) {
+ throw new IllegalArgumentException("IXOR: can't convert
the 1st argument to an integer!");
+ }
long arg2;
- if (args[1].getClass() == Long.class)
- arg2 = (Long)args[1];
- else
- arg2 = EquationUtil.doubleToLong((Double)args[1]);
+ try {
+ arg2 = FunctionUtil.getArgAsLong(args[0]);
+ } catch (final Exception e) {
+ throw new IllegalArgumentException("IXOR: can't convert
the 2nd argument to an integer!");
+ }
final long result = arg1 ^ arg2;
return (Long)result;
}
-
- /**
- * Used with the equation builder.
- *
- * @params leadingArgs the types of the arguments that have already
been selected by the user.
- * @returns the set of arguments (must be a collection of
String.class, Long.class, Double.class,
- * Boolean.class and List.class) that are candidates for the
next argument. An empty set
- * indicates that no further arguments are valid.
- */
- public List<Class> getPossibleArgTypes(final Class[] leadingArgs) {
- if (leadingArgs.length < 2) {
- final List<Class> possibleNextArgs = new
ArrayList<Class>();
- possibleNextArgs.add(Long.class);
- possibleNextArgs.add(Double.class);
- return possibleNextArgs;
- }
-
- return null;
- }
}
Modified:
csplugins/trunk/ucsd/ruschein/tutorial23/src/cytoscape/tutorial23/Tutorial23.java
===================================================================
---
csplugins/trunk/ucsd/ruschein/tutorial23/src/cytoscape/tutorial23/Tutorial23.java
2010-07-08 21:04:07 UTC (rev 20858)
+++
csplugins/trunk/ucsd/ruschein/tutorial23/src/cytoscape/tutorial23/Tutorial23.java
2010-07-08 21:13:33 UTC (rev 20859)
@@ -4,14 +4,15 @@
package cytoscape.tutorial23;
-import cytoscape.data.eqn_attribs.AttribParser;
-import cytoscape.data.eqn_attribs.Parser;
import cytoscape.plugin.CytoscapePlugin;
+import org.cytoscape.equations.EqnParser;
+import org.cytoscape.equations.Parser;
+
public class Tutorial23 extends CytoscapePlugin {
public Tutorial23() {
- final AttribParser theParser = Parser.getParser();
+ final EqnParser theParser = Parser.getParser();
theParser.registerFunction(new IXor());
}
}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.