Author: scooter
Date: 2009-03-16 11:00:48 -0700 (Mon, 16 Mar 2009)
New Revision: 16285

Added:
   csplugins/trunk/ucsf/scooter/batchTool/src/batchTool/commands/SetCommand.java
Log:
Added Set command


Added: 
csplugins/trunk/ucsf/scooter/batchTool/src/batchTool/commands/SetCommand.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/batchTool/src/batchTool/commands/SetCommand.java   
    2009-03-16 15:02:07 UTC (rev 16284)
+++ 
csplugins/trunk/ucsf/scooter/batchTool/src/batchTool/commands/SetCommand.java   
    2009-03-16 18:00:48 UTC (rev 16285)
@@ -0,0 +1,97 @@
+/* vim: set ts=2: */
+/**
+ * Copyright (c) 2007 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *   1. Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions, and the following disclaimer.
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions, and the following
+ *      disclaimer in the documentation and/or other materials provided
+ *      with the distribution.
+ *   3. Redistributions must acknowledge that this software was
+ *      originally developed by the UCSF Computer Graphics Laboratory
+ *      under support by the NIH National Center for Research Resources,
+ *      grant P41-RR01081.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+package batchTool.commands;
+
+import cytoscape.Cytoscape;
+import cytoscape.CytoscapeInit;
+import cytoscape.logger.CyLogger;
+import cytoscape.view.CyNetworkView;
+import cytoscape.visual.VisualMappingManager;
+import cytoscape.visual.VisualStyle;
+
+import java.util.List;
+import java.util.HashMap;
+import java.util.Properties;
+import java.util.Set;
+import batchTool.commands.ParseException;
+
+/**
+ * The set command sets Cytoscape properties
+ */
+public class SetCommand extends AbstractCommand {
+       String propertyName = null;
+       /**
+        * commandName returns the command name.  This is used to build the
+        * hash table of commands to hand to the command parser
+        *
+        * @return name of the command
+        */
+       public String commandName() { return "set"; }
+
+       /**
+        * parse is the main parse routine.  It is handed the entire command
+        * along with all of its arguments.  If the command is successfully
+        * parsed, the number of arguments actually read is returned.
+        *
+        * @param args the arguments to the command.  The "set" command
+        * takes a series of name=value pairs where the name is the
+        * name of a property and the value is the value to set that
+        * property to.
+        *
+        * set exportTextAsShape=true
+        */
+       public int parse(List<String> args, HashMap<String,String>optMap) 
throws ParseException {
+               if (args.size() < 2)
+                       throw new ParseException("Nothing to set");
+               // Get the properties
+               Properties props = CytoscapeInit.getProperties();
+
+               Set<String>keys = optMap.keySet();
+               for (String key: keys) {
+                       String value = optMap.get(key);
+                       props.setProperty(key, value);
+                       CyLogger.getLogger(SetCommand.class).debug("SetCommand: 
setting property "+key+" to "+value);
+               }
+               return args.size();
+       }
+
+       /**
+        * execute
+        *
+        * @param substitutions reserved for future use
+        */
+       public int execute(String[] substitutions) throws Exception {
+               return 0;
+       }
+
+}


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