Author: scooter
Date: 2010-11-22 22:29:33 -0800 (Mon, 22 Nov 2010)
New Revision: 22992

Added:
   csplugins/trunk/ucsf/scooter/nodeCharts/src/main/resources/
   csplugins/trunk/ucsf/scooter/nodeCharts/src/main/resources/nodeCharts/
   
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/resources/nodeCharts/plugin.props
Modified:
   
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/command/NodeChartCommandHandler.java
   
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/command/ValueUtils.java
   
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/view/ViewUtils.java
Log:
Put resources in the right place and support List arguments


Modified: 
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/command/NodeChartCommandHandler.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/command/NodeChartCommandHandler.java
       2010-11-23 06:28:44 UTC (rev 22991)
+++ 
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/command/NodeChartCommandHandler.java
       2010-11-23 06:29:33 UTC (rev 22992)
@@ -76,6 +76,7 @@
        public static final String CLEAR = "clear";
        public static final String CURRENT = "current";
        public static final String LABELS = "labellist";
+       public static final String LIST = "list";
        public static final String NETWORK = "network";
        public static final String NODE = "node";
        public static final String NODELIST = "nodelist";
@@ -99,6 +100,9 @@
                addDescription(CLEAR, "Remove all charts from a node");
                addArgument(CLEAR, NODE);
                addArgument(CLEAR, NODELIST, SELECTED);
+
+               addDescription(LIST, "List available chart types");
+               addArgument(LIST);
        }
 
   public CyCommandResult execute(String command, Collection<Tunable>args)
@@ -119,6 +123,15 @@
                                                       throws 
