Class LayeredLayout.LayeredLayoutConstraint.Inset
- Enclosing class:
LayeredLayout.LayeredLayoutConstraint
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbottom()Gets the bottom inset in this constraint.intcalcPreferredValue(Container parent, Component cmp) Calculate the preferred value of this inset.changeReference(Container parent, Component newRef, float pos) Changes the reference component, while updating the value to remain in the same absolute position.changeUnits(byte unit) Changes the units of this inset, and updates the value to remain the same as the current value.changeUnits(byte unit, Component cmp) Changes the units of this inset, and updates the value to remain the same as the current value.changeUnitsTo(byte unit, Container parent) Changes the units of this inset, and updates the value to remain the same as the current value.changeUnitsTo(byte unit, Rectangle refBox) Gets the constraint that contains this inset.copy()Creates a copy of this inset.Copies this inset into the corresponding inset of the provided component.Copies this inset to the corresponding inset of the provided constraint.Copies this inset into another inset.intReturns the total inset of this inset when applied to the given component.floatGets the current value of this inset in millimetres.intGets the current value of this inset in pixels.Recursively gets all of the reference components of this inset.getDependencies(Set<Component> deps) Recursively gets all of the reference components of this inset.Gets the opposite inset of this inset within its parent constraint.Gets the reference component for this inset.floatGets the reference position for this inset.intgetSide()Gets the side of this inset.bytegetUnit()Gets the unit of this inset.Gets the value of this inset as a string.getValueAsString(int decimalPlaces) Gets the value of this inset as a string rounding to the specified number of decimal places.booleanisFixed()Checks if this is a fixed inset.booleanChecks if this is a flexible inset.booleanTrue if this is a horizontal inset (left or right).booleanTrue if this is a vertical inset (top or bottom).left()Gets the left inset in this constraint.Sets the reference component for this inset.referencePosition(float position) Sets the reference position for this inset.right()Gets the right inset in the constraint.setAuto()Sets the units to "auto" (i.e. makes the inset flexible).setDips()Sets the units to "dips" (millimetres).setDips(float dips) Sets the inset value to the provided dips/millimetre value.Sets the units to percent.setPercent(float percent) Sets the inset value in percentage.Sets the units to pixels.setPixels(int px) Sets the inset value to the provided number of pixels.setValueAsString(String value) Sets the value of this inset as a string.top()Gets the top inset in this constraint.toString()Prints this inset as a string.translateMM(float delta, boolean preferMM, Container parent) Translates the inset by delta millimetres.translatePixels(int delta, boolean preferMM, Container parent) Translates the inset by delta pixels.unit(byte unit) Sets the unit for this constraint.value(float value) Sets the value of this inset.
-
Constructor Details
-
Inset
public Inset(int side) Creates a new inset for the given side.
Parameters
side: One ofComponent#TOP,Component#BOTTOM,Component#LEFT, orComponent#RIGHT.
-
-
Method Details
-
toString
-
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
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
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
Gets the left inset in this constraint.
Returns
The left inset of the constraint.
-
right
Gets the right inset in the constraint.
Returns
The right inset of the constraint.
-
top
Gets the top inset in this constraint.
Returns
The top inset in this constraint.
-
bottom
Gets the bottom inset in this constraint.
Returns
The bottom inset.
-
constraint
Gets the constraint that contains this inset.
Returns
The parent constraint of this inset.
-
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
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
Sets the units to "dips" (millimetres). Doesn't perform any calculations on the value.
Returns
Self for chaining.
See also
- #unit(byte)
-
setPercent
Sets the units to percent. Doesn't perform any calculations on the value.
Returns
Self for chaining.
See also
- #unit(byte)
-
setPixels
Sets the units to pixels. Doesn't perform any calculations on the value.
Returns
Self for chaining.
-
setPixels
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
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
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
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
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
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#RIGHTReturns
The side of this inset. One of
Component#TOP,Component#Bottom,Component#LEFT,Component#RIGHT -
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
-
getDependencies
-
getDependencies
-
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
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
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
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
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
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
-
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
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.
-
-