# Class LayeredLayout.LayeredLayoutConstraint.Inset

java.lang.Object
com.codename1.ui.layouts.LayeredLayout.LayeredLayoutConstraint.Inset

Enclosing class:
  `LayeredLayout.LayeredLayoutConstraint`

public class LayeredLayout.LayeredLayoutConstraint.Inset extends Object
Encapsulates an inset.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Inset(int side)`
  Creates a new inset for the given side.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `bottom()`
  Gets the bottom inset in this constraint.
  `int`
  `calcPreferredValue(Container parent, Component cmp)`
  Calculate the preferred value of this inset.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `changeReference(Container parent, Component newRef, float pos)`
  Changes the reference component, while updating the value to remain in the same absolute position.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `changeUnits(byte unit)`
  Changes the units of this inset, and updates the value to remain the same as the current value.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `changeUnits(byte unit, Component cmp)`
  Changes the units of this inset, and updates the value to remain the same as the current value.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `changeUnitsTo(byte unit, Container parent)`
  Changes the units of this inset, and updates the value to remain the same as the current value.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `changeUnitsTo(byte unit, Rectangle refBox)`
  `LayeredLayout.LayeredLayoutConstraint`
  `constraint()`
  Gets the constraint that contains this inset.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `copy()`
  Creates a copy of this inset.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `copyTo(Component cmp)`
  Copies this inset into the corresponding inset of the provided component.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `copyTo(LayeredLayout.LayeredLayoutConstraint dest)`
  Copies this inset to the corresponding inset of the provided constraint.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `copyTo(LayeredLayout.LayeredLayoutConstraint.Inset dest)`
  Copies this inset into another inset.
  `int`
  `getAbsolutePixels(Component cmp)`
  Returns the total inset of this inset when applied to the given component.
  `float`
  `getCurrentValueMM()`
  Gets the current value of this inset in millimetres.
  `int`
  `getCurrentValuePx()`
  Gets the current value of this inset in pixels.
  `Set<Component>`
  `getDependencies()`
  Recursively gets all of the reference components of this inset.
  `Set<Component>`
  `getDependencies(Set<Component> deps)`
  Recursively gets all of the reference components of this inset.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `getOppositeInset()`
  Gets the opposite inset of this inset within its parent constraint.
  `Component`
  `getReferenceComponent()`
  Gets the reference component for this inset.
  `float`
  `getReferencePosition()`
  Gets the reference position for this inset.
  `int`
  `getSide()`
  Gets the side of this inset.
  `byte`
  `getUnit()`
  Gets the unit of this inset.
  `String`
  `getValueAsString()`
  Gets the value of this inset as a string.
  `String`
  `getValueAsString(int decimalPlaces)`
  Gets the value of this inset as a string rounding to the specified number of decimal places.
  `boolean`
  `isFixed()`
  Checks if this is a fixed inset.
  `boolean`
  `isFlexible()`
  Checks if this is a flexible inset.
  `boolean`
  `isHorizontal()`
  True if this is a horizontal inset (left or right).
  `boolean`
  `isVertical()`
  True if this is a vertical inset (top or bottom).
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `left()`
  Gets the left inset in this constraint.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `referenceComponent(Component cmp)`
  Sets the reference component for this inset.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `referencePosition(float position)`
  Sets the reference position for this inset.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `right()`
  Gets the right inset in the constraint.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `setAuto()`
  Sets the units to "auto" (i.e. makes the inset flexible).
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `setDips()`
  Sets the units to "dips" (millimetres).
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `setDips(float dips)`
  Sets the inset value to the provided dips/millimetre value.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `setPercent()`
  Sets the units to percent.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `setPercent(float percent)`
  Sets the inset value in percentage.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `setPixels()`
  Sets the units to pixels.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `setPixels(int px)`
  Sets the inset value to the provided number of pixels.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `setValueAsString(String value)`
  Sets the value of this inset as a string.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `top()`
  Gets the top inset in this constraint.
  `String`
  `toString()`
  Prints this inset as a string.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `translateMM(float delta, boolean preferMM, Container parent)`
  Translates the inset by delta millimetres.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `translatePixels(int delta, boolean preferMM, Container parent)`
  Translates the inset by delta pixels.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `unit(byte unit)`
  Sets the unit for this constraint.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `value(float value)`
  Sets the value of this inset.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### Inset

    public Inset(int side)

    Creates a new inset for the given side.

    ###### Parameters

    - `side`: One of `Component#TOP`, `Component#BOTTOM`, `Component#LEFT`, or `Component#RIGHT`.

