net.wotonomy.ui.swing.util
Class WindowGrabber

java.lang.Object
  extended by net.wotonomy.ui.swing.util.WindowGrabber

public class WindowGrabber
extends java.lang.Object

WindowGrabber is a collection of static utility methods for taking screen shots of lightweight containers. All components that are not native peers will be drawn to a bitmap that will be run-length compressed (LZW encoding, GIF format) and written to the specified file or output stream.

Any Swing/JFC or IFC window is a good candidate for use with these methods. The component is not expected to contain more than 256 colors (the maximum that GIF allows). While there is a color depth limitation, the compression is lossless, with no blurs or bleeding color.

Version:
$Revision: 904 $ $Date: 2006-02-18 23:19:05 +0000 (Sat, 18 Feb 2006) $
Author:
michael@mpowers.net

Constructor Summary
WindowGrabber()
           
 
Method Summary
static boolean grab(java.awt.Component aComponent, java.io.OutputStream anOutputStream)
          Captures the screen contents of the specified component, and write it to a file with the specified name.
static boolean grab(java.awt.Component aComponent, java.lang.String aFileName)
          Captures the screen contents of the specified component, and write it to a file with the specified name.
static void main(java.lang.String[] argv)
          Captures images of any Swing window component classes specified as parameters.
protected static void processFilenames(java.lang.String path, java.lang.String[] filenames)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WindowGrabber

public WindowGrabber()
Method Detail

grab

public static boolean grab(java.awt.Component aComponent,
                           java.lang.String aFileName)
Captures the screen contents of the specified component, and write it to a file with the specified name.

Parameters:
aComponent - a lightweight component or container.
aFileName - the name of the file to write, optionally preceded by path.
Returns:
True if the file was successfully written, false if there was an error. Errors are written to the standard error stream.

grab

public static boolean grab(java.awt.Component aComponent,
                           java.io.OutputStream anOutputStream)
Captures the screen contents of the specified component, and write it to a file with the specified name.

Parameters:
aComponent - a lightweight component or container.
anOutputStream - an output stream to which the image will be written.
Returns:
True if the image was successfully written, false if there was an error. Errors are written to the standard error stream.

processFilenames

protected static void processFilenames(java.lang.String path,
                                       java.lang.String[] filenames)

main

public static void main(java.lang.String[] argv)
Captures images of any Swing window component classes specified as parameters. If created, image file will have the same name as the corresponding class file, but with a ".gif" extension.

Parameters:
argv - a list of filenames or directory names.


Copyright © 2006 null. All Rights Reserved.