Author: scooter
Date: 2010-12-28 20:21:58 -0800 (Tue, 28 Dec 2010)
New Revision: 23274
Modified:
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLParser.java
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLReader.java
cytoscape/trunk/application/src/main/java/cytoscape/data/writers/XGMMLWriter.java
Log:
Added fix to support proper node size handling. This fixed bug 2090.
Modified:
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLParser.java
===================================================================
---
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLParser.java
2010-12-29 00:46:12 UTC (rev 23273)
+++
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLParser.java
2010-12-29 04:21:58 UTC (rev 23274)
@@ -130,6 +130,7 @@
private double graphZoom = 1.0;
private double graphCenterX = 0.0;
private double graphCenterY = 0.0;
+ private boolean nodeSizeLocked = false;
//
private double documentVersion = 1.0;
@@ -313,7 +314,28 @@
}
}
+ /**
+ * Return the boolean attribute value for the attribute indicated by
"key". If no such attribute exists, we throw a SAXParseException.
+ * In particular, this routine looks for an attribute with a
<b>name</b> or <b>label</b> of <i>key</i> and returns the <b>value</b>
+ * of that attribute.
+ *
+ * @param atts the attributes
+ * @param key the specific attribute to get
+ * @return the value for "key."
+ * @throws SAXParseException if we either can't find the requested
attribute or if its value cannot be converted to a double.
+ */
+ boolean getBooleanAttributeValue(final Attributes atts, final String
key) throws SAXParseException {
+ final String attribute = getAttributeValue(atts, key);
+ if (attribute == null)
+ return false;
+ try {
+ return Boolean.parseBoolean(attribute);
+ } catch (final Exception e) {
+ throw new SAXParseException("Unable to convert '" +
attribute + "' to a BOOLEAN", locator);
+ }
+ }
+
/**
* Return the typed attribute value for the passed attribute. In this
case,
* the caller has already determined that this is the correct attribute
and
@@ -586,6 +608,10 @@
}
+ boolean getNodeSizeLocked() {
+ return nodeSizeLocked;
+ }
+
Point2D getGraphViewCenter() {
if (graphCenterX == 0.0 && graphCenterY == 0.0)
return null;
@@ -809,6 +835,8 @@
graphCenterX = getDoubleAttributeValue(atts,
"GRAPH_VIEW_CENTER_X");
} else if (getAttributeValue(atts,
"GRAPH_VIEW_CENTER_Y") != null) {
graphCenterY = getDoubleAttributeValue(atts,
"GRAPH_VIEW_CENTER_Y");
+ } else if (getAttributeValue(atts, "NODE_SIZE_LOCKED")
!= null) {
+ nodeSizeLocked = getBooleanAttributeValue(atts,
"NODE_SIZE_LOCKED");
} else {
objectTarget = networkName;
nextState = handleAttribute(atts,
currentAttributes, networkName);
Modified:
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLReader.java
===================================================================
---
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLReader.java
2010-12-29 00:46:12 UTC (rev 23273)
+++
cytoscape/trunk/application/src/main/java/cytoscape/data/readers/XGMMLReader.java
2010-12-29 04:21:58 UTC (rev 23274)
@@ -152,6 +152,7 @@
private Double graphViewCenterY;
private InputStream networkStream;
private XGMMLParser parser;
+ private boolean nodeSizeLocked = false;
private Properties prop = CytoscapeInit.getProperties();
private String vsbSwitch = prop.getProperty("visualStyleBuilder");
@@ -408,6 +409,8 @@
final boolean buildStyle = vsbSwitch == null ||
vsbSwitch.equals("on");
VisualStyleBuilder graphStyle = new
VisualStyleBuilder(parser.getNetworkName(), false);
+ nodeSizeLocked = parser.getNodeSizeLocked();
+ graphStyle.setNodeSizeLocked(nodeSizeLocked); // False by
default
// Set background color
if (parser.getBackgroundColor() != null) {
@@ -492,16 +495,17 @@
nodeView.setXPosition(x);
nodeView.setYPosition(y);
- if (buildStyle && h != 0.0) {
- // nodeView.setHeight(h);
- graphStyle.addProperty(nodeID,
VisualPropertyType.NODE_HEIGHT, ""+h);
+ if (buildStyle) {
+ if (nodeSizeLocked && h != 0.0) {
+ graphStyle.addProperty(nodeID,
VisualPropertyType.NODE_SIZE, ""+h);
+ } else {
+ if (h != 0.0)
+ graphStyle.addProperty(nodeID,
VisualPropertyType.NODE_HEIGHT, ""+h);
+ if (w != 0.0)
+ graphStyle.addProperty(nodeID,
VisualPropertyType.NODE_WIDTH, ""+w);
+ }
}
- if (buildStyle && w != 0.0) {
- // nodeView.setWidth(w);
- graphStyle.addProperty(nodeID,
VisualPropertyType.NODE_WIDTH, ""+w);
- }
-
CyAttributes nodeAttributes = Cytoscape.getNodeAttributes();
// Set color
Modified:
cytoscape/trunk/application/src/main/java/cytoscape/data/writers/XGMMLWriter.java
===================================================================
---
cytoscape/trunk/application/src/main/java/cytoscape/data/writers/XGMMLWriter.java
2010-12-29 00:46:12 UTC (rev 23273)
+++
cytoscape/trunk/application/src/main/java/cytoscape/data/writers/XGMMLWriter.java
2010-12-29 04:21:58 UTC (rev 23274)
@@ -62,6 +62,9 @@
import cytoscape.logger.CyLogger;
import cytoscape.view.CyNetworkView;
import cytoscape.visual.LineStyle;
+import cytoscape.visual.VisualPropertyDependency;
+import cytoscape.visual.VisualPropertyDependency.Definition;
+import cytoscape.visual.VisualStyle;
import ding.view.DGraphView;
import ding.view.DingCanvas;
@@ -203,6 +206,11 @@
/**
*
*/
+ public static final String NODE_SIZE_LOCKED = "NODE_SIZE_LOCKED";
+
+ /**
+ *
+ */
public static final String ENCODE_PROPERTY =
"cytoscape.encode.xgmml.attributes";
private CyAttributes nodeAttributes;
@@ -411,6 +419,13 @@
final Point2D center = ((DGraphView)
networkView).getCenter();
writeAttributeXML(GRAPH_VIEW_CENTER_X, ObjectType.REAL,
new Double(center.getX()) ,true);
writeAttributeXML(GRAPH_VIEW_CENTER_Y, ObjectType.REAL,
new Double(center.getY()) ,true);
+
+ // Figure out if our node height and width is locked
+ VisualStyle networkStyle =
Cytoscape.getCurrentNetworkView().getVisualStyle();
+ VisualPropertyDependency vpd =
networkStyle.getDependency();
+ if
(vpd.check(VisualPropertyDependency.Definition.NODE_SIZE_LOCKED))
+ writeAttributeXML(NODE_SIZE_LOCKED,
ObjectType.BOOLEAN, Boolean.TRUE ,true);
+
}
// Now handle all of the other network attributes
--
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.