javax.swing.text.Position#Bias ( )源码实例Demo

下面列出了javax.swing.text.Position#Bias ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: Utilities.java
static int viewToModel(JTextComponent tc, double x, double y, Position.Bias[] biasReturn) {
int offs = -1;
Document doc = tc.getDocument();
if (doc instanceof AbstractDocument) {
    ((AbstractDocument)doc).readLock();
}
try {
    Rectangle alloc = getVisibleEditorRect(tc);
    if (alloc != null) {
               View rootView = tc.getUI().getRootView(tc);
               View documentView = rootView.getView(0);
               if (documentView instanceof EditorView) {
                   documentView.setSize(alloc.width, alloc.height);
                   offs = ((EditorView) documentView).viewToModelChecked(x, y, alloc, biasReturn);
               } else {
                   rootView.setSize(alloc.width, alloc.height);
                   offs = rootView.viewToModel((float) x, (float) y, alloc, biasReturn);
               }
    }
} finally {
    if (doc instanceof AbstractDocument) {
	((AbstractDocument)doc).readUnlock();
    }
}
       return offs;
   }
 
源代码2 项目: openjdk-jdk8u   文件: MultiTextUI.java
/**
 * Invokes the <code>getNextVisualPositionFrom</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int getNextVisualPositionFrom(JTextComponent a, int b, Position.Bias c, int d, Position.Bias[] e)
        throws BadLocationException {
    int returnValue =
        ((TextUI) (uis.elementAt(0))).getNextVisualPositionFrom(a,b,c,d,e);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).getNextVisualPositionFrom(a,b,c,d,e);
    }
    return returnValue;
}
 
源代码3 项目: netbeans   文件: CaretTransaction.java
boolean setDotAndMark(@NonNull CaretItem caretItem, @NonNull Position dotPos, @NonNull Position.Bias dotBias,
        @NonNull Position markPos, @NonNull Position.Bias markBias)
{
    assert (dotPos != null) : "dotPos must not be null";
    assert (markPos != null) : "markPos must not be null";
    int index = findCaretItemIndex(origCaretItems, caretItem);
    if (index != -1) {
        Position origDotPos = caretItem.getDotPosition();
        Position origMarkPos = caretItem.getMarkPosition();
        boolean dotChanged = origDotPos == null || ComplexPositions.compare(dotPos, origDotPos) != 0 ||
                dotBias != caretItem.getDotBias();
        boolean markChanged = origMarkPos == null || ComplexPositions.compare(markPos, origMarkPos) != 0 ||
                markBias != caretItem.getMarkBias();
        scrollToLastCaret = true; // Scroll even if setDot() to same offset
        if (dotChanged || markChanged) {
            editorCaret.ensureValidInfo(caretItem);
            if (expandFoldPositions == null) {
                expandFoldPositions = new ArrayList<>(2);
            }
            if (dotChanged) {
                caretItem.setDotPos(dotPos);
                expandFoldPositions.add(dotPos);
                anyDotChanged = true;
            }
            if (markChanged) {
                caretItem.setMarkPos(markPos);
                expandFoldPositions.add(markPos);
                anyMarkChanged = true;
            }
            updateAffectedIndexes(index, index + 1);
            caretItem.markUpdateCaretBounds();
            caretItem.markInfoObsolete();
            return true;
        }
        return false;
    }
    return false;
    //caret.setDotCaret(offset, this, true);
}
 
源代码4 项目: jdk1.8-source-analysis   文件: MultiTextUI.java
/**
 * Invokes the <code>viewToModel</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int viewToModel(JTextComponent a, Point b, Position.Bias[] c) {
    int returnValue =
        ((TextUI) (uis.elementAt(0))).viewToModel(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).viewToModel(a,b,c);
    }
    return returnValue;
}
 
源代码5 项目: netbeans   文件: CaretUndoEdit.java
protected void restoreEditorCaret(EditorCaret caret) throws BadLocationException {
    Position dotPos = doc.createPosition(getOffset(dotOffsetAndBias));
    List<Position.Bias> biases = isBackwardBias(dotOffsetAndBias)
            ? Arrays.asList(Position.Bias.Backward, Position.Bias.Backward)
            : null;
    caret.replaceCarets(Arrays.asList(dotPos, dotPos), biases); // TODO handle biases
}
 
源代码6 项目: netbeans   文件: EditorView.java
/**
 * {@inheritDoc}
 */
@Override
public final Shape modelToView(int offset0, Position.Bias bias0, int offset1, Position.Bias bias1,
        Shape alloc) throws BadLocationException
{
    checkBounds(offset0);
    checkBias(bias0);
    checkBounds(offset1);
    checkBias(bias1);
    if (alloc != null) {
        return modelToViewChecked(offset0, bias0, offset1, bias1, alloc);
    } else {
        return null;
    }
}
 
源代码7 项目: Bytecoder   文件: MultiTextUI.java
@Override
public int viewToModel2D(JTextComponent a, Point2D b, Position.Bias[] c) {
    int returnValue =
        ((TextUI) (uis.elementAt(0))).viewToModel2D(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).viewToModel2D(a,b,c);
    }
    return returnValue;
}
 
