Author: clopes
Date: 2011-07-26 14:22:19 -0700 (Tue, 26 Jul 2011)
New Revision: 26276
Modified:
cytoscapeweb/trunk/cytoscapeweb/default.properties
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/XGMMLConverter.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/VisualStyleVO.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/NodeShapes.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/Nodes.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/Utils.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/VisualProperties.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/components/GraphView.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/EdgeRenderer.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
Log:
Implements feature #2566: Node shape transparency with background image.
Implements feature #2299: Allow a node to have different width/height values.
Modified: cytoscapeweb/trunk/cytoscapeweb/default.properties
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/default.properties 2011-07-26 20:12:57 UTC
(rev 26275)
+++ cytoscapeweb/trunk/cytoscapeweb/default.properties 2011-07-26 21:22:19 UTC
(rev 26276)
@@ -1,3 +1,3 @@
-build.version=0.7.3
+build.version=0.7.4
FLEX_HOME=/Applications/Adobe Flex Builder 3 Plug-in/sdks/3.2.0/
\ No newline at end of file
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
2011-07-26 20:12:57 UTC (rev 26275)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
2011-07-26 21:22:19 UTC (rev 26276)
@@ -241,12 +241,16 @@
obj.visible = ds.visible;
if (ds is NodeSprite) {
+ var n:NodeSprite = NodeSprite(ds);
obj.group = Groups.NODES;
- obj.shape = ds.shape;
- obj.size = ds.height;
- obj.color = Utils.rgbColorAsString(ds.fillColor);
- obj.borderColor = Utils.rgbColorAsString(ds.lineColor);
- obj.borderWidth = ds.lineWidth;
+ obj.shape = n.shape;
+ obj.size = n.height;
+ obj.color = Utils.rgbColorAsString(n.fillColor);
+ obj.borderColor = Utils.rgbColorAsString(n.lineColor);
+ obj.borderWidth = n.lineWidth;
+// obj.degree = n.degree;
+// obj.indegree = n.inDegree;
+// obj.outdegree = n.outDegree;
// Global coordinates:
var p:Point = getGlobalCoordinate(ds as NodeSprite);
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
2011-07-26 20:12:57 UTC (rev 26275)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
2011-07-26 21:22:19 UTC (rev 26276)
@@ -446,7 +446,8 @@
var x3:Number = x2, y3:Number = y + h/2;
var x4:Number = x1, y4:Number = y3;
// rounded corner width/height:
- var w4:Number = w/4, h4:Number = h/4;
+ var w4:Number = NodeShapes.getRoundRectCornerRadius(w, h);
+ var h4:Number = w4;
svg += '<path d="M'+(x1+w4)+','+(y1) +
' L'+(x2-w4)+','+(y2) +
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/XGMMLConverter.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/XGMMLConverter.as
2011-07-26 20:12:57 UTC (rev 26275)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/XGMMLConverter.as
2011-07-26 21:22:19 UTC (rev 26276)
@@ -119,8 +119,8 @@
};
private static const NODE_GRAPHICS_ATTR:Object = {
type: [VisualProperties.NODE_SHAPE],
- h: [VisualProperties.NODE_SIZE],
- w: [VisualProperties.NODE_SIZE],
+ w: [VisualProperties.NODE_WIDTH],
+ h: [VisualProperties.NODE_HEIGHT],
fill: [VisualProperties.NODE_COLOR],
width: [VisualProperties.NODE_LINE_WIDTH],
outline: [VisualProperties.NODE_LINE_COLOR],
@@ -615,6 +615,12 @@
value = Utils.rgbColorAsString(value);
} else {
switch (propNames[0]) {
+ case VisualProperties.NODE_WIDTH:
+ case VisualProperties.NODE_HEIGHT:
+ // if width/height not set, use size instead:
+ if (value == null || value < 0)
+ value = style.getValue(VisualProperties.NODE_SIZE,
data);
+ break;
case VisualProperties.NODE_SHAPE:
if (value != null) value = value.toUpperCase();
if (!NodeShapes.isValid(value)) value =
NodeShapes.ELLIPSE;
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/VisualStyleVO.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/VisualStyleVO.as
2011-07-26 20:12:57 UTC (rev 26275)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/VisualStyleVO.as
2011-07-26 21:22:19 UTC (rev 26276)
@@ -56,6 +56,8 @@
nodes: {
shape: NodeShapes.ELLIPSE,
size: 24,
+// width: -1,
+// height: -1,
color: "#f5f5f5",
opacity: 0.8,
borderColor: "#666666",
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/NodeShapes.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/NodeShapes.as
2011-07-26 20:12:57 UTC (rev 26275)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/NodeShapes.as
2011-07-26 21:22:19 UTC (rev 26276)
@@ -108,7 +108,8 @@
xL+w3, yB ];
break;
case NodeShapes.ROUND_RECTANGLE:
- var h4:Number = h/4, w4:Number = w/4;
+ var h4:Number = getRoundRectCornerRadius(w, h);
+ var w4:Number = h4;
// The round corners are not included:
points = [ xL, yB-h4,
xL, yT+h4,
@@ -137,6 +138,10 @@
return points;
}
+ public static function getRoundRectCornerRadius(width:Number,
height:Number):Number {
+ return Math.min(width, height)/4;
+ }
+
public static function isValid(shape:String):Boolean {
if (shape != null) shape = StringUtil.trim(shape.toUpperCase());
Modified: cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/Nodes.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/Nodes.as
2011-07-26 20:12:57 UTC (rev 26275)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/Nodes.as
2011-07-26 21:22:19 UTC (rev 26276)
@@ -77,11 +77,14 @@
if (_properties == null) {
_properties = {
shape: shape,
+ w: width,
+ h: height,
size: size,
fillColor: fillColor,
lineColor: lineColor,
lineWidth: lineWidth,
alpha: alpha,
+ "props.transparent": transparent,
"props.imageUrl": imageUrl,
visible: visible,
buttonMode: true,
@@ -105,6 +108,16 @@
return size / _properties.renderer.defaultSize;
}
+ public static function width(n:NodeSprite):Number {
+ var w:Number = style.getValue(VisualProperties.NODE_WIDTH, n.data);
+ return w;
+ }
+
+ public static function height(n:NodeSprite):Number {
+ var h:Number = style.getValue(VisualProperties.NODE_HEIGHT,
n.data);
+ return h;
+ }
+
public static function fillColor(n:NodeSprite):uint {
var propName:String = VisualProperties.NODE_COLOR;
@@ -157,6 +170,15 @@
return style.getValue(propName, n.data);
}
+
+ public static function transparent(n:NodeSprite):Boolean {
+ var propName:String = VisualProperties.NODE_COLOR;
+
+ if (n.props.$selected &&
style.hasVisualProperty(VisualProperties.NODE_SELECTION_COLOR))
+ propName = VisualProperties.NODE_SELECTION_COLOR;
+
+ return style.getValue(propName, n.data) < 0;
+ }
public static function imageUrl(n:NodeSprite):String {
var propName:String = VisualProperties.NODE_IMAGE;
Modified: cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/Utils.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/Utils.as
2011-07-26 20:12:57 UTC (rev 26275)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/Utils.as
2011-07-26 21:22:19 UTC (rev 26276)
@@ -289,6 +289,114 @@
}
/**
+ * Adapted from:
http://www.baconandgames.com/2010/02/22/intersection-of-an-ellipse-and-a-line-in-as3/
+ * @param p1 The start point of the line.
+ * @param p2 The end point of the line.
+ * @param ep: The ellipse position.
+ * @param width: Width of the ellipse at its widest horizontal point.
+ * @param height: Height of the ellipse at its tallest point.
+ * @return The intersection point. Returns null if there is no
intersection.
+ */
+ public static function lineIntersectEllipse(p1:Point, p2:Point,
ep:Point, width:Number, height:Number):Point {
+ var arr:Array = [];
+
+ var sort:Boolean=false;
+
+ var a:Number = width/2; // radius x
+ var b:Number = height/2; // radius y
+
+ 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);
+
+ // normailze points (ie, make everything relative to (0,0))
+ var p1Norm:Point = new Point(p1.x-center.x,-(p1.y-center.y));
+ var p2Norm:Point = new Point(p2.x-center.x,-(p2.y-center.y));
+ // get the slope - y = mx+b
+ var m:Number = (p2Norm.y-p1Norm.y)/(p2Norm.x-p1Norm.x);
+ // get the slope intercept
+ var si:Number = p2Norm.y-(m*p2Norm.x);
+ // get the coefficients
+ var A:Number = (b*b)+(a*a*m*m);
+ var B:Number = 2*a*a*si*m;
+ var C:Number = a*a*si*si-a*a*b*b;
+ // vars to hold the new points
+ var p3:Point = new Point();
+ var p4:Point = new Point();
+ // we're going to use the quadratic equation to find x, so let's
see what's going to be under the radicand first
+ // depending on this value, we can potentially skip a few
calculations
+ var radicand:Number = (B*B)-(4*A*C);
+
+ // returns true if pt is between anchor1 and anchor2
+ var isBetweenPoints:Function = function(anchor1:Point,
anchor2:Point, pt:Point):Boolean {
+ var xMin:Number;
+ var xMax:Number;
+ var yMin:Number;
+ var yMax:Number;
+ // determine the x bounds
+ if (anchor1.x < anchor2.x) {
+ xMin = anchor1.x;
+ xMax = anchor2.x;
+ } else {
+ xMin = anchor2.x;
+ xMax = anchor1.x;
+ }
+ // determine the y bounds
+ if (anchor1.y < anchor2.y) {
+ yMin = anchor1.y;
+ yMax = anchor2.y;
+ } else {
+ yMin = anchor2.y;
+ yMax = anchor1.y;
+ }
+ // if between those values, point is between the anchors
+ return (pt.x <= xMax && pt.x >= xMin && pt.y <= yMax && pt.y
>= yMin) ? true : false;
+ };
+
+ var distanceBetweenPoints:Function = function(p1:Point,
p2:Point):Number {
+ var dx:Number = p2.x - p1.x, dy:Number = p2.y - p1.y;
+ return Math.pow(dx * dx + dy * dy, .5);
+ }
+
+ if (radicand >= 0) {
+ // solve for x values - using the quadratic equation
+ p3.x = (-B-Math.sqrt(radicand))/(2*A);
+ p4.x = (-B+Math.sqrt(radicand))/(2*A);
+ // calculate y, since we know it's on the line at that point
(otherwise there would be no intersection)
+ p3.y = m*p3.x+si;
+ p4.y = m*p4.x+si;
+ // revert to flash coordinate system
+ p3.x += center.x;
+ p3.y = -p3.y+center.y;
+ p4.x += center.x;
+ p4.y = -p4.y+center.y;
+
+ // add to array of points
+ // only return points of the intersection that exist on the
line between p1 and p2
+ if (isBetweenPoints(p1,p2,p3)) arr.push(p3);
+ if (isBetweenPoints(p1,p2,p4)) arr.push(p4);
+
+ if (sort && arr.length > 1) {
+ // make sure that index 0 contains the closer point
+ if (distanceBetweenPoints(p1,arr[0]) >
distanceBetweenPoints(p1,arr[1])) {
+ arr.reverse();
+ }
+ }
+ } else if (radicand == 0) {
+ // in this case both points will result in the same, so we
only need to calculate one point
+ p3.x = (-B-Math.sqrt(radicand))/(2*A);
+ p3.y = m*p3.x+si;
+ // revert to flash coordinate system
+ p3.x += center.x;
+ p3.y = -p3.y+center.y;
+ // add to array of points
+ if (isBetweenPoints(p1,p2,p3)) arr.push(p3);
+ }
+
+ return arr[0];
+ }
+
+ /**
* Calculates a point along a quadratic bezier curve.
*
* @param a The start point of the curve.
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/VisualProperties.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/VisualProperties.as
2011-07-26 20:12:57 UTC (rev 26275)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/VisualProperties.as
2011-07-26 21:22:19 UTC (rev 26276)
@@ -54,6 +54,8 @@
// Nodes properties:
//------------------------------
public static const NODE_SHAPE:String = "nodes.shape";
+ public static const NODE_WIDTH:String = "nodes.width";
+ public static const NODE_HEIGHT:String = "nodes.height";
public static const NODE_SIZE:String = "nodes.size";
public static const NODE_COLOR:String = "nodes.color";
public static const NODE_ALPHA:String = "nodes.opacity";
@@ -171,15 +173,19 @@
if (value != null) {
if (isColor(name)) {
- var color:uint = Utils.rgbColorAsUint(value);
-
- if (isNaN(color))
- throw new CWError("Invalid color ('"+value+"') for
visual property '"+name+"'",
- ErrorCodes.INVALID_DATA_CONVERSION);
-
- // Add alpha, which is required by for most of the
colors:
- if (name != BACKGROUND_COLOR) color += 0xff000000;
- val = color;
+ val = -1;
+
+ if (value != "transparent") {
+ var color:uint = Utils.rgbColorAsUint(value);
+
+ if (isNaN(color))
+ throw new CWError("Invalid color ('"+value+"') for
visual property '"+name+"'",
+
ErrorCodes.INVALID_DATA_CONVERSION);
+
+ // Add alpha, which is required by for most of the
colors:
+ if (name != BACKGROUND_COLOR) color += 0xff000000;
+ val = color;
+ }
} else if (isNumber(name)) {
val = Number(value);
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/components/GraphView.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/components/GraphView.as
2011-07-26 20:12:57 UTC (rev 26275)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/components/GraphView.as
2011-07-26 21:22:19 UTC (rev 26276)
@@ -254,7 +254,8 @@
n.fillColor = Nodes.fillColor(n);
n.lineWidth = Nodes.lineWidth(n);
n.lineColor = Nodes.lineColor(n);
- n.alpha = Nodes.alpha(n);
+ n.alpha = Nodes.alpha(n);
+ n.props.transparent = Nodes.transparent(n);
n.shape = Nodes.shape(n);
n.filters = Nodes.filters(n);
if (n.props.label != null) n.props.label.alpha = n.alpha;
@@ -333,6 +334,7 @@
n.lineWidth = Nodes.selectionLineWidth(n);
n.lineColor = Nodes.lineColor(n);
n.alpha = Nodes.selectionAlpha(n);
+ n.props.transparent = Nodes.transparent(n);
n.filters = Nodes.filters(n, true);
if (n.props.label != null) n.props.label.alpha = n.alpha;
}
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/EdgeRenderer.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/EdgeRenderer.as
2011-07-26 20:12:57 UTC (rev 26275)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/EdgeRenderer.as
2011-07-26 21:22:19 UTC (rev 26276)
@@ -109,7 +109,7 @@
var taH:Number = targetArrowStyle != null ?
targetArrowStyle.height : 0;
if (loop) {
- h += Math.max(s.width, saH*2, taH*2, w*4);
+ h += Math.max(s.width, s.height, saH*2, taH*2,
w*4);
op1 = new Point(s.x, s.y - s.height/2 - h);
op2 = new Point(s.x - s.width/2 - h, s.y);
} else {
@@ -134,8 +134,8 @@
// ----------------------------------------------------
// get arrow tip point as intersection of edge with bounding box
- intersectNode(s, op2, np1, _intS);
- intersectNode(t, op1, np2, _intT);
+ intersectNode(g, s, op2, np1, _intS);
+ intersectNode(g, t, op1, np2, _intT);
var start:Point = _intS, end:Point = _intT;
//var c:Point = (curve ? op1 : null);
@@ -449,15 +449,15 @@
return [start.clone(), int1.clone(), e1.clone(), e2.clone(),
int2.clone()];
}
- private function intersectNode(n:NodeSprite, start:Point, end:Point,
int:Point):void {
+ private function intersectNode(g:Graphics, n:NodeSprite, start:Point,
end:Point, int:Point):void {
var r:Rectangle = n.getBounds(n.parent);
switch (n.shape) {
case NodeShapes.ELLIPSE:
- intersectCircle(n.height/2, start, end, int);
+ intersectEllipse(r.topLeft, n.width, n.height, start, end,
int);
break;
case NodeShapes.ROUND_RECTANGLE:
- intersectRoundRectangle(r, start, end, int);
+ intersectRoundRectangle(g, r, start, end, int);
break;
default:
var points:Array = NodeShapes.getDrawPoints(r, n.shape);
@@ -467,13 +467,23 @@
private function intersectCircle(radius:Number, start:Point,
end:Point, ip:Point):void {
var obj:Object = Utils.lineIntersectCircle(start, end, end,
radius);
+
if (obj.enter != null) {
ip.x = obj.enter.x;
ip.y = obj.enter.y;
}
}
- private function intersectRoundRectangle(r:Rectangle, start:Point,
end:Point, ip:Point):void {
+ private function intersectEllipse(ep:Point, width:Number,
height:Number, start:Point, end:Point, ip:Point):void {
+ var p:Point = Utils.lineIntersectEllipse(start, end, ep, width,
height);
+
+ if (p != null) {
+ ip.x = p.x;
+ ip.y = p.y;
+ }
+ }
+
+ private function intersectRoundRectangle(g:Graphics, 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;
@@ -486,10 +496,11 @@
res = Geometry.intersectLines(x1, y1, x2, y2, start.x,
start.y, end.x, end.y, ip);
if (res > 0) break;
}
+
if (res <= 0) {
// Verify if the edge intersects one of the rounded courners,
// which are described by four circles.
- var radius:Number = r.width/4;
+ var radius:Number =
NodeShapes.getRoundRectCornerRadius(r.width, r.height);
// Calculate the center of the circles:
var xR:Number = r.right, yB:Number = r.bottom;
var xL:Number = r.left, yT:Number = r.top;
@@ -500,6 +511,7 @@
for each (var c:Point in points) {
var obj:Object = Utils.lineIntersectCircle(start, end, c,
radius);
+
if (obj.enter != null) {
ip.x = obj.enter.x;
ip.y = obj.enter.y;
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
2011-07-26 20:12:57 UTC (rev 26275)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
2011-07-26 21:22:19 UTC (rev 26276)
@@ -85,7 +85,12 @@
var lineAlpha:Number = d.lineAlpha;
var fillAlpha:Number = d.fillAlpha;
var size:Number = d.size * defaultSize;
+ var w:Number = d.w;
+ var h:Number = d.h;
+ if (isNaN(w) || w < 0) w = size;
+ if (isNaN(h) || h < 0) h = size;
+
var g:Graphics = d.graphics;
g.clear();
@@ -101,12 +106,12 @@
// 1. Draw the background color:
// Using a bit mask to avoid transparent mdes when
fillcolor=0xffffffff.
// See https://sourceforge.net/forum/message.php?msg_id=7393265
- g.beginFill(0xffffff & d.fillColor, fillAlpha);
- drawShape(d, d.shape, size);
- g.endFill();
+ if (!d.props.transparent) g.beginFill(0xffffff & d.fillColor,
fillAlpha);
+ drawShape(d, d.shape, w, h);
+ if (!d.props.transparent) g.endFill();
// 2. Draw an image on top:
- drawImage(d, size);
+ drawImage(d, w, h);
}
// To prevent gaps between the node and its edges when the node
has the
@@ -119,14 +124,14 @@
// ========[ PRIVATE METHODS
]==============================================================
- private function drawShape(s:Sprite, shape:String, size:Number):void {
+ private function drawShape(s:Sprite, shape:String, width:Number,
height:Number):void {
var g:Graphics = s.graphics;
switch (shape) {
case null:
break;
case NodeShapes.RECTANGLE:
- g.drawRect(-size/2, -size/2, size, size);
+ g.drawRect(-width/2, -height/2, width, height);
break;
case NodeShapes.TRIANGLE:
case NodeShapes.DIAMOND:
@@ -134,23 +139,27 @@
case NodeShapes.OCTAGON:
case NodeShapes.PARALLELOGRAM:
case NodeShapes.V:
- var r:Rectangle = new Rectangle(-size/2, -size/2, size,
size);
+ var r:Rectangle = new Rectangle(-width/2, -height/2,
width, height);
var points:Array = NodeShapes.getDrawPoints(r, shape);
Shapes.drawPolygon(g, points);
break;
case NodeShapes.ROUND_RECTANGLE:
- g.drawRoundRect(-size/2, -size/2, size, size, size/2,
size/2);
+ var eh:Number = NodeShapes.getRoundRectCornerRadius(width,
height) * 2;
+ g.drawRoundRect(-width/2, -height/2, width, height, eh,
eh);
break;
case NodeShapes.ELLIPSE:
default:
- Shapes.drawCircle(g, size/2);
+ if (width == height)
+ Shapes.drawCircle(g, width/2);
+ else
+ g.drawEllipse(-width/2, -height/2, width, height);
}
}
- private function drawImage(d:DataSprite, size:Number):void {
+ private function drawImage(d:DataSprite, w:Number, h:Number):void {
var url:String = d.props.imageUrl;
- if (size > 0 && url != null && StringUtil.trim(url).length > 0) {
+ if (w > 0 && h > 0 && url != null && StringUtil.trim(url).length >
0) {
// Load the image into the cache first?
if (!_imgCache.contains(url)) {trace("Will load IMAGE...");
_imgCache.loadImage(url);
@@ -174,14 +183,14 @@
if (bd != null) {
var bmpSize:Number = Math.min(bd.height, bd.width);
- var scale:Number = size/bmpSize;
+ var scale:Number = Math.max(w, h)/bmpSize;
var m:Matrix = new Matrix();
m.scale(scale, scale);
m.translate(-(bd.width*scale)/2, -(bd.height*scale)/2);
d.graphics.beginBitmapFill(bd, m, false, true);
- drawShape(d, d.shape, size);
+ drawShape(d, d.shape, w, h);
d.graphics.endFill();
}
}
Modified:
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
2011-07-26 20:12:57 UTC (rev 26275)
+++
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
2011-07-26 21:22:19 UTC (rev 26276)
@@ -265,7 +265,9 @@
var data:Data = Fixtures.getData(Fixtures.GRAPHML_SIMPLE);
var o:Object, k:*;
- var props:Array =
["data","shape","borderColor","borderWidth","opacity","visible","color","x","y"];
+ // NODES
+ var props:Array =
["data","shape","borderColor","borderWidth","opacity","visible","color",
+ "x","y"/*, "degree", "indegree", "outdegree"*/];
var attrs:Array = ["id"];
for each (var n:NodeSprite in data.nodes) {
@@ -278,6 +280,7 @@
assertEquals(n.data.id, o.data.id);
}
+ // EDGES
props =
["data","color","width","opacity","visible","sourceArrowShape","targetArrowShape",
"sourceArrowColor","targetArrowColor","curvature","merged"];
attrs = ["id","source","target","directed"];
--
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.