Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic node.setImageAlign + diagram.setZoomFactor + node.setSelected(true) (Read 2102 times)
ChristianC
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Jun 24th, 2015
node.setImageAlign + diagram.setZoomFactor + node.setSelected(true)
Jun 24th, 2015 at 10:20pm
Print Post  
Hello,

on a ShapeNode I set an image and align it to the bootom right.

Code (Javascript)
Select All
diagramNode.setImageLocation("img/runner.png");
                        var ImageAlign = MindFusion.Diagramming.ImageAlign;
                        diagramNode.setImageAlign(ImageAlign.BottomRight);
 



The image is 32px 32px.

Later I change the ZoomFactor of the diagram. The image is resized correctly. It grows or shrinks, depending on the ZoomFactor.

The Problem occurs, when I call
Code (Javascript)
Select All
node.setSelected(true);
 



on the node containing the image. Then the image is resized "weirdly" back to its original size. Am I missing something? Is this a bug maybe? What can I do that the image stays with correct zoomfactor?

I really appreciate any help you can provide.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: node.setImageAlign + diagram.setZoomFactor + node.setSelected(true)
Reply #1 - Jun 25th, 2015 at 8:37am
Print Post  
Hi,

It's a bug; this should work around it:

Code
Select All
var Utils = MindFusion.Diagramming.Utils;
var GraphicsUnit = MindFusion.Drawing.GraphicsUnit;
ShapeNode.prototype.onUpdateVisuals = function ()
{
	var image = this.image;
	if (image && image.loaded)
	{
		var scale = GraphicsUnit.getPixel(this.parent.measureUnit);
		var imgDocSize = { x: image.image.width * scale, y: image.image.height * scale };
		var imgDocRect = Utils.getImageRect(this.bounds, imgDocSize, this.imageAlign);
		image.setBounds(imgDocRect, (this.rotateImage) ? this.rotationAngle : 0);
	}
}; 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
ChristianC
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Jun 24th, 2015
Re: node.setImageAlign + diagram.setZoomFactor + node.setSelected(true)
Reply #2 - Jun 25th, 2015 at 8:44am
Print Post  
Thanks again. You rock my world Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint