<commit_before>package example;
//-*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
//@homepage@
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;

public final class MainPanel extends JPanel {
    private MainPanel() {
        super(new BorderLayout());
        JEditorPane editor = new JEditorPane();
        editor.setEditorKit(new MyEditorKit());
        editor.setText("1234123541341234123423\nadfasdfasdfasdf\nffas213441324dfasdfas\n\nretqewrqwr");
        add(new JScrollPane(editor));
        setPreferredSize(new Dimension(320, 240));
    }
    public static void main(String... args) {
        EventQueue.invokeLater(new Runnable() {
            @Override public void run() {
                createAndShowGUI();
            }
        });
    }
    public static void createAndShowGUI() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException
               | IllegalAccessException | UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        }
        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 MyEditorKit extends StyledEditorKit {
    @Override public ViewFactory getViewFactory() {
        return new MyViewFactory();
    }
}

class MyViewFactory implements ViewFactory {
    @Override public View create(Element elem) {
        String kind = elem.getName();
        if (kind != null) {
            if (kind.equals(AbstractDocument.ContentElementName)) {
                return new LabelView(elem);
            } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
                return new MyParagraphView(elem);
            } else if (kind.equals(AbstractDocument.SectionElementName)) {
                return new BoxView(elem, View.Y_AXIS);
            } else if (kind.equals(StyleConstants.ComponentElementName)) {
                return new ComponentView(elem);
            } else if (kind.equals(StyleConstants.IconElementName)) {
                return new IconView(elem);
            }
        }
        return new LabelView(elem);
    }
}

class MyParagraphView extends ParagraphView {
    private static final Color MARK_COLOR = new Color(120, 130, 110);
    public MyParagraphView(Element elem) {
        super(elem);
    }
    @Override public void paint(Graphics g, Shape allocation) {
        super.paint(g, allocation);
        paintCustomParagraph(g, allocation);
    }
    private void paintCustomParagraph(Graphics g, Shape a) {
        try {
            Shape paragraph = modelToView(getEndOffset(), a, Position.Bias.Backward);
            Rectangle r = (paragraph == null) ? a.getBounds() : paragraph.getBounds();
            int x = r.x;
            int y = r.y;
            int h = r.height;
            Color old = g.getColor();
            g.setColor(MARK_COLOR);
            g.drawLine(x + 1, y + h / 2, x + 1, y + h - 4);
            g.drawLine(x + 2, y + h / 2, x + 2, y + h - 5);
            g.drawLine(x + 3, y + h - 6, x + 3, y + h - 6);
            g.setColor(old);
        } catch (BadLocationException ex) {
            ex.printStackTrace();
        }
    }
}<commit_msg>comment: add ParagraphMarkIcon<commit_after>package example;
//-*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
//@homepage@
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;

public final class MainPanel extends JPanel {
    private MainPanel() {
        super(new BorderLayout());
        JEditorPane editor = new JEditorPane();
        editor.setEditorKit(new MyEditorKit());
        editor.setText("1234123541341234123423\nadfasdfasdfasdf\nffas213441324dfasdfas\n\nretqewrqwr");
        add(new JScrollPane(editor));
        setPreferredSize(new Dimension(320, 240));
    }
    public static void main(String... args) {
        EventQueue.invokeLater(new Runnable() {
            @Override public void run() {
                createAndShowGUI();
            }
        });
    }
    public static void createAndShowGUI() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException
               | IllegalAccessException | UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        }
        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 MyEditorKit extends StyledEditorKit {
    @Override public ViewFactory getViewFactory() {
        return new MyViewFactory();
    }
}

class MyViewFactory implements ViewFactory {
    @Override public View create(Element elem) {
        String kind = elem.getName();
        if (kind != null) {
            if (kind.equals(AbstractDocument.ContentElementName)) {
                return new LabelView(elem);
            } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
                return new MyParagraphView(elem);
            } else if (kind.equals(AbstractDocument.SectionElementName)) {
                return new BoxView(elem, View.Y_AXIS);
            } else if (kind.equals(StyleConstants.ComponentElementName)) {
                return new ComponentView(elem);
            } else if (kind.equals(StyleConstants.IconElementName)) {
                return new IconView(elem);
            }
        }
        return new LabelView(elem);
    }
}

class MyParagraphView extends ParagraphView {
    //private static final ParagraphMarkIcon paragraphMarkIcon = new ParagraphMarkIcon();
    private static final Color MARK_COLOR = new Color(120, 130, 110);
    public MyParagraphView(Element elem) {
        super(elem);
    }
    @Override public void paint(Graphics g, Shape allocation) {
        super.paint(g, allocation);
        paintCustomParagraph(g, allocation);
    }
    private void paintCustomParagraph(Graphics g, Shape a) {
        try {
            Shape paragraph = modelToView(getEndOffset(), a, Position.Bias.Backward);
            Rectangle r = (paragraph == null) ? a.getBounds() : paragraph.getBounds();
            int x = r.x;
            int y = r.y;
            int h = r.height;
            //paragraphMarkIcon.paintIcon(null, g, x, y);
            Graphics2D g2 = (Graphics2D) g.create();
            g2.setColor(MARK_COLOR);
            g2.drawLine(x + 1, y + h / 2, x + 1, y + h - 4);
            g2.drawLine(x + 2, y + h / 2, x + 2, y + h - 5);
            g2.drawLine(x + 3, y + h - 6, x + 3, y + h - 6);
            g2.dispose();
        } catch (BadLocationException ex) {
            ex.printStackTrace();
        }
    }
}

// TEST:
// class ParagraphMarkIcon implements Icon {
//     private static final Color MARK_COLOR = new Color(120, 130, 110);
//     private final Polygon paragraphMark = new Polygon();
//     public ParagraphMarkIcon() {
//         paragraphMark.addPoint(1, 7);
//         paragraphMark.addPoint(3, 7);
//         paragraphMark.addPoint(3, 11);
//         paragraphMark.addPoint(4, 11);
//         paragraphMark.addPoint(1, 14);
//     }
//     @Override public void paintIcon(Component c, Graphics g, int x, int y) {
//         Graphics2D g2 = (Graphics2D) g.create();
//         g2.setColor(MARK_COLOR);
//         g2.translate(x, y);
//         g2.draw(paragraphMark);
//         g2.dispose();
//     }
//     @Override public int getIconWidth()  {
//         return 3;
//     }
//     @Override public int getIconHeight() {
//         return 7;
//     }
// }
{'fraction_non_alphanumeric': 0.115857523133477, 'fraction_numerical': 0.020154645709215362, 'mean_word_length': 2.2349323493234934, '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': '5821704', 'n_tokens_mistral': 2368, 'n_tokens_neox': 2236, 'n_words': 524}