org.crsh.text.ui
Class Layout.Weighted
java.lang.Object
org.crsh.text.ui.Layout
org.crsh.text.ui.Layout.Weighted
- Enclosing class:
- Layout
-
public static class Layout.Weighted
- extends Layout
-
Field Summary |
private int[] |
weights
The weights. |
Constructor Summary |
private |
Layout.Weighted(int... weights)
Create a new weighted layout. |
Method Summary |
(package private) int[] |
compute(boolean spaced, int length, int[] actualLengths, int[] minLengths)
Computes the list of lengths for the specifid list of cells with the following constraints: the sum of the returned array elements must be equals to the totalLength argument a cell length should never be lesser than the provided minimum length The returned array is the list of lengths from left to right, the array size may be less than the number of cells (i.e the size of the actualLengths and minLengths arguments). |
int[] |
getWeights()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
weights
private final int[] weights
-
The weights.
Layout.Weighted
private Layout.Weighted(int... weights)
throws NullPointerException,
IllegalArgumentException
-
Create a new weighted layout.
- Parameters:
weights
- the weights
- Throws:
NullPointerException
- if the weights argument is null
IllegalArgumentException
- if any weight is negative
getWeights
public int[] getWeights()
-
compute
int[] compute(boolean spaced,
int length,
int[] actualLengths,
int[] minLengths)
- Description copied from class:
Layout
-
Computes the list of lengths for the specifid list of cells with the following constraints:
- the sum of the returned array elements must be equals to the
totalLength
argument
- a cell length should never be lesser than the provided minimum length
The returned array is the list of lengths from left to right, the array size may be less than the number of cells (i.e the size of the actualLengths
and minLengths
arguments). Missing cells are just be discarded and not part of the resulting layout. Array should contain only positive values, any zero length cell should be discarded. When cells must be discarded it must begin with the tail of the list, i.e it is not allowed to discard a cell that does not have a successor.
-
- Specified by:
compute
in class Layout
-
- Parameters:
spaced
- true if the cells are separated by one char
length
- the total length of the line
actualLengths
- the actual length : an estimation of what cell's desired length
minLengths
- the minmum length : the length under which a cell cannot be rendered
- Returns:
- the list of length.
Copyright © 2015 eXo Platform SAS. All Rights Reserved.