Class RasterLayout

  • All Implemented Interfaces:
    Cloneable

    public class RasterLayout
    extends Object
    implements Cloneable
    A class describing the desired layout of an OpImage.

    The RasterLayout class encapsulates three types of information about an image:

    • The image bounds, comprising the min X and Y coordinates, image width, and image height;
    • The tile grid layout, comprising the tile grid X and Y offsets, the tile width, and the tile height; and

    Methods that modify the state of an RasterLayout return a reference to 'this' following the change. This allows multiple modifications to be made in a single expression. This provides a way of modifying an RasterLayout within a superclass constructor call.

    • Constructor Summary

      Constructors 
      Constructor Description
      RasterLayout()
      Constructs an RasterLayout with no parameters set.
      RasterLayout​(int minX, int minY, int width, int height)
      Constructs an RasterLayout with only the image dimension parameters set.
      RasterLayout​(int minX, int minY, int width, int height, int tileGridXOffset, int tileGridYOffset, int tileWidth, int tileHeight)
      Constructs an RasterLayout with all its parameters set.
      RasterLayout​(RenderedImage im)
      Constructs an RasterLayout with all its parameters set to equal those of a given RenderedImage.
      RasterLayout​(Rectangle bounds)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Object clone()
      Returns a clone of the RasterLayout as an Object.
      boolean equals​(Object obj)
      Tests if the specified Object equals this RasterLayout.
      int getHeight()
      Returns the value of height if it is valid, and otherwise returns the value from the supplied RenderedImage.
      int getMinX()
      Returns the value of minX if it is valid, and otherwise returns the value from the supplied RenderedImage.
      int getMinY()
      Returns the value of minY if it is valid, and otherwise returns the value from the supplied RenderedImage.
      int getTileGridXOffset()
      Returns the value of tileGridXOffset if it is valid, and otherwise returns the value from the supplied RenderedImage.
      int getTileGridYOffset()
      Returns the value of tileGridYOffset if it is valid, and otherwise returns the value from the supplied RenderedImage.
      int getTileHeight()
      Returns the value of tileHeight if it is valid, and otherwise returns the value from the supplied RenderedImage.
      int getTileWidth()
      Returns the value of tileWidth if it is valid, and otherwise returns the value from the supplied RenderedImage.
      int getWidth()
      Returns the value of width if it is valid, and otherwise returns the value from the supplied RenderedImage.
      int hashCode()  
      RasterLayout setHeight​(int height)
      Sets height to the supplied value and marks it as valid.
      RasterLayout setMinX​(int minX)
      Sets minX to the supplied value and marks it as valid.
      RasterLayout setMinY​(int minY)
      Sets minY to the supplied value and marks it as valid.
      RasterLayout setTileGridXOffset​(int tileGridXOffset)
      Sets tileGridXOffset to the supplied value and marks it as valid.
      RasterLayout setTileGridYOffset​(int tileGridYOffset)
      Sets tileGridYOffset to the supplied value and marks it as valid.
      RasterLayout setTileHeight​(int tileHeight)
      Sets tileHeight to the supplied value and marks it as valid.
      RasterLayout setTileWidth​(int tileWidth)
      Sets tileWidth to the supplied value and marks it as valid.
      RasterLayout setWidth​(int width)
      Sets width to the supplied value and marks it as valid.
      Rectangle toRectangle()  
      String toString()
      Returns a String containing the values of all valid fields.
      • Methods inherited from class Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • RasterLayout

        public RasterLayout()
        Constructs an RasterLayout with no parameters set.
      • RasterLayout

        public RasterLayout​(int minX,
                            int minY,
                            int width,
                            int height,
                            int tileGridXOffset,
                            int tileGridYOffset,
                            int tileWidth,
                            int tileHeight)
        Constructs an RasterLayout with all its parameters set. The sampleModel and colorModel parameters are ignored if null.
        Parameters:
        minX - the image's minimum X coordinate.
        minY - the image's minimum Y coordinate.
        width - the image's width.
        height - the image's height.
        tileGridXOffset - the X coordinate of tile (0, 0).
        tileGridYOffset - the Y coordinate of tile (0, 0).
        tileWidth - the width of a tile.
        tileHeight - the height of a tile.
      • RasterLayout

        public RasterLayout​(int minX,
                            int minY,
                            int width,
                            int height)
        Constructs an RasterLayout with only the image dimension parameters set.
        Parameters:
        minX - the image's minimum X coordinate.
        minY - the image's minimum Y coordinate.
        width - the image's width.
        height - the image's height.
      • RasterLayout

        public RasterLayout​(RenderedImage im)
        Constructs an RasterLayout with all its parameters set to equal those of a given RenderedImage.
        Parameters:
        im - a RenderedImage whose layout will be copied.
      • RasterLayout

        public RasterLayout​(Rectangle bounds)
    • Method Detail

      • toRectangle

        public Rectangle toRectangle()
      • getMinX

        public int getMinX()
        Returns the value of minX if it is valid, and otherwise returns the value from the supplied RenderedImage. If minX is not valid and fallback is null, 0 is returned.
        Returns:
        the appropriate value of minX.
      • setMinX

        public RasterLayout setMinX​(int minX)
        Sets minX to the supplied value and marks it as valid.
        Parameters:
        minX - the minimum X coordinate of the image, as an int.
        Returns:
        a reference to this RasterLayout following the change.
      • getMinY

        public int getMinY()
        Returns the value of minY if it is valid, and otherwise returns the value from the supplied RenderedImage. If minY is not valid and fallback is null, 0 is returned.
        Returns:
        the appropriate value of minY.
      • setMinY

        public RasterLayout setMinY​(int minY)
        Sets minY to the supplied value and marks it as valid.
        Parameters:
        minY - the minimum Y coordinate of the image, as an int.
        Returns:
        a reference to this RasterLayout following the change.
      • getWidth

        public int getWidth()
        Returns the value of width if it is valid, and otherwise returns the value from the supplied RenderedImage. If width is not valid and fallback is null, 0 is returned.
        Returns:
        the appropriate value of width.
      • setWidth

        public RasterLayout setWidth​(int width)
        Sets width to the supplied value and marks it as valid.
        Parameters:
        width - the width of the image, as an int.
        Returns:
        a reference to this RasterLayout following the change.
        Throws:
        IllegalArgumentException - if width is non-positive.
      • getHeight

        public int getHeight()
        Returns the value of height if it is valid, and otherwise returns the value from the supplied RenderedImage. If height is not valid and fallback is null, 0 is returned.
        Returns:
        the appropriate value of height.
      • setHeight

        public RasterLayout setHeight​(int height)
        Sets height to the supplied value and marks it as valid.
        Parameters:
        height - the height of the image, as an int.
        Returns:
        a reference to this RasterLayout following the change.
        Throws:
        IllegalArgumentException - if height is non-positive.
      • getTileGridXOffset

        public int getTileGridXOffset()
        Returns the value of tileGridXOffset if it is valid, and otherwise returns the value from the supplied RenderedImage. If tileGridXOffset is not valid and fallback is null, 0 is returned.
        Returns:
        the appropriate value of tileGridXOffset.
      • setTileGridXOffset

        public RasterLayout setTileGridXOffset​(int tileGridXOffset)
        Sets tileGridXOffset to the supplied value and marks it as valid.
        Parameters:
        tileGridXOffset - the X coordinate of tile (0, 0), as an int.
        Returns:
        a reference to this RasterLayout following the change.
      • getTileGridYOffset

        public int getTileGridYOffset()
        Returns the value of tileGridYOffset if it is valid, and otherwise returns the value from the supplied RenderedImage. If tileGridYOffset is not valid and fallback is null, 0 is returned.
        Returns:
        the appropriate value of tileGridYOffset.
      • setTileGridYOffset

        public RasterLayout setTileGridYOffset​(int tileGridYOffset)
        Sets tileGridYOffset to the supplied value and marks it as valid.
        Parameters:
        tileGridYOffset - the Y coordinate of tile (0, 0), as an int.
        Returns:
        a reference to this RasterLayout following the change.
      • getTileWidth

        public int getTileWidth()
        Returns the value of tileWidth if it is valid, and otherwise returns the value from the supplied RenderedImage. If tileWidth is not valid and fallback is null, 0 is returned.
        Returns:
        the appropriate value of tileWidth.
      • setTileWidth

        public RasterLayout setTileWidth​(int tileWidth)
        Sets tileWidth to the supplied value and marks it as valid.
        Parameters:
        tileWidth - the width of a tile, as an int.
        Returns:
        a reference to this RasterLayout following the change.
        Throws:
        IllegalArgumentException - if tileWidth is non-positive.
      • getTileHeight

        public int getTileHeight()
        Returns the value of tileHeight if it is valid, and otherwise returns the value from the supplied RenderedImage. If tileHeight is not valid and fallback is null, 0 is returned.
        Returns:
        the appropriate value of tileHeight.
      • setTileHeight

        public RasterLayout setTileHeight​(int tileHeight)
        Sets tileHeight to the supplied value and marks it as valid.
        Parameters:
        tileHeight - the height of a tile, as an int.
        Returns:
        a reference to this RasterLayout following the change.
        Throws:
        IllegalArgumentException - if tileHeight is non-positive.
      • toString

        public String toString()
        Returns a String containing the values of all valid fields.
        Overrides:
        toString in class Object
      • clone

        public Object clone()
        Returns a clone of the RasterLayout as an Object.
        Overrides:
        clone in class Object
      • equals

        public boolean equals​(Object obj)
        Tests if the specified Object equals this RasterLayout.
        Overrides:
        equals in class Object
        Parameters:
        obj - the Object to test for equality
        Returns:
        true if the specified Object is an instance of RasterLayout and equals this RasterLayout; false otherwise.
        Since:
        JAI 1.1
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object