Class RegionRequest


  • public class RegionRequest
    extends Object
    • Constructor Detail

      • RegionRequest

        public RegionRequest()
        Create a region that encompasses the whole picture, i.e. the 'full' syntax.
      • RegionRequest

        public RegionRequest​(boolean square)
        Pass 'true' to create a region that selects a square region from the image, i.e.the 'square' syntax.
        Parameters:
        square - true, if square region should be selected
      • RegionRequest

        public RegionRequest​(double x,
                             double y,
                             double width,
                             double height)
                      throws ResolvingException
        Create a RegionRequest request that is expressed using relative values, i.e.the "pct:x,y,w,h" syntax

        The values must be between 0.0 and 100.0.

        Parameters:
        x - relative upper left x position of region
        y - relative upper left y position of region
        width - relative width of region
        height - relative height of region
        Throws:
        ResolvingException - if the values fall outside of the allowed range
      • RegionRequest

        public RegionRequest​(int x,
                             int y,
                             int width,
                             int height)
        Create a RegionRequest request that is expressed using absolute values.
        Parameters:
        x - absolute upper left x position of region
        y - absolute upper left y position of region
        width - absolute width of region
        height - absolute height of region
    • Method Detail

      • fromString

        public static RegionRequest fromString​(String str)
                                        throws ResolvingException
        Parse an IIIF Image API compliant region request string
        Parameters:
        str - region request string
        Returns:
        resulting RegionRequest instance
        Throws:
        ResolvingException - if the request string is malformed.
      • getRegion

        public Rectangle2D getRegion()
        Returns the requested region
        Returns:
        get a Rectangle2D instance representing the region
      • isRelative

        public boolean isRelative()
        Returns whether the region is expressed in relative terms.
        Returns:
        true, if region is defined in relative values
      • isSquare

        public boolean isSquare()
        Returns whether a square region is selected.
        Returns:
        true, if region should be square
      • toString

        public String toString()
        Create an IIIF Image API compliant region request string
        Overrides:
        toString in class Object
        Returns:
        iiif image api compliant region request string
      • resolve

        public Rectangle resolve​(Dimension imageDims)
                          throws ResolvingException
        Resolve the region request into an actual region that can be used for cropping the image
        Parameters:
        imageDims - actual image dimensions
        Returns:
        Rectangle representing th actual region
        Throws:
        ResolvingException - if rectangle is outside image dimensions
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object