Author: Christian Lopes
Date: 2010-12-03 15:33:20 -0800 (Fri, 03 Dec 2010)
New Revision: 23086
Modified:
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/data/VisualPropertyVOTest.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/VisualPropertyVO.as
Log:
Fixed bug related to setting a visual style property with a defaultValue field,
but no mapper.
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/VisualPropertyVO.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/VisualPropertyVO.as
2010-12-03 22:01:31 UTC (rev 23085)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/VisualPropertyVO.as
2010-12-03 23:33:20 UTC (rev 23086)
@@ -167,9 +167,6 @@
if (name != null && prop != null) {
var defValue:* = null;
- if (prop.hasOwnProperty("defaultValue"))
- defValue = prop.defaultValue;
-
var mapper:VizMapperVO = null;
if (prop.hasOwnProperty("discreteMapper"))
@@ -180,7 +177,10 @@
mapper = PassthroughVizMapperVO.fromObject(name,
prop.passthroughMapper);
else if (prop.hasOwnProperty("customMapper"))
mapper = CustomVizMapperVO.fromObject(name,
prop.customMapper);
- else
+
+ if (prop.hasOwnProperty("defaultValue"))
+ defValue = prop.defaultValue;
+ else if (mapper == null)
defValue = prop;
defValue = VisualProperties.parseValue(name, defValue);
Modified:
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
2010-12-03 22:01:31 UTC (rev 23085)
+++
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
2010-12-03 23:33:20 UTC (rev 23086)
@@ -64,7 +64,7 @@
// A simple network:
// --------------------------------------------------------------
n = {
- schema: {
+ dataSchema: {
nodes: [
{ name: "id", type: "number" }, // WRONG! Should be
string and will be ignored
{ name: "score", type: "number", defValue: -1 }
Modified:
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/data/VisualPropertyVOTest.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/data/VisualPropertyVOTest.as
2010-12-03 22:01:31 UTC (rev 23085)
+++
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/data/VisualPropertyVOTest.as
2010-12-03 23:33:20 UTC (rev 23086)
@@ -119,5 +119,34 @@
}
}
}
+
+ public function testFromObject():void {
+ var vp:VisualPropertyVO;
+ var def:* = "/anImage.png";
+
+ vp = VisualPropertyVO.fromObject(VisualProperties.NODE_IMAGE, def);
+ assertEquals(def, vp.defaultValue);
+
+ vp = VisualPropertyVO.fromObject(VisualProperties.NODE_IMAGE, {
defaultValue: def });
+ assertEquals(def, vp.defaultValue);
+
+ vp = VisualPropertyVO.fromObject(VisualProperties.EDGE_WIDTH,
+ { defaultValue: 3,
+ continuousMapper: { attrName:
"weight", minValue: 1, maxValue: 4 } });
+ assertEquals(3, vp.defaultValue);
+ assertEquals("weight", vp.vizMapper.attrName);
+ assertEquals(1, ContinuousVizMapperVO(vp.vizMapper).minValue);
+ assertEquals(4, ContinuousVizMapperVO(vp.vizMapper).maxValue);
+
+ vp = VisualPropertyVO.fromObject(VisualProperties.EDGE_WIDTH,
+ { defaultValue: 3,
+ discreteMapper: { attrName:
"type",
+ entries: [ {
attrValue: "1", value: 10 }, { attrValue: "2", value: 40 } ]
+ } });
+ assertEquals(3, vp.defaultValue);
+ assertEquals("type", vp.vizMapper.attrName);
+ assertEquals(10, vp.vizMapper.getValue({ type: "1" }));
+ assertEquals(40, vp.vizMapper.getValue({ type: "2" }));
+ }
}
}
--
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.