org.crsh.text.ui
Class Layout.Weighted

java.lang.Object
  extended by org.crsh.text.ui.Layout
      extended by org.crsh.text.ui.Layout.Weighted
Enclosing class:
Layout

public static class Layout.Weighted
extends Layout


Nested Class Summary
 
Nested classes/interfaces inherited from class org.crsh.text.ui.Layout
Layout.Weighted
 
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 length 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 org.crsh.text.ui.Layout
flow, weighted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

weights

private final int[] weights
The weights.

Constructor Detail

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
Method Detail

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 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 length
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 © 2014 eXo Platform SAS. All Rights Reserved.