Author: scooter
Date: 2011-06-07 15:24:03 -0700 (Tue, 07 Jun 2011)
New Revision: 25669

Modified:
   
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLReader.java
   
cytoscape/trunk/application/src/main/java/cytoscape/data/writers/XGMMLWriter.java
Log:
Added support to read and write node and edge labels, which somehow was 
previously overlooked.


Modified: 
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLReader.java
===================================================================
--- 
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLReader.java
   2011-06-07 22:22:58 UTC (rev 25668)
+++ 
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLReader.java
   2011-06-07 22:24:03 UTC (rev 25669)
@@ -435,13 +435,13 @@
         * @param buildStyle if true, build the graphical style
         */
        private void layoutNodes(final GraphView myView, final 
VisualStyleBuilder graphStyle, boolean buildStyle) {
-               String label = null;
                int tempid = 0;
                NodeView view = null;
                HashMap<CyNode, Attributes> nodeGraphicsMap = 
parser.getNodeGraphics();
 
                for (CyNode node : nodeGraphicsMap.keySet()) {
                        view = myView.getNodeView(node.getRootGraphIndex());
+                       String label = node.getIdentifier();
 
                        if (view != null) {
                                if (label != null) {
@@ -545,11 +545,17 @@
                }
 
                // These are saved in the exported XGMML, but it's not clear 
how they get set
+               if (buildStyle && 
XGMMLParser.getAttributeNS(graphics,"nodeLabel", CY_NAMESPACE) != null) {
+                       String nodeLabel = 
XGMMLParser.getAttributeNS(graphics,"nodeLabel", CY_NAMESPACE);
+                       graphStyle.addProperty(nodeID, 
VisualPropertyType.NODE_LABEL, nodeLabel);
+               }
+
                if (buildStyle && 
XGMMLParser.getAttributeNS(graphics,"nodeLabelFont", CY_NAMESPACE) != null) {
                        String nodeLabelFont = 
XGMMLParser.getAttributeNS(graphics,"nodeLabelFont", CY_NAMESPACE);
                
                        String[] items = nodeLabelFont.split("-"); // e.g. 
nodeLabelFont = "Arial-0-24"
                        graphStyle.addProperty(nodeID, 
VisualPropertyType.NODE_FONT_SIZE, items[2]);
+                       graphStyle.addProperty(nodeID, 
VisualPropertyType.NODE_FONT_FACE, items[0]);
                }
 
                if (buildStyle && 
XGMMLParser.getAttributeNS(graphics,"borderLineType", CY_NAMESPACE) != null) {
@@ -575,7 +581,6 @@
         * @param buildStyle if true, build the graphical style
         */
        private void layoutEdges(final GraphView myView, final 
VisualStyleBuilder graphStyle, final boolean buildStyle) {
-               String label = null;
                int tempid = 0;
                EdgeView view = null;
                HashMap<CyEdge, Attributes> edgeGraphicsMap = 
parser.getEdgeGraphics();
@@ -673,6 +678,20 @@
                                edgeView.getBend().addHandle(point);
                        }
                }
+
+               // These are saved in the exported XGMML, but it's not clear 
how they get set
+               if (buildStyle && 
XGMMLParser.getAttributeNS(graphics,"edgeLabel", CY_NAMESPACE) != null) {
+                       String nodeLabel = 
XGMMLParser.getAttributeNS(graphics,"edgeLabel", CY_NAMESPACE);
+                       graphStyle.addProperty(edgeID, 
VisualPropertyType.EDGE_LABEL, nodeLabel);
+               }
+
+               if (buildStyle && 
XGMMLParser.getAttributeNS(graphics,"edgeLabelFont", CY_NAMESPACE) != null) {
+                       String edgeLabelFont = 
XGMMLParser.getAttributeNS(graphics,"edgeLabelFont", CY_NAMESPACE);
+               
+                       String[] items = edgeLabelFont.split("-"); // e.g. 
edgeLabelFont = "Arial-0-24"
+                       graphStyle.addProperty(edgeID, 
VisualPropertyType.EDGE_FONT_SIZE, items[2]);
+                       graphStyle.addProperty(edgeID, 
VisualPropertyType.EDGE_FONT_FACE, items[0]);
+               }
        }
 
 

Modified: 
cytoscape/trunk/application/src/main/java/cytoscape/data/writers/XGMMLWriter.java
===================================================================
--- 
cytoscape/trunk/application/src/main/java/cytoscape/data/writers/XGMMLWriter.java
   2011-06-07 22:22:58 UTC (rev 25668)
+++ 
cytoscape/trunk/application/src/main/java/cytoscape/data/writers/XGMMLWriter.java
   2011-06-07 22:24:03 UTC (rev 25669)
@@ -545,6 +545,7 @@
 
                        writeAttributePair("cy:nodeTransparency", 
Double.toString(transparency));
                        writeAttributePair("cy:nodeLabelFont", 
encodeFont(nodeView.getLabel().getFont()));
+                       writeAttributePair("cy:nodeLabel", 
nodeView.getLabel().getText());
 
                        // Where should we store line-type info???
                        final float[] dash = borderType.getDashArray();
@@ -749,6 +750,7 @@
                        writeAttributePair("cy:targetArrowColor", 
paint2string(edgeView.getTargetEdgeEndPaint()));
 
                        writeAttributePair("cy:edgeLabelFont", 
encodeFont(edgeView.getLabel().getFont()));
+                       writeAttributePair("cy:edgeLabel", 
edgeView.getLabel().getText());
                        writeAttributePair("cy:edgeLineType", 
LineStyle.extractLineStyle(edgeView.getStroke()).toString());
                        // Set curved or not
                        if (edgeView.getLineType() == EdgeView.CURVED_LINES) {

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