Java Code Examples for javax.swing.text.View#NORTH

The following examples show how to use javax.swing.text.View#NORTH . 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: TabView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public int getNextVisualPositionFromChecked(int offset, Bias bias, Shape alloc, int direction, Bias[] biasRet) {
    int startOffset = getStartOffset();
    int endOffset = startOffset + getLength();
    int retOffset = -1;
    switch (direction) {
        case EAST:
            biasRet[0] = Bias.Forward;
            if (offset == -1) {
                retOffset = getStartOffset();
            } else {
                retOffset = offset + 1;
                if (retOffset >= endOffset) {
                    retOffset = endOffset;
                    biasRet[0] = Bias.Backward;
                }
            }
            break;

        case WEST:
            biasRet[0] = Bias.Forward;
            if (offset == -1) {
                retOffset = endOffset - 1;
            } else {
                retOffset = offset - 1;
                if (retOffset < startOffset) {
                    retOffset = -1;
                }
            }
            break;

        case View.NORTH:
        case View.SOUTH:
            break; // Return -1
        default:
            throw new IllegalArgumentException("Bad direction: " + direction);
    }
    return retOffset;
}
 
Example 2
Source File: NewlineView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public int getNextVisualPositionFromChecked(int offset, Bias bias, Shape alloc, int direction, Bias[] biasRet) {
    int retOffset;
    biasRet[0] = Bias.Forward; // BaseCaret ignores bias
    int viewStartOffset = getStartOffset();
    switch (direction) {
        case View.EAST:
            if (offset == -1) {
                retOffset = viewStartOffset;
            } else {
                retOffset = -1;
            }
            break;

        case View.WEST:
            if (offset == -1) {
                retOffset = viewStartOffset;
            } else if (offset == viewStartOffset) { // Regular offset
                retOffset = -1;
            } else {
                retOffset = viewStartOffset;
            }
            break;

        case View.NORTH:
        case View.SOUTH:
            retOffset = -1;
            break;
        default:
            throw new IllegalArgumentException("Bad direction: " + direction);
    }
    return retOffset;
}