public class LayeredLayout.LayeredLayoutConstraint
- Object
- LayeredLayout.LayeredLayoutConstraint
Nested types
class LayeredLayout.LayeredLayoutConstraint.Inset | Encapsulates an inset. |
Constructors
public LayeredLayoutConstraint() |
Methods
Inherited methods
Constructor details
LayeredLayoutConstraint
public LayeredLayoutConstraint()Method details
toString
public String toString()fixDependencies
public LayeredLayout.LayeredLayoutConstraint fixDependencies(Container parent)Parameters
parentContainer- The parent container within which all dependencies should reside.
Returns
hasCircularDependency
public boolean hasCircularDependency(Component start)Parameters
startComponent- The start component to check.
Returns
getInset
public LayeredLayout.LayeredLayoutConstraint.Inset getInset(int inset)Parameters
insetint- One of
Component#TOP,Component#BOTTOM,Component#LEFTorComponent#RIGHT.
Returns
copy
public LayeredLayout.LayeredLayoutConstraint copy()copyTo
public LayeredLayout.LayeredLayoutConstraint copyTo(LayeredLayout.LayeredLayoutConstraint dest)Parameters
destLayeredLayout.LayeredLayoutConstraint- The inset to copy to.
Returns
getReferenceBox
public Rectangle getReferenceBox(Container parent, Rectangle box)cmp has no reference components in any of its insets, then the resulting box will
just bee the inner box of the parent (e.g. the parent’s inner bounds.Parameters
parentContainer- The parent container.
boxRectangle- An out parameter. This will store the bounds of the box.
Returns
getReferenceBox
public Rectangle getReferenceBox(Container parent, Component cmp2, Rectangle box)com.codename1.ui.geom.Rectangle) instead.cmp has no reference components in any of its insets, then the resulting box will
just bee the inner box of the parent (e.g. the parent’s inner bounds.Parameters
parentContainer- The parent container.
cmp2Component- Not documented.
boxRectangle- An out parameter. This will store the bounds of the box.
Returns
getReferenceBox
public Rectangle getReferenceBox(Container parent, Component cmp)getReferenceBox(com.codename1.ui.Container).cmp has no reference components in any of its insets, then the resulting box will
just bee the inner box of the parent (e.g. the parent’s inner bounds.Parameters
parentContainer- The parent container.
cmpComponent- The component whose reference box we are obtaining.
Returns
getReferenceBox
public Rectangle getReferenceBox(Container parent)cmp has no reference components in any of its insets, then the resulting box will
just bee the inner box of the parent (e.g. the parent’s inner bounds.Parameters
parentContainer- The parent container.
Returns
translatePixels
public LayeredLayout.LayeredLayoutConstraint translatePixels(int x, int y, boolean preferMM, Container parent)Parameters
xint- The number of pixels that the insets should be shifted on the x axis.
yint- The number of pixels that the insets should be shifted on the y axis.
preferMMboolean- If an inset needs to be switched from flexible to fixed, then this indicates where it will be changed to millimetres or pixels. true for millimetres.
parentContainer- The parent container in which calculations should be performed.
Returns
translateMM
public LayeredLayout.LayeredLayoutConstraint translateMM(float x, float y, boolean preferMM, Container parent)Parameters
xfloat- The number of pixels that the insets should be shifted on the x axis.
yfloat- The number of pixels that the insets should be shifted on the y axis.
preferMMboolean- If an inset needs to be switched from flexible to fixed, then this indicates where it will be changed to millimetres or pixels. true for millimetres.
parentContainer- The parent container in which calculations should be performed.
Returns
getFixedInsets
public Collection<LayeredLayout.LayeredLayoutConstraint.Inset> getFixedInsets()#UNIT_AUTO.getFlexibleInsets
public Collection<LayeredLayout.LayeredLayoutConstraint.Inset> getFlexibleInsets()#UNIT_AUTO.getReferencePositionsAsString
public String getReferencePositionsAsString(boolean withLabels)Parameters
withLabelsboolean- True to return the string in CSS format: e.g.
"top:1.0; right:0; bottom:1.0; left:1.0"false to return as a space-delimited string of inset reference positions in the order “top right bottom left”. E.g. “1.0 0 1.0 1.0”
Returns
setReferencePositions
public LayeredLayout.LayeredLayoutConstraint setReferencePositions(String positionsStr)Sets the reference component positions for this constraint from a string. The string format may be either using labels following the same output format of getReferencePositionsAsString(true) or as a space-delimited string (e.g. getReferencePositionsAsString(false). When using the label format, you may provide one or more inset values in the string. E.g. the following are all acceptable:
top:1.0; left:0; right:0; bottom:1.0
left:0.5
left:1.0; right:0.5
If you provide the positions as a space-delimited string, then they are expected to follow the same format as is used in CSS for providing margin. To summarize:
`//Apply to all four sides 1.0
//vertical | horizontal 1.0 0
// top | horizontal | bottom 1.0 0.0 0.5
// top | right | bottom | left 1.0 1.0 1.0 1.0`
Interpretation of Reference Positions:
When an inset includes a reference component, that means that the inset is “anchored” to that reference component. I.e. An inset of 1mm is measured 1mm from the outer edge of the reference component. By default it chooses the edge of on the same side as the inset. So if this is a “left” inset, then it will measure against the “left” outer edge of the reference component. This is the meaning of a 0 value for the associated reference positions.
A reference position of 1.0 will start measuring from the opposite edge. So for a “left” inset, it will measure from the “right” outer edge of the reference component. You can choose any real value for the reference position, and it will cause the measurement to be scaled accordingly. E.g. 0.5. would measure from the center point of the reference component.
Parameters
positionsStrString- The reference positions.
Returns
getReferenceComponentIndicesAsString
public String getReferenceComponentIndicesAsString(Container parent, boolean withLabels)Gets the reference component indexes within the provided parent container as a string. If an inset doesn’t have a reference component, then the corresponding index will be -1.
Use the withLabels parameter to choose whether to include labels with the indices or not. E.g:
`String indices = getReferenceComponentIndicesAsString(parent, true); // Would return something like // “top:-1; right:2; bottom:-1; left: 0”
indices = getReferenceComponentIndicesAsString(parent, false); // Would return something like: // “-1 2 -1 0” (i.e. Top Right Bottom Left)
// Interpretation: // Top inset has no reference component // Right inset has component with index 2 (i.e. parent.getComponentIndex(rightReferenceComponent) == 2) // Bottom inset has no reference component // Left inset has component with index 0 as a reference component.`
setReferenceComponentIndices
public LayeredLayout.LayeredLayoutConstraint setReferenceComponentIndices(Container parent, String indices)Parameters
parentContainer- The parent container whose children are to be used as reference components.
indicesStringThe indices to set as the reference components.
The string format may be either using labels following the same output format of cnst.getReferenceComponentIndicesAsString(true) or as a space-delimited string (e.g. cnst.getReferenceComponentIndicesAsString(false). When using the label format, you may provide one or more inset values in the string. E.g. the following are all acceptable:
getInsetsAsString
public String getInsetsAsString(boolean withLabels)Gets the insets of this constraint as a string. If withLabels is true, then it will return a string of the format:
top:2mm; right:0; bottom:10%; left:auto
If withLabels is false then it will return a space-delimited string with the inset values ordered “top right bottom left” (the same as for CSS margins) order.
setReferenceComponents
public LayeredLayout.LayeredLayoutConstraint setReferenceComponents(Component... refs)Parameters
refsComponent...- May contain 1, 2, 3, or 4 values. If only 1 value is passed, then it is set on all 4 insets. If two values are passed, then the first is set on the top and bottom insets, and the 2nd is set on the left and right insets (i.e. vertical | horizontal). If 3 values are passed, then, they are used for top, horizontal, and bottom. If 4 values are passed, then they are used for top, right, bottom, left (in that order).
Returns
setReferencePositions
public LayeredLayout.LayeredLayoutConstraint setReferencePositions(float... p)Sets the reference positions for the constraint.
Interpretation of Reference Positions:
When an inset includes a reference component, that means that the inset is “anchored” to that reference component. I.e. An inset of 1mm is measured 1mm from the outer edge of the reference component. By default it chooses the edge of on the same side as the inset. So if this is a “left” inset, then it will measure against the “left” outer edge of the reference component. This is the meaning of a 0 value for the associated reference positions.
A reference position of 1.0 will start measuring from the opposite edge. So for a “left” inset, it will measure from the “right” outer edge of the reference component. You can choose any real value for the reference position, and it will cause the measurement to be scaled accordingly. E.g. 0.5. would measure from the center point of the reference component.
Parameters
pfloat...- May contain 1, 2, 3, or 4 values. If only 1 value is passed, then it is set on all 4 insets. If two values are passed, then the first is set on the top and bottom insets, and the 2nd is set on the left and right insets (i.e. vertical | horizontal). If 3 values are passed, then, they are used for top, horizontal, and bottom. If 4 values are passed, then they are used for top, right, bottom, left (in that order).
Returns
setInsets
public LayeredLayout.LayeredLayoutConstraint setInsets(String insetStr)Sets the insets for this constraint as a string. The string may include labels or it may be a space delimited string of values with “top right bottom left” order.
If providing as a space-delimited string of inset values, then you can provide 1, 2, 3, or 4 values. If only 1 value is passed, then it is set on all 4 insets. If two values are passed, then the first is set on the top and bottom insets, and the 2nd is set on the left and right insets (i.e. vertical | horizontal). If 3 values are passed, then, they are used for top, horizontal, and bottom. If 4 values are passed, then they are used for top, right, bottom, left (in that order).
Example Inputs
“0 0 0 0” = all 4 insets are zero pixels
“0 1mm” = Vertical insets are zero. Horizontal insets are 1mm
“10% auto 20%” = Top inset is 10%. Horizontal insets are flexible. Bottom is 20%
“1mm 2mm 3mm 4mm” = Top=1mm, Right=2mm, Bottom=3mm, Left=4mm
Returns
left
public LayeredLayout.LayeredLayoutConstraint.Inset left()Returns
right
public LayeredLayout.LayeredLayoutConstraint.Inset right()Returns
top
public LayeredLayout.LayeredLayoutConstraint.Inset top()Returns
bottom
public LayeredLayout.LayeredLayoutConstraint.Inset bottom()Returns
getPercentInsetAnchorHorizontal
public float getPercentInsetAnchorHorizontal()Returns
setPercentInsetAnchorHorizontal
public LayeredLayout.LayeredLayoutConstraint setPercentInsetAnchorHorizontal(float anchor)Returns
getPercentInsetAnchorVertical
public float getPercentInsetAnchorVertical()Returns
setPercentInsetAnchorVertical
public LayeredLayout.LayeredLayoutConstraint setPercentInsetAnchorVertical(float anchor)Returns
constraint
public LayeredLayout.LayeredLayoutConstraint constraint()getDependencies
public Set<Component> getDependencies(Set<Component> deps)Parameters
depsSet<Component>- A set to add the dependencies to. (An “out” parameter).
Returns
getDependencies
public Set<Component> getDependencies()Returns
dependsOn
public boolean dependsOn(Component cmp)Parameters
cmpComponent- The component to check.