| |
|
| java.lang.Object javax.swing.text.GapVector
All known Subclasses: javax.swing.text.GapContent,
GapVector | abstract class GapVector implements Serializable(Code) | | An implementation of a gapped buffer similar to that used by
emacs. The underlying storage is a java array of some type,
which is known only by the subclass of this class. The array
has a gap somewhere. The gap is moved to the location of changes
to take advantage of common behavior where most changes occur
in the same location. Changes that occur at a gap boundary are
generally cheap and moving the gap is generally cheaper than
moving the array contents directly to accomodate the change.
author: Timothy Prinzing version: 1.19 05/05/07 See Also: GapContent |
Constructor Summary | |
public | GapVector() Creates a new GapVector object. | public | GapVector(int initialLength) Creates a new GapVector object, with the initial
size specified. |
Method Summary | |
abstract protected Object | allocateArray(int len) Allocate an array to store items of the type
appropriate (which is determined by the subclass). | void | close(int position, int nItems) Delete nItems at position. | final protected Object | getArray() Access to the array. | abstract protected int | getArrayLength() | final protected int | getGapEnd() Access to the end of the gap. | final protected int | getGapStart() Access to the start of the gap. | int | getNewArraySize(int reqSize) Calculates a new size of the storage array depending on required
capacity. | int | open(int position, int nItems) Make space for the given number of items at the given
location. | protected void | replace(int position, int rmSize, Object addItems, int addSize) Replace the given logical position in the storage with
the given new items. | void | resize(int nsize) | protected void | shiftEnd(int newSize) | protected void | shiftGap(int newGapStart) Move the start of the gap to a new location,
without changing the size of the gap. | protected void | shiftGapEndUp(int newGapEnd) Adjust the gap end upward. | protected void | shiftGapStartDown(int newGapStart) Adjust the gap end downward. |
GapVector | public GapVector()(Code) | | Creates a new GapVector object. Initial size defaults to 10.
|
GapVector | public GapVector(int initialLength)(Code) | | Creates a new GapVector object, with the initial
size specified.
Parameters: initialLength - the initial size |
allocateArray | abstract protected Object allocateArray(int len)(Code) | | Allocate an array to store items of the type
appropriate (which is determined by the subclass).
|
close | void close(int position, int nItems)(Code) | | Delete nItems at position. Squeezes any marks
within the deleted area to position. This moves
the gap to the best place by minimizing it's
overall movement. The gap must intersect the
target block.
|
getArray | final protected Object getArray()(Code) | | Access to the array. The actual type
of the array is known only by the subclass.
|
getArrayLength | abstract protected int getArrayLength()(Code) | | Get the length of the allocated array
|
getGapEnd | final protected int getGapEnd()(Code) | | Access to the end of the gap.
|
getGapStart | final protected int getGapStart()(Code) | | Access to the start of the gap.
|
getNewArraySize | int getNewArraySize(int reqSize)(Code) | | Calculates a new size of the storage array depending on required
capacity.
Parameters: reqSize - the size which is necessary for new content the new size of the storage array |
open | int open(int position, int nItems)(Code) | | Make space for the given number of items at the given
location.
the location that the caller should fill in |
replace | protected void replace(int position, int rmSize, Object addItems, int addSize)(Code) | | Replace the given logical position in the storage with
the given new items. This will move the gap to the area
being changed if the gap is not currently located at the
change location.
Parameters: position - the location to make the replacement. Thisis not the location in the underlying storage array, butthe location in the contiguous space being modeled. Parameters: rmSize - the number of items to remove Parameters: addItems - the new items to place in storage. |
resize | void resize(int nsize)(Code) | | resize the underlying storage array to the
given new size
|
shiftEnd | protected void shiftEnd(int newSize)(Code) | | Make the gap bigger, moving any necessary data and updating
the appropriate marks
|
shiftGap | protected void shiftGap(int newGapStart)(Code) | | Move the start of the gap to a new location,
without changing the size of the gap. This
moves the data in the array and updates the
marks accordingly.
|
shiftGapEndUp | protected void shiftGapEndUp(int newGapEnd)(Code) | | Adjust the gap end upward. This doesn't move
any data, but it does update any marks affected
by the boundary change. All marks from the old
gap end up to the new gap end are squeezed
to the end of the gap (their location has been
removed).
|
shiftGapStartDown | protected void shiftGapStartDown(int newGapStart)(Code) | | Adjust the gap end downward. This doesn't move
any data, but it does update any marks affected
by the boundary change. All marks from the old
gap start down to the new gap start are squeezed
to the end of the gap (their location has been
removed).
|
|
|
|