org.apache.fop.traits

## Class MinOptMax

- java.lang.Object
- - org.apache.fop.traits.MinOptMax

All Implemented Interfaces:
  Serializable

    public final class MinOptMax
    extends Object
    implements 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:
  Serialized Form

### Field Summary

Fields
`static MinOptMax` `ZERO` The zero `MinOptMax` instance with `min == opt == max == 0`.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`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()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### ZERO

    public static final MinOptMax ZERO

The zero `MinOptMax` instance with `min == opt == max == 0`.

### Method Detail

#### getInstance

    public static MinOptMax getInstance(int min,
                                        int opt,
                                        int max)
                                 throws IllegalArgumentException

Returns an instance of `MinOptMax` with the given values.

Parameters:
  `min` - the minimum value
  `opt` - the optimum value
  `max` - the maximum value
Returns:
  the corresponding instance
Throws:
  `IllegalArgumentException` - if `min > opt || max < opt`.

#### getInstance

    public static MinOptMax getInstance(int value)

Returns an instance of `MinOptMax` 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:
  `isStiff()`

#### getMin

    public int getMin()

Returns the minimum value of this `MinOptMax`.

Returns:
  the minimum value of this `MinOptMax`.

#### getOpt

    public int getOpt()

Returns the optimum value of this `MinOptMax`.

Returns:
  the optimum value of this `MinOptMax`.

#### getMax

    public int getMax()

Returns the maximum value of this `MinOptMax`.

Returns:
  the maximum value of this `MinOptMax`.

#### getShrink

    public int getShrink()

Returns the shrinkability of this `MinOptMax` which is the absolute difference between `min` and `opt`.

Returns:
  the shrinkability of this `MinOptMax` which is always non-negative.

#### getStretch

    public int getStretch()

Returns the stretchability of this `MinOptMax` which is the absolute difference between `opt` and `max`.

Returns:
  the stretchability of this `MinOptMax` which is always non-negative.

#### plus

    public MinOptMax plus(MinOptMax operand)

Returns the sum of this `MinOptMax` and the given `MinOptMax`.

Parameters:
  `operand` - the second operand of the sum (the first is this instance itself),
Returns:
  the sum of this `MinOptMax` and the given `MinOptMax`.

#### plus

    public MinOptMax plus(int value)

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

    public MinOptMax minus(MinOptMax operand)
                    throws ArithmeticException

Returns the difference of this `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.

Parameters:
  `operand` - the value to be subtracted
Returns:
  the difference of this `MinOptMax` and the given `MinOptMax`.
Throws:
  `ArithmeticException` - if this instance has strictly less shrink or stretch than the operand

#### minus

    public MinOptMax minus(int value)

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

    public MinOptMax plusMin(int minOperand)
                      throws IllegalArgumentException

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` - if `min + minOperand > opt || max < opt`.

#### minusMin

    public MinOptMax minusMin(int minOperand)
                       throws IllegalArgumentException

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` - if `min - minOperand > opt || max < opt`.

#### plusMax

    public MinOptMax plusMax(int maxOperand)
                      throws IllegalArgumentException

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` - if `min > opt || max < opt + maxOperand`.

#### minusMax

    public MinOptMax minusMax(int maxOperand)
                       throws IllegalArgumentException

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` - if `min > opt || max < opt - maxOperand`.

#### mult

    public MinOptMax mult(int factor)
                   throws IllegalArgumentException

Returns the product of this `MinOptMax` 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 this `MinOptMax` represents a non-zero dimension, which means that not all values (min, opt, max) are zero.

Returns:
  `true` if this `MinOptMax` represents a non-zero dimension; `false` otherwise.

#### isStiff

    public boolean isStiff()

Determines whether this `MinOptMax` doesn't allow for shrinking or stretching, which means that all values (min, opt, max) are the same.

Returns:
  `true` if whether this `MinOptMax` doesn't allow for shrinking or stretching; `false` otherwise.
See Also:
  `isElastic()`

#### isElastic

    public 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.

Returns:
  `true` if this `MinOptMax` allows for shrinking or stretching; `false` otherwise.
See Also:
  `isStiff()`

#### extendMinimum

    public MinOptMax extendMinimum(int newMin)

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

    public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`