public boolean targetOffsetReached(int pos, char ch, int x, int charWidth, DrawContext ctx) { r.x = x; r.y = getY(); r.width = charWidth; r.height = getEditorUI().getLineHeight(); return false; }
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException { return new Rectangle(a.getBounds().x, a.getBounds().y, getCollapsedFoldStringWidth(), getEditorUI().getLineHeight()); }
public float getPreferredSpan(int axis){ switch (axis) { case Y_AXIS: return getEditorUI().getLineHeight(); case X_AXIS: return getCollapsedFoldStringWidth(); } return 1f; }
public void actionPerformed(ActionEvent evt, JTextComponent target) { if (target != null) { EditorUI editorUI = Utilities.getEditorUI(target); Rectangle bounds = editorUI.getExtentBounds(); bounds.y -= editorUI.getLineHeight(); editorUI.scrollRectToVisible(bounds, EditorUI.SCROLL_SMALLEST); } }
public void actionPerformed(ActionEvent evt, JTextComponent target) { if (target != null) { EditorUI editorUI = Utilities.getEditorUI(target); Rectangle bounds = editorUI.getExtentBounds(); bounds.y += editorUI.getLineHeight(); editorUI.scrollRectToVisible(bounds, EditorUI.SCROLL_SMALLEST); } }
public float getPreferredSpan(int axis) { switch (axis) { case Y_AXIS: /*try{ Shape retShape = modelToView(getStartOffset(), new Rectangle(), Position.Bias.Forward); int ret = retShape.getBounds().height; return Math.max(ret, 1f); }catch(BadLocationException ble){ ble.printStackTrace(); } */ return getEditorUI().getLineHeight(); case X_AXIS: try{ int offset = Math.max(0, getEndOffset() - 1); Shape retShape = modelToView(offset, new Rectangle(), Position.Bias.Forward); int ret = retShape.getBounds().x + retShape.getBounds().width; return Math.max(ret, 1f); }catch(BadLocationException ble){ ble.printStackTrace(); } } return 1f; }
/** * Get the position that is one line above and visually at some x-coordinate * value. * * @param c * text component to operate on * @param offset * position in document from which the current line is determined * @param x * float x-coordinate value * @return position of the character that is at the one line above at the * required x-coordinate value */ public static int getPositionBelow(JTextComponent c, int offset, int x) throws BadLocationException { BaseDocument doc = (BaseDocument) c.getDocument(); BaseTextUI ui = (BaseTextUI) c.getUI(); offset = ui.viewToModel(c, x, ui.getYFromPos(offset) + ui.getEditorUI().getLineHeight()); return offset; }
public void actionPerformed(ActionEvent evt, JTextComponent target) { if (target != null) { EditorUI editorUI = Utilities.getEditorUI(target); Rectangle bounds = editorUI.getExtentBounds(); bounds.y -= editorUI.getLineHeight(); bounds.x += editorUI.getTextMargin().left; editorUI.scrollRectToVisible(bounds, EditorUI.SCROLL_SMALLEST); } }
/** * Get the position that is one line above and visually at some x-coordinate * value. * * @param doc * document to operate on * @param offset * position in document from which the current line is determined * @param x * float x-coordinate value * @return position of the character that is at the one line above at the * required x-coordinate value */ public static int getPositionAbove(JTextComponent c, int offset, int x) throws BadLocationException { BaseDocument doc = (BaseDocument) c.getDocument(); BaseTextUI ui = (BaseTextUI) c.getUI(); offset = ui.viewToModel(c, x, ui.getYFromPos(offset) - ui.getEditorUI().getLineHeight()); return offset; }
public void actionPerformed(ActionEvent evt, JTextComponent target) { if (target != null) { EditorUI editorUI = Utilities.getEditorUI(target); Rectangle bounds = editorUI.getExtentBounds(); bounds.y += editorUI.getLineHeight(); bounds.x += editorUI.getTextMargin().left; editorUI.scrollRectToVisible(bounds, EditorUI.SCROLL_SMALLEST); } }
/** Compute and update main area height */ public void updateMainHeight() { LeafElement elem = (LeafElement) getElement(); // need leaf element try { int lineDiff = (elem.getEndMark().getLine() - elem.getStartMark().getLine() + 1); mainHeight = lineDiff * getEditorUI().getLineHeight(); } catch (InvalidMarkException e) { mainHeight = 0; } }
/** * Get y coordinate from position. The position can lay anywhere inside this * view. */ protected int getYFromPos(int pos) throws BadLocationException { int relLine = 0; try { relLine = ((BaseDocument) getDocument()).op.getLine(pos) - ((BaseElement) getElement()).getStartMark().getLine(); } catch (InvalidMarkException e) { if (Boolean.getBoolean("netbeans.debug.exceptions")) { // NOI18N e.printStackTrace(); } } return getStartY() + ((insets != null) ? insets.top : 0) + relLine * getEditorUI().getLineHeight(); }
private Rectangle getModel2ViewRect(int startOffset, int endOffset, int startX, int startY, int targetOffset){ Rectangle ret = new Rectangle(); ret.y = startY; if (isEstimatedSpan()) { ret.height = getEditorUI().getLineHeight(); ret.x = startX; ret.width = 1; } else { // exact measurements try{ ModelToViewDG modelToViewDG = getModelToViewDG(); // synchronized (modelToViewDG){ - view access is single-threaded modelToViewDG.r = ret; // set the current rectangle DrawEngine.getDrawEngine().draw(this, modelToViewDG, getEditorUI(), startOffset, endOffset, startX, startY, targetOffset); LockView lv = LockView.get(this); if (lv!=null && (lv.getLockThread() != Thread.currentThread())){ throw new IllegalStateException("View access without view lock"); // NOI18N } modelToViewDG.r = null; // } }catch(BadLocationException ble){ ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ble); } } return ret; }
/** Compute and update main area height */ public void updateMainHeight() { LeafElement elem = (LeafElement)getElement(); // need leaf element try { int lineDiff = (elem.getEndMark().getLine() - elem.getStartMark().getLine() + 1); mainHeight = lineDiff * getEditorUI().getLineHeight(); } catch (InvalidMarkException e) { Utilities.annotateLoggable(e); mainHeight = 0; } }
/** Remove from document notification. */ public void removeUpdate(DocumentEvent evt) { try { BaseDocumentEvent bevt = (BaseDocumentEvent)evt; EditorUI editorUI = getEditorUI(); int y = getYFromPos(evt.getOffset()); int lineHeight = editorUI.getLineHeight(); int syntaxY = getYFromPos(bevt.getSyntaxUpdateOffset()); // !!! patch for case when DocMarksOp.eolMark is at the end of document if (bevt.getSyntaxUpdateOffset() == evt.getDocument().getLength()) { syntaxY += lineHeight; } if (getComponent().isShowing()) { editorUI.repaint(y, Math.max(lineHeight, syntaxY - y)); } } catch (BadLocationException ex) { Utilities.annotateLoggable(ex); } }
/** Insert to document notification. */ public void insertUpdate(DocumentEvent evt) { try { BaseDocumentEvent bevt = (BaseDocumentEvent)evt; EditorUI editorUI = getEditorUI(); int y = getYFromPos(evt.getOffset()); int lineHeight = editorUI.getLineHeight(); int syntaxY = getYFromPos(bevt.getSyntaxUpdateOffset()); // !!! patch for case when DocMarksOp.eolMark is at the end of document if (bevt.getSyntaxUpdateOffset() == evt.getDocument().getLength()) { syntaxY += lineHeight; } if (getComponent().isShowing()) { editorUI.repaint(y, Math.max(lineHeight, syntaxY - y)); } } catch (BadLocationException ex) { Utilities.annotateLoggable(ex); } }
public boolean targetOffsetReached(int offset, char ch, int x, int charWidth, DrawContext ctx) { JTextComponent c = BaseCaret.this.component; if (c != null) { BaseCaret.this.beforeCaretFont = (offset == ctx.getFragmentOffset()) ? previousFont : ctx.getFont(); BaseCaret.this.afterCaretFont = ctx.getFont(); BaseCaret.this.x = x; BaseCaret.this.y = this.getY(); BaseCaret.this.width = charWidth; BaseCaret.this.height = Utilities.getEditorUI(c).getLineHeight(); BaseCaret.this.textForeColor = ctx.getForeColor(); BaseCaret.this.textBackColor = ctx.getBackColor(); BaseCaret.this.dotChar[0] = ch; } return false; }
/** Get y coordinate from position. * The position can lay anywhere inside this view. */ protected int getYFromPos(int pos) throws BadLocationException { int relLine = 0; try { relLine = Utilities.getLineOffset(((BaseDocument)getDocument()), pos) - ((BaseElement)getElement()).getStartMark().getLine(); } catch (InvalidMarkException e) { Utilities.annotateLoggable(e); } return getStartY() + ((insets != null) ? insets.top : 0) + relLine * getEditorUI().getLineHeight(); }
EditorUI editorUI = getEditorUI(); int y = getYFromPos(evt.getOffset()); int lineHeight = editorUI.getLineHeight(); if (bevt.getLFCount() > 0) { // one or more lines inserted int addHeight = bevt.getLFCount() * lineHeight;
EditorUI editorUI = getEditorUI(); int y = getYFromPos(evt.getOffset()); int lineHeight = editorUI.getLineHeight(); if (bevt.getLFCount() > 0) { // one or more lines removed int removeHeight = bevt.getLFCount() * lineHeight;