Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Only image output (Read 4681 times)
iazeibak
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!
A little.

Posts: 14
Joined: Jul 27th, 2007
Only image output
Aug 17th, 2007 at 9:31pm
Print Post  
I am fairly new to JDiagram and have a question...

I would like to know if there is any way to only output the diagram as an image, and not display it in a frame or applet at all?

Thank you.
  

Jdiagram-ing,&&&&Issam
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Only image output
Reply #1 - Aug 18th, 2007 at 8:55am
Print Post  
Hi,

The FlowChart.createImage() method creates an Image object and renders the diagram in it. You can save the image to a file or stream using the ImageIO.write() method.

Stoyan
  
Back to top
 
IP Logged
 
iazeibak
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!
A little.

Posts: 14
Joined: Jul 27th, 2007
Re: Only image output
Reply #2 - Aug 29th, 2007 at 3:15pm
Print Post  
Oh no, I definitely have this method creating an image output. It is what is producing the PNG version of my my diagram.

I'm pretty much a newbie to Swing too, I guess, otherwise this may not be a particularly JDiagram issue. Since Jdiagram classes extend JFrame, I can't seem to output an image without actually opening an applet or a frame first, having it draw there then outputting the image. When I try it I simple get a blank image.

My ideal situation: Have a command line prompt me for some xml file and have the program produce a bitmap image in some destination folder. No frames or applets would open. Is it possible?

Please excuse my lack of knowledge in the area of applet/frames display... And thanks.
  

Jdiagram-ing,&&&&Issam
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Only image output
Reply #3 - Aug 30th, 2007 at 7:10am
Print Post  
Hi,

This works fine here, could you try it?

Code
Select All
public static void main(String[] args)
{
	FlowChart fc = new FlowChart();
	Box b = fc.createBox(30, 30, 80, 80);

	Image img = fc.createImage();
	if (img == null)
		JOptionPane.showMessageDialog(new JFrame(), "Error!!!");

	try {
		// Save as PNG
		File file = new File("d:\\newimage.png");
		ImageIO.write((RenderedImage) img, "png", file);
	} catch (FileNotFoundException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	} catch (IOException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}
}
 



Stoyan
  
Back to top
 
IP Logged
 
iazeibak
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!
A little.

Posts: 14
Joined: Jul 27th, 2007
Re: Only image output
Reply #4 - Sep 18th, 2007 at 2:56pm
Print Post  
Thanks! this worked perfectly.
  

Jdiagram-ing,&&&&Issam
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint