Author: clopes
Date: 2011-09-13 12:12:24 -0700 (Tue, 13 Sep 2011)
New Revision: 26779
Modified:
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/read/xgmml/XGMMLNetworkReader.java
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/read/xgmml/handler/ReadDataManager.java
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/xgmml/XGMMLWriter.java
Log:
XGMML reader ignores the network name attribute when loading XGMML as part of a
Cy3 session file (the name is already stored in a cytable column).
XGMML writer does not write the network name as an XGMML attribute when saving
it into a session file for the same reason.
Replaced hard coded "name" by the constant CyNetwork.NAME.
Modified:
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/read/xgmml/XGMMLNetworkReader.java
===================================================================
---
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/read/xgmml/XGMMLNetworkReader.java
2011-09-13 18:24:35 UTC (rev 26778)
+++
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/read/xgmml/XGMMLNetworkReader.java
2011-09-13 19:12:24 UTC (rev 26779)
@@ -133,14 +133,20 @@
public CyNetworkView buildCyNetworkView(CyNetwork network) {
// any existing equations should be parsed first
readDataMgr.parseAllEquations();
-
netView = cyNetworkViewFactory.getNetworkView(network);
if (netView != null) {
// Network Title
- CyRow netRow = netView.getModel().getCyRow();
- String netName = readDataMgr.getNetworkName();
- netRow.set(CyTableEntry.NAME, netName);
+ // (only when directly importing an XGMML file or if as
part of a 2.x CYS file;
+ // otherwise the name is stored in a cyTable)
+ if (!sessionFormat || readDataMgr.getDocumentVersion()
< 3.0) {
+ String netName = readDataMgr.getNetworkName();
+
+ if (netName != null) {
+ CyRow netRow =
netView.getModel().getCyRow();
+ netRow.set(CyTableEntry.NAME, netName);
+ }
+ }
// Nodes and edges
if (netView.getModel().getNodeCount() > 0) {
@@ -190,28 +196,26 @@
layoutGraphics(ev, atts);
}
- // TODO edge bend:
- // if
(attributeValueUtil.getAttributeNS(attr, "curved", CY_NAMESPACE) != null) {
- // String value =
attributeValueUtil.getAttributeNS(attr, "curved",
- // CY_NAMESPACE);
- // if
(value.equals("STRAIGHT_LINES")) {
- //
edgeView.setLineType(EdgeView.STRAIGHT_LINES);
- // } else if
(value.equals("CURVED_LINES")) {
- //
edgeView.setLineType(EdgeView.CURVED_LINES);
- // }
- // }
- // if
(attributeValueUtil.getAttribute(attr, "edgeHandleList") != null) {
- // String handles[] =
attributeValueUtil.getAttribute(attr,
- //
"edgeHandleList").split(";");
- // for (int i = 0; i <
andles.length; i++) {
- // String points[] =
handles[i].split(",");
- // double x = (new
Double(points[0])).doubleValue();
- // double y = (new
Double(points[1])).doubleValue();
- // Point2D.Double point =
new Point2D.Double();
- // point.setLocation(x, y);
- //
edgeView.getBend().addHandle(point);
- // }
- // }
+ // TODO Edge bend
+// if (readDataMgr.getAttributeNS(attr, "curved",
CY_NAMESPACE) != null) {
+// String value = readDataMgr.getAttributeNS(attr,
"curved", CY_NAMESPACE);
+// if (value.equals("STRAIGHT_LINES")) {
+// ev.setLineType(EdgeView.STRAIGHT_LINES);
+// } else if (value.equals("CURVED_LINES")) {
+// ev.setLineType(EdgeView.CURVED_LINES);
+// }
+// }
+// if (readDataMgr.getAttribute(attr, "edgeHandleList") !=
null) {
+// String handles[] =
readDataMgr.getAttribute(attr, "edgeHandleList").split(";");
+// for (int i = 0; i < handles.length; i++) {
+// String points[] = handles[i].split(",");
+// double x = (new
Double(points[0])).doubleValue();
+// double y = (new
Double(points[1])).doubleValue();
+// Point2D.Double point = new
Point2D.Double();
+// point.setLocation(x, y);
+// ev.getBend().addHandle(point);
+// }
+// }
}
}
Modified:
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/read/xgmml/handler/ReadDataManager.java
===================================================================
---
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/read/xgmml/handler/ReadDataManager.java
2011-09-13 18:24:35 UTC (rev 26778)
+++
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/read/xgmml/handler/ReadDataManager.java
2011-09-13 19:12:24 UTC (rev 26779)
@@ -144,6 +144,10 @@
sessionFormat = false;
}
+ public double getDocumentVersion() {
+ return documentVersion;
+ }
+
public boolean isSessionFormat() {
return sessionFormat;
}
Modified:
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/xgmml/XGMMLWriter.java
===================================================================
---
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/xgmml/XGMMLWriter.java
2011-09-13 18:24:35 UTC (rev 26778)
+++
core3/impl/trunk/io-impl/src/main/java/org/cytoscape/io/internal/write/xgmml/XGMMLWriter.java
2011-09-13 19:12:24 UTC (rev 26779)
@@ -277,7 +277,6 @@
java.util.Date now = new java.util.Date();
java.text.DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd
HH:mm:ss");
writeElement("<dc:date>" + df.format(now) + "</dc:date>\n");
- // TODO fix the use of hardcoded "name" here
writeElement("<dc:title>" + getNetworkName(network) + "</dc:title>\n");
writeElement("<dc:source>http://www.cytoscape.org/</dc:source>\n");
writeElement("<dc:format>Cytoscape-XGMML</dc:format>\n");
@@ -316,12 +315,14 @@
writeAttributeXML(GRAPH_VIEW_CENTER_Y, ObjectType.REAL, cy, true);
}
- // Now handle all of the other network attributes
- CyRow row = network.getCyRow();
- CyTable table = row.getTable();
-
- for (final CyColumn column : table.getColumns())
- writeAttribute(row, column.getName());
+ // Now handle all of the other network attributes, but only if
exporting to XGMML directly
+ if (!sessionFormat) {
+ CyRow row = network.getCyRow();
+ CyTable table = row.getTable();
+
+ for (final CyColumn column : table.getColumns())
+ writeAttribute(row, column.getName());
+ }
}
/**
@@ -349,7 +350,7 @@
// Output the node
String id = quote(Long.toString(node.getSUID()));
- String label = quote(node.getCyRow().get("name", String.class));
+ String label = quote(node.getCyRow().get(CyNetwork.NAME,
String.class));
writeElement("<node id=" + id + " label=" + label + ">\n");
depth++;
@@ -451,7 +452,7 @@
if (!nodeMap.containsKey(curEdge.getTarget()) ||
!nodeMap.containsKey(curEdge.getSource())) return;
String id = quote(Long.toString(curEdge.getSUID()));
- String label = quote(curEdge.getCyRow().get("name",
String.class));
+ String label = quote(curEdge.getCyRow().get(CyNetwork.NAME,
String.class));
String directed = quote(curEdge.isDirected() ? "1" : "0");
writeElement("<edge id=" + id + " label=" + label + " source="
+ source + " target=" + target +
@@ -759,7 +760,7 @@
}
private String getNetworkName(CyNetwork network) {
- String name = encode(network.getCyRow().get("name", String.class));
+ String name = encode(network.getCyRow().get(CyNetwork.NAME,
String.class));
if (name == null) name = "UNDEFINED";
return name;
--
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.