javax.swing
Class SizeSequence

java.lang.Object
  |
  +--javax.swing.SizeSequence

public class SizeSequence
extends Object

Safe:


Field Summary
private  int[] a
           
private static int[] emptyArray
           
 
Constructor Summary
SizeSequence()
          Enabled: Creates a new SizeSequence object that contains no entries.
SizeSequence(int numEntries)
          Enabled: Creates a new SizeSequence object that contains the specified number of entries, all initialized to have size 0.
SizeSequence(int[] sizes)
          Enabled: Creates a new SizeSequence object that contains the specified sizes.
SizeSequence(int numEntries, int value)
          Enabled: Creates a new SizeSequence object that contains the specified number of entries, all initialized to have size value.
 
Method Summary
private  void changeSize(int from, int to, int index, int delta)
           
 int getIndex(int position)
          Enabled: Returns the index of the entry that corresponds to the specified position.
private  int getIndex(int from, int to, int position)
           
 int getPosition(int index)
          Enabled: Returns the start position for the specified entry.
private  int getPosition(int from, int to, int index)
           
 int getSize(int index)
          Enabled: Returns the size of the specified entry.
 int[] getSizes()
          Enabled: Returns the size of all entries.
private  int getSizes(int from, int to, int[] sizes)
           
 void insertEntries(int start, int length, int value)
          Enabled: Adds a contiguous group of entries to this SizeSequence.
 void removeEntries(int start, int length)
          Enabled: Removes a contiguous group of entries from this SizeSequence.
 void setSize(int index, int size)
          Enabled: Sets the size of the specified entry.
 void setSizes(int[] sizes)
          Enabled: Resets this SizeSequence object, using the data in the sizes argument.
private  int setSizes(int from, int to, int[] sizes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

emptyArray

private static int[] emptyArray

a

private int[] a
Constructor Detail

SizeSequence

public SizeSequence()
Enabled: Creates a new SizeSequence object that contains no entries. To add entries, you can use insertEntries or setSizes.

See Also:
insertEntries(int, int, int), setSizes(int[])

SizeSequence

public SizeSequence(int numEntries)
Enabled: Creates a new SizeSequence object that contains the specified number of entries, all initialized to have size 0.

Parameters:
numEntries - the number of sizes to track

SizeSequence

public SizeSequence(int numEntries,
                    int value)
Enabled: Creates a new SizeSequence object that contains the specified number of entries, all initialized to have size value.

Parameters:
numEntries - the number of sizes to track
value - the initial value of each size

SizeSequence

public SizeSequence(int[] sizes)
Enabled: Creates a new SizeSequence object that contains the specified sizes.

Parameters:
sizes - the array of sizes to be contained in the SizeSequence
Method Detail

setSizes

public void setSizes(int[] sizes)
Enabled: Resets this SizeSequence object, using the data in the sizes argument. This method reinitializes this object so that it contains as many entries as the sizes array. Each entry's size is initialized to the value of the corresponding item in sizes.

Parameters:
sizes - the array of sizes to be contained in this SizeSequence

setSizes

private int setSizes(int from,
                     int to,
                     int[] sizes)

getSizes

public int[] getSizes()
Enabled: Returns the size of all entries.

Returns:
a new array containing the sizes in this object

getSizes

private int getSizes(int from,
                     int to,
                     int[] sizes)

getPosition

public int getPosition(int index)
Enabled: Returns the start position for the specified entry. For example, getPosition(0) returns 0, getPosition(1) is equal to getSize(0), getPosition(2) is equal to getSize(0) + getSize(1), and so on.

Note that if index is greater than length the value returned may be meaningless.

Parameters:
index - the index of the entry whose position is desired
Returns:
the starting position of the specified entry

getPosition

private int getPosition(int from,
                        int to,
                        int index)

getIndex

public int getIndex(int position)
Enabled: Returns the index of the entry that corresponds to the specified position. For example, getIndex(0) is 0, since the first entry always starts at position 0.

Parameters:
position - the position of the entry
Returns:
the index of the entry that occupies the specified position

getIndex

private int getIndex(int from,
                     int to,
                     int position)

getSize

public int getSize(int index)
Enabled: Returns the size of the specified entry. If index is out of the range (0 <= index < getSizes().length) the behavior is unspecified.

Parameters:
index - the index corresponding to the entry
Returns:
the size of the entry

setSize

public void setSize(int index,
                    int size)
Enabled: Sets the size of the specified entry. Note that if the value of index does not fall in the range: (0 <= index < getSizes().length) the behavior is unspecified.

Parameters:
index - the index corresponding to the entry
size - the size of the entry

changeSize

private void changeSize(int from,
                        int to,
                        int index,
                        int delta)

insertEntries

public void insertEntries(int start,
                          int length,
                          int value)
Enabled: Adds a contiguous group of entries to this SizeSequence. Note that the values of start and length must satisfy the following conditions: (0 <= start < getSizes().length) AND (length >= 0). If these conditions are not met, the behavior is unspecified and an exception may be thrown.

Parameters:
start - the index to be assigned to the first entry in the group
length - the number of entries in the group
value - the size to be assigned to each new entry

removeEntries

public void removeEntries(int start,
                          int length)
Enabled: Removes a contiguous group of entries from this SizeSequence. Note that the values of start and length must satisfy the following conditions: (0 <= start < getSizes().length) AND (length >= 0). If these conditions are not met, the behavior is unspecified and an exception may be thrown.

Parameters:
start - the index of the first entry to be removed
length - the number of entries to be removed


comments?