Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic diagram.createImage(800,600) saves empty image ? (Read 3003 times)
jay
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 59
Joined: Feb 4th, 2009
diagram.createImage(800,600) saves empty image ?
Mar 9th, 2009 at 11:50am
Print Post  
hi stoyo,


         I am using following way to save graph image as it was mentioned in one of the forum reply.

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

          try {
                  // Save as PNG
                  File file = new File("C:\\Image.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();
          }

But it saves an image with white area and nothing else in it.

can you please explain, Where the things are going 
wrong ?

Thank you...
  
Back to top
 
IP Logged
 
jay
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 59
Joined: Feb 4th, 2009
Re: diagram.createImage(800,600) saves empty image
Reply #1 - Mar 9th, 2009 at 12:47pm
Print Post  
Hi,

   I have added diagramView to scrollPane and scorllPane to a Panel.
   it is looks like following;

Diagram Diag= new Diagram();
DiagramView diagView = new DiagramView();
diagView.setDiagram(Diag);
scrollPane = new JScrollPane(diagView);
mainPanel = new JPanel();mainPanel.add(scrollPane);
   
   Is this affecting any where to createImage() ?

Thank you
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: diagram.createImage(800,600) saves empty image
Reply #2 - Mar 9th, 2009 at 2:36pm
Print Post  
BufferedImage createImage(int pixelWidth, int pixelHeight) is an internal method, how have you managed to call it at all? You should use the no-args createImage() method instead.

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


I love YaBB 1G - SP1!

Posts: 59
Joined: Feb 4th, 2009
Re: diagram.createImage(800,600) saves empty image
Reply #3 - Mar 10th, 2009 at 5:05am
Print Post  
Hi stoyo,



sorry , I was using diagram view method  diagView.createImage(800,600) ;

           Now I am using diagram.createImage() and it is working fine. But The image save shows a big image with minute node size. so the graph area is appearing wide and graph is appearing very small in it.  Would you please suggest how this could be overcome.

Thank you.




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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: diagram.createImage(800,600) saves empty image
Reply #4 - Mar 10th, 2009 at 9:02am
Print Post  
Hi Jay,

Before exporting call setBounds with a smaller rectangle as argument or call resizetoFitItems.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jay
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 59
Joined: Feb 4th, 2009
Re: diagram.createImage(800,600) saves empty image
Reply #5 - Mar 10th, 2009 at 10:11am
Print Post  
Hi stoyo,

           This works exact as needed to save graph image.

Thanks a lot....
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint