Top Fields Constructors Methods
org.apache.pdfbox.jbig2.util

public Class Utils

extends Object
Class Inheritance
Imports
java.awt.Rectangle, java.awt.geom.Rectangle2D

Field Summary

Modifier and TypeField and Description
private static final double
private static final int
private static final double

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static int

Returns:

resulting ceil value
ceil
(double
the argument
x
)

A fast implementation of Math#ceil(double).

public static double

Returns:

the clamped value
clamp
(double
input value
value
,
double
minimal value
min
,
double
maximal value
max
)

Clamp the value into the range [min..max].

public static Rectangle2D

Returns:

the resulting rectangle
dilateRect
(Rectangle2D
the given rectangle
r
,
double
horizontal value of the additional margin
marginX
,
double
vertical value of the additional margin
marginY
)

Return a new rectangle which covers the area of the given rectangle with an additional margin on the sides.

public static Rectangle

Returns:

the resulting rectangle
enlargeRectToGrid
(Rectangle2D
the given rectangle
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.

public static int

Returns:

resulting floor value
floor
(double
the argument
x
)

A fast implementation of Math#floor(double).

public static int

Returns:

rounded value
round
(double
the argument
x
)

A fast implementation of Math#round(double).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BIG_ENOUGH_FLOORback to summary
private static final double BIG_ENOUGH_FLOOR
BIG_ENOUGH_INTback to summary
private static final int BIG_ENOUGH_INT
BIG_ENOUGH_ROUNDback to summary
private static final double BIG_ENOUGH_ROUND

Constructor Detail

Utilsback to summary
public Utils()

Method Detail

ceilback to summary
public static int ceil(double x)

A fast implementation of Math#ceil(double).

Parameters
x:double

the argument

Returns:int

resulting ceil value

clampback to summary
public static double clamp(double value, double min, double max)

Clamp the value into the range [min..max].

Parameters
value:double

input value

min:double

minimal value

max:double

maximal value

Returns:double

the clamped value

dilateRectback to summary
public 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.

Parameters
r:Rectangle2D

the given rectangle

marginX:double

horizontal value of the additional margin

marginY:double

vertical value of the additional margin

Returns:Rectangle2D

the resulting rectangle

enlargeRectToGridback to summary
public static Rectangle enlargeRectToGrid(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 that enlargeToGrid(r).contains(r) == true holds. This can be depicted as the edges being stretched in an outward direction.

Parameters
r:Rectangle2D

the given rectangle

Returns:Rectangle

the resulting rectangle

floorback to summary
public static int floor(double x)

A fast implementation of Math#floor(double).

Parameters
x:double

the argument

Returns:int

resulting floor value

roundback to summary
public static int round(double x)

A fast implementation of Math#round(double).

Parameters
x:double

the argument

Returns:int

rounded value