<commit_before>// -*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
// @homepage@

package example;

import java.awt.*;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.font.LineMetrics;
import java.awt.font.TextLayout;
import java.awt.geom.Line2D;
import javax.swing.*;

public final class MainPanel extends JPanel {
  private MainPanel() {
    super(new GridLayout(2, 1));
    add(new TextLayoutPanel());
    add(new GlyphVectorPanel());
    setPreferredSize(new Dimension(320, 240));
  }

  public static void main(String[] args) {
    EventQueue.invokeLater(MainPanel::createAndShowGui);
  }

  private static void createAndShowGui() {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
      ex.printStackTrace();
      Toolkit.getDefaultToolkit().beep();
    }
    JFrame frame = new JFrame("@title@");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.getContentPane().add(new MainPanel());
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
}

class TextLayoutPanel extends JComponent {
  private static final String TEXT = "abcdefthijklmnopqrstuvwxyz";
  private static final Font FONT = new Font(Font.SERIF, Font.ITALIC, 64);
  private static final TextLayout TEXT_LAYOUT = new TextLayout(TEXT, FONT, new FontRenderContext(null, true, true));

  @Override protected void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g.create();
    int w = getWidth();
    float baseline = getHeight() / 2f;

    g2.setPaint(Color.RED);
    g2.draw(new Line2D.Double(0, baseline, w, baseline));

    g2.setPaint(Color.GREEN);
    float ascent = baseline - TEXT_LAYOUT.getAscent();
    g2.draw(new Line2D.Double(0, ascent, w, ascent));

    g2.setPaint(Color.BLUE);
    float descent = baseline + TEXT_LAYOUT.getDescent();
    g2.draw(new Line2D.Double(0, descent, w, descent));

    g2.setPaint(Color.ORANGE);
    float leading = baseline + TEXT_LAYOUT.getDescent() + TEXT_LAYOUT.getLeading();
    g2.draw(new Line2D.Double(0, leading, w, leading));

    g2.setPaint(Color.CYAN);
    float xheight = baseline - (float) TEXT_LAYOUT.getBlackBoxBounds(23, 24).getBounds().getHeight();
    g2.draw(new Line2D.Double(0, xheight, w, xheight));

    g2.setPaint(Color.BLACK);
    TEXT_LAYOUT.draw(g2, 0f, baseline);
    g2.dispose();
  }
}

class GlyphVectorPanel extends JComponent {
  private static final String TEXT = "abcdefthijklmnopqrstuvwxyz";
  private static final FontRenderContext FRC = new FontRenderContext(null, true, true);
  private final Font font = new Font(Font.SERIF, Font.ITALIC, 64);
  private final GlyphVector gv = font.createGlyphVector(FRC, TEXT);
  private final LineMetrics lm = font.getLineMetrics(TEXT, FRC);

  @Override protected void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g.create();
    int w = getWidth();
    float baseline = getHeight() / 2f;

    g2.setPaint(Color.RED);
    g2.draw(new Line2D.Double(0, baseline, w, baseline));

    g2.setPaint(Color.GREEN);
    float ascent = baseline - lm.getAscent();
    g2.draw(new Line2D.Double(0, ascent, w, ascent));

    g2.setPaint(Color.BLUE);
    float descent = baseline + lm.getDescent();
    g2.draw(new Line2D.Double(0, descent, w, descent));

    g2.setPaint(Color.ORANGE);
    float leading = baseline + lm.getDescent() + lm.getLeading();
    g2.draw(new Line2D.Double(0, leading, w, leading));

    g2.setPaint(Color.CYAN);
    float xheight = baseline - (float) gv.getGlyphMetrics(23).getBounds2D().getHeight();
    g2.draw(new Line2D.Double(0, xheight, w, xheight));

    g2.setPaint(Color.BLACK);
    g2.drawGlyphVector(gv, 0f, baseline);
    g2.dispose();
  }
}<commit_msg>refactor: fix typo abcdeft should be abcdefg<commit_after>// -*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
// @homepage@

package example;

