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();
        }
    }
}

@@ -2390,16 +2390,106 @@
 hView %7B%0A
+    //private static final ParagraphMarkIcon paragraphMarkIcon = new ParagraphMarkIcon();%0A
     priv
@@ -3115,30 +3115,103 @@
     
-Color old = g.getColor
+//paragraphMarkIcon.paintIcon(null, g, x, y);%0A            Graphics2D g2 = (Graphics2D) g.create
 ();%0A
@@ -3215,32 +3215,33 @@
 );%0A            g
+2
 .setColor(MARK_C
@@ -3252,32 +3252,33 @@
 );%0A            g
+2
 .drawLine(x + 1,
@@ -3313,32 +3313,33 @@
 );%0A            g
+2
 .drawLine(x + 2,
@@ -3382,16 +3382,17 @@
        g
+2
 .drawLin
@@ -3447,21 +3447,18 @@
    g
-.setColor(old
+2.dispose(
 );%0A 
@@ -3544,16 +3544,882 @@
       %7D%0A    %7D%0A%7D%0A
+%0A// TEST:%0A// class ParagraphMarkIcon implements Icon %7B%0A//     private static final Color MARK_COLOR = new Color(120, 130, 110);%0A//     private final Polygon paragraphMark = new Polygon();%0A//     public ParagraphMarkIcon() %7B%0A//         paragraphMark.addPoint(1, 7);%0A//         paragraphMark.addPoint(3, 7);%0A//         paragraphMark.addPoint(3, 11);%0A//         paragraphMark.addPoint(4, 11);%0A//         paragraphMark.addPoint(1, 14);%0A//     %7D%0A//     @Override public void paintIcon(Component c, Graphics g, int x, int y) %7B%0A//         Graphics2D g2 = (Graphics2D) g.create();%0A//         g2.setColor(MARK_COLOR);%0A//         g2.translate(x, y);%0A//         g2.draw(paragraphMark);%0A//         g2.dispose();%0A//     %7D%0A//     @Override public int getIconWidth()  %7B%0A//         return 3;%0A//     %7D%0A//     @Override public int getIconHeight() %7B%0A//         return 7;%0A//     %7D%0A// %7D%0A

add ParagraphMarkIcon