Class ImageAccessor
java.lang.Object
org.tquadrat.foundation.config.spi.prefs.PreferenceAccessor<BufferedImage>
org.tquadrat.foundation.config.spi.prefs.BulkDataAccessorBase<BufferedImage>
org.tquadrat.foundation.config.spi.prefs.ImageAccessor
@ClassVersion(sourceVersion="$Id: ImageAccessor.java 911 2021-05-06 22:07:00Z tquadrat $")
@API(status=STABLE,
since="0.0.1")
public final class ImageAccessor
extends BulkDataAccessorBase<BufferedImage>
The implementation of
PreferenceAccessor
for instances of
BufferedImage.- Note:
-
- The image will be stored to the preferences as PNG, no matter what the original image format was!
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: ImageAccessor.java 911 2021-05-06 22:07:00Z tquadrat $
- Since:
- 0.0.1
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.config.spi.prefs.ImageAccessor"
-
Constructor Summary
ConstructorsConstructorDescriptionImageAccessor(String propertyName, Getter<BufferedImage> getter, Setter<BufferedImage> setter) Creates a newMapAccessorinstance. -
Method Summary
Modifier and TypeMethodDescriptionprotected final BufferedImagefromByteArray(Preferences node, byte[] source) Converts the givenbytearray to an instance of the property type.protected final byte[]toByteArray(Preferences node, BufferedImage source) Converts the given instance of the property type into abytearray.Methods inherited from class org.tquadrat.foundation.config.spi.prefs.BulkDataAccessorBase
readPreference, writePreferenceMethods inherited from class org.tquadrat.foundation.config.spi.prefs.PreferenceAccessor
getPropertyName, getter, hasKey, setter
-
Constructor Details
-
ImageAccessor
public ImageAccessor(String propertyName, Getter<BufferedImage> getter, Setter<BufferedImage> setter) Creates a newMapAccessorinstance.- Parameters:
propertyName- The name of the property.getter- The property getter.setter- The property setter.
-
-
Method Details
-
fromByteArray
protected final BufferedImage fromByteArray(Preferences node, byte[] source) throws InvalidPreferenceValueException Converts the givenbytearray to an instance of the property type.- Specified by:
fromByteArrayin classBulkDataAccessorBase<BufferedImage>- Parameters:
node- The reference to thePreferencesnode that provides the value.source- The byte array; can benull.- Returns:
- The instance, or
nullif the source was alreadynull. - Throws:
InvalidPreferenceValueException- The preferences value cannot be translated to the property type.
-
toByteArray
protected final byte[] toByteArray(Preferences node, BufferedImage source) throws InvalidPreferenceValueException Converts the given instance of the property type into abytearray.- Specified by:
toByteArrayin classBulkDataAccessorBase<BufferedImage>- Parameters:
node- The reference to thePreferencesnode that is used to store the preferences value.source- The instance; can benull.- Returns:
- The
bytearray, ornullif the source was alreadynull. - Throws:
InvalidPreferenceValueException- The conversion failed to abytearray failed.
-
