public class LayeredLayout.LayeredLayoutConstraint.Inset
- Object
- LayeredLayout.LayeredLayoutConstraint.Inset
Encapsulates an inset.
Constructors
public Inset(int side) | Creates a new inset for the given side. |
Methods
Inherited methods
Constructor details
Inset
public Inset(int side)Creates a new inset for the given side.
Parameters
sideint- One of
Component#TOP,Component#BOTTOM,Component#LEFT, orComponent#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
valueString- 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
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
unitbyte- 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
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
pxint- 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
dipsfloat- 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
percentfloat- 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
cmpComponent- 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
positionfloat- 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
valuefloat- 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#RIGHTReturns
The side of this inset. One of
Component#TOP, Component#Bottom, Component#LEFT, Component#RIGHTgetReferenceComponent
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
parentContainer- The parent container.
cmpComponent- 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
depsSet<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
destLayeredLayout.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
destLayeredLayout.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
cmpComponent- 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_AUTOReturns
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
unitbyte- 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
unitbyte- The unit. One of
#UNIT_AUTO,#UNIT_DIPS,#UNIT_PIXELS, or#UNIT_PERCENT. cmpComponent- 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
unitbyte- The unit. One of
#UNIT_AUTO,#UNIT_DIPS,#UNIT_PIXELS, or#UNIT_PERCENT. parentContainer- 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
parentContainer- The parent container.
newRefComponent- The new reference component.
posfloat- 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
cmpComponent- 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
deltaint- Pixels to translate this inset by.
preferMMboolean- If this is a flexible inset, then translating it will require changing it to fixed. true to use millimetres. false to use pixels.
parentContainer- 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
deltafloat- Pixels to translate this inset by.
preferMMboolean- If this is a flexible inset, then translating it will require changing it to fixed. true to use millimetres. false to use pixels.
parentContainer- The parent container used for calculating equivalent percent if this is a percent inset.
Returns
Self for chaining.