edu.ntnu.ecosim.visual
Class ScreenImage

java.lang.Object
  extended by edu.ntnu.ecosim.visual.ScreenImage

public class ScreenImage
extends java.lang.Object

This class is NOT the work of Martin Børke, but is copied from http://www.discoverteenergy.com/files/ScreenImage.java The original author allows for usage of the code.


Constructor Summary
ScreenImage()
           
 
Method Summary
static java.awt.image.BufferedImage createImage(javax.swing.JComponent component, java.awt.Rectangle region, java.lang.String fileName)
          Create a BufferedImage for Swing components.
static java.awt.image.BufferedImage createImage(javax.swing.JComponent component, java.lang.String fileName)
          Create a BufferedImage for Swing components.
static void writeImage(java.awt.image.BufferedImage image, java.lang.String fileName)
          Write a BufferedImage to a File.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScreenImage

public ScreenImage()
Method Detail

createImage

public static java.awt.image.BufferedImage createImage(javax.swing.JComponent component,
                                                       java.lang.String fileName)
                                                throws java.io.IOException
Create a BufferedImage for Swing components. The entire component will be captured to an image.

Parameters:
component - Swing component to create image from
fileName - name of file to be created or null
Returns:
image the image for the given region
Throws:
java.io.IOException - if an error occurs during writing

createImage

public static java.awt.image.BufferedImage createImage(javax.swing.JComponent component,
                                                       java.awt.Rectangle region,
                                                       java.lang.String fileName)
                                                throws java.io.IOException
Create a BufferedImage for Swing components. All or part of the component can be captured to an image.

Parameters:
component - Swing component to create image from
region - The region of the component to be captured to an image
fileName - name of file to be created or null
Returns:
image the image for the given region
Throws:
java.io.IOException - if an error occurs during writing

writeImage

public static void writeImage(java.awt.image.BufferedImage image,
                              java.lang.String fileName)
                       throws java.io.IOException
Write a BufferedImage to a File.

Parameters:
image - image to be written
fileName - name of file to be created
Throws:
java.io.IOException - if an error occurs during writing