Class EditableImage

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class EditableImage
    extends java.lang.Object
    implements java.lang.Cloneable, java.io.Serializable
    An opaque class which encapsulates all the image manipulation logics, and allows the implementation of these logics to be transparently changed (e.g. by using or not JAI, etc...)
    Author:
    Fabrizio Giudici
    See Also:
    Serialized Form
    • Field Detail

      • PROP_FORMAT

        public static final java.lang.String PROP_FORMAT
      • PROP_MIME_TYPE

        public static final java.lang.String PROP_MIME_TYPE
      • latestOperationTime

        public long latestOperationTime
    • Constructor Detail

      • EditableImage

        public EditableImage()
        For serialization only. Do not use.
      • EditableImage

        public EditableImage​(ImageModel imageModel)
        For inner implementation only. Do not use.
    • Method Detail

      • setNickName

        public void setNickName​(java.lang.String nickName)
      • getNickName

        public java.lang.String getNickName()
      • create

        @Nonnull
        public static EditableImage create​(@Nonnull
                                           AbstractCreateOp createOp)
        Creates a new EditableImage as specified by the parameter
        Parameters:
        createOp - the way the image should be created
        Returns:
        the image
      • create

        @Nonnull
        public static EditableImage create​(@Nonnull
                                           ReadOp readOp)
                                    throws java.io.IOException
        Reads a new EditableImage as specified by the parameter
        Parameters:
        readOp - the way the image should be read
        Returns:
        the image
        Throws:
        java.io.IOException
      • hasRaster

        public final boolean hasRaster()
        Returns true if the image has a raster (EditableImages can be loaded with metadata only).
        Returns:
        true if the image has a raster
      • getImageModel

        public final ImageModel getImageModel()
        DO NOT USE THIS. This method is only used by the module implementation.
      • getAvailableExtensions

        public static java.util.Collection<java.lang.String> getAvailableExtensions()
        Returns all the file extensions of file formats that can be read into an EditableImage. The ImageIO registry is called to retrieve the requested information.
        Returns:
        an array of all file extensions
      • getMetadata

        public final <T> T getMetadata​(java.lang.Class<T> metadataClass)
      • getMetadata

        public final <T> T getMetadata​(java.lang.Class<T> metadataClass,
                                       int index)
      • getMetadataCount

        public final int getMetadataCount​(java.lang.Class<?> metadataClass)
      • getWidth

        public final int getWidth()
        Returns the width of this image.
        Returns:
        the width
      • getHeight

        public final int getHeight()
        Returns the height of this image.
        Returns:
        the height
      • getDataType

        public final EditableImage.DataType getDataType()
        Returns the dataType used by this image.
        Returns:
        the data type
      • getBandCount

        public final int getBandCount()
        Returns the number of bands this EditableImage is composed of.
        Returns:
        the band count
      • getBitsPerBand

        public final int getBitsPerBand()
        Returns the number of sample bits for each band this EditableImage is composed of.
        Returns:
        the number of bits
      • getBitsPerPixel

        public final int getBitsPerPixel()
        Returns the number of sample bits for each pixel this EditableImage is composed of.
        Returns:
        the number of bits
      • execute

        @Nonnull
        public final <T extends Operation> T execute​(@Nonnull
                                                     T operation)
        Executes an operation. The original image is lost and replaced by results.
        Parameters:
        operation - the operation to perform
        Returns:
        the operation (as a convenience in case it carries results)
      • execute2

        @Nonnull
        public final EditableImage execute2​(@Nonnull
                                            Operation operation)
        Executes an operation. The original image is untouched as the results are placed in a brand new instance of EditableImage.
        Parameters:
        operation - the operation to perform
        Returns:
        the result
      • getLatestOperationTime

        public final long getLatestOperationTime()
        Returns the elapsed time of the latest operation performed. Note that for execute2() this value is available on the result. When an image is deserialized, this method returns the serialization time (this relies upon the fact that the clocks on all network nodes are synchronized).
        Returns:
        the latest operation elapsed time
      • createSimilarImage

        public final EditableImage createSimilarImage()
        Deprecated.
        will be merged with create(AbstractCreateOp)
        Creates a similar image, that is a blank image with the same characteristics of this image (width, height, data type, color model).
        Returns:
        a new, similar image
      • cloneImage

        public final EditableImage cloneImage()
        Clones this image.
      • clone

        public java.lang.Object clone()
        Overrides:
        clone in class java.lang.Object
      • createResizedImage

        public final EditableImage createResizedImage​(int width,
                                                      int height)
        Deprecated.
        Creates a resized image. - FIXME should be removed
      • createResizedImage

        public final EditableImage createResizedImage​(int width,
                                                      int height,
                                                      Quality quality)
        Deprecated.
        Creates a resized image. - FIXME should be removed
      • setAttribute

        public final void setAttribute​(java.lang.String name,
                                       java.lang.Object value)
        Sets an attribute of this image. Attributes are user-specific name-value pairs.
        Parameters:
        name - the attribute name
        value - the attribute value
      • getAttribute

        public final java.lang.Object getAttribute​(java.lang.String name)
        Returns an attribute of this image.
        Parameters:
        name - the attribute name
        Returns:
        the attribute value
      • setAttributes

        public final void setAttributes​(java.util.Map<java.lang.String,​java.lang.Object> attributes)
      • getAttributes

        public final java.util.Map<java.lang.String,​java.lang.Object> getAttributes()
      • removeAttribute

        public final java.lang.Object removeAttribute​(java.lang.String name)
        Removes an attribute from this image.
        Parameters:
        name - the attribute name
        Returns:
        the attribute value
      • dispose

        public final void dispose()
        Removes all the resources bound to this image.
      • getMemorySize

        public final long getMemorySize()
        Returns an estimate of the memory allocated by this image.
        Returns:
        the memory allocated for this image
      • getColorModel

        public final java.awt.image.ColorModel getColorModel()
        Returns the ColorModel of this image.
        Returns:
        the color model
      • getICCProfile

        public final java.awt.color.ICC_Profile getICCProfile()
        Returns the ICC_Profile of this image (null will be returned if the ColorModel is not ICC-based). Note that this is the profile of the image as it is optimized for the display, which is almost surely sRGB; and it's probably different than the original image profile.
        Returns:
        the color profile
      • getLatestSerializationSize

        public int getLatestSerializationSize()
      • getInnerProperty

        public final <T> T getInnerProperty​(java.lang.Class<T> propertyClass)
        This is only for testing purposes.
      • loadMetadata

        public void loadMetadata​(javax.imageio.ImageReader reader,
                                 int imageIndex)
        Don't use it. Only for internal implementation.