Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to display an animated GIF in a ShapeNode (Read 3821 times)
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
How to display an animated GIF in a ShapeNode
Sep 26th, 2011 at 11:33am
Print Post  
Hello,

I have a problem with JDiagram 3.2.
I need to display an animated gif in a ShapeNode.
I have seen in your forum a topic about this done in february 2011, and I used the method : the image is displayed but is not animated.

Here is the code used :
[code]
Image img = Toolkit.getDefaultToolkit().getImage("D:\\workspace_eclipse\\VegaWebGraphe\\engrenage.gif");

// The next 3 lines (fake) are only here to allow the OS to load the image
// Asynchronous loading
int h = img.getHeight(_flowChart);
int w = img.getWidth(_flowChart);
h = w; w= h;

ShapeNode image = _flowChart.getFactory().createShapeNode((boxPosX(colonne+1) + ((LNG_TACHE_X - LNG_IMAGE_XY) / 2)),boxPosY(tac.getPalier()+1),LNG_IMAGE_XY, LNG_IMAGE_XY);

image.setImage(img);
image.setImageAlign(ImageAlign.Fit);
[/code]

Can you help us ?

Regards
« Last Edit: Sep 26th, 2011 at 12:37pm by JR »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to display an animated GIF in a ShapeNode
Reply #1 - Sep 26th, 2011 at 1:19pm
Print Post  
This is enough to show animated gif in my test project:

Code
Select All
Image img = Toolkit.getDefaultToolkit().getImage(
	"C:/Program Files/jdk1.6.0_13/demo/plugin/jfc/Java2D/src/images/duke.running.gif");
ShapeNode node = diagram.getFactory().createShapeNode(20, 20, 20, 20);
node.setImage(img); 



If it doesn't work for your image, either it has a single frame, or Java cannot load the rest of the frames for some reason.

Stoyan
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: How to display an animated GIF in a ShapeNode
Reply #2 - Sep 26th, 2011 at 2:11pm
Print Post  
I try with your code with your same gif file. It don't work.

I think I have found something.
My graph is not displayed directly.
I use the saveToString() method in a custom layout class and the loadFromString() method in the display class.

Maybe it is the reason ? Can you confirm this ?

I have to use this method because the graph must be generated in a servlet and displayed in your applet.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to display an animated GIF in a ShapeNode
Reply #3 - Sep 26th, 2011 at 5:17pm
Print Post  
Yes, the images are encoded as png when you save the diagram, so you will lose the animation. You will have to load them directly into the applet for the time being.

Stoyan
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: How to display an animated GIF in a ShapeNode
Reply #4 - Sep 29th, 2011 at 3:28pm
Print Post  
Hello,

Do you have an example to change (load) dynamically the gif file in your applet ?

Can I use javascript with your scripthelper or have I to extend your applet and do it myself in a new applet ?

Thanks.

Regards
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to display an animated GIF in a ShapeNode
Reply #5 - Sep 29th, 2011 at 4:28pm
Print Post  
Hi,

You can use the DiagramApplet.loadImage() method:

Code
Select All
applet = document.getElementById("jDiagApplet");
applet.getDiagram().getNodes().get(0).setImage(
	applet.loadImage("duke.running.gif")); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint