@Override public void run() { try { int endPos = component.getDocument().getLength(); Rectangle rect = component.modelToView(endPos); if (rect != null && rect.y != lastHeight) { setPreferredWidth(); repaint(); lastHeight = rect.y; } } catch (BadLocationException ex) { /* nothing to do */ } } });
Rectangle r = component.modelToView(rowStartOffset); int lineHeight = fontMetrics.getHeight(); int y = r.y + r.height;
+ "Blabla\nBlabla\nBlabla\nBlabla\nBlabla"; int pos2 = textArea.getText().indexOf(turnToString2); Rectangle startIndex = textArea.modelToView(pos2); textArea.getHighlighter().addHighlight(pos2, pos2 + turnToString2.length(),
private void adjustScrollIfNecessary(JTextComponent text, Rectangle visible, int initialY, int index) { try { Rectangle dotBounds = text.modelToView(index); if (dotBounds.y < visible.y || (dotBounds.y > (visible.y + visible.height)) || (dotBounds.y + dotBounds.height) > (visible.y + visible.height)) { int y; if (dotBounds.y < visible.y) { y = dotBounds.y; } else { y = dotBounds.y + dotBounds.height - visible.height; } if ((direction == -1 && y < initialY) || (direction == 1 && y > initialY)) { // Only adjust if won't cause scrolling upward. visible.y = y; } } } catch (BadLocationException ble) {} }
private void scrollToWord(int offset) { try { textComponent.scrollRectToVisible(textComponent.modelToView(offset)); } catch (BadLocationException e) { e.printStackTrace(); } }
char dotChar; try { r = comp.modelToView(dot); if (r == null) { return;
private Rectangle getLocationFromOffset( int i ) throws BadLocationException { Rectangle rectangle = _editor.modelToView( i ); if( rectangle == null ) { rectangle = TEST_RECTANGLE; } return rectangle; }
@Override public Rectangle call() throws BadLocationException { Rectangle rect = tc.modelToView(index); return rect; } };
private Rectangle getLocationFromOffset( int i ) throws BadLocationException { Rectangle rectangle = _editor.modelToView( i ); if( rectangle == null ) { rectangle = TEST_RECTANGLE; } return rectangle; }
@Override public void run() { try { int endPos = component.getDocument().getLength(); Rectangle rect = component.modelToView(endPos); if (rect != null && rect.y != lastHeight) { setPreferredWidth(); repaint(); lastHeight = rect.y; } } catch (BadLocationException ex) { /* nothing to do */ } } });
@Override public void run() { try { int endPos = component.getDocument().getLength(); Rectangle rect = component.modelToView(endPos); if (rect != null && rect.y != lastHeight) { setPreferredWidth(); repaint(); lastHeight = rect.y; } } catch (BadLocationException ex) { /* nothing to do */ } } });
@Override public void run() { try { int endPos = component.getDocument().getLength(); Rectangle rect = component.modelToView( endPos ); if ( rect != null && rect.y != lastHeight ) { setPreferredWidth(); repaint(); lastHeight = rect.y; } } catch ( BadLocationException ex ) { /* nothing to do */ } } } );
@Override public void run() { try { int endPos = component.getDocument().getLength(); Rectangle rect = component.modelToView(endPos); if (rect != null && rect.y != lastHeight) { setPreferredWidth(); repaint(); lastHeight = rect.y; } } catch (BadLocationException ex) { /* nothing to do */ } } });
private void scrollToCurrent() { try { Rectangle r1 = currentComp.modelToView(currentStart); Rectangle r2 = currentComp.modelToView(currentStart); Rectangle r = r1.union(r2); currentComp.scrollRectToVisible(r); } catch (BadLocationException blex) { BugtrackingManager.LOG.log(Level.INFO, blex.getMessage(), blex); } }
@Override public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c) { try { Rectangle r = c.modelToView(c.getCaretPosition()); g.setColor(color); g.fillRect(0, r.y, c.getWidth(), r.height); } catch (BadLocationException ignore) {} } };
private int getLineStart(int i) throws BadLocationException { Element line = editor.getDocument().getDefaultRootElement().getElement(i); Rectangle result = editor.modelToView(line.getStartOffset()); if (result != null) { return result.y; } return -1; }
private int getLineStart(int i) throws BadLocationException { Element line = editor.getDocument().getDefaultRootElement().getElement(i); Rectangle result = editor.modelToView(line.getStartOffset()); if (result != null) { return result.y; } return -1; }
private void drawError(SyntaxHighlightingScanner scanner, Graphics g, int x, int length, int y, boolean selected) throws BadLocationException { if (isErrorHighlighting()) { if (!selected) { g.setColor(new Color(255, 0, 0)); } Rectangle rec = ((JTextComponent) getContainer()).modelToView(scanner.getStartOffset()); if (rec != null) { drawZigZag(g, x, rec.x, length, y); } } }
public void run() { try { int offset = component.getCaretPosition(); Rectangle currentView = component.modelToView(offset); // Remove the highlighting from the previously highlighted line if (lastView.y != currentView.y) { component.repaint(0, lastView.y, component.getWidth(), lastView.height); lastView = currentView; } } catch (BadLocationException ble) { } } });
public void displayContextMenu( IScriptEditor editor, int iXPos, int iYPos, Component eventSource ) { editor.getEditor().requestFocus(); try { Rectangle rcCaretBounds = editor.getEditor().modelToView( editor.getEditor().getCaretPosition() ); getContextMenu( editor ).show( editor.getEditor(), rcCaretBounds.x, rcCaretBounds.y + rcCaretBounds.height ); } catch( BadLocationException e ) { throw new RuntimeException( e ); } } }