Author: Christian Lopes
Date: 2011-03-08 15:01:38 -0800 (Tue, 08 Mar 2011)
New Revision: 24337

Modified:
   core3/io-impl/trunk/pom.xml
   
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/xgmml/XGMMLNetworkViewReader.java
   
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/xgmml/handler/HandleEdgeGraphics.java
Log:
XGMMLNetworkViewReader: parsing more visual properties, including node and 
arrow shapes.

Modified: core3/io-impl/trunk/pom.xml
===================================================================
--- core3/io-impl/trunk/pom.xml 2011-03-08 22:48:55 UTC (rev 24336)
+++ core3/io-impl/trunk/pom.xml 2011-03-08 23:01:38 UTC (rev 24337)
@@ -119,7 +119,7 @@
                <dependency>
                        <groupId>org.cytoscape</groupId>
                        <artifactId>default-mappings</artifactId>
-                       <version>3.0.0-alpha1</version>
+                       <version>3.0.0-alpha2-SNAPSHOT</version>
                </dependency>
                <dependency>
                        <groupId>com.lowagie.text</groupId>

Modified: 
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/xgmml/XGMMLNetworkViewReader.java
===================================================================
--- 
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/xgmml/XGMMLNetworkViewReader.java
  2011-03-08 22:48:55 UTC (rev 24336)
+++ 
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/xgmml/XGMMLNetworkViewReader.java
  2011-03-08 23:01:38 UTC (rev 24337)
@@ -233,7 +233,6 @@
             layoutEdges(styleBuilder);
         }
 
-        // TODO: find a better place to do this:
         CyRow netRow = view.getModel().getCyRow();
 
         String netName = readDataManager.getNetworkName();
@@ -315,15 +314,6 @@
         nodeView.setVisualProperty(TwoDVisualLexicon.NODE_Y_LOCATION, y);
 
         layoutGraphics(attr, nodeView, styleBuilder);
