Author: clopes
Date: 2011-10-12 15:30:39 -0700 (Wed, 12 Oct 2011)
New Revision: 27147
Modified:
cytoscapeweb/branches/compound/html-template/js/compound.js
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/ExternalMediator.as
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/GraphMediator.as
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/Labeler.as
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/NodeRenderer.as
Log:
Fixed node renderer bug: running labeler could force a new compound node to be
rendered before its dimensions were calculated.
Modified: cytoscapeweb/branches/compound/html-template/js/compound.js
===================================================================
--- cytoscapeweb/branches/compound/html-template/js/compound.js 2011-10-12
21:53:07 UTC (rev 27146)
+++ cytoscapeweb/branches/compound/html-template/js/compound.js 2011-10-12
22:30:39 UTC (rev 27147)
@@ -555,13 +555,12 @@
return data;
}
-function sampleElements()
-{
- var array = [ { group: "nodes", x: 20, y: 70, data: { id: "cn03",
label: "cn03"}, parent: "cn01" },
- { group: "nodes", x: 100, y:150 , data: { id: "cn07", label:
"cn07"}, parent: "cn04" },
- { group: "nodes", x: 45, y: 95, data: { id: "cn05", label: "cn05"},
parent: "cn01" },
- { group: "nodes", x: 90, y: 130, data: { id: "cn04", label:
"cn04"}, parent: "cn02" },
- { group: "nodes", x: 120, y: 150, data: { id: "cn06", label:
"cn06"}, parent: "cn02" },
+function sampleElements() {
+ var array = [ { group: "nodes", x: 20, y: 70, data: { id: "cn03",
label: "cn03", parent: "cn01"} },
+ { group: "nodes", x: 100, y:150 , data: { id: "cn07", label:
"cn07", parent: "cn04"} },
+ { group: "nodes", x: 45, y: 95, data: { id: "cn05", label: "cn05",
parent: "cn01"} },
+ { group: "nodes", x: 90, y: 130, data: { id: "cn04", label: "cn04",
parent: "cn02"} },
+ { group: "nodes", x: 120, y: 150, data: { id: "cn06", label:
"cn06", parent: "cn02"} },
{ group: "nodes", x: 10, y: 35, data: { id: "cn01", label: "cn01" }
},
{ group: "nodes", x: 20, y: 70, data: { id: "cn02", label: "cn02"}
},
{ group: "edges", data: { source: "cn01", target: "cn02" } },
Modified:
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/ExternalMediator.as
===================================================================
---
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/ExternalMediator.as
2011-10-12 21:53:07 UTC (rev 27146)
+++
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/ExternalMediator.as
2011-10-12 22:30:39 UTC (rev 27147)
@@ -436,7 +436,10 @@
for each (o in childrenToAdd) {
parent = this.graphProxy.getNode(o.data.parent);
- this.graphMediator.updateCompoundNode(parent, o.sprite);
+
+ if (parent != null) {
+ this.graphMediator.updateCompoundNode(parent,
o.sprite);
+ }
}
// Do it before converting the Nodes/Edges to
plain objects,
Modified:
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/GraphMediator.as
===================================================================
--- cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/GraphMediator.as
2011-10-12 21:53:07 UTC (rev 27146)
+++ cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/GraphMediator.as
2011-10-12 22:30:39 UTC (rev 27147)
@@ -297,26 +297,8 @@
public function initialize(gr:String, items:Array):void {
addListeners(items);
- updateDataSprites(gr, items)
- }
-
- public function updateDataSprites(gr:String, items:Array):void {
- var props:Object;
-
- if (gr === Groups.NODES) {
- props = Nodes.properties;
- } else if (gr === Groups.COMPOUND_NODES) {
- props = CompoundNodes.properties;
- } else {
- props = Edges.properties;
- }
-
- for (var name:String in props) {
- Arrays.setProperty(items, name, props[name], null);
- }
-
+ updateDataSprites(gr, items);
vis.updateLabels(gr);
- separateDisconnected();
}
public function separateDisconnected():void {
@@ -396,6 +378,24 @@
// ========[ PRIVATE METHODS
]==============================================================
+ private function updateDataSprites(gr:String, items:Array):void {
+ var props:Object;
+
+ if (gr === Groups.NODES) {
+ props = Nodes.properties;
+ } else if (gr === Groups.COMPOUND_NODES) {
+ props = CompoundNodes.properties;
+ } else {
+ props = Edges.properties;
+ }
+
+ for (var name:String in props) {
+ Arrays.setProperty(items, name, props[name], null);
+ }
+
+ separateDisconnected();
+ }
+
private function onRenderInitialize(evt:GraphViewEvent):void {
graphView.addEventListener(GraphViewEvent.LAYOUT_INITIALIZE,
onLayoutInitialize, false, 0, true);
graphView.addEventListener(GraphViewEvent.RENDER_COMPLETE,
onRenderComplete, false, 0, true);
Modified:
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/Labeler.as
===================================================================
--- cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/Labeler.as
2011-10-12 21:53:07 UTC (rev 27146)
+++ cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/Labeler.as
2011-10-12 22:30:39 UTC (rev 27147)
@@ -234,10 +234,10 @@
}
} else {
// The offset should be based on each node's size (not just
from the node's center):
- if (label.horizontalAnchor == TextSprite.LEFT) myXOffset
+= d.width/2;
- else if (label.horizontalAnchor == TextSprite.RIGHT) myXOffset
-= d.width/2;
- if (label.verticalAnchor == TextSprite.TOP) myYOffset
+= d.height/2;
- else if (label.verticalAnchor == TextSprite.BOTTOM) myYOffset
-= d.height/2;
+ if (label.horizontalAnchor === TextSprite.LEFT)
myXOffset += d.width/2;
+ else if (label.horizontalAnchor === TextSprite.RIGHT)
myXOffset -= d.width/2;
+ if (label.verticalAnchor === TextSprite.TOP)
myYOffset += d.height/2;
+ else if (label.verticalAnchor === TextSprite.BOTTOM)
myYOffset -= d.height/2;
if (d.props.autoSize) {
if (! (d is CompoundNodeSprite && (d as
CompoundNodeSprite).nodesCount > 0)) {
Modified:
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/NodeRenderer.as
===================================================================
---
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/NodeRenderer.as
2011-10-12 21:53:07 UTC (rev 27146)
+++
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/NodeRenderer.as
2011-10-12 22:30:39 UTC (rev 27147)
@@ -179,6 +179,8 @@
var x:Number = bounds.x;
var y:Number = bounds.y;
+ if (isNaN(w) || isNaN(h)) return;
+
switch (shape) {
case null:
break;
--
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.