protected void paintLine(Graphics gfx, TokenMarker tokenMarker, int line, int x) { Font defaultFont = getFont(); Color defaultColor = getForeground(); currentLineIndex = line; int y = textArea.lineToY(line); if(line < 0 || line >= textArea.getLineCount()) { if(paintInvalid) { paintHighlight(gfx,line,y); styles[Token.INVALID].setGraphicsFlags(gfx,defaultFont); gfx.drawString("~",0,y + fm.getHeight()); } } else if(tokenMarker == null) { paintPlainLine(gfx,line,defaultFont,defaultColor,x,y); } else { paintSyntaxLine(gfx,tokenMarker,line,defaultFont, defaultColor,x,y); } }
/** * Recalculates the number of visible lines. This should not * be called directly. */ public final void recalculateVisibleLines() { if(painter == null) return; int height = painter.getHeight(); int lineHeight = painter.getFontMetrics().getHeight(); visibleLines = height / lineHeight; updateScrollBars(); }
/** * Returns the painter's minimum size. */ public Dimension getMinimumSize() { return getPreferredSize(); }
FontMetrics fm = painter.getFontMetrics(); int charWidth; if(c == '\t') charWidth = (int)painter.nextTabStop(width,i) - width; else charWidth = fm.charWidth(c); if(painter.isBlockCaretEnabled()) painter.getToolkit(); Font defaultFont = painter.getFont(); SyntaxStyle[] styles = painter.getStyles(); fm = painter.getFontMetrics(); else fm = styles[id].getFontMetrics(defaultFont); int charWidth; if(c == '\t') charWidth = (int)painter.nextTabStop(width,offset + i) - width; else charWidth = fm.charWidth(c); if(painter.isBlockCaretEnabled())
gfx.setColor(getBackground()); gfx.fillRect(clipRect.x,clipRect.y,clipRect.width,clipRect.height); paintLine(gfx,tokenMarker,line,x); repaint(0,h,getWidth(),getHeight() - h);
FontMetrics fm = painter.getFontMetrics(); painter.getToolkit(); Font defaultFont = painter.getFont(); SyntaxStyle[] styles = painter.getStyles(); fm = painter.getFontMetrics(); else fm = styles[id].getFontMetrics(defaultFont);
painter = new TextAreaPainter(this,defaults); documentHandler = new DocumentHandler(); listenerList = new EventListenerList(); painter.addComponentListener(new ComponentHandler()); painter.addMouseListener(new MouseHandler()); painter.addMouseMotionListener(new DragHandler()); addFocusListener(new FocusHandler());
int width = painter.getFontMetrics().charWidth('w'); - x + width + 5); else if(x + width >= painter.getWidth()) (painter.getWidth() - x) - width - 5;
/** * Converts a y co-ordinate to a line index. * @param y The y co-ordinate */ public int yToLine(int y) { FontMetrics fm = painter.getFontMetrics(); int height = fm.getHeight(); return Math.max(0,Math.min(getLineCount() - 1, y / height + firstLine)); }
/** * Updates the state of the scroll bars. This should be called * if the number of lines in the document changes, or when the * size of the text are changes. */ public void updateScrollBars() { if(vertical != null && visibleLines != 0) { vertical.setValues(firstLine,visibleLines,0,getLineCount()); vertical.setUnitIncrement(2); vertical.setBlockIncrement(visibleLines); } int width = painter.getWidth(); if(horizontal != null && width != 0) { horizontal.setValues(-horizontalOffset,width,0,width * 5); horizontal.setUnitIncrement(painter.getFontMetrics() .charWidth('w')); horizontal.setBlockIncrement(width / 2); } }
public int lineToBottomY(int line) { FontMetrics fm = painter.getFontMetrics(); return (line - firstLine) * fm.getHeight() + (fm.getLeading()+ fm.getAscent()+ fm.getMaxDescent()); }
/** * Converts a line index to a y co-ordinate. * @param line The line */ public int lineToY(int line) { FontMetrics fm = painter.getFontMetrics(); return (line - firstLine) * fm.getHeight() - (fm.getLeading() + fm.getMaxDescent()); } public int lineToBottomY(int line)