Java Code Examples for javax.swing.text.Position#Bias
The following examples show how to use
javax.swing.text.Position#Bias .
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: Utilities.java From netbeans with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: CaretTransaction.java From netbeans with Apache License 2.0 | 5 votes |
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); }
Example 3
Source File: MultiTextUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 4
Source File: MultiTextUI.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 5
Source File: MultiTextUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 6
Source File: CascadingNavigationFilter.java From netbeans with Apache License 2.0 | 5 votes |
@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); } }
Example 7
Source File: JList.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * 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; }
Example 8
Source File: MultiTextUI.java From Bytecoder with Apache License 2.0 | 5 votes |
@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; }
Example 9
Source File: EditorView.java From netbeans with Apache License 2.0 | 5 votes |
/** * {@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; } }
Example 10
Source File: CaretUndoEdit.java From netbeans with Apache License 2.0 | 5 votes |
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 }
Example 11
Source File: MultiTextUI.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * 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; }
Example 12
Source File: MultiTextUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 13
Source File: HighlightsViewPart.java From netbeans with Apache License 2.0 | 4 votes |
@Override public Shape modelToViewChecked(int offset, Shape alloc, Position.Bias bias) { return HighlightsViewUtils.indexToView(getTextLayout(), null, offset - getStartOffset(), bias, getLength(), alloc); }
Example 14
Source File: MultiMark.java From netbeans with Apache License 2.0 | 4 votes |
/** Construct bias mark */ MultiMark(BasePosition pos, MarkVector markVector, int offset, Position.Bias bias) { this(pos, markVector, offset, (bias == Position.Bias.Backward) ? BACKWARD_BIAS : 0); }
Example 15
Source File: TestHighlightsView.java From netbeans with Apache License 2.0 | 4 votes |
public int viewToModelChecked(double x, double y, Shape alloc, Position.Bias[] biasReturn, int index) { return getStartOffset(); }
Example 16
Source File: MultiTextUI.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * 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); } }
Example 17
Source File: CaretUndoEdit.java From netbeans with Apache License 2.0 | 4 votes |
static Position.Bias getBias(int offsetAndBias) { return ((offsetAndBias & BACKWARD_BIAS_BIT) != 0) ? Position.Bias.Backward : Position.Bias.Forward; }
Example 18
Source File: MultiTextUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * 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); } }
Example 19
Source File: GapBoxView.java From netbeans with Apache License 2.0 | 3 votes |
/** * 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); }
Example 20
Source File: PositionRef.java From netbeans with Apache License 2.0 | 2 votes |
/** 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); }