Esempio n. 1
0
  protected void paintSyntaxLine(
      Graphics gfx,
      TokenMarker tokenMarker,
      int line,
      Font defaultFont,
      Color defaultColor,
      int x,
      int y) {
    textArea.getLineText(currentLineIndex, currentLine);
    currentLineTokens = tokenMarker.markTokens(currentLine, currentLineIndex);

    paintHighlight(gfx, line, y);

    gfx.setFont(defaultFont);
    gfx.setColor(defaultColor);
    y += fm.getHeight();
    x = SyntaxUtilities.paintSyntaxLine(currentLine, currentLineTokens, styles, this, gfx, x, y);
    /*
     * Draw characters via input method.
     */
    if (compositionTextPainter != null && compositionTextPainter.hasComposedTextLayout()) {
      compositionTextPainter.draw(gfx, lineHighlightColor);
    }
    if (eolMarkers) {
      gfx.setColor(eolMarkerColor);
      gfx.drawString(".", x, y);
    }
  }
Esempio n. 2
0
  protected void paintPlainLine(
      Graphics gfx, int line, Font defaultFont, Color defaultColor, int x, int y) {
    paintHighlight(gfx, line, y);
    textArea.getLineText(line, currentLine);

    gfx.setFont(defaultFont);
    gfx.setColor(defaultColor);

    y += fm.getHeight();
    x = Utilities.drawTabbedText(currentLine, x, y, gfx, this, 0);

    if (eolMarkers) {
      gfx.setColor(eolMarkerColor);
      gfx.drawString(".", x, y);
    }
  }
Esempio n. 3
0
  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);
    }
  }
Esempio n. 4
0
  protected void paintPlainLine(
      Graphics gfx, int line, Font defaultFont, Color defaultColor, int x, int y) {
    paintHighlight(gfx, line, y);
    textArea.getLineText(line, currentLine);

    gfx.setFont(defaultFont);
    gfx.setColor(defaultColor);

    y += fm.getHeight();
    x = Utilities.drawTabbedText(currentLine, x, y, gfx, this, 0);
    // Draw characters via input method.
    if (compositionTextPainter != null && compositionTextPainter.hasComposedTextLayout()) {
      compositionTextPainter.draw(gfx, lineHighlightColor);
    }
    if (eolMarkers) {
      gfx.setColor(eolMarkerColor);
      gfx.drawString(".", x, y);
    }
  }
Esempio n. 5
0
  /**
   * Draw the line numbers
   *
   * @param g
   */
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    ((Graphics2D) g)
        .setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    //	Determine the width of the space available to draw the line number

    FontMetrics fontMetrics = component.getFontMetrics(component.getFont());
    Insets insets = getInsets();
    int availableWidth = getSize().width - insets.left - insets.right;

    //  Determine the rows to draw within the clipped bounds.

    Rectangle clip = g.getClipBounds();
    int rowStartOffset = component.viewToModel(new Point(0, clip.y));
    int endOffset = component.viewToModel(new Point(0, clip.y + clip.height));

    while (rowStartOffset <= endOffset) {
      try {
        if (isCurrentLine(rowStartOffset)) g.setColor(getCurrentLineForeground());
        else g.setColor(getForeground());

        //  Get the line number as a string and then determine the
        //  "X" and "Y" offsets for drawing the string.

        String lineNumber = getTextLineNumber(rowStartOffset);
        int stringWidth = fontMetrics.stringWidth(lineNumber);
        int x = getOffsetX(availableWidth, stringWidth) + insets.left;
        int y = getOffsetY(rowStartOffset, fontMetrics);
        g.drawString(lineNumber, x, y);

        //  Move to the next row

        rowStartOffset = Utilities.getRowEnd(component, rowStartOffset) + 1;
      } catch (Exception e) {
        break;
      }
    }
  }
Esempio n. 6
0
  protected void paintSyntaxLine(
      Graphics gfx,
      TokenMarker tokenMarker,
      int line,
      Font defaultFont,
      Color defaultColor,
      int x,
      int y) {
    textArea.getLineText(currentLineIndex, currentLine);
    currentLineTokens = tokenMarker.markTokens(currentLine, currentLineIndex);

    paintHighlight(gfx, line, y);

    gfx.setFont(defaultFont);
    gfx.setColor(defaultColor);
    y += fm.getHeight();
    x = SyntaxUtilities.paintSyntaxLine(currentLine, currentLineTokens, styles, this, gfx, x, y);

    if (eolMarkers) {
      gfx.setColor(eolMarkerColor);
      gfx.drawString(".", x, y);
    }
  }