Package org.apache.fop.render.txt
Class Helper
- java.lang.Object
-
- org.apache.fop.render.txt.Helper
-
public final class Helper extends java.lang.Object
This class has a few convenient static methods for number quantization.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
ceil(int x, int quantum)
Returns minimal possible integer, greater or equal thanx
, divisible byquantum
.static int
ceilPosition(int x, int y)
Returns the smallest integer that is greater than or equal to thex/y
fraction.static int
floor(int x, int quantum)
Returns maximum possible integer, less or equal thanoldValue
, divisible byquantum
.static int
floorPosition(int x, int y)
Returns the largest integer that is less than or equal to the argument and is equal tox/y
fraction.static int
round(int x, int quantum)
Returns nearest integer tox
, divisible byquantum
.static int
roundPosition(int x, int y)
Returns the closest integer tox/y
fraction.
-
-
-
Method Detail
-
round
public static int round(int x, int quantum)
Returns nearest integer tox
, divisible byquantum
.- Parameters:
x
- integer for quantizationquantum
- integer, representing quantization- Returns:
- computed nearest integer
-
ceil
public static int ceil(int x, int quantum)
Returns minimal possible integer, greater or equal thanx
, divisible byquantum
.- Parameters:
x
- integer for quantizationquantum
- integer, representing quantization- Returns:
- computed nearest integer
-
floor
public static int floor(int x, int quantum)
Returns maximum possible integer, less or equal thanoldValue
, divisible byquantum
.- Parameters:
x
- integer for quantizationquantum
- integer, representing quantization- Returns:
- computed nearest integer
-
roundPosition
public static int roundPosition(int x, int y)
Returns the closest integer tox/y
fraction. It's possible to consider this methos as a analog of Math.round(x/y), without having deal with non-integer.- Parameters:
x
- integer, fraction numeratory
- integer, fraction denominator- Returns:
- the value of the fraction rounded to the nearest
- See Also:
Math.round(double)
-
ceilPosition
public static int ceilPosition(int x, int y)
Returns the smallest integer that is greater than or equal to thex/y
fraction. It's possible to consider this function as a analog of Math.ceil(x/y), without having deal with non-integer.- Parameters:
x
- integer, fraction numeratory
- integer, fraction denominator- Returns:
- the smallest integer that is greater than or equal to
x/y
fraction - See Also:
Math.ceil(double)
-
floorPosition
public static int floorPosition(int x, int y)
Returns the largest integer that is less than or equal to the argument and is equal tox/y
fraction. It's possible to consider this function as a analog of Math.floor(x/y), without having deal with non-integer.- Parameters:
x
- integer, fraction numeratory
- integer, fraction denominator- Returns:
- the largest integer that is less than or equal to
the argument and is equal to
x/y
fraction - See Also:
Math.floor(double)
-
-