Class SnapshotTool

java.lang.Object
org.opensourcephysics.tools.SnapshotTool
All Implemented Interfaces:
Tool

public class SnapshotTool extends 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 Details

    • setLocale

      public static void setLocale(Locale locale)
    • getString

      public static String getString(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)
      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)
    • saveImage

      public boolean saveImage(String filename, 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(String filename, Component component, 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(String filename, Component component, 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(String format)
    • copyImage

      public void copyImage(Image image)
      Copies the specified image to the system clipboard.
      Parameters:
      image - the image to copy
    • getClipboardImage

      public Image getClipboardImage()
      Returns the image on the clipboard, if any.
      Returns:
      the image, or null if none found
    • copyImage

      public void copyImage(Component component)
      Copies an image of a component to the clipboard
      Parameters:
      component - the component to copy
    • printImage

      public void printImage(Component component)
      Prints an image of a component
      Parameters:
      component - the component to print