public class LayeredLayout.LayeredLayoutConstraint.Inset

  1. Object
  2. LayeredLayout.LayeredLayoutConstraint.Inset
Encapsulates an inset.

Constructors

public Inset(int side)Creates a new inset for the given side.

Methods

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

Inherited methods

Constructor details

Inset

public Inset(int side)
Creates a new inset for the given side.

Parameters

side int
One of Component#TOP, Component#BOTTOM, Component#LEFT, or Component#RIGHT.

Method details

toString

public String toString()
Prints this inset as a string.

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

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 byte
The unit. One of #UNIT_AUTO, #UNIT_DIPS, #UNIT_PIXELS, or #UNIT_PERCENT.

Returns

Self for chaining.

See also

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

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

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

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 int
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 float
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 float
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 Component
The reference component. (I.e. the component that the inset is “anchored” to).

Returns

Self for chaining.

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

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 Container
The parent container.
cmp Component
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 Set<Component>
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 LayeredLayout.LayeredLayoutConstraint.Inset
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 LayeredLayout.LayeredLayoutConstraint
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 Component
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)
Deprecated. Use com.codename1.ui.Container)
Changes the units of this inset, and updates the value to remain the same as the current value.

Parameters

unit byte
The unit. One of #UNIT_AUTO, #UNIT_DIPS, #UNIT_PIXELS, or #UNIT_PERCENT.

Returns

Self for chaining.

changeUnits

public LayeredLayout.LayeredLayoutConstraint.Inset changeUnits(byte unit, Component cmp)
Deprecated. Use com.codename1.ui.Container)
Changes the units of this inset, and updates the value to remain the same as the current value.

Parameters

unit byte
The unit. One of #UNIT_AUTO, #UNIT_DIPS, #UNIT_PIXELS, or #UNIT_PERCENT.
cmp Component
The component for which the inset is applying.

Returns

Self for chaining.

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 byte
The unit. One of #UNIT_AUTO, #UNIT_DIPS, #UNIT_PIXELS, or #UNIT_PERCENT.
parent Container
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 Container
The parent container.
newRef Component
The new reference component.
pos float
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

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 Component
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 int
Pixels to translate this inset by.
preferMM boolean
If this is a flexible inset, then translating it will require changing it to fixed. true to use millimetres. false to use pixels.
parent Container
The parent container used for calculating equivalent percent if this is a percent inset.

Returns

Self for chaining.

translateMM

public LayeredLayout.LayeredLayoutConstraint.Inset translateMM(float delta, boolean preferMM, Container parent)
Translates the inset by delta millimetres.

Parameters

delta float
Pixels to translate this inset by.
preferMM boolean
If this is a flexible inset, then translating it will require changing it to fixed. true to use millimetres. false to use pixels.
parent Container
The parent container used for calculating equivalent percent if this is a percent inset.

Returns

Self for chaining.