Package org.apache.fop.render.txt
Class Helper
java.lang.Object
org.apache.fop.render.txt.Helper
This class has a few convenient static methods for number quantization.
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 Details
-
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:
-
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:
-
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:
-