public final class MinOptMax extends Object implements Serializable
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.
Modifier and Type | Field and Description |
---|---|
static MinOptMax |
ZERO
The zero
MinOptMax instance with min == opt == max == 0 . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
MinOptMax |
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 of
MinOptMax with one fixed value for all three
properties (min, opt, max). |
static MinOptMax |
getInstance(int min,
int opt,
int max)
Returns an instance of
MinOptMax with the given values. |
int |
getMax()
Returns the maximum value of this
MinOptMax . |
int |
getMin()
Returns the minimum value of this
MinOptMax . |
int |
getOpt()
Returns the optimum value of this
MinOptMax . |
int |
getShrink()
Returns the shrinkability of this
MinOptMax which is the absolute difference
between min and opt . |
int |
getStretch()
Returns the stretchability of this
MinOptMax which is the absolute difference
between opt and max . |
int |
hashCode() |
boolean |
isElastic()
Determines whether this
MinOptMax 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 |
isNonZero()
Determines whether this
MinOptMax represents a non-zero dimension, which means
that not all values (min, opt, max) are zero. |
boolean |
isStiff()
Determines whether this
MinOptMax doesn't allow for shrinking or stretching,
which means that all values (min, opt, max) are the same. |
MinOptMax |
minus(int value)
Subtracts the given value from all three components of this instance and returns the result.
|
MinOptMax |
minus(MinOptMax operand)
Returns the difference of this
MinOptMax and the given
MinOptMax . |
MinOptMax |
minusMax(int maxOperand)
Do not use, backwards compatibility only.
|
MinOptMax |
minusMin(int minOperand)
Do not use, backwards compatibility only.
|
MinOptMax |
mult(int factor)
Returns the product of this
MinOptMax and the given factor. |
MinOptMax |
plus(int value)
Adds the given value to all three components of this instance and returns the result.
|
MinOptMax |
plus(MinOptMax operand)
Returns the sum of this
MinOptMax and the given MinOptMax . |
MinOptMax |
plusMax(int maxOperand)
Do not use, backwards compatibility only.
|
MinOptMax |
plusMin(int minOperand)
Do not use, backwards compatibility only.
|
String |
toString() |
public static final MinOptMax ZERO
MinOptMax
instance with min == opt == max == 0
.public static MinOptMax getInstance(int min, int opt, int max) throws IllegalArgumentException
MinOptMax
with the given values.min
- the minimum valueopt
- the optimum valuemax
- the maximum valueIllegalArgumentException
- if min > opt || max < opt
.public static MinOptMax getInstance(int value)
MinOptMax
with one fixed value for all three
properties (min, opt, max).value
- the value for min, opt and maxisStiff()
public int getMin()
MinOptMax
.MinOptMax
.public int getOpt()
MinOptMax
.MinOptMax
.public int getMax()
MinOptMax
.MinOptMax
.public int getShrink()
MinOptMax
which is the absolute difference
between min
and opt
.MinOptMax
which is always non-negative.public int getStretch()
MinOptMax
which is the absolute difference
between opt
and max
.MinOptMax
which is always non-negative.public MinOptMax plus(MinOptMax operand)
MinOptMax
and the given MinOptMax
.operand
- the second operand of the sum (the first is this instance itself),MinOptMax
and the given MinOptMax
.public MinOptMax plus(int value)
value
- value to add to the min, opt, max componentspublic MinOptMax minus(MinOptMax operand) throws ArithmeticException
MinOptMax
and the given
MinOptMax
. This instance must be a compound of the operand and another
MinOptMax
, that is, there must exist a MinOptMax
m
such that this.equals(m.plus(operand))
. In other words, the operand
must have less shrink and stretch than this instance.operand
- the value to be subtractedMinOptMax
and the given
MinOptMax
.ArithmeticException
- if this instance has strictly less shrink or stretch
than the operandpublic MinOptMax minus(int value)
value
- value to subtract from the min, opt, max componentspublic MinOptMax plusMin(int minOperand) throws IllegalArgumentException
minOperand
- the minimal value to be added.IllegalArgumentException
- if
min + minOperand > opt || max < opt
.public MinOptMax minusMin(int minOperand) throws IllegalArgumentException
minOperand
- the minimal value to be subtracted.IllegalArgumentException
- if
min - minOperand > opt || max < opt
.public MinOptMax plusMax(int maxOperand) throws IllegalArgumentException
maxOperand
- the maximal value to be added.IllegalArgumentException
- if
min > opt || max < opt + maxOperand
.public MinOptMax minusMax(int maxOperand) throws IllegalArgumentException
maxOperand
- the maximal value to be subtracted.IllegalArgumentException
- if
min > opt || max < opt - maxOperand
.public MinOptMax mult(int factor) throws IllegalArgumentException
MinOptMax
and the given factor.factor
- the factorMinOptMax
and the given factorIllegalArgumentException
- if the factor is negativepublic boolean isNonZero()
MinOptMax
represents a non-zero dimension, which means
that not all values (min, opt, max) are zero.true
if this MinOptMax
represents a non-zero dimension;
false
otherwise.public boolean isStiff()
MinOptMax
doesn't allow for shrinking or stretching,
which means that all values (min, opt, max) are the same.true
if whether this MinOptMax
doesn't allow for shrinking
or stretching; false
otherwise.isElastic()
public boolean isElastic()
MinOptMax
allows for shrinking or stretching, which
means that at least one of the min or max values isn't equal to the opt value.true
if this MinOptMax
allows for shrinking or stretching;
false
otherwise.isStiff()
public MinOptMax extendMinimum(int newMin)
newMin
- the new minimum lengthMinOptMax
instance with the minimum length extendedCopyright © 2022 Apache Software Foundation. All rights reserved.