Author: pwang
Date: 2012-05-11 16:34:10 -0700 (Fri, 11 May 2012)
New Revision: 29253

Added:
   core3/samples/trunk/sample23/pom.xml
   core3/samples/trunk/sample23/src/
   core3/samples/trunk/sample23/src/main/
   core3/samples/trunk/sample23/src/main/java/
   core3/samples/trunk/sample23/src/main/java/org/
   core3/samples/trunk/sample23/src/main/java/org/cytoscape/
   core3/samples/trunk/sample23/src/main/java/org/cytoscape/sample/
   core3/samples/trunk/sample23/src/main/java/org/cytoscape/sample/internal/
   
core3/samples/trunk/sample23/src/main/java/org/cytoscape/sample/internal/CyActivator.java
   
core3/samples/trunk/sample23/src/main/java/org/cytoscape/sample/internal/IXor.java
   
core3/samples/trunk/sample23/src/main/java/org/cytoscape/sample/internal/Sample23.java
Log:
Ported from 2.8 sample23

Added: core3/samples/trunk/sample23/pom.xml
===================================================================
--- core3/samples/trunk/sample23/pom.xml                                (rev 0)
+++ core3/samples/trunk/sample23/pom.xml        2012-05-11 23:34:10 UTC (rev 
29253)
@@ -0,0 +1,94 @@
+<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";>
+       <modelVersion>4.0.0</modelVersion>
+
+       <properties>
+               <bundle.symbolicName>sample23</bundle.symbolicName>
+               
<bundle.namespace>org.cytoscape.sample.internal</bundle.namespace>
+               
<cytoscape.api.version>3.0.0-alpha8-SNAPSHOT</cytoscape.api.version>
+               
+               <maven-bundle-plugin.version>2.3.4</maven-bundle-plugin.version>
+               <osgi.api.version>4.2.0</osgi.api.version>
+       </properties>
+
+       <groupId>org.cytoscape.sample</groupId>
+       <artifactId>sample23</artifactId>
+       <packaging>bundle</packaging>
+       <name>${bundle.symbolicName}</name>
+
+       <version>3.0.0-alpha8-SNAPSHOT</version>
+  
+       <repositories>
+               <repository>
+                       <id>cytoscape_snapshots</id>
+                       <snapshots>
+                               <enabled>true</enabled>
+                       </snapshots>
+                       <releases>
+                               <enabled>false</enabled>
+                       </releases>
+                       <name>Cytoscape Snapshots</name>
+                       
<url>http://code.cytoscape.org/nexus/content/repositories/snapshots/</url>
+               </repository>
+               <repository>
+                       <id>cytoscape_releases</id>
+                       <snapshots>
+                               <enabled>false</enabled>
+                       </snapshots>
+                       <releases>
+                               <enabled>true</enabled>
+                       </releases>
+                       <name>Cytoscape Releases</name>
+                       
<url>http://code.cytoscape.org/nexus/content/repositories/releases/</url>
+               </repository>
+       </repositories>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               
<version>${maven-bundle-plugin.version}</version>
+                               <extensions>true</extensions>
+                               <configuration>
+                                       <instructions>
+                                               
<Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
+                                               
<Bundle-Version>${project.version}</Bundle-Version>
+                                               
<Export-Package>!${bundle.namespace}.*</Export-Package>
+                                               
<Private-Package>${bundle.namespace}.*</Private-Package>
+                                               
<Bundle-Activator>${bundle.namespace}.CyActivator</Bundle-Activator>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+  
+       <dependencies>
+               <dependency>
+                       <groupId>org.cytoscape</groupId>
+                       <artifactId>core-task-api</artifactId>
+                       <version>${cytoscape.api.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.cytoscape</groupId>
+                       <artifactId>equations-api</artifactId>
+                       <version>${cytoscape.api.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.cytoscape</groupId>
+                       <artifactId>work-api</artifactId>
+                       <version>${cytoscape.api.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.cytoscape</groupId>
+                       <artifactId>service-api</artifactId>
+                       <version>${cytoscape.api.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.osgi</groupId>
+                       <artifactId>org.osgi.core</artifactId>
+                       <version>${osgi.api.version}</version>
+               </dependency>
+               
+    </dependencies>
+  
+</project>

Added: 
core3/samples/trunk/sample23/src/main/java/org/cytoscape/sample/internal/CyActivator.java
===================================================================
--- 
core3/samples/trunk/sample23/src/main/java/org/cytoscape/sample/internal/CyActivator.java
                           (rev 0)
+++ 
core3/samples/trunk/sample23/src/main/java/org/cytoscape/sample/internal/CyActivator.java
   2012-05-11 23:34:10 UTC (rev 29253)
@@ -0,0 +1,36 @@
+package org.cytoscape.sample.internal;
+
+import org.osgi.framework.BundleContext;
+import org.cytoscape.equations.EquationCompiler;
+import org.cytoscape.equations.Interpreter;
+import org.cytoscape.service.util.AbstractCyActivator;
+import java.util.Properties;
+
+
+public class CyActivator extends AbstractCyActivator {
+       public CyActivator() {
+               super();
+       }
+
+
+       public void start(BundleContext bc) {
+
+               
+               //MyNodeViewTaskFactory myNodeViewTaskFactory = new 
MyNodeViewTaskFactory();
+               
+               
+//             Properties myNodeViewTaskFactoryProps = new Properties();
+//             myNodeViewTaskFactoryProps.setProperty("title","Double node 
size");
+               
//registerService(bc,myNodeViewTaskFactory,NodeViewTaskFactory.class, 
myNodeViewTaskFactoryProps);
+
+               // Get service reference
+               
+               EquationCompiler eqCompilerRef = 
getService(bc,EquationCompiler.class);
+               Interpreter interpreterRef =  getService(bc,Interpreter.class);
+               
+
+               Sample23 sample23 = new Sample23(eqCompilerRef, interpreterRef);
+               
+       }
+}
+

Added: 
core3/samples/trunk/sample23/src/main/java/org/cytoscape/sample/internal/IXor.java
===================================================================
--- 
core3/samples/trunk/sample23/src/main/java/org/cytoscape/sample/internal/IXor.java
                          (rev 0)
+++ 
core3/samples/trunk/sample23/src/main/java/org/cytoscape/sample/internal/IXor.java
  2012-05-11 23:34:10 UTC (rev 29253)
@@ -0,0 +1,54 @@
+package org.cytoscape.sample.internal;
+
+
+import org.cytoscape.equations.AbstractFunction;
+import org.cytoscape.equations.ArgDescriptor;
+import org.cytoscape.equations.ArgType;
+import org.cytoscape.equations.FunctionUtil;
+
+
+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.
+        */
+       public String getName() { return "IXOR"; }
+
+       /**
+        *  Used to provide help for users.
+        *  @returns a description of what this function does
+        */
+       public String getFunctionSummary() { return "Returns an integer value 
that is the exclusive-or of 2 other integer values."; }
+
+       public Class getReturnType() { 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;
+               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;
+               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;
+       }
+}

Added: 
core3/samples/trunk/sample23/src/main/java/org/cytoscape/sample/internal/Sample23.java
===================================================================
--- 
core3/samples/trunk/sample23/src/main/java/org/cytoscape/sample/internal/Sample23.java
                              (rev 0)
+++ 
core3/samples/trunk/sample23/src/main/java/org/cytoscape/sample/internal/Sample23.java
      2012-05-11 23:34:10 UTC (rev 29253)
@@ -0,0 +1,14 @@
+package org.cytoscape.sample.internal;
+
+import org.cytoscape.equations.EquationCompiler;
+import org.cytoscape.equations.Interpreter;
+import org.cytoscape.equations.EquationParser;
+
+
+public class Sample23 {
+
+       public Sample23(EquationCompiler eqCompilerRef, Interpreter 
interpreterRef){
+               final EquationParser theParser = eqCompilerRef.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.

Reply via email to