Package com.day.image

Class Layer

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Layer.LuminanceSystem
      The LuminanceSystem class encapsulates luminance factor values for greyscaling operations.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ALPHA_CHANNEL_ID
      Channel number to identify the alpha channel for diverse methods involving color channels, i.e.
      static int BLUE_CHANNEL_ID
      Channel number to identify the blue color channel for diverse methods involving color channels, i.e.
      static java.lang.String DEFAULT_MIME_TYPE
      Default MIME type for writing the image.
      static Layer.LuminanceSystem GAMMA22
      Luminance factors for RGB in a Gamma 2.2 color space.
      static int GREEN_CHANNEL_ID
      Channel number to identify the green color channel for diverse methods involving color channels, i.e.
      static Layer.LuminanceSystem LINEAR
      Luminance factors for RGB in a linear color space.
      static Layer.LuminanceSystem REC709
      Luminance factors for RGB in a color space for contemporary CRT phosphors according to Rec.
      static int RED_CHANNEL_ID
      Channel number to identify the red color channel for diverse methods involving color channels, i.e.
    • Constructor Summary

      Constructors 
      Constructor Description
      Layer​(int width, int height, java.awt.Paint bground)
      Creates a Layer with the indicated dimensions and background paint.
      Layer​(Layer src)
      Creates a new Layer by copying the image of the source layer and setting all properties to the exact same value they are set in the source layer.
      Layer​(java.awt.image.BufferedImage image)
      Creates a new Layer by wrapping the BufferedImage with the Layer properties.
      Layer​(java.io.InputStream input)
      Creates a new Layer instance by loading an image from the InputStream.
      Layer​(java.io.InputStream input, int idx)
      Creates a new Layer instance by loading the indexed image from the InputStream.
      Layer​(java.io.InputStream input, int idx, java.awt.Dimension max)
      Creates a new Layer instance by loading the indexed image from the InputStream.
      Layer​(java.io.InputStream input, int idx, java.awt.Dimension max, javax.imageio.ImageReadParam params)
      Creates a new Layer instance by loading the indexed image from the InputStream.
      Layer​(java.io.InputStream input, java.awt.Dimension max)
      Creates a new Layer instance by loading an image from the InputStream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void adjust​(int brightness, float contrast)
      Adjust brightness and contrast of the image using the adjustments indicated : The brightness operand is a number in the range -255 ..
      void blit​(Layer src, int dw, int dh)
      Copy a subimage from the given source layer to this layer.
      void blit​(Layer src, int dx, int dy, int dw, int dh, int sx, int sy)
      Copy a subimage from the given source layer to this layer.
      void blur​(double radius, double scale, int flags, double gran, double maxdata)
      Blurs the picture in the layer using the values given.
      void colorize​(java.awt.Color darkcolor, java.awt.Color brightcolor)
      Colorizes the layer, i.e.
      void colorMask​(Layer src, java.awt.Color col)
      Colorizes the identical pixel of the source and destination layer with the indicated color.
      void copyChannel​(Layer src, int fromChannel, int toChannel)
      Copy the color or alpha channel from the source the same or another color or alpha channel in this layer.
      void crop​(java.awt.geom.Rectangle2D rect)
      Get the subimage indicated by the rectangle from the layer.
      void dispose()
      Releases as much resources as possible.
      void draw​(java.awt.Graphics g)
      Draws the layer into another graphics element, for example another image or a canvas.
      void draw​(java.awt.Shape shape)
      Draws (the outline of) the given shape.
      void drawEllipse​(float cx, float cy, float a, float b)
      Draws an ellipse around the given center with the indicated horizontal and vertical radii.
      void drawImage​(java.awt.image.BufferedImage img, java.awt.image.BufferedImageOp op, int x, int y)
      Draws the image onto the layers image at the indicated position doing the image operation before drawing.
      void drawLine​(float x1, float y1, float x2, float y2)
      Draws a straight line between the points (x1/y1) and (x2/y2) in the current stroke and paint mode applying the current composite.
      void drawPolyLine​(float[][] points)
      Draws a connected lines of multiple points given in the points array.
      void drawRect​(java.awt.geom.Rectangle2D rect)
      Draws the outline of the given rectangle with the preset color and stroke obeying the current composite setting.
      void drawSector​(float cx, float cy, float a, float b, double from, double extent)
      Draws an arc of the given ellipse with which is closed by drawing additional lines from the center point to the starting and ending points of the arc.
      void drawSegment​(float cx, float cy, float a, float b, double from, double extent)
      Draws an arc of the given ellipse.
      int drawText​(int x, int y, int width, int height, java.lang.String text, AbstractFont font, int align, double cs, int ls)
      Render the given text string in the given font to the Layer using the attributes given.
      void emboss​(Layer bump, int azimut, int elevation, int filtersize)
      Embosses the layer using the bump (if specified) and the light direction specified by aizmut and elevation.
      void fill​(java.awt.Shape shape)
      Fills (the area of) the given shape.
      void fillEllipse​(float cx, float cy, float a, float b)
      Fills an ellipse around the given center with the indicated horizontal and vertical radii.
      void fillRect​(Layer src, java.awt.geom.Rectangle2D rect)
      Fill the given rectangle with the layer defined as the temporary paint object.
      void fillRect​(java.awt.geom.Rectangle2D rect)
      According to the current paint and composite setting, the given rectangle is drawn onto the layer.
      void fillSector​(float cx, float cy, float a, float b, double from, double extent)
      Filles a sector of the given ellipse with which is closed by drawing additional lines from the center point to the starting and ending points of the arc.
      void flatten​(java.awt.Color color)
      Adapt the alpha channel of the image so that each color value has its value multiplied with the alpha value.
      void flipHorizontally()
      Flips the layer horizontally.
      void flipVertically()
      Flips the layer vertically.
      void floodFill​(java.awt.Color fillColor, int blur)
      Floods the background with the new fill color.
      void floodFill​(java.awt.Color fillColor, int blur, java.awt.Color bgColor)
      Starting from the four edges of the image towards the center, the method replaces background color by the fill color.
      java.awt.Paint getBackground()
      Returns the background of the layer.
      java.awt.Color getBackgroundColor()
      Gets the background color of the image.
      java.awt.geom.Rectangle2D getBoundingBox()
      Gets the bounding box of the image, that is the size of the rectangle spanning all pixels, that do not have the same color as the background color.
      java.awt.geom.Rectangle2D getBoundingBox​(java.awt.Color bgcolor)
      Gets the bounding box of the image, that is the size of the rectangle spanning all pixels, that do not have the same color as the given color which is supposed to be the background color.
      java.awt.Rectangle getBounds()
      Returns the rectangle spanned by the image.
      java.awt.Composite getComposite()
      Returns the current Composite in the Graphics2D context.
      java.awt.Graphics2D getG2()
      Returns the Graphics2D object used to draw into this layer.
      int getHeight()
      Returns the height of the layer.
      java.awt.image.BufferedImage getImage()
      Returns the image on which this layer is based.
      int getImageIndex()
      Returns the index of image of this layer within the multi-image file from which this layer has been loaded.
      java.awt.Composite getLayerComposite()
      Returns the current Composite of this layer.
      java.lang.String getMimeType()
      Returns the MIME type of the image from which the layer has been loaded.
      int getNumImages()
      Returns the number of images in the source from where this layer has been loaded or -1 if the number of images is not known or the lay has not been loaded from an image file.
      float getOpacity()
      Gets the opacity of the layer.
      java.awt.Paint getPaint()  
      int getPixel​(int x, int y)
      After checking whether the desired coordinate lies within the layer it gets the ARGB value out of storage and returns that value
      java.lang.Object getRenderingHint​(java.awt.RenderingHints.Key hintKey)
      Returns the value of a single preference for the rendering algorithms.
      java.awt.Stroke getStroke()  
      java.awt.Color getTransparency()
      Returns the Color value of transparent pixels.
      int getWidth()
      Returns the width of the layer.
      int getX()
      Returns the left edge of the layer.
      int getY()
      Returns the top edge of the layer.
      void grayscale()
      Converts the color image into a grayscale image
      void merge​(Layer layer)
      Merges a layer onto the current layer whereby obeying the layer's opacity level.
      void merge​(Layer[] layers)
      Merges a number of layers onto the current layer whereby obeying each layers opacity level.
      void monotone​(java.awt.Color color)
      Monotonize the image with a base color other than black.
      void multitone​(ColorCurve[] colorCurves)
      Colorize the image according to the color curves.
      void multitone​(java.awt.Color[] colors)
      Multitone an image.
      void reduceColors​(int numColors)
      Reduces the number of colors of the image to the indicated number, doing easy 'nearest' color replacement based on a weighting algorithm.
      void replaceColor​(long color1, long color2, boolean ignoreAlpha)
      Sets all pixels having color1 to color2.
      void resize​(int width, int height)
      Resize the image scaling it by the scaling factor indicated by the new width and height parameters.
      void resize​(int width, int height, boolean fast)
      Resize the image scaling it by the scaling factor indicated by the new width and height parameters.
      void rotate​(double degrees)
      Rotates the layer by the given angle in degrees in clockwise direction.
      void setBackground​(java.awt.Paint bground)
      Sets the background of the layer.
      void setBackgroundColor​(java.awt.Color bgColor)
      Set the background color to the indicated value.
      void setComposite​(java.awt.Composite composite)
      Sets the drawing composite for drawing and filling operations to the composite given.
      void setLayerComposite​(java.awt.Composite layerComposite)
      Sets the AlphaComposite used for merging this layer onto other layers.
      void setLineStyle​(LineStyle lineStyle)
      Sets both the paint and the stroke for the next draw and fill operations.
      void setLuminanceSystem​(Layer.LuminanceSystem system)
      Define the set of color weights to use in luminance definition
      void setMimeType​(java.lang.String mimeType)
      Sets the MIME type of the image, which is used when writing the image with no explicite MIME type setting.
      void setOpacity​(float opacity)
      Sets the opacity of the layer.
      void setPaint​(java.awt.Paint paint)
      Sets the paint for subsequent draw and fill operations.
      void setPixel​(int x, int y, long color)
      After checking whether the pixel lies within the layer, its color is set to the desired value.
      void setRenderingHint​(java.awt.RenderingHints.Key hintKey, java.lang.Object hintValue)
      Sets the value of a single preference for the rendering algorithms.
      void setStroke​(java.awt.Stroke stroke)
      Sets the line stroke to use for the subsequent draw operation.
      void setTransform​(java.awt.geom.AffineTransform transfrom)
      Sets the affine transformation applied to all of the drawing and filling operations.
      void setTransparency​(java.awt.Color transparency)
      Sets the Color value of pixels to be regarded transparent.
      void setX​(int x)
      Sets the left edge of the layer.
      void setY​(int y)
      Sets the top edge of the layer.
      void sharpen​(float amount, float radius)
      Sharpens the image by applying a convolution operation which involves ehancing the center of a kernel.
      java.lang.String toString()
      Convert the Layer to some string representation for intelligent display.
      boolean write​(java.lang.String mimeType, double quality, java.io.OutputStream outStream)
      Write the image to the given OutputStream using the desired MIME type.
      void xForm​(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, boolean crop)
      Distorts the layer along a 4-edged shape.
      void xFormColors​(double[][] matrix, double[] vector, boolean crop)
      Recombines the channels of the layer.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Layer

        public Layer​(int width,
                     int height,
                     java.awt.Paint bground)
        Creates a Layer with the indicated dimensions and background paint. The background paint may be any valid Paint implementation but will usually be a simple Color instance.

        The remaining properties of the layer are set to their default value. The origin is set to zero, the image type is GIF and the transparency color is not set.

        Note, that the background Paint is painted into the newly created layer. If you later set the background Paint to something else and resize the layer or merge it with other layer(s) some part of the layer will still have the old background color.

        Parameters:
        width - Width of the new layer. The minimum width of a layer is 1.
        height - Height of the new layer. The minimum height of a layer is 1.
        bground - The background paint of the new layer. This may be null in which case the background is assumed to be in transparent white.
        Throws:
        java.lang.IllegalArgumentException - if either the width or the height are specified lower than 1.
      • Layer

        public Layer​(java.io.InputStream input)
              throws java.io.IOException,
                     javax.imageio.IIOException
        Creates a new Layer instance by loading an image from the InputStream.

        The width and height are set to the values of the image, while the other values are set to their respective default values as defined in the class comment above.

        This constructor is equivalent to calling the Layer(InputStream, int) constructor with an index value or zero.

        Parameters:
        input - The InputStream to read the image data from
        Throws:
        java.lang.NullPointerException - if the InputStream is null.
        java.io.IOException - if reading from the stream throws such an exception.
        javax.imageio.IIOException - if decoding the image fails
      • Layer

        public Layer​(java.io.InputStream input,
                     java.awt.Dimension max)
              throws java.io.IOException,
                     javax.imageio.IIOException
        Creates a new Layer instance by loading an image from the InputStream.

        The width and height are set to the values of the image, while the other values are set to their respective default values as defined in the class comment above.

        if max is given, the loaded image will not be bigger than the given dimensions. eg: if the image is 1000x400 and the constraints are 500x500, the resulting layer will be 500x200. This constructor is equivalent to calling the Layer(InputStream, int, Dimension) constructor with an index value or zero.

        Parameters:
        input - The InputStream to read the image data from
        max - optional constraint for the maximal dimensions.
        Throws:
        java.lang.NullPointerException - if the InputStream is null.
        java.io.IOException - if reading from the stream throws such an exception.
        javax.imageio.IIOException - if decoding the image fails
      • Layer

        public Layer​(java.io.InputStream input,
                     int idx)
              throws java.io.IOException,
                     javax.imageio.IIOException
        Creates a new Layer instance by loading the indexed image from the InputStream.

        The width and height are set to the values of the image, while the other values are set to their respective default values as defined in the class comment above.

        Parameters:
        input - The InputStream to read the image data from
        idx - The zero-based index of the image in the image data stream. The first image has index zero. This must not be a negative number.
        Throws:
        java.lang.NullPointerException - if the InputStream is null.
        java.lang.IndexOutOfBoundsException - If idx is higher than the index of the last image in the image file.
        java.io.IOException - if reading from the stream throws such an exception.
        javax.imageio.IIOException - if decoding the image fails
      • Layer

        public Layer​(java.io.InputStream input,
                     int idx,
                     java.awt.Dimension max)
              throws java.io.IOException,
                     javax.imageio.IIOException
        Creates a new Layer instance by loading the indexed image from the InputStream.

        The width and height are set to the values of the image, while the other values are set to their respective default values as defined in the class comment above. if max is given, the loaded image will not be bigger than the given dimensions. eg: if the image is 1000x400 and the constraints are 500x500, the resulting layer will be 500x200.

        Parameters:
        input - The InputStream to read the image data from
        idx - The zero-based index of the image in the image data stream. The first image has index zero. This must not be a negative number.
        max - optional constraints for the maximal dimensions.
        Throws:
        java.lang.NullPointerException - if the InputStream is null.
        java.lang.IndexOutOfBoundsException - If idx is higher than the index of the last image in the image file.
        java.io.IOException - if reading from the stream throws such an exception.
        javax.imageio.IIOException - if decoding the image fails
      • Layer

        public Layer​(java.io.InputStream input,
                     int idx,
                     java.awt.Dimension max,
                     javax.imageio.ImageReadParam params)
              throws java.io.IOException,
                     javax.imageio.IIOException
        Creates a new Layer instance by loading the indexed image from the InputStream.

        The width and height are set to the values of the image, while the other values are set to their respective default values as defined in the class comment above. if max is given, the loaded image will not be bigger than the given dimensions. eg: if the image is 1000x400 and the constraints are 500x500, the resulting layer will be 500x200.

        Parameters:
        input - The InputStream to read the image data from
        idx - The zero-based index of the image in the image data stream. The first image has index zero. This must not be a negative number.
        max - optional constraints for the maximal dimensions.
        params - an instance of ImageReadParam.
        Throws:
        java.lang.NullPointerException - if the InputStream is null.
        java.lang.IndexOutOfBoundsException - If idx is higher than the index of the last image in the image file.
        java.io.IOException - if reading from the stream throws such an exception.
        javax.imageio.IIOException - if decoding the image fails
      • Layer

        public Layer​(Layer src)
        Creates a new Layer by copying the image of the source layer and setting all properties to the exact same value they are set in the source layer.
        Parameters:
        src - The layer to copy
        Throws:
        java.lang.NullPointerException - if the source layer is null.
      • Layer

        public Layer​(java.awt.image.BufferedImage image)
        Creates a new Layer by wrapping the BufferedImage with the Layer properties. Note that this really is a wrapping constructor and not a copy constructor. That is if you keep drawing into the original image, you get a mixed result.
        Parameters:
        image - The BufferedImage to wrap as a Layer.
        Throws:
        java.lang.NullPointerException - if the image is null.
    • Method Detail

      • write

        public boolean write​(java.lang.String mimeType,
                             double quality,
                             java.io.OutputStream outStream)
                      throws javax.imageio.IIOException,
                             java.io.IOException
        Write the image to the given OutputStream using the desired MIME type. If the MIME type is empty or null, we use the MIME type of the layer.

        The quality parameter is used to define the compression level of JPEG image creation, if JPEG output is desired as per the MIME type. The quality value must be in the range 0.0 .. 1.0 inclusive. Any value outside this range results in the default compression factor 0.82 being used.

        For GIF images the colors will be reduced according to the quality argument. If the argument is missing, at most 256 colors will be in the image or as much as need be.

        Note that specifying the MIME type for the image type is simply used to decide on the output format to use for writing. Especially the method is not able set any Content-Type headers whatsoever.

        The OutputStream is neither flushed nor closed at the end. It is the sole responsibilty of the client of this method to do so.

        Parameters:
        mimeType - MIME type to use for writing. If empty or null the MIME type of the image will be used. As a last fall back the default MIME type as per DEFAULT_MIME_TYPE is used.
        quality - Defines the JPEG compression quality (0.0 .. 1.0) or the numbers of colors to use for the GIF image.
        outStream - OutputStream to use to write the layer.
        Returns:
        true if the layer could be written, else false is returned.
        Throws:
        java.lang.IllegalArgumentException - if a mimeType is specified either as a parameter or as the layer's image type, which is not supported for writing by the ImageIO system.
        java.lang.NullPointerException - if the OutputStream is null.
        javax.imageio.IIOException - we get from the ImageIO Library we use.
        java.io.IOException - we get from writing to the OutputStream.
      • dispose

        public void dispose()
        Releases as much resources as possible. This method is called when the layer is not intended to be used any more.

        Note that using the layer object again after calling this method results in unexpected behaviour and at least throwing of NullPointerExceptions.

      • merge

        public void merge​(Layer layer)
        Merges a layer onto the current layer whereby obeying the layer's opacity level. The size of the current Layer is adapted to the compound size of both layers merged.
        Parameters:
        layer - the Layers to merge onto this one. If null this layer is not changed.
      • merge

        public void merge​(Layer[] layers)
        Merges a number of layers onto the current layer whereby obeying each layers opacity level. The layers are merged in the sequence the are listed in the array. The size of the current Layer is adapted to the compound size of all layers merged.

        Each layer is painted over the already painted layers according to the opacity and composite set on the layer to be painted. If the getLayerComposite() is not a AlphaComposite, the opacity is ignored.

        This method is conservative in that it is a null operation if the layers is null or empty.

        Parameters:
        layers - the list of Layers to merge onto this one.
      • blit

        public void blit​(Layer src,
                         int dw,
                         int dh)
        Copy a subimage from the given source layer to this layer. The copied image is hooked in the top left corner of the Layer.
        Parameters:
        src - the source Layer to copy from
        dw - the width of reactangle to copy
        dh - the height of the rectangle to copy.
        See Also:
        blit(Layer, int, int, int, int, int, int)
      • blit

        public void blit​(Layer src,
                         int dx,
                         int dy,
                         int dw,
                         int dh,
                         int sx,
                         int sy)
        Copy a subimage from the given source layer to this layer. The source rectangle is fully specified by its origin, width and height while the destination position of the top left corner is also given.
        Parameters:
        src - the source Layer to copy from
        dx - the left edge of the destination area in this layer
        dy - the top edge of the destination area in this layer
        dw - the width of reactangle to copy
        dh - the height of the rectangle to copy.
        sx - the left edge of the source area in the source layer
        sy - the top edge of the source area in the source layer
      • copyChannel

        public void copyChannel​(Layer src,
                                int fromChannel,
                                int toChannel)
        Copy the color or alpha channel from the source the same or another color or alpha channel in this layer. Nothing is done, if the method would do an identity copy, that is l.copyChannel(null, c, c) will do nothing.
        Parameters:
        src - the source layer for the channel copy, if null this is used as the src.
        fromChannel - channel to copy from the the source layer. If negative, the alpha channel will be copied
        toChannel - channel in this layer to copy the fromChannel into. If negative the same channel as fromChannel will be used.
        Throws:
        java.lang.IndexOutOfBoundsException - if the channel number is higher than number of available channels in either the source or this layer.
      • colorMask

        public void colorMask​(Layer src,
                              java.awt.Color col)
        Colorizes the identical pixel of the source and destination layer with the indicated color. This can be used to produce a transparent text over a background image.
        Parameters:
        src - the source layer for the masking operation or null this.
        col - the color to set for identical pixels. If null opaque black is used.
      • flatten

        public void flatten​(java.awt.Color color)
        Adapt the alpha channel of the image so that each color value has its value multiplied with the alpha value. For each pixel not set the indicated color is set.

        The DST_OVER composite paints the background only as much as the alpha channel of the layer pixels allows also respecting the alpha value of the background color !!

        Parameters:
        color - The color to use for unlit pixels. Set to a negative value to use the background color of the layer.
      • rotate

        public void rotate​(double degrees)
        Rotates the layer by the given angle in degrees in clockwise direction.
        Parameters:
        degrees - the angle to rotate the layer by. Usually this angle should be in the range 0-360�.
      • flipHorizontally

        public void flipHorizontally()
        Flips the layer horizontally.
      • flipVertically

        public void flipVertically()
        Flips the layer vertically.
      • resize

        public void resize​(int width,
                           int height)
        Resize the image scaling it by the scaling factor indicated by the new width and height parameters. If the aspect ration of the existing layer should be kept, the new width and height values should be set accordingly.
        Parameters:
        width - the new width of the layer. Set to 0 or a negative value to keep the current width.
        height - the new height of the layer. Set to 0 or a negative value to keep the current height.
      • resize

        public void resize​(int width,
                           int height,
                           boolean fast)
        Resize the image scaling it by the scaling factor indicated by the new width and height parameters. If the aspect ration of the existing layer should be kept, the new width and height values should be set accordingly.
        Parameters:
        width - the new width of the layer. Set to 0 or a negative value to keep the current width.
        height - the new height of the layer. Set to 0 or a negative value to keep the current height.
        fast - if set to true a faster resizing algorithm is used but with poorer detail.
      • crop

        public void crop​(java.awt.geom.Rectangle2D rect)
        Get the subimage indicated by the rectangle from the layer. The subimage is simply cut out the bigger one.
        Parameters:
        rect - the rectangle definiing the part of the image to cut out
      • emboss

        public void emboss​(Layer bump,
                           int azimut,
                           int elevation,
                           int filtersize)
        Embosses the layer using the bump (if specified) and the light direction specified by aizmut and elevation.
        NOTE: This implementation is a copy of the existing rgbaLayer routine. It may therefore not be very fast. But it works the same as the corresponding ECMA routine ;-)
        Parameters:
        bump - the bump layer to emboss this layer with. If null this layer itself will also be used as the bump.
        azimut - the light direction azimut. Specify a negative value to get the default value of 30.
        elevation - the light direction elevation. Specify a negative value to get the default value of 30.
        filtersize - the filtersize for the embossing. Specify a negative value to get the default value of 3.
      • xForm

        public void xForm​(int x1,
                          int y1,
                          int x2,
                          int y2,
                          int x3,
                          int y3,
                          int x4,
                          int y4,
                          boolean crop)
        Distorts the layer along a 4-edged shape. The transformation of the rectangle may lead to a rectangle of a different size. Depending on the crop parameter, the size of the layer is adapted to the new size or not. If crop==true, the layer's size is either enlarged or made smaller depending on the bounding box of the transformed layer.

        This method internally uses the DistortOp class to calculate the transformed layer. Therefore the same warning about memory usage applies to this method as does to the DistortOp class.

        Parameters:
        x1 - x-coordinate of top left corner of transformed rectangle
        y1 - y-coordinate of top left corner of transformed rectangle
        x2 - x-coordinate of top right corner of transformed rectangle
        y2 - y-coordinate of top right corner of transformed rectangle
        x3 - x-coordinate of bottom left corner of transformed rectangle
        y3 - y-coordinate of bottom left corner of transformed rectangle
        x4 - x-coordinate of bottom right corner of transformed rectangle
        y4 - y-coordinate of bottom right corner of transformed rectangle
        crop - true of the layer should be adapted to the bounding of the transformed rectangle.
      • grayscale

        public void grayscale()
        Converts the color image into a grayscale image
      • colorize

        public void colorize​(java.awt.Color darkcolor,
                             java.awt.Color brightcolor)
        Colorizes the layer, i.e. map the brightness of the image onto the gradient from darkcolor to brightcolor.
        Parameters:
        darkcolor - the dark start color for the colorization. If negative 0xff000000 (black) will be used.
        brightcolor - the bright end color for the colorization. If negative 0xffffffff (white) will be used.
      • monotone

        public void monotone​(java.awt.Color color)
        Monotonize the image with a base color other than black. This method is equivalent to calling multitone(new Color[]{ color }).
        Parameters:
        color - Color to use as the base for the monotonized image
        Throws:
        java.lang.NullPointerException - if the color value is null.
      • multitone

        public void multitone​(java.awt.Color[] colors)
        Multitone an image. The luminance scaled image is applied the listed colors in order to get the multitoned image result.

        Note that monotone(Color) is the single color special case of multitone.

        This method does not yet work as expected

        Parameters:
        colors - The colors to apply.
        Throws:
        java.lang.NullPointerException - if the colors array or any of the elements in the array is null.
        java.lang.IllegalArgumentException - if the colors array is empty
      • multitone

        public void multitone​(ColorCurve[] colorCurves)
        Colorize the image according to the color curves. This operation is similar to the Photohop Duplex operation where you define a number of colors and optional tone curves.
        Parameters:
        colorCurves - The color curves to use in the MultitoneOp filter.
        See Also:
        MultitoneOp, ColorCurve
      • blur

        public void blur​(double radius,
                         double scale,
                         int flags,
                         double gran,
                         double maxdata)
        Blurs the picture in the layer using the values given. Optionally only one of the color channels is blurred while all the others remain untouched. This method is simply a reimplementation of the ECMA method using the ConvolveOp class of the Java 2D API. Maybe we should specify the matrix better ?
        Parameters:
        radius - (default:1)
        scale - (default:1)
        flags - (default:all channels) - not used at the moment
        gran - (default:1)
        maxdata - (default:255)
      • sharpen

        public void sharpen​(float amount,
                            float radius)
        Sharpens the image by applying a convolution operation which involves ehancing the center of a kernel. Each element of the convolution matirx is set to -1, while the center - which is the source pixel - is set to the negative sum of all the other elements plus the given percentage amount of that sum. That is, the pixel is enhanced relativ to the neighbours.
        Parameters:
        amount - Center enhancement in percent in the range 0 .. 1.0
        radius - Size of the convolution matrix. The size is rounded to and integral matrix edge according to edge = int(2 * (radius + 1)). That is the minimum matrix size is guaranteed to be 1, which has no effect whatsoever. Allowed range for this value is 0.5 .. 10.0
      • xFormColors

        public void xFormColors​(double[][] matrix,
                                double[] vector,
                                boolean crop)
        Recombines the channels of the layer. According to matrix4obj and vector4obj the channels (alpha, red, green, blue) of the layer are recombined and possibly scaled.
        Parameters:
        matrix - 4x4 matrix to multiply to the vector of channel values of each pixel
        vector - array of 4 elements to add to each resulting value got from the multiplication.
        crop - default true
      • replaceColor

        public void replaceColor​(long color1,
                                 long color2,
                                 boolean ignoreAlpha)
        Sets all pixels having color1 to color2. The alpha channel value is only touched if ignoreAlpha is not set.
        Parameters:
        color1 - Color identifying pixels to be modified
        color2 - New color of those pixels
        ignoreAlpha - Set to true to not touch the alpha channel of the pixels.
      • adjust

        public void adjust​(int brightness,
                           float contrast)
        Adjust brightness and contrast of the image using the adjustments indicated :
        • The brightness operand is a number in the range -255 .. 255 where larger valus make the image brighter and lower values darken the image. A value of 0 does not change the brightness
        • The contrast operand is a positive float indicating the contrast enhancement. A value of 1.0 does not change the contrast. Values less than 1.0 lower the contrast while values higher than 1.0 enhance the contrast.
        The operation involved calculates the following value for each color of each pixel (the alpha channel is not modified) :
        destination = ( source * contrast ) + brightness
        The result is clipped to the range 0..255.
        Parameters:
        brightness - The brightness operand in the range -255 .. 255
        contrast - The contrast factor in the rang 0.0f .. infinity
      • reduceColors

        public void reduceColors​(int numColors)
        Reduces the number of colors of the image to the indicated number, doing easy 'nearest' color replacement based on a weighting algorithm.
        Parameters:
        numColors - The number of colors to reduce the current image to.
      • setPaint

        public void setPaint​(java.awt.Paint paint)
        Sets the paint for subsequent draw and fill operations. In its simplest case the paint will be a color to paint, but it can be any Paint implementations such as GradientPaint.

        The paint setting remains active until changed by the next setLineStyle() or setPaint() call.

      • getPaint

        public java.awt.Paint getPaint()
      • setStroke

        public void setStroke​(java.awt.Stroke stroke)
        Sets the line stroke to use for the subsequent draw operation. A stroke defines how the outline of a shape is drawn, e.g. solid, dashed, etc., and how the lines are terminated or interconnected.

        The stroke setting remains active until changed by the next setLineStyle() or setStroke() call.

      • getStroke

        public java.awt.Stroke getStroke()
      • setLineStyle

        public void setLineStyle​(LineStyle lineStyle)
        Sets both the paint and the stroke for the next draw and fill operations.

        The paint and stroke settings remain active until changed by the next setLineStyle() or setPaint() or setStroke() call.

      • setComposite

        public void setComposite​(java.awt.Composite composite)
        Sets the drawing composite for drawing and filling operations to the composite given. Most commonly the composite will be one of the predefined AlphaComposite implementations.
        Parameters:
        composite - The composite to set for the drawing operations.
        Throws:
        java.lang.NullPointerException - if composite is null.
      • getComposite

        public java.awt.Composite getComposite()
        Returns the current Composite in the Graphics2D context.
        Returns:
        the current Graphics2D Composite, which defines a compositing style.
      • setTransform

        public void setTransform​(java.awt.geom.AffineTransform transfrom)
        Sets the affine transformation applied to all of the drawing and filling operations. Setting the affine transformation this way you can apply rotation, resizing and combinations thereof to single objects to be drawn instead of having to rotate or resize the complete layer.
        Parameters:
        transfrom - The affine transformation to apply to all drawing and filling operations when operating on the layer.
      • setLuminanceSystem

        public void setLuminanceSystem​(Layer.LuminanceSystem system)
        Define the set of color weights to use in luminance definition
        Parameters:
        system - The luminance vector to use.
        See Also:
        GAMMA22, LINEAR
      • setRenderingHint

        public void setRenderingHint​(java.awt.RenderingHints.Key hintKey,
                                     java.lang.Object hintValue)
        Sets the value of a single preference for the rendering algorithms. Hint categories include controls for rendering quality and overall time/quality trade-off in the rendering process. Refer to the RenderingHints class for definitions of some common keys and values.
        Parameters:
        hintKey - the key of the hint to be set.
        hintValue - the value indicating preferences for the specified hint category.
      • getRenderingHint

        public java.lang.Object getRenderingHint​(java.awt.RenderingHints.Key hintKey)
        Returns the value of a single preference for the rendering algorithms. Hint categories include controls for rendering quality and overall time/quality trade-off in the rendering process. Refer to the RenderingHints class for definitions of some common keys and values.
        Parameters:
        hintKey - the key corresponding to the hint to ge
        Returns:
        an object representing the value for the specified hint key. Some of the keys and their associated values are defined in the RenderingHints class.
      • drawText

        public int drawText​(int x,
                            int y,
                            int width,
                            int height,
                            java.lang.String text,
                            AbstractFont font,
                            int align,
                            double cs,
                            int ls)
        Render the given text string in the given font to the Layer using the attributes given. Use the default values given for unspecified values.

        If the width of the text box is set to some value other than zero, the text is broken to fit lines of the given length. The line breaking algorithm breaking algorithm breaks on whitespace (blank, tab), carriage return and linefeed (CR/LF) in any combination as well as on other characters such as hyphens.

        If the text contains carriage return and/or linefeed characters, the text is broken into several lines, regardless of whether the text would be broken because of the text box width setting.

        The layer may be enlarged to accomodate for the space needed for the text to be drawn. This is not the same behaviour as standard Java2D text drawing, where the text is clipped at the edges of the image.

        Parameters:
        x - left edge of the text box relative to the layer.
        y - top edge of the text box relative to the layer.
        width - maximum width of the textbox. If 0 (or negative) the width of the bounding box is dependent of the rendering attributes
        height - maximum height of the textbox. If 0 (or negative) the width of the bounding box is dependent of the rendering attributes
        text - the text string to draw
        font - the font to render the text string
        align - alignment, rotation and TrueType attributes for the text. Use AbstractFont.ALIGN_LEFT as default value.
        cs - extra intercharacter spacing. Use 0 as default value to not add additional space.
        ls - extra line spacing. Use 0 as default value to not add additional space.
        Returns:
        the number of text lines drawn to the layer
        Throws:
        java.lang.NullPointerException - if either the text or the font argument is null.
        java.lang.IllegalArgumentException - if either x or y are negative.
        See Also:
        Font.drawText(com.day.image.Layer, int, int, int, int, java.lang.String, java.awt.Paint, java.awt.Stroke, int, double, int)
      • fillRect

        public void fillRect​(java.awt.geom.Rectangle2D rect)
        According to the current paint and composite setting, the given rectangle is drawn onto the layer. If the rect parameter is null, the entire layer is filled with the paint.

        The edges of the rectangle drawn are defined as in Java2D, that is the left edge is x, the right edge is x+width-1, the top edge is y and the bottom edge is y+width-1.

        Parameters:
        rect - the rectangle to paint onto the layer. If set to null, the entire layer will be filled with that color.
      • fillRect

        public void fillRect​(Layer src,
                             java.awt.geom.Rectangle2D rect)
        Fill the given rectangle with the layer defined as the temporary paint object. This obeys the composite setting, but ignores the current paint setting as the layer is taken as the paint. After the method has finished the current paint is set again.
        Parameters:
        src - the source Layer to use. If this is the same as src, nothin happens.
        rect - the rectangle to paint onto the layer. If set to null, the entire layer will be filled with that color.
        Throws:
        java.lang.NullPointerException - if src is null.
      • drawRect

        public void drawRect​(java.awt.geom.Rectangle2D rect)
        Draws the outline of the given rectangle with the preset color and stroke obeying the current composite setting. If rect is null, this draws the outline on the edges of the layer.

        The edges of the rectangle drawn are defined as in Java2D, that is the left edge is x, the right edge is x+width, the top edge is y and the bottom edge is y+width.

        Parameters:
        rect - the rectangle to draw onto the layer. If set to null, the entire layer will be surrounded with a border line.
      • drawLine

        public void drawLine​(float x1,
                             float y1,
                             float x2,
                             float y2)
        Draws a straight line between the points (x1/y1) and (x2/y2) in the current stroke and paint mode applying the current composite.
        Parameters:
        x1 - The x coordinate of the starting point
        y1 - The y coordinate of the starting point
        x2 - The x coordinate of the ending point
        y2 - The y coordinate of the ending point
      • drawPolyLine

        public void drawPolyLine​(float[][] points)
        Draws a connected lines of multiple points given in the points array. Each entry in the array contains of a x/y coordinate pair denoting one point in the line.
        Parameters:
        points - Array of x/y coordinate pairs. The array must consist of at least two entries, each entry containing at least two elements where the first element is interpreted as the x- and the second element is interpreted as the y-coordinate of that entry's point.
      • drawEllipse

        public void drawEllipse​(float cx,
                                float cy,
                                float a,
                                float b)
        Draws an ellipse around the given center with the indicated horizontal and vertical radii. The ellipse is drawn filling a rectangle that is twice the vertical radius high and twice the horizontal radius wide. The center of this rectangle is designated by the center coordinates. To draw a circle define the horizontal and vertical radius to be the same value.
        Parameters:
        cx - The x coordinate of the ellipse center
        cy - The y coordinate of the ellipse center
        a - The horizontal radius of the ellipse
        b - The vertical radius of the ellipse
      • fillEllipse

        public void fillEllipse​(float cx,
                                float cy,
                                float a,
                                float b)
        Fills an ellipse around the given center with the indicated horizontal and vertical radii. The ellipse is drawn filling a rectangle that is twice the vertical radius high and twice the horizontal radius wide. The center of this rectangle is designated by the center coordinates. To fill a circle define the horizontal and vertical radius to be the same value.
        Parameters:
        cx - The x coordinate of the ellipse center
        cy - The y coordinate of the ellipse center
        a - The horizontal radius of the ellipse
        b - The vertical radius of the ellipse
      • drawSegment

        public void drawSegment​(float cx,
                                float cy,
                                float a,
                                float b,
                                double from,
                                double extent)
        Draws an arc of the given ellipse. The base ellipse is defined as for drawEllipse(float, float, float, float), while only a segment of this ellipse is drawn. The segement is defined by the from and to angle denoting the starting and ending angle specified in degrees. The angle are defined such, that 0 degrees is the axis from the center to the right edge and positive angles turn counter clockwise.
        Parameters:
        cx - The x coordinate of the base ellipse center
        cy - The y coordinate of the base ellipse center
        a - The horizontal radius of the base ellipse
        b - The vertical radius of the base ellipse
        from - The starting angle as defined above
        extent - The angle the arc spans as defined above
      • drawSector

        public void drawSector​(float cx,
                               float cy,
                               float a,
                               float b,
                               double from,
                               double extent)
        Draws an arc of the given ellipse with which is closed by drawing additional lines from the center point to the starting and ending points of the arc. The base ellipse is defined as for of this ellipse is drawn. The segement is defined by the from and to angle denoting the starting and ending angle specified in degrees. The angle are defined such, that 0 degrees is the axis from the center to the right edge and positive angles turn counter clockwise.
        Parameters:
        cx - The x coordinate of the base ellipse center
        cy - The y coordinate of the base ellipse center
        a - The horizontal radius of the base ellipse
        b - The vertical radius of the base ellipse
        from - The starting angle as defined above
        extent - The angle the arc spans as defined above
      • fillSector

        public void fillSector​(float cx,
                               float cy,
                               float a,
                               float b,
                               double from,
                               double extent)
        Filles a sector of the given ellipse with which is closed by drawing additional lines from the center point to the starting and ending points of the arc. The base ellipse is defined as for drawEllipse(float, float, float, float), while only a segment of this ellipse is drawn. The segement is defined by the from and to angle denoting the starting and ending angle specified in degrees. The angle are defined such, that 0 degrees is the axis from the center to the right edge and positive angles turn counter clockwise.
        Parameters:
        cx - The x coordinate of the base ellipse center
        cy - The y coordinate of the base ellipse center
        a - The horizontal radius of the base ellipse
        b - The vertical radius of the base ellipse
        from - The starting angle as defined above
        extent - The angle the arc spans as defined above
      • draw

        public void draw​(java.awt.Shape shape)
        Draws (the outline of) the given shape. This is the generalized method of the different draw methods above. Using this method you can draw virtually anything you can possibly define in terms of a Shape.

        The Shape interface forms the basis for all geometrical figures such as circles, rectangles, lines but also text and even constructive area geometry.

        Parameters:
        shape - The Shape implementation object to draw
      • fill

        public void fill​(java.awt.Shape shape)
        Fills (the area of) the given shape. This is the generalized method of the different fill methods above. Using this method you can fill virtually anything you can possibly define in terms of a Shape.

        The Shape interface forms the basis for all geometrical figures such as circles, rectangles, lines but also text and even constructive area geometry.

        Parameters:
        shape - The Shape implementation object to draw
      • getPixel

        public int getPixel​(int x,
                            int y)
        After checking whether the desired coordinate lies within the layer it gets the ARGB value out of storage and returns that value
        Parameters:
        x - horizontal coordinate (0 at the left) of the pixel
        y - vertical coordinate (0 at the top) of the pixel
        Returns:
        0 if pixel lies outside the layer, else the ARGB value of the pixel.
      • setPixel

        public void setPixel​(int x,
                             int y,
                             long color)
        After checking whether the pixel lies within the layer, its color is set to the desired value. If the pixel lies outside the layer no value is set and false is returned.
        Parameters:
        x - horizontal coordinate (0 at the left) of the pixel
        y - vertical coordinate (0 at the top) of the pixel
        color - ARGB value for the pixel
      • getBoundingBox

        public java.awt.geom.Rectangle2D getBoundingBox()
        Gets the bounding box of the image, that is the size of the rectangle spanning all pixels, that do not have the same color as the background color. This background color is first guessed using the getBackgroundColor() method.
        Returns:
        The calculated bounding box based on the guessed background color.
        See Also:
        getBoundingBox(Color)
      • getBoundingBox

        public java.awt.geom.Rectangle2D getBoundingBox​(java.awt.Color bgcolor)
        Gets the bounding box of the image, that is the size of the rectangle spanning all pixels, that do not have the same color as the given color which is supposed to be the background color.

        The algorithm scans starting on each edge of the image rectangle and aborts the scan as soon as a non-background pixel is encountered.

        Parameters:
        bgcolor - The color value not being considered image color, ie background color.
        Returns:
        The calculated bounding box based on the guessed background color.
        Throws:
        java.lang.NullPointerException - if bgcolor is null.
      • floodFill

        public void floodFill​(java.awt.Color fillColor,
                              int blur)
        Floods the background with the new fill color. The backrgound color is first guessed using the getBackgroundColor() method.
        Parameters:
        fillColor - The color to replace the background pixels
        blur - The maximal color distance to apply to a pixel to treat it as a background color pixel.
        See Also:
        floodFill(Color, int, Color)
      • floodFill

        public void floodFill​(java.awt.Color fillColor,
                              int blur,
                              java.awt.Color bgColor)
        Starting from the four edges of the image towards the center, the method replaces background color by the fill color. Pixels are considered background if the have the same color as the background color or if there color has a distance from the backrgound color which is less than the blur value as per the following formula :
        blur < sqrt( dr^2 + dg^2 + db^2 )
        where dr, dg and db are the difference of the red, blue and green component of the pixel and the background color, resp.

        As a side effect the transparency color is set to the fill color if the transparency was set to the backrgound color just replaced.

        Parameters:
        fillColor - The color teplace for the background color.
        blur - The maximum color distance as defined above.
        bgColor - The background color to be replaced.
        Throws:
        java.lang.NullPointerException - if either fillColor or bgColor is null.
      • drawImage

        public void drawImage​(java.awt.image.BufferedImage img,
                              java.awt.image.BufferedImageOp op,
                              int x,
                              int y)
        Draws the image onto the layers image at the indicated position doing the image operation before drawing. Note that the x and y coordinates are relative to the layers image and not relative to the x/y coordinates of the layer itself. That is, the coordinate 0/0 draws at the top left corner of the layer regardless of the value of the layers x/y value.
        Parameters:
        img - The image to draw
        op - The BufferedImageOp to execute on the image before drawing, if null the image is drawn unaltered.
        x - The left position to draw the image to
        y - The top position to draw the image to
      • draw

        public void draw​(java.awt.Graphics g)
        Draws the layer into another graphics element, for example another image or a canvas. The image is drawn at the position specified by the left and top edge of the layer.
        Parameters:
        g - The graphics element to draw into
      • getX

        public int getX()
        Returns the left edge of the layer. This value is relevant, if the layer is to be merged with other layers, to position the layers relative to each other.
        Returns:
        left edge of the layer.
      • setX

        public void setX​(int x)
        Sets the left edge of the layer. This value is relevant, if the layer is to be merged with other layers, to position the layers relative to each other.
        Parameters:
        x - left edge of the layer.
      • getY

        public int getY()
        Returns the top edge of the layer. This value is relevant, if the layer is to be merged with other layers, to position the layers relative to each other.
        Returns:
        top edge of the layer.
      • setY

        public void setY​(int y)
        Sets the top edge of the layer. This value is relevant, if the layer is to be merged with other layers, to position the layers relative to each other.
        Parameters:
        y - top edge of the layer.
      • getWidth

        public int getWidth()
        Returns the width of the layer.
        Returns:
        the width of the layer.
      • getHeight

        public int getHeight()
        Returns the height of the layer.
        Returns:
        the height of the layer.
      • getBounds

        public java.awt.Rectangle getBounds()
        Returns the rectangle spanned by the image. This rectangle encompasses the complete image where as getBoundingBox() returns the smallest area of the image not only covered by the background color.
      • getImageIndex

        public int getImageIndex()
        Returns the index of image of this layer within the multi-image file from which this layer has been loaded. This field will only be non-zero if the layer has been created by a call to the Layer(InputStream, int) constructor with a non-zero index.
        Returns:
        The index of the image of this layer in the image source file.
      • getNumImages

        public int getNumImages()
        Returns the number of images in the source from where this layer has been loaded or -1 if the number of images is not known or the lay has not been loaded from an image file.
        Returns:
        The number of images in the source file or -1 if not known.
      • getBackground

        public java.awt.Paint getBackground()
        Returns the background of the layer.
        Returns:
        the background of the layer.
      • setBackground

        public void setBackground​(java.awt.Paint bground)
        Sets the background of the layer. If the background is a Color the background color (getBackgroundColor()) is also set.
        Parameters:
        bground - The new background.
      • setBackgroundColor

        public void setBackgroundColor​(java.awt.Color bgColor)
        Set the background color to the indicated value. This value is overwritten by setBackground(Paint) and potentially also by getBackgroundColor().

        You may set the background color to null, if you want to recalculate the background color based on the image data the next time you call getBackgroundColor().

        Parameters:
        bgColor - The Color to set for the background or null to force recalculation by the next getBackgroundColor() call.
      • getBackgroundColor

        public java.awt.Color getBackgroundColor()
        Gets the background color of the image. If the background color has not been set by setBackgroundColor(Color), the background color is taken to be the background (getBackground() if the background is a color, else the color is calculated to be the color most often occuring on the edges of the layer. This may not be 100% correct but gets acceptable results.
        Returns:
        The supposed background color.
      • getTransparency

        public java.awt.Color getTransparency()
        Returns the Color value of transparent pixels. This is prominently used by the GIF image format, which does not know about alpha values. For GIF images, a color may be specified to identify pixels which should be show transparent.
        Returns:
        the Color value of transparent pixels
      • setTransparency

        public void setTransparency​(java.awt.Color transparency)
        Sets the Color value of pixels to be regarded transparent. This is prominently used by the GIF image format, which does not know about alpha values. For GIF images, a color may be specified to identify pixels which should be show transparent.
        Parameters:
        transparency - The transparency color.
      • setMimeType

        public void setMimeType​(java.lang.String mimeType)
        Sets the MIME type of the image, which is used when writing the image with no explicite MIME type setting.
        Parameters:
        mimeType - The MIME type to set on the layer. If null or empty, the currently set MIME type is not changed.
      • getMimeType

        public java.lang.String getMimeType()
        Returns the MIME type of the image from which the layer has been loaded. If the layer is not created from an image, the method returns the default MIME type image/gif.
        Returns:
        the MIME type assigned to the layer.
      • getOpacity

        public float getOpacity()
        Gets the opacity of the layer. The opacity value is used when merging layers to define the relative transparency of two layers merged.
        Returns:
        the layer's opacity.
        See Also:
        setOpacity(float)
      • setOpacity

        public void setOpacity​(float opacity)
        Sets the opacity of the layer. The opacity value is used when merging layers to define the relative transparency of two layers merged.
        Parameters:
        opacity - the layer's opacity. If less than zero, zero is set; if higher than 1.0, 1.0 is set; if not a number (Float.NaN) the opacity is not changed.
        See Also:
        getOpacity()
      • getLayerComposite

        public java.awt.Composite getLayerComposite()
        Returns the current Composite of this layer. The default composite set is AlphaComposite.SrcOver.

        This method returns the Composite which is set on this layer and which is used for layer merging. This is different from the Composite returned from the getComposite() method, which returns the Composite used for drawing operations until reset.

        Returns:
        The current Composite.
        See Also:
        setLayerComposite(java.awt.Composite)
      • setLayerComposite

        public void setLayerComposite​(java.awt.Composite layerComposite)
        Sets the AlphaComposite used for merging this layer onto other layers.

        This method sets the Composite on this layer which is used for layer merging. This is different from the Composite set through setComposite(java.awt.Composite), which sets the Composite used for drawing operations until reset.

        Parameters:
        layerComposite - The Composite to set on this layer. If null the current Composite is not changed.
        See Also:
        getLayerComposite()
      • getImage

        public java.awt.image.BufferedImage getImage()
        Returns the image on which this layer is based. This may not be an RGBA image and may even have a custom color space attached.
        Returns:
        The image on which this layer is based.
      • getG2

        public java.awt.Graphics2D getG2()
        Returns the Graphics2D object used to draw into this layer.
        Returns:
        the Graphics2D object used to draw into this layer.
      • toString

        public java.lang.String toString()
        Convert the Layer to some string representation for intelligent display.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the String representation of the Layer.