Author: ruschein
Date: 2010-07-08 14:03:28 -0700 (Thu, 08 Jul 2010)
New Revision: 20857

Modified:
   coreplugins/trunk/EquationFunctions/build.xml
   
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/InDegree.java
   
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/OutDegree.java
   
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/SourceID.java
   
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/TargetID.java
Log:
Converted to take advantage of the simplifications that deriving from 
AbstractFunction makes possible.

Modified: coreplugins/trunk/EquationFunctions/build.xml
===================================================================
--- coreplugins/trunk/EquationFunctions/build.xml       2010-07-08 19:54:44 UTC 
(rev 20856)
+++ coreplugins/trunk/EquationFunctions/build.xml       2010-07-08 21:03:28 UTC 
(rev 20857)
@@ -25,7 +25,7 @@
     <property name="EquationFunctions.root.dir" value="."/>
     <property name="EquationFunctions.lib.dir" 
value="${EquationFunctions.root.dir}/lib"/>
     
-    <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: 
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/InDegree.java
===================================================================
--- 
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/InDegree.java
     2010-07-08 19:54:44 UTC (rev 20856)
+++ 
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/InDegree.java
     2010-07-08 21:03:28 UTC (rev 20857)
@@ -30,17 +30,20 @@
 package org.cytoscape.EquationFunctions.functions;
 
 
-import java.util.ArrayList;
-import java.util.List;
-
 import cytoscape.Cytoscape;
 import cytoscape.CyNetwork;
 import cytoscape.CyNode;
 