源代码8 项目: JDKSourceCode1.8   文件: JList.java
/**
 * Returns the next list element whose {@code toString} value
 * starts with the given prefix.
 *
 * @param prefix the string to test for a match
 * @param startIndex the index for starting the search
 * @param bias the search direction, either
 * Position.Bias.Forward or Position.Bias.Backward.
 * @return the index of the next list element that
 * starts with the prefix; otherwise {@code -1}
 * @exception IllegalArgumentException if prefix is {@code null}
 * or startIndex is out of bounds
 * @since 1.4
 */
public int getNextMatch(String prefix, int startIndex, Position.Bias bias) {
    ListModel<E> model = getModel();
    int max = model.getSize();
    if (prefix == null) {
        throw new IllegalArgumentException();
    }
    if (startIndex < 0 || startIndex >= max) {
        throw new IllegalArgumentException();
    }
    prefix = prefix.toUpperCase();

    // start search from the next element after the selected element
    int increment = (bias == Position.Bias.Forward) ? 1 : -1;
    int index = startIndex;
    do {
        E element = model.getElementAt(index);

        if (element != null) {
            String string;

            if (element instanceof String) {
                string = ((String)element).toUpperCase();
            }
            else {
                string = element.toString();
                if (string != null) {
                    string = string.toUpperCase();
                }
            }

            if (string != null && string.startsWith(prefix)) {
                return index;
            }
        }
        index = (index + increment + max) % max;
    } while (index != startIndex);
    return -1;
}
 
源代码9 项目: netbeans   文件: CascadingNavigationFilter.java
@Override
public void setDot(FilterBypass fb, int dot, Position.Bias bias) {
    if (previous != null) {
        previous.setDot(fb, dot, bias);
    } else {
        super.setDot(fb, dot, bias);
    }
}
 
源代码10 项目: openjdk-jdk9   文件: MultiTextUI.java
/**
 * Invokes the <code>viewToModel</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
@Deprecated(since = "9")
@Override
public int viewToModel(JTextComponent a, Point b, Position.Bias[] c) {
    int returnValue =
        ((TextUI) (uis.elementAt(0))).viewToModel(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).viewToModel(a,b,c);
    }
    return returnValue;
}
 
源代码11 项目: jdk8u60   文件: MultiTextUI.java
/**
 * Invokes the <code>viewToModel</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int viewToModel(JTextComponent a, Point b, Position.Bias[] c) {
    int returnValue =
        ((TextUI) (uis.elementAt(0))).viewToModel(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).viewToModel(a,b,c);
    }
    return returnValue;
}
 
源代码12 项目: openjdk-jdk8u   文件: MultiTextUI.java
/**
 * Invokes the <code>modelToView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Rectangle modelToView(JTextComponent a, int b, Position.Bias c)
        throws BadLocationException {
    Rectangle returnValue =
        ((TextUI) (uis.elementAt(0))).modelToView(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).modelToView(a,b,c);
    }
    return returnValue;
}
 
源代码13 项目: netbeans   文件: TestHighlightsView.java
public int viewToModelChecked(double x, double y, Shape alloc, Position.Bias[] biasReturn, int index) {
    return getStartOffset();
}
 
源代码14 项目: netbeans   文件: MultiMark.java
/** Construct bias mark */
MultiMark(BasePosition pos, MarkVector markVector, int offset, Position.Bias bias) {
    this(pos, markVector, offset,
        (bias == Position.Bias.Backward) ? BACKWARD_BIAS : 0);
}
 
源代码15 项目: netbeans   文件: HighlightsViewPart.java
@Override
public Shape modelToViewChecked(int offset, Shape alloc, Position.Bias bias) {
    return HighlightsViewUtils.indexToView(getTextLayout(), null, offset - getStartOffset(),
            bias, getLength(), alloc);
}
 
源代码16 项目: Bytecoder   文件: MultiTextUI.java
/**
 * Invokes the <code>damageRange</code> method on each UI handled by this object.
 */
public void damageRange(JTextComponent a, int b, int c, Position.Bias d, Position.Bias e) {
    for (int i = 0; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).damageRange(a,b,c,d,e);
    }
}
 
源代码17 项目: netbeans   文件: CaretUndoEdit.java
static Position.Bias getBias(int offsetAndBias) {
    return ((offsetAndBias & BACKWARD_BIAS_BIT) != 0)
            ? Position.Bias.Backward
            : Position.Bias.Forward;
}
 
源代码18 项目: openjdk-jdk8u   文件: MultiTextUI.java
/**
 * Invokes the <code>damageRange</code> method on each UI handled by this object.
 */
public void damageRange(JTextComponent a, int b, int c, Position.Bias d, Position.Bias e) {
    for (int i = 0; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).damageRange(a,b,c,d,e);
    }
}
 
源代码19 项目: netbeans   文件: GapBoxView.java
/**
    * Returns the child view index representing the given position in
    * the model.
    *
    * @param offset the position >= 0.
    * @param b either forward or backward bias.
    * @return  index of the view representing the given position, or 
    *   -1 if no view represents that position
    */
   public @Override int getViewIndex(int offset, Position.Bias b) {
if (b == Position.Bias.Backward) {
    offset -= 1;
}
       
       return getViewIndex(offset);
   }
 
源代码20 项目: netbeans   文件: PositionRef.java
/** Creates new <code>PositionRef</code> using the given manager at the specified
* position offset.
* @param manager manager for the position
* @param offset - position in the document
* @param bias the bias for the position
*/
PositionRef(Manager manager, int offset, Position.Bias bias) {
    this(manager, new Manager.OffsetKind(offset, manager), bias);
}
 
 方法所在类
 同类方法