Class Utils
java.lang.Object
org.apache.pdfbox.jbig2.util.Utils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intceil(double x) A fast implementation ofMath.ceil(double).static doubleclamp(double value, double min, double max) Clamp the value into the range [min..max].static Rectangle2DdilateRect(Rectangle2D r, double marginX, double marginY) Return a new rectangle which covers the area of the given rectangle with an additional margin on the sides.static RectangleCreate a rectangle with the same area as the given input rectangle but with all of its edges snapped (rounded) to the integer grid.static intfloor(double x) A fast implementation ofMath.floor(double).static intround(double x) A fast implementation ofMath.round(double).
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
enlargeRectToGrid
Create a rectangle with the same area as the given input rectangle but with all of its edges snapped (rounded) to the integer grid. The resulting rectangle is guaranteed to cover all of the input rectangle's area, so thatenlargeToGrid(r).contains(r) == trueholds. This can be depicted as the edges being stretched in an outward direction.- Parameters:
r- the given rectangle- Returns:
- the resulting rectangle
-
dilateRect
Return a new rectangle which covers the area of the given rectangle with an additional margin on the sides.- Parameters:
r- the given rectanglemarginX- horizontal value of the additional marginmarginY- vertical value of the additional margin- Returns:
- the resulting rectangle
-
clamp
public static double clamp(double value, double min, double max) Clamp the value into the range [min..max].- Parameters:
value- input valuemin- minimal valuemax- maximal value- Returns:
- the clamped value
-
floor
public static int floor(double x) A fast implementation ofMath.floor(double).- Parameters:
x- the argument- Returns:
- resulting floor value
-
round
public static int round(double x) A fast implementation ofMath.round(double).- Parameters:
x- the argument- Returns:
- rounded value
-
ceil
public static int ceil(double x) A fast implementation ofMath.ceil(double).- Parameters:
x- the argument- Returns:
- resulting ceil value
-