import java.awt.*;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.font.LineMetrics;
import java.awt.font.TextLayout;
import java.awt.geom.Line2D;
import javax.swing.*;

public final class MainPanel extends JPanel {
  private MainPanel() {
    super(new GridLayout(2, 1));
    add(new TextLayoutPanel());
    add(new GlyphVectorPanel());
    setPreferredSize(new Dimension(320, 240));
  }

  public static void main(String[] args) {
    EventQueue.invokeLater(MainPanel::createAndShowGui);
  }

  private static void createAndShowGui() {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
      ex.printStackTrace();
      Toolkit.getDefaultToolkit().beep();
    }
    JFrame frame = new JFrame("@title@");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.getContentPane().add(new MainPanel());
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
}

class TextLayoutPanel extends JComponent {
  private static final String TEXT = "abcdefghijklmnopqrstuvwxyz";
  private static final Font FONT = new Font(Font.SERIF, Font.ITALIC, 64);
  private static final TextLayout TEXT_LAYOUT = new TextLayout(TEXT, FONT, new FontRenderContext(null, true, true));

  @Override protected void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g.create();
    int w = getWidth();
    float baseline = getHeight() / 2f;

    g2.setPaint(Color.RED);
    g2.draw(new Line2D.Double(0, baseline, w, baseline));

    g2.setPaint(Color.GREEN);
    float ascent = baseline - TEXT_LAYOUT.getAscent();
    g2.draw(new Line2D.Double(0, ascent, w, ascent));

    g2.setPaint(Color.BLUE);
    float descent = baseline + TEXT_LAYOUT.getDescent();
    g2.draw(new Line2D.Double(0, descent, w, descent));

    g2.setPaint(Color.ORANGE);
    float leading = baseline + TEXT_LAYOUT.getDescent() + TEXT_LAYOUT.getLeading();
    g2.draw(new Line2D.Double(0, leading, w, leading));

    g2.setPaint(Color.CYAN);
    float xh = baseline - (float) TEXT_LAYOUT.getBlackBoxBounds(23, 24).getBounds().getHeight();
    g2.draw(new Line2D.Double(0, xh, w, xh));

    g2.setPaint(Color.BLACK);
    TEXT_LAYOUT.draw(g2, 0f, baseline);
    g2.dispose();
  }
}

class GlyphVectorPanel extends JComponent {
  private static final String TEXT = "abcdefghijklmnopqrstuvwxyz";
  private static final FontRenderContext FRC = new FontRenderContext(null, true, true);
  private static final Font FONT = new Font(Font.SERIF, Font.ITALIC, 64);
  private final transient GlyphVector gv = FONT.createGlyphVector(FRC, TEXT);
  private final transient LineMetrics lm = FONT.getLineMetrics(TEXT, FRC);

  @Override protected void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g.create();
    int w = getWidth();
    float baseline = getHeight() / 2f;

    g2.setPaint(Color.RED);
    g2.draw(new Line2D.Float(0f, baseline, w, baseline));

    g2.setPaint(Color.GREEN);
    float ascent = baseline - lm.getAscent();
    g2.draw(new Line2D.Float(0f, ascent, w, ascent));

    g2.setPaint(Color.BLUE);
    float descent = baseline + lm.getDescent();
    g2.draw(new Line2D.Float(0f, descent, w, descent));

    g2.setPaint(Color.ORANGE);
    float leading = baseline + lm.getDescent() + lm.getLeading();
    g2.draw(new Line2D.Float(0f, leading, w, leading));

    g2.setPaint(Color.CYAN);
    float xh = baseline - (float) gv.getGlyphMetrics(23).getBounds2D().getHeight();
    g2.draw(new Line2D.Float(0f, xh, w, xh));

    g2.setPaint(Color.BLACK);
    g2.drawGlyphVector(gv, 0f, baseline);
    g2.dispose();
  }
}
{'fraction_non_alphanumeric': 0.13116649537512848, 'fraction_numerical': 0.020041109969167522, 'mean_word_length': 4.148809523809524, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3213495', 'n_tokens_mistral': 2717, 'n_tokens_neox': 2623, 'n_words': 567}