Package org.apache.pdfbox.jbig2.util
Class Utils
- java.lang.Object
-
- org.apache.pdfbox.jbig2.util.Utils
-
public class Utils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static double
BIG_ENOUGH_FLOOR
private static int
BIG_ENOUGH_INT
private static double
BIG_ENOUGH_ROUND
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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 java.awt.geom.Rectangle2D
dilateRect(java.awt.geom.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 java.awt.Rectangle
enlargeRectToGrid(java.awt.geom.Rectangle2D r)
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 Detail
-
BIG_ENOUGH_INT
private static final int BIG_ENOUGH_INT
- See Also:
- Constant Field Values
-
BIG_ENOUGH_FLOOR
private static final double BIG_ENOUGH_FLOOR
- See Also:
- Constant Field Values
-
BIG_ENOUGH_ROUND
private static final double BIG_ENOUGH_ROUND
- See Also:
- Constant Field Values
-
-
Method Detail
-
enlargeRectToGrid
public static java.awt.Rectangle enlargeRectToGrid(java.awt.geom.Rectangle2D r)
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
public static java.awt.geom.Rectangle2D dilateRect(java.awt.geom.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.- 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
-
-