|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectComponent
Container
JComponent
ImageProperties
ImageFileProperties
public class ImageFileProperties
A panel showing the properties of an image file. This is different than
ImageProperties, which shows the properties of a RenderedImage.
The panel contains the following tabs:
IIOMetadataPanel.ImagePane.
All setImage methods defined in this class may be slow because they involve I/O
operations. It is recommended to invoke them from an other thread than the Swing thread.
Using this component together with a FileChooser
This component can be registered to a JFileChooser for listening to change events.
When the file selection change, the propertyChange(PropertyChangeEvent) method is
automatically invoked. The default implementation invokes in turn setImage(File) in
a background thread. This allows this ImageFileProperties to be updated automatically
when the user selection changed. Example:
ImageFileChooser chooser = new ImageFileChooser("png");
ImageFileProperties properties = new ImageFileProperties();
chooser.addPropertyChangeListener(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY, properties);
//
// Add the FileChooser and ImageFileProperties to some panel with the layout constraints
// of your choice. The example below uses BorderLayout in such a way that, when resizing
// the panel, only the properties pane is resized.
//
JPanel panel = new JPanel(new BorderLayout());
panel.add(this, BorderLayout.WEST);
panel.add(properties, BorderLayout.CENTER);
ImageProperties,
ImageFileChooser,
Serialized Form
| display/geotk-widgets-swing (download) | View source code for this class |
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary |
|---|
| Fields inherited from class ImageProperties |
|---|
viewer |
| Fields inherited from class JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
ImageFileProperties()
Creates a new instance of ImageFileProperties with no image. |
|
ImageFileProperties(File file)
Creates a new instance of ImageFileProperties initialized to the given file. |
|
| Method Summary | |
|---|---|
Dimension |
getPreferredThumbnailSize()
Returns the preferred size of the thumbnail. |
void |
propertyChange(PropertyChangeEvent event)
Invoked when the state of a JFileChooser (or any other component at caller choice)
changed. |
void |
setImage(File file)
Sets the specified file as the source of metadata and thumbnails. |
void |
setImage(ImageReader reader)
Sets the specified image reader as the source of metadata and thumbnails. |
void |
setImage(ImageReader reader,
int imageIndex)
Sets the specified image reader as the source of metadata and thumbnails, reading the information at the given image index. |
void |
setImageInput(Object input)
Sets the specified image input as the source of metadata and thumbnails. |
void |
setImageLater(Object input)
Reads the metadata and thumbnails from the given image input in a background thread. |
void |
setPreferredThumbnailSize(Dimension size)
Sets the preferred size of the thumbnail. |
static void |
show(File image)
Shows the properties for the specified image file in a frame. |
| Methods inherited from class ImageProperties |
|---|
commitEdit, setImage, setImage, setImage, show, showDialog |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ImageFileProperties()
ImageFileProperties with no image.
One of setImage(...) methods must be
invoked in order to set the properties source.
public ImageFileProperties(File file)
throws IOException
ImageFileProperties initialized to the given file.
file - The image file.
IOException - If the file is not found, or no suitable image reader is found for the
given file, or if an error occurred while reading the metadata or the thumbnails.| Method Detail |
|---|
public void setImage(ImageReader reader,
int imageIndex)
throws IOException
Resources management
This method does not close the
Image Input Stream (if any).
It is caller responsibility to dispose reader resources (including closing the
input stream) after this method call, if desired.
Thread safety
This method can be invoked from any thread. Actually it is recommended to invoke
it from an other thread than the Swing one.
reader - The image reader from which to read the informations.imageIndex - The index of the image to read (usually 0).
IOException - If an error occurred while reading the metadata or the thumbnails.
public void setImage(ImageReader reader)
throws IOException
The default implementation delegates to setImage(ImageReader, int) with
an image index of 0. Subclasses should override this method if they
want to choose automatically an image index depending on the format and the input.
Thread safety
This method can be invoked from any thread. Actually it is recommended to invoke
it from an other thread than the Swing one.
reader - The image reader from which to read the informations.
IOException - If an error occurred while reading the metadata or the thumbnails.
public void setImage(File file)
throws IOException
JFileChooser
is associated to this widget as described in the class javadoc.
The default implementation delegates to setImageInput(Object), but subclasses
can override if they want to perform additional processing.
Thread safety
This method can be invoked from any thread. Actually it is recommended to invoke
it from an other thread than the Swing one.
file - The image file.
IOException - If the file is not found, or no suitable image reader is found for the
given file, or if an error occurred while reading the metadata or the thumbnails.
public void setImageInput(Object input)
throws IOException
ImageReader for the given input as below:
ImageReader, then it is used
directly. Note that this method does not close the image
input stream after usage, as specified by setImage(ImageReader, int).setImage(ImageReader), then disposes the resources
(reader and input stream).
Then, this method delegates to setImage(ImageReader).
Thread safety
This method can be invoked from any thread. Actually it is recommended to invoke
it from an other thread than the Swing one.
input - The image input.
IOException - If the file is not found, or no suitable image reader is found for the
given input, or if an error occurred while reading the metadata or the thumbnails.public void setImageLater(Object input)
setImage(File) method if the given input is a
file, or to setImageInput(Object) otherwise, from a background thread. If
the operation fails, then the IOException is painted in the quicklook area.
NOTE: This method must be invoked from the Swing thread.
input - The image input, or null if none.public Dimension getPreferredThumbnailSize()
public void setPreferredThumbnailSize(Dimension size)
size - The new preferred thumbnail size.public void propertyChange(PropertyChangeEvent event)
JFileChooser (or any other component at caller choice)
changed. If the event property name is
"SelectedFileChangedProperty", then this method invokes
setImage(File) in a background thread.
This method is invoked automatically when this ImageFileProperties is registered
to a JFileChooser as an PropertyChangeListener. It can be invoked from
the Swing thread only.
propertyChange in interface PropertyChangeListenerevent - The property change event.@Debug public static void show(File image)
image - The image to display in a frame.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||