Author: clopes
Date: 2011-09-19 14:16:55 -0700 (Mon, 19 Sep 2011)
New Revision: 26865
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/GraphProxy.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/VisualStyleVO.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/ErrorCodes.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/Utils.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/EdgeRenderer.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
Log:
Fixed issue #2587: Edge end does not intercept ellipse node border when the
edge is a loop.
Fixed Visual Style issue: programmatically added nodes can have no shape after
initially calling draw() with empty data, if node size is determined by a
continuous mapper.
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/GraphProxy.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/GraphProxy.as
2011-09-19 20:51:26 UTC (rev 26864)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/GraphProxy.as
2011-09-19 21:16:55 UTC (rev 26865)
@@ -103,6 +103,9 @@
return data as Data;
}
+ /**
+ * @param data It has to be a flare.vis.data.Data instance.
+ */
public override function setData(data:Object):void {
super.setData(data);
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/VisualStyleVO.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/VisualStyleVO.as
2011-09-19 20:51:26 UTC (rev 26864)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/VisualStyleVO.as
2011-09-19 21:16:55 UTC (rev 26865)
@@ -32,6 +32,7 @@
import org.cytoscapeweb.util.LineStyles;
import org.cytoscapeweb.util.NodeShapes;
import org.cytoscapeweb.util.Utils;
+ import org.cytoscapeweb.util.VisualProperties;
public class VisualStyleVO {
@@ -186,8 +187,10 @@
if (vp != null) {
var mapper:VizMapperVO = vp.vizMapper;
- if (data != null && mapper != null)
+ if (data != null && mapper != null) {
value = mapper.getValue(data);
+ if (isNaN(value)) value = null;
+ }
if (value == null)
value = vp.defaultValue;
}
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/ErrorCodes.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/ErrorCodes.as
2011-09-19 20:51:26 UTC (rev 26864)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/ErrorCodes.as
2011-09-19 21:16:55 UTC (rev 26865)
@@ -39,6 +39,7 @@
public static const INVALID_DATA_CONVERSION:String = "dat001";
public static const MISSING_DATA_FIELD:String = "dat002";
public static const BROKEN_IMAGE:String = "img001";
+ public static const RENDERING_ERROR:String = "vis001";
// ========[ CONSTRUCTOR
]==================================================================
Modified: cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/Utils.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/Utils.as
2011-09-19 20:51:26 UTC (rev 26864)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/Utils.as
2011-09-19 21:16:55 UTC (rev 26865)
@@ -307,7 +307,7 @@
var x:Number = ep.x; // horizontal position of the ellipse.
var y:Number = ep.y; // vertical position of the ellipse
- var center:Point = new Point(x + width * 0.5, y + height * 0.5);
+ var center:Point = new Point(x+a, y+b);
// normailze points (ie, make everything relative to (0,0))
var p1Norm:Point = new Point(p1.x-center.x,-(p1.y-center.y));
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/EdgeRenderer.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/EdgeRenderer.as
2011-09-19 20:51:26 UTC (rev 26864)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/EdgeRenderer.as
2011-09-19 21:16:55 UTC (rev 26865)
@@ -134,11 +134,17 @@
// ----------------------------------------------------
// get arrow tip point as intersection of edge with bounding box
- intersectNode(g, s, op2, np1, _intS);
- intersectNode(g, t, op1, np2, _intT);
+ if (loop && s.shape === NodeShapes.ELLIPSE) {
+ // TODO: find out why ellipse intersection does not work with
loop and remove this workaround
+ var r:Rectangle = s.getBounds(s.parent);
+ intersectLines([r.topLeft.x, r.topLeft.y, r.topLeft.x,
r.topLeft.y + r.height], op2, np1, _intS);
+ intersectLines([r.topLeft.x, r.topLeft.y, r.topLeft.x +
r.width, r.topLeft.y], op1, np2, _intT);
+ } else {
+ intersectNode(s, op2, np1, _intS);
+ intersectNode(t, op1, np2, _intT);
+ }
- var start:Point = _intS, end:Point = _intT;
- //var c:Point = (curve ? op1 : null);
+ var start:Point = _intS.clone(), end:Point = _intT.clone();
// Using a bit mask to avoid transparent edges when
fillcolor=0xffffffff.
// See https://sourceforge.net/forum/message.php?msg_id=7393265
@@ -449,15 +455,18 @@
return [start.clone(), int1.clone(), e1.clone(), e2.clone(),
int2.clone()];
}
- private function intersectNode(g:Graphics, n:NodeSprite, start:Point,
end:Point, int:Point):void {
+ private function intersectNode(n:NodeSprite, start:Point, end:Point,
int:Point):void {
var r:Rectangle = n.getBounds(n.parent);
switch (n.shape) {
case NodeShapes.ELLIPSE:
- intersectEllipse(r.topLeft, n.width, n.height, start, end,
int);
+ if (n.width == n.height)
+ intersectCircle(n.width/2, start, end, int);
+ else
+ intersectEllipse(r.topLeft, r.width, r.height, start,
end, int);
break;
case NodeShapes.ROUND_RECTANGLE:
- intersectRoundRectangle(g, r, start, end, int);
+ intersectRoundRectangle(r, start, end, int);
break;
default:
var points:Array = NodeShapes.getDrawPoints(r, n.shape);
@@ -483,7 +492,7 @@
}
}
- private function intersectRoundRectangle(g:Graphics, r:Rectangle,
start:Point, end:Point, ip:Point):void {
+ private function intersectRoundRectangle(r:Rectangle, start:Point,
end:Point, ip:Point):void {
var points:Array = NodeShapes.getDrawPoints(r,
NodeShapes.ROUND_RECTANGLE);
var res:int = Geometry.NO_INTERSECTION;
var length:int = points.length;
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
2011-09-19 20:51:26 UTC (rev 26864)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
2011-09-19 21:16:55 UTC (rev 26865)
@@ -46,6 +46,9 @@
import org.cytoscapeweb.ApplicationFacade;
import org.cytoscapeweb.model.ConfigProxy;
import org.cytoscapeweb.model.GraphProxy;
+ import org.cytoscapeweb.model.error.CWError;
+ import org.cytoscapeweb.model.methods.error;
+ import org.cytoscapeweb.util.ErrorCodes;
import org.cytoscapeweb.util.NodeShapes;
@@ -82,50 +85,57 @@
/** @inheritDoc */
public override function render(d:DataSprite):void {trace("RENDER
NODE: " + d.data.id);
- // Using a bit mask to avoid transparent mdes when
fillcolor=0xffffffff.
- // See https://sourceforge.net/forum/message.php?msg_id=7393265
- var fillColor:uint = 0xffffff & d.fillColor;
- var fillAlpha:Number = d.fillAlpha;
- var size:Number = d.size * defaultSize;
-
- var lineColor:uint = d.lineColor;
- var lineAlpha:Number = d.lineAlpha;
- var lineWidth:Number = d.lineWidth;
-
- var w:Number = d.props.width;
- var h:Number = d.props.height;
-
- if (isNaN(w) || w < 0) w = size;
- if (isNaN(h) || h < 0) h = size;
-
- var g:Graphics = d.graphics;
- g.clear();
-
- // Just to prevent rendering issues when drawing large bitmaps on
small nodes:
- d.cacheAsBitmap = d.props.imageUrl != null;
-
- if (lineAlpha > 0 && lineWidth > 0) {
- var pixelHinting:Boolean = d.shape ===
NodeShapes.ROUND_RECTANGLE;
- g.lineStyle(lineWidth, lineColor, lineAlpha, pixelHinting);
+ try {
+ // Using a bit mask to avoid transparent mdes when
fillcolor=0xffffffff.
+ // See https://sourceforge.net/forum/message.php?msg_id=7393265
+ var fillColor:uint = 0xffffff & d.fillColor;
+ var fillAlpha:Number = d.fillAlpha;
+ var size:Number = d.size * defaultSize;
+
+ var lineColor:uint = d.lineColor;
+ var lineAlpha:Number = d.lineAlpha;
+ var lineWidth:Number = d.lineWidth;
+
+ var w:Number = d.props.width;
+ var h:Number = d.props.height;
+
+ if (isNaN(w) || w < 0) w = size;
+ if (isNaN(h) || h < 0) h = size;
+
+ var g:Graphics = d.graphics;
+ g.clear();
+
+ // Just to prevent rendering issues when drawing large bitmaps
on small nodes:
+ d.cacheAsBitmap = d.props.imageUrl != null;
+
+ if (isNaN(w) || isNaN(h) || w <= 0 || h <= 0) return;
+
+ if (lineAlpha > 0 && lineWidth > 0) {
+ var pixelHinting:Boolean = d.shape ===
NodeShapes.ROUND_RECTANGLE;
+ g.lineStyle(lineWidth, lineColor, lineAlpha, pixelHinting);
+ }
+
+ // 1. Draw the background color:
+ // Even if "transparent", we still need to draw a shape,
+ // or the node will not receive mouse events
+ if (d.props.transparent) fillAlpha = 0;
+ g.beginFill(fillColor, fillAlpha);
+ drawShape(d, d.shape, w, h);
+ g.endFill();
+
+ // 2. Draw an image on top:
+ drawImage(d, w, h);
+
+ // To prevent gaps between the node and its edges when the
node has the
+ // border width changed on mouseover or selection
+ NodeSprite(d).visitEdges(function(e:EdgeSprite):Boolean {
+ e.dirty();
+ return false;
+ }, NodeSprite.GRAPH_LINKS);
+ } catch (err:Error) {
+ error(new CWError("Error rendering Node '" + d.data.id +"': "
+ err.message,
+ ErrorCodes.RENDERING_ERROR));
}
-
- // 1. Draw the background color:
- // Even if "transparent", we still need to draw a shape,
- // or the node will not receive mouse events
- if (d.props.transparent) fillAlpha = 0;
- g.beginFill(fillColor, fillAlpha);
- drawShape(d, d.shape, w, h);
- g.endFill();
-
- // 2. Draw an image on top:
- drawImage(d, w, h);
-
- // To prevent gaps between the node and its edges when the node
has the
- // border width changed on mouseover or selection
- NodeSprite(d).visitEdges(function(e:EdgeSprite):Boolean {
- e.dirty();
- return false;
- }, NodeSprite.GRAPH_LINKS);
}
// ========[ PRIVATE METHODS
]==============================================================
--
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.