Package org.apache.pdfbox.jbig2.util
Class Utils
java.lang.Object
org.apache.pdfbox.jbig2.util.Utils
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final double
private static final int
private static final double
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
ceil
(double x) A fast implementation ofMath.ceil(double)
.static double
clamp
(double value, double min, double max) Clamp the value into the range [min..max].static Rectangle2D
dilateRect
(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 Rectangle
Create a rectangle with the same area as the given input rectangle but with all of its edges snapped (rounded) to the integer grid.static int
floor
(double x) A fast implementation ofMath.floor(double)
.static int
round
(double x) A fast implementation ofMath.round(double)
.
-
Field Details
-
BIG_ENOUGH_INT
private static final int BIG_ENOUGH_INT- See Also:
-
BIG_ENOUGH_FLOOR
private static final double BIG_ENOUGH_FLOOR- See Also:
-
BIG_ENOUGH_ROUND
private static final double BIG_ENOUGH_ROUND- See Also:
-
-
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) == true
holds. 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
-