-
-        // TODO: Depends on Ding! Wait for Visual Lexicon redesign
-        // String type = attributeValueUtil.getAttribute(attr, "type");
-        // if (type != null) {
-        //     if (type.equals("rhombus"))
-        //         graphStyle.addProperty(attr, VisualPropertyType.NODE_SHAPE, 
"parallelogram");
-        //     else
-        //         graphStyle.addProperty(attr, VisualPropertyType.NODE_SHAPE, 
type);
-        // }
     }
 
     /**
@@ -364,31 +354,7 @@
 
         layoutGraphics(attr, edgeView, styleBuilder);
 
-        // TODO missing styles: depends on Ding implementation!
-        //        if (attributeValueUtil.getAttributeNS(attr, "sourceArrow", 
CY_NAMESPACE) != null) {
-        //            Integer arrowType = 
attributeValueUtil.getIntegerAttributeNS(attr, "sourceArrow", CY_NAMESPACE);
-        //            ArrowShape shape = ArrowShape.getArrowShape(arrowType);
-        //            String arrowName = shape.getName();
-        //            styleBuilder.addProperty(edgeAttrs, 
VisualPropertyType.EDGE_SRCARROW_SHAPE, arrowName);
-        //        }
-        //        if (attributeValueUtil.getAttributeNS(attr, "targetArrow", 
CY_NAMESPACE) != null) {
-        //            Integer arrowType = 
attributeValueUtil.getIntegerAttributeNS(attr, "targetArrow", CY_NAMESPACE);
-        //            ArrowShape shape = ArrowShape.getArrowShape(arrowType);
-        //            String arrowName = shape.getName();
-        //            styleBuilder.addProperty(edgeAttrs, 
VisualPropertyType.EDGE_TGTARROW_SHAPE, arrowName);
-        //        }
-        //        if (attributeValueUtil.getAttributeNS(attr, 
"sourceArrowColor", CY_NAMESPACE) != null) {
-        //            String arrowColor = 
attributeValueUtil.getAttributeNS(attr, "sourceArrowColor", CY_NAMESPACE);
-        //            styleBuilder.addProperty(edgeAttrs, 
VisualPropertyType.EDGE_SRCARROW_COLOR, arrowColor);
-        //        }
-        //        if (attributeValueUtil.getAttributeNS(attr, 
"targetArrowColor", CY_NAMESPACE) != null) {
-        //            String arrowColor = 
attributeValueUtil.getAttributeNS(attr, "targetArrowColor", CY_NAMESPACE);
-        //            styleBuilder.addProperty(edgeAttrs, 
VisualPropertyType.EDGE_TGTARROW_COLOR, arrowColor);
-        //        }
-        //        if (attributeValueUtil.getAttributeNS(attr, "edgeLineType", 
CY_NAMESPACE) != null) {
-        //            String value = attributeValueUtil.getAttributeNS(attr, 
"edgeLineType", CY_NAMESPACE);
-        //            styleBuilder.addProperty(edgeAttrs, 
VisualPropertyType.EDGE_LINE_STYLE, value);
-        //        }
+        // TODO missing styles:
         //        if (attributeValueUtil.getAttributeNS(attr, "curved", 
CY_NAMESPACE) != null) {
         //            String value = attributeValueUtil.getAttributeNS(attr, 
"curved", CY_NAMESPACE);
         //            if (value.equals("STRAIGHT_LINES")) {
@@ -425,7 +391,7 @@
             VisualProperty vp = lexicon.lookup(type, key);
 
             if (vp != null) {
-                Object value = conv.getValue(attr, attributeValueUtil);
+                Object value = conv.getValue(attr, attributeValueUtil, vp);
 
                 if (value != null) {
                     if (conv.isBypass()) {
@@ -462,20 +428,23 @@
         nodeConverters.add(new GraphicsConverter<Color>("fill", Color.class));
         nodeConverters.add(new GraphicsConverter<Color>("outline", 
Color.class));
         nodeConverters.add(new GraphicsConverter<Double>("width", 
Double.class));
-        //        nodeConverters.add(new 
ValueMapping<Object>("borderLineType", Object.class));
+        nodeConverters.add(new GraphicsConverter<Object>("borderLineType", 
Object.class));
         nodeConverters.add(new GraphicsConverter<Font>("nodeLabelFont", 
Font.class, CY_NAMESPACE));
         nodeConverters.add(new GraphicsConverter<Integer>("nodeTransparency", 
Integer.class, CY_NAMESPACE));
-        //        nodeConverters.add(new ValueMapping<Object>("type", 
Object.class));
+        nodeConverters.add(new GraphicsConverter<Object>("type", 
Object.class));
 
         // TODO: add more
         edgeConverters.add(new GraphicsConverter<Double>("width", 
Double.class));
         edgeConverters.add(new GraphicsConverter<Color>("fill", Color.class));
+        edgeConverters.add(new GraphicsConverter<Object>("sourceArrow", 
Object.class, CY_NAMESPACE));
+        edgeConverters.add(new GraphicsConverter<Object>("targetArrow", 
Object.class, CY_NAMESPACE));
         edgeConverters.add(new GraphicsConverter<Font>("edgeLabelFont", 
Font.class, CY_NAMESPACE));
         edgeConverters.add(new GraphicsConverter<Integer>("edgeTransparency", 
Integer.class, CY_NAMESPACE));
 
         // attr (bypass):
         // ----------------------------------
         // TODO: add more
+        nodeConverters.add(new GraphicsConverter<Object>("nodeshape", 
Object.class, true));
         nodeConverters.add(new GraphicsConverter<Double>("nodeheight", 
Double.class, true));
         nodeConverters.add(new GraphicsConverter<Double>("nodewidth", 
Double.class, true));
         nodeConverters.add(new GraphicsConverter<Color>("nodefillcolor", 
Color.class, true));
@@ -488,8 +457,7 @@
         nodeConverters.add(new GraphicsConverter<Color>("nodelabelcolor", 
Color.class, true));
         nodeConverters.add(new GraphicsConverter<Integer>("nodelabelopacity", 
Integer.class, true));
         nodeConverters.add(new GraphicsConverter<Double>("nodelabelwidth", 
Double.class, true));
-        
-        
+
         edgeConverters.add(new GraphicsConverter<Double>("edgelinewidth", 
Double.class, true));
         edgeConverters.add(new GraphicsConverter<Color>("edgecolor", 
Color.class, true));
         edgeConverters.add(new GraphicsConverter<Integer>("edgeopacity", 
Integer.class, true));
@@ -499,8 +467,10 @@
         edgeConverters.add(new GraphicsConverter<Color>("edgelabelcolor", 
Color.class, true));
         edgeConverters.add(new GraphicsConverter<Integer>("edgelabelopacity", 
Integer.class, true));
         edgeConverters.add(new GraphicsConverter<Double>("edgelabelwidth", 
Double.class, true));
+        edgeConverters.add(new GraphicsConverter<Object>("edgesourcearrow", 
Object.class, true));
         edgeConverters.add(new 
GraphicsConverter<Color>("edgesourcearrowcolor", Color.class, true));
         edgeConverters.add(new 
GraphicsConverter<Integer>("edgesourcearrowopacity", Integer.class, true));
+        edgeConverters.add(new GraphicsConverter<Object>("edgetargetarrow", 
Object.class, true));
         edgeConverters.add(new 
GraphicsConverter<Color>("edgetargetarrowcolor", Color.class, true));
         edgeConverters.add(new 
GraphicsConverter<Integer>("edgetargetarrowopacity", Integer.class, true));
         edgeConverters.add(new GraphicsConverter<String>("edgetooltip", 
String.class, true));
@@ -531,7 +501,7 @@
         this.namespace = namespace;
     }
 
-    public T getValue(final Attributes attr, final AttributeValueUtil 
attributeValueUtil) {
+    public T getValue(final Attributes attr, final AttributeValueUtil 
attributeValueUtil, final VisualProperty<T> vp) {
         Object value = null;
 
         if (attr != null) {
@@ -575,15 +545,17 @@
                     value = new Font(name, style, size);
                 }
             } else {
-                // String or Number...
+                // String, Number or Object...
                 String s = null;
 
                 if (namespace == null)
-                    value = s = attributeValueUtil.getAttribute(attr, key);
+                    s = attributeValueUtil.getAttribute(attr, key);
                 else
-                    value = s = attributeValueUtil.getAttributeNS(attr, key, 
namespace);
+                    s = attributeValueUtil.getAttributeNS(attr, key, 
namespace);
 
-                if (s != null && Number.class.isAssignableFrom(type)) {
+                if (type == String.class) {
+                    value = s;
+                } else if (s != null && Number.class.isAssignableFrom(type)) {
                     Double d = null;
 
                     try {
@@ -604,6 +576,8 @@
                             value = new Float(d.floatValue());
                         }
                     }
+                } else if (s != null) {
+                    value = vp.parseSerializableString(s);
                 }
             }
         }

Modified: 
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/xgmml/handler/HandleEdgeGraphics.java
===================================================================
--- 
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/xgmml/handler/HandleEdgeGraphics.java
      2011-03-08 22:48:55 UTC (rev 24336)
+++ 
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/xgmml/handler/HandleEdgeGraphics.java
      2011-03-08 23:01:38 UTC (rev 24337)
@@ -5,7 +5,6 @@
 
 import org.cytoscape.io.internal.read.xgmml.ParseState;
 import org.cytoscape.model.CyEdge;
-import org.cytoscape.model.CyNode;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.AttributesImpl;

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