public class ScreenImageSVG extends Object
a) an entire component b) a region of the component c) the entire desktop d) a region of the desktop
The first two use the Swing paint() method to draw the component image to the BufferedImage. The latter two use the AWT Robot to create the BufferedImage.
The created image can then be saved to a file by usig the writeImage(...) method. The type of file must be supported by the ImageIO write method.
Although this class was originally designed to create an image of a component on the screen it can be used to create an image of components not displayed on a GUI. Behind the scenes the component will be given a size and the component will be layed out. The default size will be the preferred size of the component although you can invoke the setSize() method on the component before invoking a createImage(...) method. The default functionality should work in most cases. However the only foolproof way to get a image to is make sure the component has been added to a realized window with code something like the following:
JFrame frame = new JFrame(); frame.setContentPane( someComponent ); frame.pack(); ScreenImage.createImage( someComponent );
Constructor and Description |
---|
ScreenImageSVG() |
Modifier and Type | Method and Description |
---|---|
static org.jfree.graphics2d.svg.SVGGraphics2D |
createImage(JComponent component)
Create a BufferedImage for Swing components.
|
static org.jfree.graphics2d.svg.SVGGraphics2D |
createImage(JComponent component,
Rectangle region)
Create a BufferedImage for Swing components.
|
public static org.jfree.graphics2d.svg.SVGGraphics2D createImage(JComponent component)
component
- Swing component to create image frompublic static org.jfree.graphics2d.svg.SVGGraphics2D createImage(JComponent component, Rectangle region)
component
- Swing component to create image fromregion
- The region of the component to be captured to an imageCopyright © 2020–2022 Leibniz Institute for Natural Product Research and Infection Biology - Hans Knöll Institute (HKI). All rights reserved.