- ## Method Details

  - ### toString

    public String toString()
    Prints this inset as a string.
    Overrides:
      `toString` in class `Object`

  - ### getValueAsString

    public String getValueAsString()

    Gets the value of this inset as a string. Values will be in the format , e.g. 2mm, 15%, 5px, auto (meaning it is flexible.

    ###### Returns

    The value of this inset as a string.

  - ### setValueAsString

    public LayeredLayout.LayeredLayoutConstraint.Inset setValueAsString(String value)

    Sets the value of this inset as a string. E.g. "2mm", or "2px", or "3%", "auto", or "baseline".

    ###### Parameters

    - `value`: The value of this inset.

    ###### Returns

    Self for chaining.

  - ### getValueAsString

    public String getValueAsString(int decimalPlaces)

    Gets the value of this inset as a string rounding to the specified number of decimal places. Values will be in the format , e.g. 2mm, 15%, 5px, auto (meaning it is flexible.

    ###### Returns

    The value of this inset as a string.

    ###### See also

    - #getValueAsString()

  - ### left

    public LayeredLayout.LayeredLayoutConstraint.Inset left()

    Gets the left inset in this constraint.

    ###### Returns

    The left inset of the constraint.

  - ### right

    public LayeredLayout.LayeredLayoutConstraint.Inset right()

    Gets the right inset in the constraint.

    ###### Returns

    The right inset of the constraint.

  - ### top

    public LayeredLayout.LayeredLayoutConstraint.Inset top()

    Gets the top inset in this constraint.

    ###### Returns

    The top inset in this constraint.

  - ### bottom

    public LayeredLayout.LayeredLayoutConstraint.Inset bottom()

    Gets the bottom inset in this constraint.

    ###### Returns

    The bottom inset.

  - ### constraint

    public LayeredLayout.LayeredLayoutConstraint constraint()

    Gets the constraint that contains this inset.

    ###### Returns

    The parent constraint of this inset.

  - ### unit

    public LayeredLayout.LayeredLayoutConstraint.Inset unit(byte unit)

    Sets the unit for this constraint. This doesn't perform any recalculation on the value. Just sets the unit.

    ###### Parameters

    - `unit`: The unit. One of `#UNIT_AUTO`, `#UNIT_DIPS`, `#UNIT_PIXELS`, or `#UNIT_PERCENT`.

    ###### Returns

    Self for chaining.

    ###### See also

    - #setAuto()

    - #setDips()

    - #setPixels()

    - #setPercent()

    - #changeUnits(byte) To change units while recalculating the value to be effectively equivalent.

  - ### setAuto

    public LayeredLayout.LayeredLayoutConstraint.Inset setAuto()

    Sets the units to "auto" (i.e. makes the inset flexible). Doesn't perform any calculations on the value.

    ###### Returns

    Self for chaining.

    ###### See also

    - #unit(byte)

  - ### setDips

    public LayeredLayout.LayeredLayoutConstraint.Inset setDips()

    Sets the units to "dips" (millimetres). Doesn't perform any calculations on the value.

    ###### Returns

    Self for chaining.

    ###### See also

    - #unit(byte)

  - ### setPercent

    public LayeredLayout.LayeredLayoutConstraint.Inset setPercent()

    Sets the units to percent. Doesn't perform any calculations on the value.

    ###### Returns

    Self for chaining.

    ###### See also

    - #unit(byte)

  - ### setPixels

    public LayeredLayout.LayeredLayoutConstraint.Inset setPixels()

    Sets the units to pixels. Doesn't perform any calculations on the value.

    ###### Returns

    Self for chaining.

  - ### setPixels

    public LayeredLayout.LayeredLayoutConstraint.Inset setPixels(int px)

    Sets the inset value to the provided number of pixels. This will chnage the unit to pixels.

    ###### Parameters

    - `px`: The pixel value of the inset.

    ###### Returns

    Self for chaining.

  - ### setDips

    public LayeredLayout.LayeredLayoutConstraint.Inset setDips(float dips)

    Sets the inset value to the provided dips/millimetre value. This will change the unit to millimetres.

    ###### Parameters

    - `dips`: The inset value in millimetres.

    ###### Returns

    Self for chaining.

  - ### setPercent

    public LayeredLayout.LayeredLayoutConstraint.Inset setPercent(float percent)

    Sets the inset value in percentage. This will change the unit to percentage.

    ###### Parameters

    - `percent`: The inset value as a percentage.

    ###### Returns

    Self for chaining.

  - ### referenceComponent

    public LayeredLayout.LayeredLayoutConstraint.Inset referenceComponent(Component cmp)

    Sets the reference component for this inset.

    ###### Parameters

    - `cmp`: The reference component. (I.e. the component that the inset is "anchored" to).

    ###### Returns

    Self for chaining.

    ###### See also

    - #referencePosition(float)

    - LayeredLayoutConstraint#setReferenceComponents(com.codename1.ui.Component...)

  - ### referencePosition

    public LayeredLayout.LayeredLayoutConstraint.Inset referencePosition(float position)

    Sets the reference position for this inset. A value of 0 indicates that the inset is anchored to the same side of the reference component (e.g. right inset anchored to right edge of reference component, left inset anchored to left edge of reference component). A value of 1 indicates that the inset is anchored to the opposite side of the reference component. E.g. right inset to left edge.

    ###### Parameters

    - `position`: The reference position.

    ###### Returns

    Self for chaining.

    ###### See also

    - #setReferencePositions(java.lang.String)

    - #setReferencePositions(com.codename1.ui.Component, java.lang.String)

    - #setReferencePositions(com.codename1.ui.Component, float...)

  - ### value

    public LayeredLayout.LayeredLayoutConstraint.Inset value(float value)

    Sets the value of this inset. The interpretation of the value will depend on the `#unit`. If the unit is `#UNIT_DIPS`, then this value is interpreted in millimetres, etc..

    ###### Parameters

    - `value`: The value to set this inset to.

    ###### Returns

    Self for chaining.

  - ### getSide

    public int getSide()

    Gets the side of this inset. One of `Component#TOP`, `Component#Bottom`, `Component#LEFT`, `Component#RIGHT`

    ###### Returns

    The side of this inset. One of `Component#TOP`, `Component#Bottom`, `Component#LEFT`, `Component#RIGHT`

  - ### getReferenceComponent

    public Component getReferenceComponent()

    Gets the reference component for this inset.

    ###### Returns

    The reference component for this inset.

    ###### See also

    - #referenceComponent(com.codename1.ui.Component)

  - ### getReferencePosition

    public float getReferencePosition()

    Gets the reference position for this inset.

    ###### Returns

    The reference position for this inset.

  - ### calcPreferredValue

    public int calcPreferredValue(Container parent, Component cmp)

    Calculate the preferred value of this inset.

    ###### Parameters

    - `parent`: The parent container.

    - `cmp`: The component

    ###### Returns

    The preferred value of this inset in pixels.

  - ### getDependencies

    public Set<Component> getDependencies(Set<Component> deps)

    Recursively gets all of the reference components of this inset.

    ###### Parameters

    - `deps`: An "out" parameter. The set that will hold the dependencies.

    ###### Returns

    The set of all reference components (crawled recursively of this inset.

  - ### getDependencies

    public Set<Component> getDependencies()

    Recursively gets all of the reference components of this inset.

    ###### Returns

    The set of all reference components (crawled recursively of this inset.

  - ### getOppositeInset

    public LayeredLayout.LayeredLayoutConstraint.Inset getOppositeInset()

    Gets the opposite inset of this inset within its parent constraint. E.g. if this is the left inset, it will get the associated right inset.

    ###### Returns

    The opposite inset.

  - ### copyTo

    public LayeredLayout.LayeredLayoutConstraint.Inset copyTo(LayeredLayout.LayeredLayoutConstraint.Inset dest)

    Copies this inset into another inset.

    ###### Parameters

    - `dest`: The inset to copy to.

    ###### Returns

    The copied inset.

  - ### copyTo

    public LayeredLayout.LayeredLayoutConstraint.Inset copyTo(LayeredLayout.LayeredLayoutConstraint dest)

    Copies this inset to the corresponding inset of the provided constraint.

    ###### Parameters

    - `dest`: The constraint to copy the inset into.

    ###### Returns

    The corresponding inset in dest that we copied the inset into.

  - ### copyTo

    public LayeredLayout.LayeredLayoutConstraint.Inset copyTo(Component cmp)

    Copies this inset into the corresponding inset of the provided component.

    ###### Parameters

    - `cmp`: The component that we are copying the inset into.

    ###### Returns

    The copied inset.

  - ### copy

    public LayeredLayout.LayeredLayoutConstraint.Inset copy()
    Creates a copy of this inset.

  - ### getUnit

    public byte getUnit()

    Gets the unit of this inset.

    ###### Returns

    One of `#UNIT_AUTO`, `#UNIT_DIPS`, `#UNIT_PIXELS`, or `#UNIT_PERCENT`.

  - ### isFixed

    public boolean isFixed()

    Checks if this is a fixed inset. An inset is considered "fixed" if its unit is not `#UNIT_AUTO`

    ###### Returns

    True if the inset is fixed.

  - ### getCurrentValueMM

    public float getCurrentValueMM()
    Gets the current value of this inset in millimetres. If the inset uses a different unit, then this will calculate the corresponding value.

  - ### getCurrentValuePx

    public int getCurrentValuePx()

    Gets the current value of this inset in pixels. If the inset uses a different unit then this will calculate the corresponding value.

    ###### Returns

    The value of this inset in pixels.

  - ### isVertical

    public boolean isVertical()
    True if this is a vertical inset (top or bottom).

  - ### isHorizontal

    public boolean isHorizontal()
    True if this is a horizontal inset (left or right).

  - ### changeUnits

    public LayeredLayout.LayeredLayoutConstraint.Inset changeUnits(byte unit)

    Changes the units of this inset, and updates the value to remain the same as the current value.

    ###### Parameters

    - `unit`: The unit. One of `#UNIT_AUTO`, `#UNIT_DIPS`, `#UNIT_PIXELS`, or `#UNIT_PERCENT`.

    ###### Returns

    Self for chaining.

    ###### Deprecated

    Use `com.codename1.ui.Container)`

  - ### changeUnits

    public LayeredLayout.LayeredLayoutConstraint.Inset changeUnits(byte unit, Component cmp)

    Changes the units of this inset, and updates the value to remain the same as the current value.

    ###### Parameters

    - `unit`: The unit. One of `#UNIT_AUTO`, `#UNIT_DIPS`, `#UNIT_PIXELS`, or `#UNIT_PERCENT`.

    - `cmp`: The component for which the inset is applying.

    ###### Returns

    Self for chaining.

    ###### Deprecated

    Use `com.codename1.ui.Container)`

  - ### changeUnitsTo

    public LayeredLayout.LayeredLayoutConstraint.Inset changeUnitsTo(byte unit, Container parent)

    Changes the units of this inset, and updates the value to remain the same as the current value.

    ###### Parameters

    - `unit`: The unit. One of `#UNIT_AUTO`, `#UNIT_DIPS`, `#UNIT_PIXELS`, or `#UNIT_PERCENT`.

    - `parent`: The container in which the layout applies.

    ###### Returns

    Self for chaining.

  - ### changeUnitsTo

    public LayeredLayout.LayeredLayoutConstraint.Inset changeUnitsTo(byte unit, Rectangle refBox)

  - ### changeReference

    public LayeredLayout.LayeredLayoutConstraint.Inset changeReference(Container parent, Component newRef, float pos)

    Changes the reference component, while updating the value to remain in the same absolute position.

    ###### Parameters

    - `parent`: The parent container.

    - `newRef`: The new reference component.

    - `pos`: The reference position.

    ###### Returns

    Self for chaining.

  - ### isFlexible

    public boolean isFlexible()

    Checks if this is a flexible inset. An inset is considered flexible if its unit is `#UNIT_AUTO`.

    ###### Returns

    True if this is a flexible inset.

    ###### See also

    - #isFixed()

  - ### getAbsolutePixels

    public int getAbsolutePixels(Component cmp)

    Returns the total inset of this inset when applied to the given component. This will calculate and sum all of the insets of reference components to get the total inset in pixels from the parent component.

    ###### Parameters

    - `cmp`: The component context.

    ###### Returns

    The total inset in pixels from the parent.

  - ### translatePixels

    public LayeredLayout.LayeredLayoutConstraint.Inset translatePixels(int delta, boolean preferMM, Container parent)

    Translates the inset by delta pixels.

    ###### Parameters

    - `delta`: Pixels to translate this inset by.

    - `preferMM`: If this is a flexible inset, then translating it will require changing it to fixed. true to use millimetres. false to use pixels.

    - `parent`: The parent container used for calculating equivalent percent if this is a percent inset.

    ###### Returns

    Self for chaining.

    ###### See also

    - #translateMM(float, boolean, com.codename1.ui.Container)

  - ### translateMM

    public LayeredLayout.LayeredLayoutConstraint.Inset translateMM(float delta, boolean preferMM, Container parent)

    Translates the inset by delta millimetres.

    ###### Parameters

    - `delta`: Pixels to translate this inset by.

    - `preferMM`: If this is a flexible inset, then translating it will require changing it to fixed. true to use millimetres. false to use pixels.

    - `parent`: The parent container used for calculating equivalent percent if this is a percent inset.

    ###### Returns

    Self for chaining.