org.opensourcephysics.tools
Class SnapshotTool

java.lang.Object
  extended by org.opensourcephysics.tools.SnapshotTool
All Implemented Interfaces:
java.rmi.Remote, Tool

public class SnapshotTool
extends java.lang.Object
implements Tool

This provides a simple way to capture screen images.

Version:
1.0
Author:
Francisco Esquembre (http://fem.um.es), Wolfgang Christian

Method Summary
 void copyImage(java.awt.Component component)
          Copies an image of a component to the clipboard
 void copyImage(java.awt.Image image)
          Copies the specified image to the system clipboard.
protected static void createChooser()
           
 java.awt.Image getClipboardImage()
          Returns the image on the clipboard, if any.
static java.lang.String getString(java.lang.String key)
           
static SnapshotTool getTool()
          Gets the shared SnapshotTool.
static boolean isImageFormatSupported(java.lang.String format)
           
 void printImage(java.awt.Component component)
          Prints an image of a component
 boolean saveImage(java.lang.String filename, java.awt.Component component)
          Saves the image produced by a component
 boolean saveImage(java.lang.String filename, java.awt.Component component, java.io.OutputStream output)
          Saves the image produced by a component to an output stream
 boolean saveImage(java.lang.String filename, java.awt.Component component, java.io.OutputStream output, double scale)
          Saves the (possibly scaled) image produced by a component to an output stream
 void send(Job job, Tool replyTo)
          Sends a job to this tool and specifies a tool to reply to.
static void setLocale(java.util.Locale locale)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setLocale

public static void setLocale(java.util.Locale locale)

getString

public static java.lang.String getString(java.lang.String key)

getTool

public static SnapshotTool getTool()
Gets the shared SnapshotTool.

Returns:
the shared SnapshotTool

createChooser

protected static void createChooser()

send

public void send(Job job,
                 Tool replyTo)
          throws java.rmi.RemoteException
Sends a job to this tool and specifies a tool to reply to.

Specified by:
send in interface Tool
Parameters:
job - the Job
replyTo - the tool to notify when the job is complete (may be null)
Throws:
java.rmi.RemoteException

saveImage

public boolean saveImage(java.lang.String filename,
                         java.awt.Component component)
Saves the image produced by a component

Parameters:
filename - the name of a file
component - the component to get the image from
Returns:
true if the file was correctly saved

saveImage

public boolean saveImage(java.lang.String filename,
                         java.awt.Component component,
                         java.io.OutputStream output)
Saves the image produced by a component to an output stream

Parameters:
filename - the name of a file (the extension indicates the format). If null, teh user will be prompted for a name
component - the component to get the image from
output - An optional output stream to save to. If null the image is saved to a file
Returns:
true if the image was correctly saved

saveImage

public boolean saveImage(java.lang.String filename,
                         java.awt.Component component,
                         java.io.OutputStream output,
                         double scale)
Saves the (possibly scaled) image produced by a component to an output stream

Parameters:
filename - the name of a file (the extension indicates the format). If null, the user will be prompted for a name
component - the component to get the image from
output - An optional output stream to save to. If null the image is saved to a file
scale - A scale factor that resizes the image. A value of 1 uses the actual size.
Returns:
true if the image was correctly saved

isImageFormatSupported

public static boolean isImageFormatSupported(java.lang.String format)

copyImage

public void copyImage(java.awt.Image image)
Copies the specified image to the system clipboard.

Parameters:
image - the image to copy

getClipboardImage

public java.awt.Image getClipboardImage()
Returns the image on the clipboard, if any.

Returns:
the image, or null if none found

copyImage

public void copyImage(java.awt.Component component)
Copies an image of a component to the clipboard

Parameters:
component - the component to copy

printImage

public void printImage(java.awt.Component component)
Prints an image of a component

Parameters:
component - the component to print