Best web site - Java Swing - O Reilly Obtains a vector of

Java Swing - O Reilly Obtains a vector of position references spanning the specified range. The return value can be passed to updateUndoPositions() to update the positions. protected void updateUndoPositions(Vector positions) Updates the position references returned by getPositionsInRange(). 20.1.16 The GapContent Class This implementation of the AbstractDocument.Content interface made its Swing debut in Swing 1.0.2. As of JDK 1.2 beta4, it was not actually used within the Swing text package, possibly because it did not yet support undoable edits. Look for this feature to be added in a future release, but for now you can use it in your own applications if you don’t need undo support. The idea behind GapContent is to take advantage of the fact that text is typically inserted sequentially. In other words, if the user inserts a character at position 10 in the document, chances are good that the next insertion will be at position 11. With StringContent, each insertion results in an array copy to make room for the new text. In contrast, GapContent keeps a “gap” in its character array, located at the current insertion point. When the insertion point changes, the gap is moved to the new input location by shifting the contents of the array to the end. The easiest way to understand this is by example. Figure 20.7 shows how GapContent would manage a 35-character array (you can specify the initial size when you create the content object). Each line represents the state of the array at some point of the insertion process. We show the “gap” by shading that portion of the array. Figure 20.7. GapContent example Initially, the entire array is the gap (actually, GapContent starts with a single n in the array, but we’ll ignore that detail). As text is inserted (lines 1 and 2), the right edge of the gap is shifted, staying just beyond that last inserted character. Line 3 is the most important. This line shows what happens when we go back and insert text into the middle of the document. At this point, everything to the right of the insertion point is copied to the end of the array via a single array copy. We’re now (line 4) able to insert additional data into the middle of the document without having to pay for additional array copies. Contrast this approach with the approach used by StringContentin which the insertion of the letter w would have shifted “anymore.” down one space, the insertion of e would have shifted it down again, and so on. - 639
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

Leave a Reply