Class RegionRequest
- java.lang.Object
-
- de.digitalcollections.iiif.model.image.RegionRequest
-
public class RegionRequest extends Object
-
-
Constructor Summary
Constructors Constructor Description RegionRequest()Create a region that encompasses the whole picture, i.e.RegionRequest(boolean square)Pass 'true' to create a region that selects a square region from the image, i.e.the 'square' syntax.RegionRequest(double x, double y, double width, double height)Create a RegionRequest request that is expressed using relative values, i.e.the "pct:x,y,w,h" syntaxRegionRequest(int x, int y, int width, int height)Create a RegionRequest request that is expressed using absolute values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)static RegionRequestfromString(String str)Parse an IIIF Image API compliant region request stringStringgetCanonicalForm(Dimension imageDims)Rectangle2DgetRegion()Returns the requested regioninthashCode()booleanisRelative()Returns whether the region is expressed in relative terms.booleanisSquare()Returns whether a square region is selected.Rectangleresolve(Dimension imageDims)Resolve the region request into an actual region that can be used for cropping the imageStringtoString()Create an IIIF Image API compliant region request string
-
-
-
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 ResolvingExceptionCreate a RegionRequest request that is expressed using relative values, i.e.the "pct:x,y,w,h" syntaxThe values must be between 0.0 and 100.0.
- Parameters:
x- relative upper left x position of regiony- relative upper left y position of regionwidth- relative width of regionheight- 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 regiony- absolute upper left y position of regionwidth- absolute width of regionheight- 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
-
getCanonicalForm
public String getCanonicalForm(Dimension imageDims) throws ResolvingException
- Throws:
ResolvingException
-
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
-
-