Author: clopes
Date: 2012-03-26 12:19:14 -0700 (Mon, 26 Mar 2012)
New Revision: 28649
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
Log:
Fixed bug #2696: Node image cropped if proportions are the same
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
2012-03-26 19:01:28 UTC (rev 28648)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/render/NodeRenderer.as
2012-03-26 19:19:14 UTC (rev 28649)
@@ -231,13 +231,25 @@
var bd:BitmapData = _imgCache.getImage(url);
if (bd != null) {
- var bmpSize:Number = Math.min(bd.height, bd.width);
- var scale:Number = Math.max(w, h)/bmpSize;
+ // Rescale te image, if necessary
+ var scale:Number = 1;
+ var iw:Number = bd.width;
+ var ih:Number = bd.height;
+ var nodeEdge:Number = w;
+ var imgEdge:Number = iw;
+
+ if (h/w > ih/iw) {
+ nodeEdge = h;
+ imgEdge = ih;
+ }
+
+ scale = nodeEdge / imgEdge;
var m:Matrix = new Matrix();
m.scale(scale, scale);
m.translate(-(bd.width*scale)/2, -(bd.height*scale)/2);
+ // Draw the image as background
d.graphics.beginBitmapFill(bd, m, false, true);
drawShape(d, d.shape, new Rectangle(-w/2, -h/2, w, h));
d.graphics.endFill();
--
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.