CyCommandException, RuntimeException {
                CyCommandResult result = new CyCommandResult();
 
+               if (command.equals(LIST)) {
+                       result.addMessage("Available chart types: ");
+                       for (String type: viewerMap.keySet()) {
+                               result.addMessage("  "+type);
+                       }
+                       result.addResult("typeList", new 
ArrayList<String>(viewerMap.keySet()));
+                       return result;
+               }
+
                if (!args.containsKey(NODE) && !args.containsKey(NODELIST)) {
                        throw new CyCommandException("node or nodelist to map 
chart to must be specified");
                }
@@ -165,13 +178,13 @@
                List<Double> values = null;
                if (args.containsKey(VALUES)) {
                        // Get our values.  convertData returns an array of 
values in degrees of arc
-                       values = 
ValueUtils.convertInputToDouble((String)args.get(VALUES));
+                       values = 
ValueUtils.convertInputToDouble(args.get(VALUES));
                }
 
                List<String> labels = new ArrayList<String>();
                if (args.containsKey(LABELS)) {
                        // Get our labels.  These may or may not be printed 
depending on options
-                       labels = 
ValueUtils.getStringList((String)args.get(LABELS));
+                       labels = ValueUtils.getStringList(args.get(LABELS));
                }
 
                // Get our position
@@ -188,7 +201,7 @@
                        // If we've got an attributelist, we need to get our 
values now since they will change based on
                        // the node
                        if (args.containsKey(ATTRIBUTELIST))
-                               values = ValueUtils.getDataFromAttributes 
(node, (String)args.get(ATTRIBUTELIST), labels);
+                               values = ValueUtils.getDataFromAttributes 
(node, args.get(ATTRIBUTELIST), labels);
 
                        List<CustomGraphic> cgList = 
viewer.getCustomGraphics(args, values, labels, node, view, pos);
                        ViewUtils.addCustomGraphics(cgList, node, view);

Modified: 
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/command/ValueUtils.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/command/ValueUtils.java
    2010-11-23 06:28:44 UTC (rev 22991)
+++ 
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/command/ValueUtils.java
    2010-11-23 06:29:33 UTC (rev 22992)
@@ -82,14 +82,22 @@
         * @return the list of values
         * @throws CyCommandException if the attributes aren't numeric
         */
-       public static List<Double> getDataFromAttributes (CyNode node, String 
attributesList, List<String> labels) 
+       public static List<Double> getDataFromAttributes (CyNode node, Object 
attributesList, List<String> labels) 
                                                                                
             throws CyCommandException {
                if (attributesList == null)
                        throw new CyCommandException("no attributes with 
data?");
                CyAttributes nodeAttributes = Cytoscape.getNodeAttributes();
                String nodeName = node.getIdentifier();
 
-               String[] attributeArray = attributesList.split(",");
+               String[] attributeArray = null;
+               if (attributesList instanceof String) {
+                       attributeArray = ((String)attributesList).split(",");
+               } else if (attributesList instanceof List) {
+                       String[] s = new String[1];
+                       attributeArray = 
((List<String>)attributesList).toArray(s);
+               } else {
+                       return new ArrayList<Double>();
+               }
                if (attributeArray.length == 1) {
                        // Handle the case where we were given a single, list 
attribute
                        if (labels.size() == 0) {
@@ -163,14 +171,23 @@
        public static List<Double> parseStringList(String input) throws 
CyCommandException {
                if (input == null)
                        throw new CyCommandException("no input data?");
-
-               String[] inputArray = input.split(",");
+               String[] inputArray = ((String)input).split(",");
                return convertStringList(Arrays.asList(inputArray));
        }
 
-       public static List<String> getStringList(String input) {
-               String[] inputArray = input.split(",");
-               return Arrays.asList(inputArray);
+       public static List<String> getStringList(Object input) {
+               if (input instanceof String) {
+                       String[] inputArray = ((String)input).split(",");
+                       return Arrays.asList(inputArray);
+               } else if (input instanceof List) {
+                       List<String> result = new ArrayList<String>();
+                       for (Object o: (List)input) {
+                               result.add(o.toString());
+                       }
+                       return result;
+               }
+
+               return new ArrayList<String>();
        }
 
        /**

Modified: 
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/view/ViewUtils.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/view/ViewUtils.java
        2010-11-23 06:28:44 UTC (rev 22991)
+++ 
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/java/nodeCharts/view/ViewUtils.java
        2010-11-23 06:29:33 UTC (rev 22992)
@@ -219,7 +219,7 @@
                        // We don't want to scale down too far.  If scale < 20% 
of the font size, skip the label
                        if (scale < 0.20)
                                return null;
-                       System.out.println("scale = "+scale);
+                       // System.out.println("scale = "+scale);
                        AffineTransform sTransform = new AffineTransform();
                        sTransform.scale(scale, scale);
                        lShape = sTransform.createTransformedShape(lShape);

Added: 
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/resources/nodeCharts/plugin.props
===================================================================
--- 
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/resources/nodeCharts/plugin.props
                          (rev 0)
+++ 
csplugins/trunk/ucsf/scooter/nodeCharts/src/main/resources/nodeCharts/plugin.props
  2010-11-23 06:29:33 UTC (rev 22992)
@@ -0,0 +1,27 @@
+# This props file would be filled out and included in the plugin jar file.  
This props file will be used 
+# to put information into the Plugin Manager about the plugin 
+
+# -- The following properties are REQUIRED -- #
+
+# The plugin name that will be displayed to users
+pluginName=nodeCharts
+
+# Description used to give users information about the plugin such as what it 
does.  
+# Html tags are encouraged for formatting purposes.
+pluginDescription=Paint a chart on a node
+
+# Plugin version number, this must be two numbers separated by a decimlal.  
Ex. 0.2, 14.03
+pluginVersion=0.9
+
+# Compatible Cytoscape version
+cytoscapeVersion=2.8
+
+# Category, use one of the categories listed on the website or create your own
+pluginCategory=Visualization
+
+
+# List of authors.  Note each author and institution pair are separated by a : 
(colon)
+# each additional author institution pair must be separated from other pairs 
bye a ; (semicolon)
+pluginAuthorsIntstiutions=John "Scooter" Morris:UCSF;Allan 
Kuchinsky:Agilent;Alex Pico:Gladtone Institutes
+
+# -- The following properties should be set ONLY BY CORE PLUGINS -- #

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