Package adams.gui.core
Class BaseSizeSequence
- java.lang.Object
-
- javax.swing.SizeSequence
-
- adams.gui.core.BaseSizeSequence
-
- All Implemented Interfaces:
Serializable
public class BaseSizeSequence extends SizeSequence implements Serializable
Specialized size sequence that can handle mixed row sizes.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BaseSizeSequence()Creates a newBaseSizeSequenceobject that contains no entries.BaseSizeSequence(int numEntries)Creates a newBaseSizeSequenceobject that contains the specified number of entries, all initialized to have size 0.BaseSizeSequence(int[] sizes)Creates a newBaseSizeSequenceobject that contains the specified sizes.BaseSizeSequence(int numEntries, int value)Creates a newBaseSizeSequenceobject that contains the specified number of entries, all initialized to have sizevalue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetIndex(int position)Returns the index of the entry that corresponds to the specified position.intgetPosition(int index)Returns the start position for the specified entry.intgetSize(int index)Returns the size of the specified entry.int[]getSizes()Returns the size of all entries.voidinsertEntries(int start, int length, int value)Adds a contiguous group of entries to thisBaseSizeSequence.voidremoveEntries(int start, int length)Removes a contiguous group of entries from thisBaseSizeSequence.voidsetSize(int index, int size)Sets the size of the specified entry.voidsetSizes(int[] sizes)Resets thisBaseSizeSequenceobject, using the data in thesizesargument.protected voidupdatePositions(int start)Updates the positions based on the current sizes.
-
-
-
Constructor Detail
-
BaseSizeSequence
public BaseSizeSequence()
Creates a newBaseSizeSequenceobject that contains no entries. To add entries, you can useinsertEntriesorsetSizes.
-
BaseSizeSequence
public BaseSizeSequence(int numEntries)
Creates a newBaseSizeSequenceobject that contains the specified number of entries, all initialized to have size 0.- Parameters:
numEntries- the number of sizes to track- Throws:
NegativeArraySizeException- ifnumEntries < 0
-
BaseSizeSequence
public BaseSizeSequence(int numEntries, int value)Creates a newBaseSizeSequenceobject that contains the specified number of entries, all initialized to have sizevalue.- Parameters:
numEntries- the number of sizes to trackvalue- the initial value of each size
-
BaseSizeSequence
public BaseSizeSequence(int[] sizes)
Creates a newBaseSizeSequenceobject that contains the specified sizes.- Parameters:
sizes- the array of sizes to be contained in theBaseSizeSequence
-
-
Method Detail
-
setSizes
public void setSizes(int[] sizes)
Resets thisBaseSizeSequenceobject, using the data in thesizesargument. This method reinitializes this object so that it contains as many entries as thesizesarray. Each entry's size is initialized to the value of the corresponding item insizes.- Overrides:
setSizesin classSizeSequence- Parameters:
sizes- the array of sizes to be contained in thisBaseSizeSequence
-
getSizes
public int[] getSizes()
Returns the size of all entries.- Overrides:
getSizesin classSizeSequence- Returns:
- a new array containing the sizes in this object
-
getPosition
public int getPosition(int index)
Returns the start position for the specified entry. For example,getPosition(0)returns 0,getPosition(1)is equal togetSize(0),getPosition(2)is equal togetSize(0)+getSize(1), and so on.Note that if
indexis greater thanlengththe value returned may be meaningless.- Overrides:
getPositionin classSizeSequence- Parameters:
index- the index of the entry whose position is desired- Returns:
- the starting position of the specified entry
-
getIndex
public int getIndex(int position)
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.- Overrides:
getIndexin classSizeSequence- Parameters:
position- the position of the entry- Returns:
- the index of the entry that occupies the specified position
-
getSize
public int getSize(int index)
Returns the size of the specified entry. Ifindexis out of the range(0 <= index < getSizes().length)the behavior is unspecified.- Overrides:
getSizein classSizeSequence- Parameters:
index- the index corresponding to the entry- Returns:
- the size of the entry, -1 if outside boundaries
-
setSize
public void setSize(int index, int size)Sets the size of the specified entry. Note that if the value ofindexdoes not fall in the range:(0 <= index < getSizes().length)the behavior is unspecified.- Overrides:
setSizein classSizeSequence- Parameters:
index- the index corresponding to the entrysize- the size of the entry
-
insertEntries
public void insertEntries(int start, int length, int value)Adds a contiguous group of entries to thisBaseSizeSequence. Note that the values ofstartandlengthmust 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.- Overrides:
insertEntriesin classSizeSequence- Parameters:
start- the index to be assigned to the first entry in the grouplength- the number of entries in the groupvalue- the size to be assigned to each new entry- Throws:
ArrayIndexOutOfBoundsException- if the parameters are outside of the range: (0 <= start < (getSizes().length)) AND (length >= 0)
-
removeEntries
public void removeEntries(int start, int length)Removes a contiguous group of entries from thisBaseSizeSequence. Note that the values ofstartandlengthmust 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.- Overrides:
removeEntriesin classSizeSequence- Parameters:
start- the index of the first entry to be removedlength- the number of entries to be removed
-
updatePositions
protected void updatePositions(int start)
Updates the positions based on the current sizes.- Parameters:
start- the starting index
-
-