org.apache.fop.render.txt

Class Helper


public final class Helper
extends java.lang.Object

This class has a few convenient static methods for number quantization.

Method Summary

static int
ceil(int x, int quantum)
Returns minimal possible integer, greater or equal than x, divisible by quantum.
static int
ceilPosition(int x, int y)
Returns the smallest integer that is greater than or equal to the x/y fraction.
static int
floor(int x, int quantum)
Returns maximum possible integer, less or equal than oldValue, divisible by quantum.
static int
floorPosition(int x, int y)
Returns the largest integer that is less than or equal to the argument and is equal to x/y fraction.
static int
round(int x, int quantum)
Returns nearest integer to x, divisible by quantum.
static int
roundPosition(int x, int y)
Returns the closest integer to x/y fraction.

Method Details

ceil

public static int ceil(int x,
                       int quantum)
Returns minimal possible integer, greater or equal than x, divisible by quantum.
Parameters:
x - integer for quantization
quantum - integer, representing quantization
Returns:
computed nearest integer

ceilPosition

public static int ceilPosition(int x,
                               int y)
Returns the smallest integer that is greater than or equal to the x/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 numerator
y - integer, fraction denominator
Returns:
the smallest integer that is greater than or equal to x/y fraction
See Also:
java.lang.Math.ceil(double)

floor

public static int floor(int x,
                        int quantum)
Returns maximum possible integer, less or equal than oldValue, divisible by quantum.
Parameters:
x - integer for quantization
quantum - integer, representing quantization
Returns:
computed nearest integer

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 to x/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 numerator
y - 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:
java.lang.Math.floor(double)

round

public static int round(int x,
                        int quantum)
Returns nearest integer to x, divisible by quantum.
Parameters:
x - integer for quantization
quantum - integer, representing quantization
Returns:
computed nearest integer

roundPosition

public static int roundPosition(int x,
                                int y)
Returns the closest integer to x/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 numerator
y - integer, fraction denominator
Returns:
the value of the fraction rounded to the nearest
See Also:
java.lang.Math.round(double)

Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.