

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object com.miginfocom.calendar.layout.Distributor
public class Distributor
A class that evenly distributes a number of onedimensional lines (start, length) over some bounds given a
gap and the number of lines. Uses float
precision.
Also contains a number of static layout methods that will help laying out arbitrary sizes in one dimension.
Field Summary  

static int 
MAX

static int 
MIN

static int 
PREFERRED

Constructor Summary  

Distributor(float start,
float size,
AtRefNumber linePrefSize,
AtRefNumber lineMinSize,
AtRefNumber lineMaxSize,
AtRefNumber internalGap,
AtRefNumber externalGap,
int lineCount,
boolean roundToCords)
Constructor 
Method Summary  

static AtRefNumber[][] 
cloneSizes(AtRefNumber[][] arr)
Shallow clones the array 
static float[] 
distribute(AtRefNumber[][] sizes,
float bounds,
boolean toBounds)
Distributes some sizes that have optionally min, preferred and max size constraints within bounds . 
static int[][] 
distribute(float[] lengths,
float gap,
boolean retCoords,
boolean forDraw)
Distributes a number of lines with different lengths and rounds the start and stop/lengths to int s. 
static int[] 
distribute(int size,
int count)
Distribute (chops) a size count number of times and round the resulting sizes to ints. 
double 
getBoundsLength()
Returns the bounds length. 
java.util.ListIterator 
getDoubleGapIterator(int index)
Returns an Iterator that iterates over bounds s returning Double s
that are the start of every dstributed line AND the length. 
java.util.ListIterator 
getDoubleIterator(int index)
Returns an Iterator that iterates over bounds s returning Double s
that are the start of every dstributed line AND the length. 
java.util.ListIterator 
getFloatGapIterator(int index)
Returns an Iterator that iterates over bounds s returning Float s
that are the start of every dstributed line AND the length. 
java.util.ListIterator 
getFloatIterator(int index)
Returns an Iterator that iterates over bounds s returning Float s
that are the start of every dstributed line AND the length. 
java.util.ListIterator 
getIntegerGapIterator(int index)
Returns an Iterator that iterates over bounds s returning Integers s
that are the start of every distributed line AND the length. 
java.util.ListIterator 
getIntegerIterator(int index)
Returns an Iterator that iterates over bounds s returning Integers s
that are the start of every distributed line AND the length. 
double 
getLineLength()
Returns the length of the lines (i.e. 
static int[] 
roundSizes(float[] sizes)
Round a number of float sizes into int sizes so that the total length match up 
static int[] 
roundSizes(float size,
int count)
Round a float size into int sizes so that the total length match up 
Methods inherited from class java.lang.Object 

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Field Detail 

public static final int MIN
public static final int PREFERRED
public static final int MAX
Constructor Detail 

public Distributor(float start, float size, AtRefNumber linePrefSize, AtRefNumber lineMinSize, AtRefNumber lineMaxSize, AtRefNumber internalGap, AtRefNumber externalGap, int lineCount, boolean roundToCords)
start
 The start of the boundssize
 The length of the boundslinePrefSize
 If != null
it it the length of returned line. null
means that the length
should be so that, counting the gap, it exactly fills the bounds given the number of lines.lineMinSize
 If != null
it it the minimum length of returned line. null
means no minimum.lineMaxSize
 If != null
it it the maximum length of returned line. null
means no maximum.internalGap
 The gap between the different lines. Negative values makes lines overlap. null
means that the The gap is calculated
so that the lines exactly fills the bounds (minus external gap).externalGap
 The gap before the first and after the last line. null
means no gap (not same a 0!! see {link #getFloatGapIterator}).lineCount
 The number of lines to distribute over bounds
roundToCords
 If true
the returned lines is rounded so that the start and end
coordinates is as close to the real positions as possible.false
the length of the lines is more accurate than the end position.true
is best for layout that are painted on a pixel based screen.Method Detail 

public java.util.ListIterator getDoubleGapIterator(int index)
Iterator
that iterates over bounds
s returning Double
s
that are the start of every dstributed line AND the length. The length is always the same for every line and can be fetched
with getLineLength()
but is included for consistency resons with getIntegerIterator(int)
index
 The index to start from.
Iterator
that iterates over bounds
s. The list is the one used internally in this
calss, so it must NOT be changed via the Iterator
!public java.util.ListIterator getFloatGapIterator(int index)
Iterator
that iterates over bounds
s returning Float
s
that are the start of every dstributed line AND the length. The length is always the same for every line and can be fetched
with getLineLength()
but is included for consistency resons with getIntegerIterator(int)
index
 The index to start from.
Iterator
that iterates over bounds
s. The list is the one used internally in this
class, so it must NOT be changed via the Iterator
!public java.util.ListIterator getIntegerGapIterator(int index)
Iterator
that iterates over bounds
s returning Integers
s
that are the start of every distributed line AND the length. If roundToCords
was set to true
in the constructor, the length rounded to an Integer might not be the same all the time, since it is more
important that the line ends in a certain place rather than have a specific length. Tis is why this
Iterator
returns Integer
s of both the start and length of every line.getDoubleIterator(int)
does!. If
roundToCords
was set to false, the length is always the same, but included anyway for consistency.
index
 The index to start from.
Iterator
that iterates over bounds
s. The list is the one used internally in this
class, so it must NOT be changed via the Iterator
!public java.util.ListIterator getDoubleIterator(int index)
Iterator
that iterates over bounds
s returning Double
s
that are the start of every dstributed line AND the length. The length is always the same for every line and can be fetched
with getLineLength()
but is included for consistency resons with getIntegerIterator(int)
index
 The index to start from.
Iterator
that iterates over bounds
s. The list is the one used internally in this
calss, so it must NOT be changed via the Iterator
!public java.util.ListIterator getFloatIterator(int index)
Iterator
that iterates over bounds
s returning Float
s
that are the start of every dstributed line AND the length. The length is always the same for every line and can be fetched
with getLineLength()
but is included for consistency resons with getIntegerIterator(int)
index
 The index to start from.
Iterator
that iterates over bounds
s. The list is the one used internally in this
class, so it must NOT be changed via the Iterator
!public java.util.ListIterator getIntegerIterator(int index)
Iterator
that iterates over bounds
s returning Integers
s
that are the start of every distributed line AND the length. If roundToCords
was set to true
in the constructor, the length rounded to an Integer might not be the same all the time, since it is more
important that the line ends in a certain place rather than have a specific length. Tis is why this
Iterator
returns Integer
s of both the start and length of every line.getDoubleIterator(int)
does!. If
roundToCords
was set to false, the length is always the same, but included anyway for consistency.
index
 The index to start from.
Iterator
that iterates over bounds
s. The list is the one used internally in this
class, so it must NOT be changed via the Iterator
!public double getLineLength()
public double getBoundsLength()
length
in the constructor is
the same as returned here.
public static float[] distribute(AtRefNumber[][] sizes, float bounds, boolean toBounds)
bounds
.
sizes
 The sizes to distribute. Every size has a MIN, PREFERRED and MAX constraints. However the constraints may be null
and if so does not apply, except for PREFERRED witch is set to 1.0 if null
. E.g. size[0][PREFERRED]
is the first size's preferred size.
The sizes themselves can be absolute or relative depending on the type of the AtRefNumber
. This means that the size constraints can be very flexible.
Sizes will never be allowed to be negative.
bounds
 The bounds that the sizes are laied out towards. An effort will be made lay out the sizes so they add up to bounds
but
the MAX/MIN boundaries won't be broken to do it.toBounds
 If true
:
AtNumber
) will be normalised so they add upp to 1.0
.
Otherwise if there are for instance just two preferred sizes, both with value 0.7f
, the sum of the returned sizes will be 40% more
than bounds
. This might, or might not, be desirable depending on what's being layed out.bounds
. MAX/MIN, though, are not. They are, if they are relative (I.e. no a AtNumber
) relative to
the whole of bounds.null
.public static AtRefNumber[][] cloneSizes(AtRefNumber[][] arr)
arr
 The array to clone. Size = [rowCount][3]
public static int[] distribute(int size, int count)
count
number of times and round the resulting sizes to ints.
size
 The size copy up.count
 The number of times to distribute/chop size
.
count
length with the sizes. Element's sizes will differ by 1 if (size % count != 0)
public static int[] roundSizes(float[] sizes)
sizes
 The sizes to round
sizes
.public static int[] roundSizes(float size, int count)
size
 The sizes to round
sizes
.public static int[][] distribute(float[] lengths, float gap, boolean retCoords, boolean forDraw)
int
s.
Can for instance be used to lay out (i.e. map to ints) a number of rows in a table that all are of different heights.
int
can hold. Since
this method should be used to lay out stuff on a screen this should never be a problem though.
retCoords
is
false
. This is because the length is also used as a regulator to lay out the lines correctly and there might
be rounding errors. The lengths should never differ from the length sent in by more than 1 though.
lengths
 The absolute lengths of the "lines" that are to be distributed.gap
 The gap between the lines.retCoords
 If true
the second element is an absolute coordinate.false
the second elements is the length of the line.forDraw
 If the returned coordinates if to be used in a "draw" command (as opposed to a "fill" command)
set this to true
. If will reduce the end coord with 1. This has no effect if retCoords
is false
since the length is always correct anyway.


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 