Author: Christian Lopes
Date: 2011-05-13 11:07:51 -0700 (Fri, 13 May 2011)
New Revision: 25049

Modified:
   
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/LineTypeVisualProperty.java
   
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/NodeShapeVisualProperty.java
   
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/RichVisualLexicon.java
Log:
Implemented toSerializableString and parseSerializableString for LineType and 
NodeShape visual properties

Modified: 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/LineTypeVisualProperty.java
===================================================================
--- 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/LineTypeVisualProperty.java
     2011-05-13 17:26:25 UTC (rev 25048)
+++ 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/LineTypeVisualProperty.java
     2011-05-13 18:07:51 UTC (rev 25049)
@@ -1,11 +1,11 @@
 package org.cytoscape.view.presentation.property;
 
+import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Set;
+import java.util.Map;
 
 import org.cytoscape.view.model.AbstractVisualProperty;
 import org.cytoscape.view.model.DiscreteRange;
-import org.cytoscape.view.model.DiscreteRange;
 import org.cytoscape.view.presentation.property.values.LineType;
 
 public class LineTypeVisualProperty extends AbstractVisualProperty<LineType> {
@@ -19,18 +19,18 @@
 
        
        private static DiscreteRange<LineType> LINE_TYPE_RANGE;
-       private static final Set<LineType> lineTypes;
+       private static final Map<String, LineType> lineTypes;
        
        static {
-               lineTypes = new HashSet<LineType>();
+               lineTypes = new HashMap<String, LineType>();
                
-               lineTypes.add(SOLID);
-               lineTypes.add(LONG_DASH);
-               lineTypes.add(EQUAL_DASH);
-               lineTypes.add(DASH_DOT);
-               lineTypes.add(DOT);
+               lineTypes.put(SOLID.getSerializableString().toUpperCase(), 
SOLID);
+               lineTypes.put(LONG_DASH.getSerializableString().toUpperCase(), 
LONG_DASH);
+               lineTypes.put(EQUAL_DASH.getSerializableString().toUpperCase(), 
EQUAL_DASH);
+               lineTypes.put(DASH_DOT.getSerializableString().toUpperCase(), 
DASH_DOT);
+               lineTypes.put(DOT.getSerializableString().toUpperCase(), DOT);
                
-               LINE_TYPE_RANGE = new DiscreteRange<LineType>(LineType.class, 
new HashSet<LineType>(lineTypes));
+               LINE_TYPE_RANGE = new DiscreteRange<LineType>(LineType.class, 
new HashSet<LineType>(lineTypes.values()));
        }
 
        public LineTypeVisualProperty(LineType defaultValue,
@@ -40,14 +40,21 @@
 
        @Override
        public String toSerializableString(LineType value) {
-               // TODO Auto-generated method stub
-               return null;
+               return value.getSerializableString();
        }
 
        @Override
        public LineType parseSerializableString(String value) {
-               // TODO Auto-generated method stub
-               return null;
+               LineType lineType = null;
+               
+               if (value != null) {
+                       value = value.toUpperCase();
+                       lineType = lineTypes.get(value);
+               }
+               
+               if (lineType == null) lineType = SOLID;
+               
+               return lineType;
        }
        
        private static final class LineTypeImpl extends 
AbstractVisualPropertyValue implements LineType {

Modified: 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/NodeShapeVisualProperty.java
===================================================================
--- 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/NodeShapeVisualProperty.java
    2011-05-13 17:26:25 UTC (rev 25048)
+++ 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/NodeShapeVisualProperty.java
    2011-05-13 18:07:51 UTC (rev 25049)
@@ -1,11 +1,14 @@
 package org.cytoscape.view.presentation.property;
 
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
 import org.cytoscape.view.model.AbstractVisualProperty;
 import org.cytoscape.view.model.DiscreteRange;
 import org.cytoscape.view.model.DiscreteRange;
+import org.cytoscape.view.presentation.property.values.LineType;
 import org.cytoscape.view.presentation.property.values.NodeShape;
 
 public final class NodeShapeVisualProperty extends
@@ -31,21 +34,20 @@
 
        private static final DiscreteRange<NodeShape> NODE_SHAPE_RANGE;
 
-       private static final Set<NodeShape> DEFAULT_SHAPES;
+       private static final Map<String, NodeShape> DEFAULT_SHAPES;
 
        static {
-               DEFAULT_SHAPES = new HashSet<NodeShape>();
-               DEFAULT_SHAPES.add(RECTANGLE);
-               DEFAULT_SHAPES.add(ROUND_RECTANGLE);
-               DEFAULT_SHAPES.add(TRIANGLE);
-               DEFAULT_SHAPES.add(PARALLELOGRAM);
-               DEFAULT_SHAPES.add(DIAMOND);
-               DEFAULT_SHAPES.add(ELLIPSE);
-               DEFAULT_SHAPES.add(HEXAGON);
-               DEFAULT_SHAPES.add(OCTAGON);
+               DEFAULT_SHAPES = new HashMap<String, NodeShape>();
+               
DEFAULT_SHAPES.put(RECTANGLE.getSerializableString().toUpperCase(), RECTANGLE);
+               
DEFAULT_SHAPES.put(ROUND_RECTANGLE.getSerializableString().toUpperCase(), 
ROUND_RECTANGLE);
+               
DEFAULT_SHAPES.put(TRIANGLE.getSerializableString().toUpperCase(), TRIANGLE);
+               
DEFAULT_SHAPES.put(PARALLELOGRAM.getSerializableString().toUpperCase(), 
PARALLELOGRAM);
+               
DEFAULT_SHAPES.put(DIAMOND.getSerializableString().toUpperCase(), DIAMOND);
+               
DEFAULT_SHAPES.put(ELLIPSE.getSerializableString().toUpperCase(), ELLIPSE);
+               
DEFAULT_SHAPES.put(HEXAGON.getSerializableString().toUpperCase(), HEXAGON);
+               
DEFAULT_SHAPES.put(OCTAGON.getSerializableString().toUpperCase(), OCTAGON);
 
-               NODE_SHAPE_RANGE = new DiscreteRange<NodeShape>(NodeShape.class,
-                               new HashSet<NodeShape>(DEFAULT_SHAPES));
+               NODE_SHAPE_RANGE = new 
DiscreteRange<NodeShape>(NodeShape.class, new 
HashSet<NodeShape>(DEFAULT_SHAPES.values()));
        }
 
        public NodeShapeVisualProperty(NodeShape defaultValue, String id,
@@ -61,15 +63,16 @@
 
        @Override
        public NodeShape parseSerializableString(String value) {
-               // TODO
-               return null;
+               NodeShape shape = null;
+               
+               if (value != null)
+                       shape = DEFAULT_SHAPES.get(value.toUpperCase());
+               
+               return shape;
        }
 
        public static boolean isDefaultShape(final NodeShape shape) {
-               if (DEFAULT_SHAPES.contains(shape))
-                       return true;
-               else
-                       return false;
+               return DEFAULT_SHAPES.containsValue(shape);
        }
 
        private static final class NodeShapeImpl extends

Modified: 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/RichVisualLexicon.java
===================================================================
--- 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/RichVisualLexicon.java
  2011-05-13 17:26:25 UTC (rev 25048)
+++ 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/RichVisualLexicon.java
  2011-05-13 18:07:51 UTC (rev 25049)
@@ -169,6 +169,7 @@
                addIdentifierMapping(CyNode.class, "nodeFontSize", 
NODE_LABEL_FONT_SIZE);
                addIdentifierMapping(CyNode.class, "nodeToolTip", NODE_TOOLTIP);
 
+               addIdentifierMapping(CyEdge.class, "edgeLineStyle", 
EDGE_LINE_TYPE);
                addIdentifierMapping(CyEdge.class, "edgeToolTip", EDGE_TOOLTIP);
                addIdentifierMapping(CyEdge.class, "edgeFont", 
EDGE_LABEL_FONT_FACE);
                addIdentifierMapping(CyEdge.class, "edgeFontSize", 
EDGE_LABEL_FONT_SIZE);

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