Java Code Examples for javax.swing.text.Segment#isPartialReturn()

The following examples show how to use javax.swing.text.Segment#isPartialReturn() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OverviewControllerUI.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void getText(int offset, int length, Segment txt) throws BadLocationException {
    if (lastOffset == offset && lastLength == length) {
        txt.array = segArray;
        txt.offset = segOffset;
        txt.count = segCount;
        txt.setPartialReturn(segPartialReturn);
        return;
    }
    super.getText(offset, length, txt);
    if (length > CACHE_BOUNDARY || lastLength <= CACHE_BOUNDARY) {
        segArray = txt.array;
        segOffset = txt.offset;
        segCount = txt.count;
        segPartialReturn = txt.isPartialReturn();
        lastOffset = offset;
        lastLength = length;
    }
}
 
Example 2
Source File: ThreadDumpWindow.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void getText(int offset, int length, Segment txt) throws BadLocationException {
    if (lastOffset == offset && lastLength == length) {
        txt.array = segArray;
        txt.offset = segOffset;
        txt.count = segCount;
        txt.setPartialReturn(segPartialReturn);
        return;
    }
    super.getText(offset, length, txt);
    if (length > CACHE_BOUNDARY || lastLength <= CACHE_BOUNDARY) {
        segArray = txt.array;
        segOffset = txt.offset;
        segCount = txt.count;
        segPartialReturn = txt.isPartialReturn();
        lastOffset = offset;
        lastLength = length;
    }
}
 
Example 3
Source File: HTMLTextComponent.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public void getText(int offset, int length, Segment txt) throws BadLocationException {
    if (lastOffset == offset && lastLength == length) {
        txt.array = segArray;
        txt.offset = segOffset;
        txt.count = segCount;
        txt.setPartialReturn(segPartialReturn);
        return;
    }
    super.getText(offset, length, txt);
    if (length > CACHE_BOUNDARY || lastLength <= CACHE_BOUNDARY) {
        segArray = txt.array;
        segOffset = txt.offset;
        segCount = txt.count;
        segPartialReturn = txt.isPartialReturn();
        lastOffset = offset;
        lastLength = length;
    }
}
 
Example 4
Source File: OverviewControllerUI.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void getText(int offset, int length, Segment txt) throws BadLocationException {
    if (lastOffset == offset && lastLength == length) {
        txt.array = segArray;
        txt.offset = segOffset;
        txt.count = segCount;
        txt.setPartialReturn(segPartialReturn);
        return;
    }
    super.getText(offset, length, txt);
    if (length > CACHE_BOUNDARY || lastLength <= CACHE_BOUNDARY) {
        segArray = txt.array;
        segOffset = txt.offset;
        segCount = txt.count;
        segPartialReturn = txt.isPartialReturn();
        lastOffset = offset;
        lastLength = length;
    }
}
 
Example 5
Source File: ThreadDumpWindow.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void getText(int offset, int length, Segment txt) throws BadLocationException {
    if (lastOffset == offset && lastLength == length) {
        txt.array = segArray;
        txt.offset = segOffset;
        txt.count = segCount;
        txt.setPartialReturn(segPartialReturn);
        return;
    }
    super.getText(offset, length, txt);
    if (length > CACHE_BOUNDARY || lastLength <= CACHE_BOUNDARY) {
        segArray = txt.array;
        segOffset = txt.offset;
        segCount = txt.count;
        segPartialReturn = txt.isPartialReturn();
        lastOffset = offset;
        lastLength = length;
    }
}
 
Example 6
Source File: ThreadDumpView.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void getText(int offset, int length, Segment txt) throws BadLocationException {
    if (lastOffset == offset && lastLength == length) {
        txt.array = segArray;
        txt.offset = segOffset;
        txt.count = segCount;
        txt.setPartialReturn(segPartialReturn);
        return;
    }
    super.getText(offset, length, txt);
    if (length > CACHE_BOUNDARY || lastLength <= CACHE_BOUNDARY) {
        segArray = txt.array;
        segOffset = txt.offset;
        segCount = txt.count;
        segPartialReturn = txt.isPartialReturn();
        lastOffset = offset;
        lastLength = length;
    }
}
 
Example 7
Source File: OutputDocument.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void getText(int offset, int length, Segment txt) throws BadLocationException {
    checkLocation(offset);
    if (length < 0) {
        throw new BadLocationException("negative length", offset);  //NOI18N
    }
    if (length == 0) {
        txt.array = new char[0];
        txt.offset = 0;
        txt.count = 0;
        return;
    }
    if (offset + length > getLength()) {
        throw new BadLocationException("too long text requested",   //NOI18N
                                       getLength());
    }

    int elemIndex = getElementIndex(offset);
    DocElement docElem = docElements[elemIndex];
    if ((offset == docElem.offset) && (length == docElem.length)) {
        txt.array = docElem.getChars();
        txt.offset = 0;
        txt.count = length;
    } else if (offset + length <= docElem.offset + docElem.length) {
        txt.array = docElem.getChars();
        txt.offset = offset - docElem.offset;
        txt.count = length;
    } else if (txt.isPartialReturn()) {
        txt.array = docElem.getChars();
        txt.offset = offset - docElem.offset;
        txt.count = docElem.offset + docElem.length - offset;
    } else {
        int finalOffset = offset + length;
        int charsStoredCount;
        char[] result = new char[length];

        /* append the first line: */
        System.arraycopy(docElem.getChars(), offset - docElem.offset,
                         result, 0,
                         charsStoredCount = docElem.offset + docElem.length - offset);

        /* append whole lines: */
        while ((docElem = docElements[++elemIndex]).offset < finalOffset) {
            System.arraycopy(docElem.getChars(), 0,
                             result, charsStoredCount,
                             docElem.length);
            charsStoredCount += docElem.length;
        }

        /* append the last line: */
        if (docElem.offset < finalOffset) {
            System.arraycopy(docElem.getChars(), 0,
                             result, charsStoredCount,
                             finalOffset - docElem.offset);
        }

        txt.array = result;
        txt.offset = 0;
        txt.count = length;
    }
}