Package repast.simphony.ui.widget
Class SnapshotTaker
- java.lang.Object
-
- repast.simphony.ui.widget.SnapshotTaker
-
public class SnapshotTaker extends Object
Takes a snapshot of a JComponent.- Author:
- Nick Collier
-
-
Constructor Summary
Constructors Constructor Description SnapshotTaker(JComponent comp)
SnapshotTaker(Imageable imageable)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Action
createSnapshotAction(JComponent comp)
Creates an Action that will take a snapshot fo the specified JComponent when triggered.void
save(File file, String imageFormat)
Saves the snapshot to the specified file and in the specified format.void
takeSnapshot(JComponent parent)
Takes a snapshot of the Imageable associated with this Snapshot taker.
-
-
-
Field Detail
-
JPEG
public static final String JPEG
- See Also:
- Constant Field Values
-
JPG
public static final String JPG
- See Also:
- Constant Field Values
-
TIFF
public static final String TIFF
- See Also:
- Constant Field Values
-
TIF
public static final String TIF
- See Also:
- Constant Field Values
-
PNG
public static final String PNG
- See Also:
- Constant Field Values
-
BMP
public static final String BMP
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SnapshotTaker
public SnapshotTaker(Imageable imageable)
-
SnapshotTaker
public SnapshotTaker(JComponent comp)
-
-
Method Detail
-
takeSnapshot
public void takeSnapshot(JComponent parent) throws IOException
Takes a snapshot of the Imageable associated with this Snapshot taker. This will display a file dialog.- Parameters:
parent
- the component to center the file dialog over- Throws:
IOException
- if there is an error taking the snapshot
-
save
public void save(File file, String imageFormat) throws IOException
Saves the snapshot to the specified file and in the specified format.- Parameters:
file
- the file to save the image toimageFormat
- the image format. One of "bmp", "jpg", "tif", or "png".- Throws:
IOException
- if there is an error saving the snapshot
-
createSnapshotAction
public static Action createSnapshotAction(JComponent comp)
Creates an Action that will take a snapshot fo the specified JComponent when triggered.- Parameters:
comp
- the component to take a snapshot of.- Returns:
- an Action that will take a snapshot fo the specified JComponent when triggered.
-
-