Class SizeRequest


  • public class SizeRequest
    extends Object
    • Constructor Detail

      • SizeRequest

        public SizeRequest()
        Create a size request for the full native resolution of the image region.
      • SizeRequest

        public SizeRequest​(boolean isMax)
        Create a size request for the maximum supported size of the image region, if isMax is true. If isMax is false, it behaves identically to the default constructor.
        Parameters:
        isMax - true causes a size request for the maximum supported size of the image region
      • SizeRequest

        public SizeRequest​(Integer width,
                           Integer height)
                    throws ResolvingException
        Create a size request for a given width or height. One of both can be null (the other value will be determined based on the aspect ratio of the image region), but not both at once.
        Parameters:
        width - width of size request
        height - height of size request
        Throws:
        ResolvingException - if neither width nor height are specified
      • SizeRequest

        public SizeRequest​(int width,
                           int height,
                           boolean bestFit)
                    throws ResolvingException
        Create a size request for a given width and height and signal that the server can decide to render smaller resolutions as it deems neccessary.
        Parameters:
        width - width of size request
        height - height of size request
        bestFit - true, if server can decide to render smaller resolutions as it deems neccessary
        Throws:
        ResolvingException - if params can not be resolved to Size Request
      • SizeRequest

        public SizeRequest​(BigDecimal percentage)
                    throws ResolvingException
        Create a size request that scaled both dimensions according to a fixed percentage, maintaining the aspect ratio.
        Parameters:
        percentage - scaling percentage, maintaining aspect ratio
        Throws:
        ResolvingException - if the percentage is not between 0 and 100
    • Method Detail

      • fromString

        public static SizeRequest fromString​(String str)
                                      throws ResolvingException
        Parse an IIIF Image API compliant size request string
        Parameters:
        str - IIIF Image API compliant size request string
        Returns:
        parsed SizeRequest
        Throws:
        ResolvingException - if the request string is malformed
      • isMax

        public boolean isMax()
        Return whether the maximum resolution was requested.
        Returns:
        true, if maximum resolution was requested
      • isBestFit

        public boolean isBestFit()
        Return whether the server can decide to render smaller resolutions than desired.
        Returns:
        true, if the server can decide to render smaller resolutions than desired
      • getWidth

        public Integer getWidth()
        Get the requested width
        Returns:
        requested width
      • getHeight

        public Integer getHeight()
        Get the requested height
        Returns:
        requested height
      • getPercentage

        public BigDecimal getPercentage()
        Get the requested percentage to be used for scaling
        Returns:
        requested percentage to be used for scaling
      • resolve

        public Dimension resolve​(Dimension nativeSize,
                                 List<Dimension> availableSizes,
                                 ImageApiProfile profile)
                          throws ResolvingException
        Resolve the request to dimensions that can be used for scaling, based on the native size of the image region and the available profile.
        Parameters:
        nativeSize - native size of the image region
        availableSizes - available sizes
        profile - image api profile
        Returns:
        resolved dimension
        Throws:
        ResolvingException - if params can not be resolved to Dimension
      • toString

        public String toString()
        Create an IIIF Image API compliant size request string
        Overrides:
        toString in class Object
        Returns:
        String representation of size request
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object