Author: clopes
Date: 2011-07-27 13:27:54 -0700 (Wed, 27 Jul 2011)
New Revision: 26292
Modified:
cytoscapeweb/trunk/cytoscapeweb/html-template/js/tests.js
cytoscapeweb/trunk/cytoscapeweb/lib/AlivePDF.swc
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/view/render/ImageCacheTest.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/PDFExporter.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/GraphUtils.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/VisualProperties.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
Log:
- Fixed bug #2567: SVG Export: node image opacity should be affected by the
node opacity.
- Feature #2299: (Allow a node to have different width/height values): fixed
PDF Export and graph bounds calculation.
- Feature #2566 (Node shape transparency with background image): fixed SVG
Export and VisualStyle object.
- Updated AlivePDF to version 0.1.5 RC.
Modified: cytoscapeweb/trunk/cytoscapeweb/html-template/js/tests.js
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/html-template/js/tests.js 2011-07-27
19:52:38 UTC (rev 26291)
+++ cytoscapeweb/trunk/cytoscapeweb/html-template/js/tests.js 2011-07-27
20:27:54 UTC (rev 26292)
@@ -502,7 +502,7 @@
test("Visual Style", function() {
vis.visualStyle(style);
- var nodes = vis.nodes, edges = vis.edges();
+ var nodes = vis.nodes(), edges = vis.edges();
var s = vis.visualStyle();
same(s.global.backgroundColor, style.global.backgroundColor);
@@ -531,6 +531,28 @@
});
+ test("Visual Style--transparent nodes", function() {
+ vis.visualStyle({
+ global: { backgroundColor: "transparent" },
+ nodes: { color: "transparent" },
+ edges: { color: "transparent" }
+ });
+ same(vis.visualStyle().global.backgroundColor, "#ffffff", "Visual Style
backgroundColor color");
+ same(vis.visualStyle().nodes.color, "transparent", "Visual Style nodes
color");
+ same(vis.visualStyle().edges.color, "#ffffff", "Visual Style edges
color");
+
+ var nodes = vis.nodes(), edges = vis.edges();
+
+ $.each(nodes, function(i, n) {
+ same(n.color, "transparent", "Node color");
+ });
+ $.each(edges, function(i, e) {
+ same(e.color, "#ffffff", "Edge color");
+ });
+
+ vis.visualStyle(style);
+ });
+
test("Get empty Visual Style Bypass", function() {
var bypass = vis.visualStyleBypass();
ok(bypass.nodes != null);
Modified: cytoscapeweb/trunk/cytoscapeweb/lib/AlivePDF.swc
===================================================================
(Binary files differ)
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
2011-07-27 19:52:38 UTC (rev 26291)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
2011-07-27 20:27:54 UTC (rev 26292)
@@ -245,7 +245,7 @@
obj.group = Groups.NODES;
obj.shape = n.shape;
obj.size = n.height;
- obj.color = Utils.rgbColorAsString(n.fillColor);
+ obj.color = n.props.transparent ? "transparent" :
Utils.rgbColorAsString(n.fillColor);
obj.borderColor = Utils.rgbColorAsString(n.lineColor);
obj.borderWidth = n.lineWidth;
// obj.degree = n.degree;
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/PDFExporter.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/PDFExporter.as
2011-07-27 19:52:38 UTC (rev 26291)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/PDFExporter.as
2011-07-27 20:27:54 UTC (rev 26292)
@@ -141,7 +141,7 @@
var orientation:String = Orientation.PORTRAIT;
// Create the PFD document with 1 page:
- var pdf:PDF = new PDF(orientation, Unit.POINT, true, size);
+ var pdf:PDF = new PDF(orientation, Unit.POINT, size);
pdf.setDisplayMode(Display.FULL_PAGE, Layout.SINGLE_PAGE);
var page:Page = new Page(orientation, Unit.POINT, size);
pdf.addPage(page);
@@ -304,7 +304,7 @@
// So we just draw a bigger shape behind the node:
pdf.lineStyle(gc, gw, 0, Math.min(glow.alpha, n.alpha),
WindingRule.NON_ZERO, Blend.NORMAL,
null, Caps.ROUND, Joint.ROUND);
- drawNode(pdf, n.shape, np.x, np.y, nw, nh);
+ drawNodeShape(pdf, n.shape, np.x, np.y, nw, nh);
}
}
@@ -314,9 +314,10 @@
pdf.lineStyle(new RGBColor(n.lineColor), n.lineWidth*_scale,
0, n.alpha,
WindingRule.NON_ZERO, Blend.NORMAL, null,
Caps.ROUND, Joint.ROUND);
- pdf.beginFill(new RGBColor(n.fillColor));
- drawNode(pdf, n.shape, np.x, np.y, nw, nh);
- pdf.endFill();
+
+ if (!n.props.transparent) pdf.beginFill(new
RGBColor(n.fillColor));
+ drawNodeShape(pdf, n.shape, np.x, np.y, nw, nh);
+ if (!n.props.transparent) pdf.endFill();
}
}
@@ -391,15 +392,16 @@
}
}
- private function drawNode(pdf:PDF, shape:String, x:Number, y:Number,
w:Number, h:Number):void {
+ private function drawNodeShape(pdf:PDF, shape:String, x:Number,
y:Number, w:Number, h:Number):void {
var r:Rectangle = new Rectangle(x-w/2, y-h/2, w, h);
switch (shape) {
case NodeShapes.ELLIPSE:
- pdf.drawCircle(x, y, h/2);
+ pdf.drawEllipse(x, y, w/2, h/2);
break;
case NodeShapes.ROUND_RECTANGLE:
- pdf.drawRoundRect(r, w/4);
+ var ew:Number = NodeShapes.getRoundRectCornerRadius(w,
h);
+ pdf.drawRoundRect(r, ew);
break;
default:
var points:Array = NodeShapes.getDrawPoints(r, shape);
@@ -444,7 +446,7 @@
if (shape === ArrowShapes.CIRCLE) {
var center:Point = points[0];
pdf.drawCircle(center.x, center.y, diameter/2);
- pdf.end(false);
+ pdf.end();
} else if (shape === ArrowShapes.ARROW) {
var p1:Point = points[0];
var c1:Point = points[1];
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
2011-07-27 19:52:38 UTC (rev 26291)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/converters/SVGExporter.as
2011-07-27 20:27:54 UTC (rev 26292)
@@ -308,7 +308,7 @@
// The current version of AlivePDF does not support
glows, gradients, etc.
// So we just draw a bigger shape behind the node:
svg += '<g fill="none" stroke="'+lc+'"
stroke-linejoin="round" stroke-width="'+lw+'" stroke-linecap="butt"
stroke-opacity="'+a+'">';
- svg += drawNodeShape(n.shape, np.x, np.y, w, h);
+ svg += drawNodeShape(n.shape, np.x, np.y, w, h, true);
svg += '</g>';
}
}
@@ -321,10 +321,10 @@
w = (n.width - n.lineWidth) * _scale;
h = (n.height - n.lineWidth) * _scale;
- svg += '<g class="'+NODE_SHAPE_CLASS+'" fill="'+c+'"
fill-opacity="'+a+'" stroke="'+lc+'" stroke-linejoin="round"
stroke-width="'+lw+'" stroke-linecap="butt" stroke-opacity="'+a+'">';
+ svg += '<g class="'+NODE_SHAPE_CLASS+'" fill="'+c+'"
opacity="'+a+'" stroke="'+lc+'" stroke-linejoin="round" stroke-width="'+lw+'"
stroke-linecap="butt" stroke-opacity="'+a+'">';
// Basic node shape
- svg += (nodeSvgShape = drawNodeShape(n.shape, np.x, np.y, w,
h));
+ svg += (nodeSvgShape = drawNodeShape(n.shape, np.x, np.y, w,
h, n.props.transparent));
// Node image, if any:
img = _imgCache.getImage(n.props.imageUrl);
@@ -428,16 +428,17 @@
return svg;
}
- private function drawNodeShape(shape:String, x:Number, y:Number,
w:Number, h:Number):String {
+ private function drawNodeShape(shape:String, x:Number, y:Number,
w:Number, h:Number, transparent:Boolean):String {
var svg:String = '';
var r:Rectangle = new Rectangle(x-w/2, y-h/2, w, h);
+ var fillOpacity:String = transparent ? ' fill-opacity="0"' : '';
switch (shape) {
case NodeShapes.ELLIPSE:
- svg += '<circle cx="'+x+'" cy="'+y+'" r="'+(h/2)+'"/>';
+ svg += '<circle cx="'+x+'" cy="'+y+'"
r="'+(h/2)+'"'+fillOpacity+'/>';
break;
case NodeShapes.RECTANGLE:
- svg += '<rect x="'+(x-w/2)+'" y="'+(y-h/2)+'"
width="'+w+'" height="'+h+'"/>';
+ svg += '<rect x="'+(x-w/2)+'" y="'+(y-h/2)+'"
width="'+w+'" height="'+h+'"'+fillOpacity+'/>';
break;
case NodeShapes.ROUND_RECTANGLE:
// corners (and control points), clockwise:
@@ -457,13 +458,14 @@
' L'+(x4+w4)+','+(y4) +
' Q'+(x4)+','+(y4)+' '+(x4)+','+(y4-h4) +
' L'+(x1)+','+(y1+h4) +
- ' Q'+(x1)+','+(y1)+'
'+(x1+w4)+','+(y1)+'"/>';
+ ' Q'+(x1)+','+(y1)+' '+(x1+w4)+','+(y1)+'"'+
+ fillOpacity+'/>';
break;
default:
var points:Array = NodeShapes.getDrawPoints(r, shape);
var pp:String = '';
for (var i:int = 0; i < points.length; i += 2) pp +=
(points[i]+','+points[i+1]+' ');
- svg += '<polygon points="'+pp+'"/>';
+ svg += '<polygon points="'+pp+'"'+fillOpacity+'/>';
}
return svg;
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/GraphUtils.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/GraphUtils.as
2011-07-27 19:52:38 UTC (rev 26291)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/GraphUtils.as
2011-07-27 20:27:54 UTC (rev 26292)
@@ -96,12 +96,15 @@
$each(data.nodes, function(i:uint, n:NodeSprite):void {
if (!isFilteredOut(n)) {
// The node size (its shape must have the same height
and width; e.g. a circle)
- var ns:Number = n.height;
+ var w:Number = n.width;
+ var h:Number = n.height;
+ var w2:Number = w/2, h2:Number = h/2;
+
// Verify MIN and MAX x/y again:
- minX = Math.min(minX, (n.x - ns/2));
- minY = Math.min(minY, (n.y - ns/2));
- maxX = Math.max(maxX, (n.x + ns/2));
- maxY = Math.max(maxY, (n.y + ns/2));
+ minX = Math.min(minX, (n.x - w2));
+ minY = Math.min(minY, (n.y - h2));
+ maxX = Math.max(maxX, (n.x + w2));
+ maxY = Math.max(maxY, (n.y + h2));
// Consider the LABELS bounds, too:
var lbl:TextSprite = n.props.label;
@@ -116,6 +119,7 @@
}
});
+ // Also mesure edge bounds:
$each(data.edges, function(i:uint, e:EdgeSprite):void {
if (!isFilteredOut(e)) {
// Edge LABELS first, to avoid checking edges that are
already inside the bounds:
@@ -138,7 +142,7 @@
var p2:Point = e.props.$points.end;
// Alwasys check a few points along the bezier
curve to see
// if any of them is out of the bounds:
- var fractions:Array, mp:Point, f:Number;
+ var mp:Point, f:Number;
if (e.source === e.target) {
// Loop...
@@ -148,9 +152,7 @@
mp = new Point();
var w:Number = e.lineWidth/2;
- fractions = [0.1, 0.2, 0.4, 0.6, 0.8, 0.9];
-
- for each (f in fractions) {
+ for (f = 0.1; f < 1.0; f += 0.1) {
Geometry.cubicCoeff(p1, c2, c1, p2,
cc1, cc2, cc3);
mp = Geometry.cubic(f, p1, cc1, cc2,
cc3, mp);
minX = Math.min(minX, mp.x - w);
@@ -159,9 +161,7 @@
maxY = Math.max(maxY, mp.y + w);
}
} else {
- fractions = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6,
0.7, 0.8, 0.9];
-
- for each (f in fractions) {
+ for (f = 0.1; f < 1.0; f += 0.1) {
mp = Utils.bezierPoint(p1, p2, c1, f);
minX = Math.min(minX, mp.x);
maxX = Math.max(maxX, mp.x);
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/VisualProperties.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/VisualProperties.as
2011-07-27 19:52:38 UTC (rev 26291)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/VisualProperties.as
2011-07-27 20:27:54 UTC (rev 26292)
@@ -185,6 +185,9 @@
// Add alpha, which is required by for most of the
colors:
if (name != BACKGROUND_COLOR) color += 0xff000000;
val = color;
+ } else if (name === BACKGROUND_COLOR) {
+ // background cannot be transparent; will be white
instead
+ val = 0xffffff;
}
} else if (isNumber(name)) {
val = Number(value);
@@ -215,7 +218,7 @@
if (value === undefined) value = null;
if (isColor(name)) {
- value = Utils.rgbColorAsString(uint(value));
+ value = name === NODE_COLOR && value < 0 ? "transparent" :
Utils.rgbColorAsString(uint(value));
} else if (isNumber(name)) {
value = Number(value);
} else if (isString(name)) {
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
2011-07-27 19:52:38 UTC (rev 26291)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
2011-07-27 20:27:54 UTC (rev 26292)
@@ -82,9 +82,16 @@
/** @inheritDoc */
public override function render(d:DataSprite):void {trace("RENDER
NODE: " + d.data.id);
- var lineAlpha:Number = d.lineAlpha;
+ // 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.w;
var h:Number = d.h;
@@ -97,23 +104,22 @@
// Just to prevent rendering issues when drawing large bitmaps on
small nodes:
d.cacheAsBitmap = d.props.imageUrl != null;
- if (lineAlpha > 0 && d.lineWidth > 0) {
+ if (lineAlpha > 0 && lineWidth > 0) {
var pixelHinting:Boolean = d.shape ===
NodeShapes.ROUND_RECTANGLE;
- g.lineStyle(d.lineWidth, d.lineColor, lineAlpha, pixelHinting);
+ g.lineStyle(lineWidth, lineColor, lineAlpha, pixelHinting);
}
- if (fillAlpha > 0) {
- // 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
- 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, w, h);
- }
+ // 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 {
Modified:
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/view/render/ImageCacheTest.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/view/render/ImageCacheTest.as
2011-07-27 19:52:38 UTC (rev 26291)
+++
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/view/render/ImageCacheTest.as
2011-07-27 20:27:54 UTC (rev 26292)
@@ -101,7 +101,7 @@
}
public function testDispose():void {
- function runTest():void {trace(_cache.size)
+ function runTest():void {
// Initial state:
assertTrue(_cache.size > 0);
assertFalse(_cache.isLoading());
--
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.