Interface ImagePane.ImageValue
- All Superinterfaces:
Observable<BufferedImage>, Observer<BufferedImage>, Sensor, Value<BufferedImage>
- Enclosing class:
ImagePane
Controls the image displayed in an ImagePane.
Image bytes set on the event dispatch thread, where the pane's byte[] ComponentValue always sets
them, are decoded in the background, unless ImagePane.async() is disabled, this value holding null until
their image is set, see set(byte[]).
- Author:
- Slav Boleslawski, Björn Darri Sigurðsson
-
Nested Class Summary
Nested classes/interfaces inherited from interface Value
Value.Builder<T,B>, Value.BuilderFactory, Value.Locked, Value.Notify, Value.Validator<T> -
Method Summary
Modifier and TypeMethodDescriptionvoidSets the image bytes, the pane'sbyte[]ComponentValue, displayed turned as their EXIF orientation says where enabled, seeImagePane.Builder.orient(boolean).voidset(byte @Nullable [] imageBytes, Consumer<BufferedImage> onImage) Sets the image bytes, seeset(byte[]), callingonImagewith their image once it is set: on the event dispatch thread when decoded in the background, before this method returns when decoded on the calling thread, so code acting on the image works the same either way.voidset(BufferedImage image, String format) voidReads the image bytes from the given file, on the calling thread, and sets them, seeset(byte[]).voidset(String imagePath, Consumer<BufferedImage> onImage) Reads the image bytes from the given file, on the calling thread, and sets them, seeset(byte[], Consumer).Methods inherited from interface Observable
changed, get, getOrThrow, getOrThrow, is, isNot, isNull, isNullable, optionalMethods inherited from interface Observer
addConsumer, addWeakConsumer, observer, removeConsumer, removeWeakConsumer, sensor, when, whenMethods inherited from interface Sensor
addListener, addWeakListener, removeListener, removeWeakListenerMethods inherited from interface Value
addValidator, clear, link, link, locked, observable, removeValidator, set, unlink, unlink, update, validate
-
Method Details
-
set
Sets the image bytes, the pane's
byte[]ComponentValue, displayed turned as their EXIF orientation says where enabled, seeImagePane.Builder.orient(boolean).Set on the event dispatch thread, the bytes are decoded in the background, unless
ImagePane.async()is disabled. The bytes are then the component value at once, while this value is cleared, null until the image is decoded, and notifies on the event dispatch thread when it is set. So code following this call, zooming or translating coordinates, finds no image: it belongs in a callback, seeset(byte[], Consumer), or a listener on this value. Bytes set while a decode is under way supersede it, as does an image set directly, the latest winning, a superseded decode aborted and its image discarded.Set elsewhere, or with
ImagePane.async()disabled, the bytes are decoded on the calling thread. The pane'sbyte[]ComponentValuesets them on the event dispatch thread, whichever thread it is set from, so they are decoded in the background whenever set via the component value, or the builder.Null or empty bytes clear the image, one set directly included. Bytes no image reader can read result in no image. An exception decoding them clears the image and is passed to the exception handler, see
ImagePane.Builder.onException(Consumer), which by default rethrows it, from this method when decoding on the calling thread.- Parameters:
imageBytes- the image bytes
-
set
Sets the image bytes, see
set(byte[]), callingonImagewith their image once it is set: on the event dispatch thread when decoded in the background, before this method returns when decoded on the calling thread, so code acting on the image works the same either way. Called once this value andImagePane.decoding()have notified. Where the bytes equal those already set, it is called with their image, once set, there being nothing to decode again.Not called where no image results, from empty bytes or bytes no image reader can read, where decoding fails, the exception handler's to handle, or where superseded before their image is set, by other bytes or an image set directly.
- Parameters:
imageBytes- the image bytesonImage- called with the image once it is set
-
set
Reads the image bytes from the given file, on the calling thread, and sets them, seeset(byte[]). A file on a slow share is best read in the background, its bytes then set on the event dispatch thread.- Parameters:
imagePath- the path from which to load the image- Throws:
IOException- in case reading the file failed
-
set
Reads the image bytes from the given file, on the calling thread, and sets them, seeset(byte[], Consumer).- Parameters:
imagePath- the path from which to load the imageonImage- called with the image once it is set- Throws:
IOException- in case reading the file failed
-
set
- Parameters:
image- the imageformat- the format- Throws:
IOException- in case of an exceptionIllegalArgumentException- in case no writer was found for the given format
-