-import org.cytoscape.equations.Function;
+import org.cytoscape.equations.ArgDescriptor;
+import org.cytoscape.equations.ArgType;
+import org.cytoscape.equations.AbstractFunction;
 
 
-public class InDegree implements Function {
+public class InDegree extends AbstractFunction {
+       public InDegree() {
+               super(new ArgDescriptor[] { new 
ArgDescriptor(ArgType.STRICT_STRING, "edge_ID", "An ID identifying a node.") });
+       }
+
        /**
         *  Used to parse the function string.  This name is treated in a 
case-insensitive manner!
         *  @return the name by which you must call the function when used in 
an attribute equation.
@@ -53,25 +56,9 @@
         */
        public String getFunctionSummary() { return "Returns indegree of a 
node."; }
 
-       /**
-        *  Used to provide help for users.
-        *  @return a description of how to use this function
-        */
-       public String getUsageDescription() { return "Call this with 
\"INDEGREE(node_ID)\""; }
-
        public Class getReturnType() { return Long.class; }
 
        /**
-        *  @return String.class or null if there is not exactly 1 arg or the 
arg is not of type String
-        */
-       public Class validateArgTypes(final Class[] argTypes) {
-               if (argTypes.length != 1 || (argTypes[0] != String.class))
-                       return null;
-
-               return Long.class;
-       }
-
-       /**
         *  @param args the function arguments which must be either one object 
of type Double or Long
         *  @return the result of the function evaluation which is the natural 
logarithm of the first argument
         */
@@ -88,22 +75,4 @@
                
                return (Long)(long)currentNetwork.getInDegree(node, /* 
count_undirected_edges = */ false);
        }
-
-       /**
-        *  Used with the equation builder.
-        *
-        *  @param leadingArgs the types of the arguments that have already 
been selected by the user.
-        *  @return 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 == 0) {
-                       final List<Class> possibleNextArgs = new 
ArrayList<Class>();
-                       possibleNextArgs.add(String.class);
-                       return possibleNextArgs;
-               }
-
-               return null;
-       }
 }

Modified: 
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/OutDegree.java
===================================================================
--- 
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/OutDegree.java
    2010-07-08 19:54:44 UTC (rev 20856)
+++ 
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/OutDegree.java
    2010-07-08 21:03:28 UTC (rev 20857)
@@ -30,16 +30,20 @@
 package org.cytoscape.EquationFunctions.functions;
 
 
-import java.util.ArrayList;
-import java.util.List;
 import cytoscape.Cytoscape;
 import cytoscape.CyNetwork;
 import cytoscape.CyNode;
 
-import org.cytoscape.equations.Function;
+import org.cytoscape.equations.ArgDescriptor;
+import org.cytoscape.equations.ArgType;
+import org.cytoscape.equations.AbstractFunction;
 
 
-public class OutDegree implements Function {
+public class OutDegree extends AbstractFunction {
+       public OutDegree() {
+               super(new ArgDescriptor[] { new 
ArgDescriptor(ArgType.STRICT_STRING, "edge_ID", "An ID identifying a node.") });
+       }
+
        /**
         *  Used to parse the function string.  This name is treated in a 
case-insensitive manner!
         *  @return the name by which you must call the function when used in 
an attribute equation.
@@ -52,25 +56,9 @@
         */
        public String getFunctionSummary() { return "Returns indegree of a 
node."; }
 
-       /**
-        *  Used to provide help for users.
-        *  @return a description of how to use this function
-        */
-       public String getUsageDescription() { return "Call this with 
\"OUTDEGREE(node_ID)\""; }
-
        public Class getReturnType() { return Long.class; }
 
        /**
-        *  @return String.class or null if there is not exactly 1 arg or the 
arg is not of type String
-        */
-       public Class validateArgTypes(final Class[] argTypes) {
-               if (argTypes.length != 1 || (argTypes[0] != String.class))
-                       return null;
-
-               return Long.class;
-       }
-
-       /**
         *  @param args the function arguments which must be either one object 
of type Double or Long
         *  @return the result of the function evaluation which is the natural 
logarithm of the first argument
         */
@@ -87,22 +75,4 @@
                
                return (Long)(long)currentNetwork.getOutDegree(node, /* 
count_undirected_edges = */ false);
        }
-
-       /**
-        *  Used with the equation builder.
-        *
-        *  @param leadingArgs the types of the arguments that have already 
been selected by the user.
-        *  @return 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 == 0) {
-                       final List<Class> possibleNextArgs = new 
ArrayList<Class>();
-                       possibleNextArgs.add(String.class);
-                       return possibleNextArgs;
-               }
-
-               return null;
-       }
 }

Modified: 
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/SourceID.java
===================================================================
--- 
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/SourceID.java
     2010-07-08 19:54:44 UTC (rev 20856)
+++ 
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/SourceID.java
     2010-07-08 21:03:28 UTC (rev 20857)
@@ -30,16 +30,19 @@
 package org.cytoscape.EquationFunctions.functions;
 
 
-import java.util.ArrayList;
-import java.util.List;
 import cytoscape.CyEdge;
 import cytoscape.Cytoscape;
 import cytoscape.CyNetwork;
 
-import org.cytoscape.equations.Function;
+import org.cytoscape.equations.ArgDescriptor;
+import org.cytoscape.equations.ArgType;
+import org.cytoscape.equations.AbstractFunction;
 
+public class SourceID extends AbstractFunction {
+       public SourceID() {
+               super(new ArgDescriptor[] { new 
ArgDescriptor(ArgType.STRICT_STRING, "edge_ID", "An ID identifying an edge.") 
});
+       }
 
-public class SourceID implements Function {
        /**
         *  Used to parse the function string.  This name is treated in a 
case-insensitive manner!
         *  @return the name by which you must call the function when used in 
an attribute equation.
@@ -50,27 +53,11 @@
         *  Used to provide help for users.
         *  @return a description of what this function does
         */
-       public String getFunctionSummary() { return "Returns source ID  of an 
edge."; }
+       public String getFunctionSummary() { return "Returns source ID of an 
edge."; }
 
-       /**
-        *  Used to provide help for users.
-        *  @return a description of how to use this function
-        */
-       public String getUsageDescription() { return "Call this with 
\"SOURCEID(edge_ID)\""; }
-
        public Class getReturnType() { return Long.class; }
 
        /**
-        *  @return String.class or null if there is not exactly 1 arg or the 
arg is not of type String
-        */
-       public Class validateArgTypes(final Class[] argTypes) {
-               if (argTypes.length != 1 || (argTypes[0] != String.class))
-                       return null;
-
-               return Long.class;
-       }
-
-       /**
         *  @param args the function arguments which must be either one object 
of type Double or Long
         *  @return the result of the function evaluation which is the natural 
logarithm of the first argument
         */
@@ -83,22 +70,4 @@
                
                return edge.getSource().getIdentifier();
        }
-
-       /**
-        *  Used with the equation builder.
-        *
-        *  @param leadingArgs the types of the arguments that have already 
been selected by the user.
-        *  @return 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 == 0) {
-                       final List<Class> possibleNextArgs = new 
ArrayList<Class>();
-                       possibleNextArgs.add(String.class);
-                       return possibleNextArgs;
-               }
-
-               return null;
-       }
 }

Modified: 
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/TargetID.java
===================================================================
--- 
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/TargetID.java
     2010-07-08 19:54:44 UTC (rev 20856)
+++ 
coreplugins/trunk/EquationFunctions/src/org/cytoscape/EquationFunctions/functions/TargetID.java
     2010-07-08 21:03:28 UTC (rev 20857)
@@ -30,16 +30,20 @@
 package org.cytoscape.EquationFunctions.functions;
 
 
-import java.util.ArrayList;
-import java.util.List;
 import cytoscape.CyEdge;
 import cytoscape.Cytoscape;
 import cytoscape.CyNetwork;
 
-import org.cytoscape.equations.Function;
+import org.cytoscape.equations.ArgDescriptor;
+import org.cytoscape.equations.ArgType;
+import org.cytoscape.equations.AbstractFunction;
 
 
-public class TargetID implements Function {
+public class TargetID extends AbstractFunction {
+       public TargetID() {
+               super(new ArgDescriptor[] { new 
ArgDescriptor(ArgType.STRICT_STRING, "edge_ID", "An ID identifying an edge.") 
});
+       }
+
        /**
         *  Used to parse the function string.  This name is treated in a 
case-insensitive manner!
         *  @return the name by which you must call the function when used in 
an attribute equation.
@@ -50,27 +54,11 @@
         *  Used to provide help for users.
         *  @return a description of what this function does
         */
-       public String getFunctionSummary() { return "Returns source ID  of an 
edge."; }
+       public String getFunctionSummary() { return "Returns target ID of an 
edge."; }
 
-       /**
-        *  Used to provide help for users.
-        *  @return a description of how to use this function
-        */
-       public String getUsageDescription() { return "Call this with 
\"TARGETID(edge_ID)\""; }
-
        public Class getReturnType() { return Long.class; }
 
        /**
-        *  @return String.class or null if there is not exactly 1 arg or the 
arg is not of type String
-        */
-       public Class validateArgTypes(final Class[] argTypes) {
-               if (argTypes.length != 1 || (argTypes[0] != String.class))
-                       return null;
-
-               return Long.class;
-       }
-
-       /**
         *  @param args the function arguments which must be either one object 
of type Double or Long
         *  @return the result of the function evaluation which is the natural 
logarithm of the first argument
         */
@@ -83,22 +71,4 @@
                
                return edge.getTarget().getIdentifier();
        }
-
-       /**
-        *  Used with the equation builder.
-        *
-        *  @param leadingArgs the types of the arguments that have already 
been selected by the user.
-        *  @return 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 == 0) {
-                       final List<Class> possibleNextArgs = new 
ArrayList<Class>();
-                       possibleNextArgs.add(String.class);
-                       return possibleNextArgs;
-               }
-
-               return null;
-       }
 }

-- 
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.

Reply via email to