Package org.apache.fop.traits
Class MinOptMax
java.lang.Object
org.apache.fop.traits.MinOptMax
- All Implemented Interfaces:
Serializable
This class holds the resolved (as mpoints) form of a
LengthRange
or
Space
type property value.
Instances of this class are immutable. All arithmetic methods like
plus
, minus
or mult
return a different instance. So it is possible to pass around instances without
copying.
MinOptMax
values are used during layout calculations.
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionboolean
extendMinimum
(int newMin) Extends the minimum length to the given length if necessary, and adjusts opt and max accordingly.static MinOptMax
getInstance
(int value) Returns an instance ofMinOptMax
with one fixed value for all three properties (min, opt, max).static MinOptMax
getInstance
(int min, int opt, int max) Returns an instance ofMinOptMax
with the given values.int
getMax()
Returns the maximum value of thisMinOptMax
.int
getMin()
Returns the minimum value of thisMinOptMax
.int
getOpt()
Returns the optimum value of thisMinOptMax
.int
Returns the shrinkability of thisMinOptMax
which is the absolute difference betweenmin
andopt
.int
Returns the stretchability of thisMinOptMax
which is the absolute difference betweenopt
andmax
.int
hashCode()
boolean
Determines whether thisMinOptMax
allows for shrinking or stretching, which means that at least one of the min or max values isn't equal to the opt value.boolean
Determines whether thisMinOptMax
represents a non-zero dimension, which means that not all values (min, opt, max) are zero.boolean
isStiff()
Determines whether thisMinOptMax
doesn't allow for shrinking or stretching, which means that all values (min, opt, max) are the same.minus
(int value) Subtracts the given value from all three components of this instance and returns the result.Returns the difference of thisMinOptMax
and the givenMinOptMax
.minusMax
(int maxOperand) Do not use, backwards compatibility only.minusMin
(int minOperand) Do not use, backwards compatibility only.mult
(int factor) Returns the product of thisMinOptMax
and the given factor.plus
(int value) Adds the given value to all three components of this instance and returns the result.Returns the sum of thisMinOptMax
and the givenMinOptMax
.plusMax
(int maxOperand) Do not use, backwards compatibility only.plusMin
(int minOperand) Do not use, backwards compatibility only.toString()
-
Field Details
-
ZERO
The zeroMinOptMax
instance withmin == opt == max == 0
.
-
-
Method Details
-
getInstance
Returns an instance ofMinOptMax
with the given values.- Parameters:
min
- the minimum valueopt
- the optimum valuemax
- the maximum value- Returns:
- the corresponding instance
- Throws:
IllegalArgumentException
- ifmin > opt || max < opt
.
-
getInstance
Returns an instance ofMinOptMax
with one fixed value for all three properties (min, opt, max).- Parameters:
value
- the value for min, opt and max- Returns:
- the corresponding instance
- See Also:
-
getMin
public int getMin()Returns the minimum value of thisMinOptMax
.- Returns:
- the minimum value of this
MinOptMax
.
-
getOpt
public int getOpt()Returns the optimum value of thisMinOptMax
.- Returns:
- the optimum value of this
MinOptMax
.
-
getMax
public int getMax()Returns the maximum value of thisMinOptMax
.- Returns:
- the maximum value of this
MinOptMax
.
-
getShrink
public int getShrink()Returns the shrinkability of thisMinOptMax
which is the absolute difference betweenmin
andopt
.- Returns:
- the shrinkability of this
MinOptMax
which is always non-negative.
-
getStretch
public int getStretch()Returns the stretchability of thisMinOptMax
which is the absolute difference betweenopt
andmax
.- Returns:
- the stretchability of this
MinOptMax
which is always non-negative.
-
plus
Returns the sum of thisMinOptMax
and the givenMinOptMax
.- Parameters:
operand
- the second operand of the sum (the first is this instance itself),- Returns:
- the sum of this
MinOptMax
and the givenMinOptMax
.
-
plus
Adds the given value to all three components of this instance and returns the result.- Parameters:
value
- value to add to the min, opt, max components- Returns:
- the result of the addition
-
minus
Returns the difference of thisMinOptMax
and the givenMinOptMax
. This instance must be a compound of the operand and anotherMinOptMax
, that is, there must exist aMinOptMax
m such thatthis.equals(m.plus(operand))
. In other words, the operand must have less shrink and stretch than this instance.- Parameters:
operand
- the value to be subtracted- Returns:
- the difference of this
MinOptMax
and the givenMinOptMax
. - Throws:
ArithmeticException
- if this instance has strictly less shrink or stretch than the operand
-
minus
Subtracts the given value from all three components of this instance and returns the result.- Parameters:
value
- value to subtract from the min, opt, max components- Returns:
- the result of the subtraction
-
plusMin
Do not use, backwards compatibility only. Returns an instance with the given value added to the minimal value.- Parameters:
minOperand
- the minimal value to be added.- Returns:
- an instance with the given value added to the minimal value.
- Throws:
IllegalArgumentException
- ifmin + minOperand > opt || max < opt
.
-
minusMin
Do not use, backwards compatibility only. Returns an instance with the given value subtracted to the minimal value.- Parameters:
minOperand
- the minimal value to be subtracted.- Returns:
- an instance with the given value subtracted to the minimal value.
- Throws:
IllegalArgumentException
- ifmin - minOperand > opt || max < opt
.
-
plusMax
Do not use, backwards compatibility only. Returns an instance with the given value added to the maximal value.- Parameters:
maxOperand
- the maximal value to be added.- Returns:
- an instance with the given value added to the maximal value.
- Throws:
IllegalArgumentException
- ifmin > opt || max < opt + maxOperand
.
-
minusMax
Do not use, backwards compatibility only. Returns an instance with the given value subtracted to the maximal value.- Parameters:
maxOperand
- the maximal value to be subtracted.- Returns:
- an instance with the given value subtracted to the maximal value.
- Throws:
IllegalArgumentException
- ifmin > opt || max < opt - maxOperand
.
-
mult
Returns the product of thisMinOptMax
and the given factor.- Parameters:
factor
- the factor- Returns:
- the product of this
MinOptMax
and the given factor - Throws:
IllegalArgumentException
- if the factor is negative
-
isNonZero
public boolean isNonZero()Determines whether thisMinOptMax
represents a non-zero dimension, which means that not all values (min, opt, max) are zero.- Returns:
true
if thisMinOptMax
represents a non-zero dimension;false
otherwise.
-
isStiff
public boolean isStiff()Determines whether thisMinOptMax
doesn't allow for shrinking or stretching, which means that all values (min, opt, max) are the same.- Returns:
true
if whether thisMinOptMax
doesn't allow for shrinking or stretching;false
otherwise.- See Also:
-
isElastic
public boolean isElastic()Determines whether thisMinOptMax
allows for shrinking or stretching, which means that at least one of the min or max values isn't equal to the opt value.- Returns:
true
if thisMinOptMax
allows for shrinking or stretching;false
otherwise.- See Also:
-
extendMinimum
Extends the minimum length to the given length if necessary, and adjusts opt and max accordingly.- Parameters:
newMin
- the new minimum length- Returns:
- a
MinOptMax
instance with the minimum length extended
-
equals
-
hashCode
public int hashCode() -
toString
-