001 package nl.cwi.sen1.gui.plugin.editor; 002 003 import java.awt.Color; 004 import java.awt.Graphics; 005 import java.awt.Rectangle; 006 import java.awt.Shape; 007 008 import javax.swing.text.BadLocationException; 009 import javax.swing.text.DefaultHighlighter; 010 import javax.swing.text.JTextComponent; 011 import javax.swing.text.Position; 012 import javax.swing.text.View; 013 014 public class JaggedHighlightPainter extends 015 DefaultHighlighter.DefaultHighlightPainter { 016 017 public JaggedHighlightPainter(Color color) { 018 super(color); 019 } 020 021 public Shape paintLayer(Graphics g, int offs0, int offs1, Shape bounds, 022 JTextComponent c, View view) { 023 try { 024 Shape shape = view.modelToView(offs0, Position.Bias.Forward, offs1, 025 Position.Bias.Backward, bounds); 026 027 Rectangle r = (shape instanceof Rectangle) ? (Rectangle) shape 028 : shape.getBounds(); 029 030 int y = (int) (shape.getBounds().getY() + shape.getBounds() 031 .getHeight()); 032 int x1 = (int) shape.getBounds().getX(); 033 int x2 = (int) (shape.getBounds().getX() + shape.getBounds() 034 .getWidth()); 035 036 g.setColor(getColor()); 037 for (int i = x1; i < x2 - 6; i += 6) { 038 g.drawArc(i, y - 3, 3, 2, 0, 180); 039 g.drawArc(i + 3, y - 3, 3, 2, 180, 181); 040 } 041 return r; 042 } catch (BadLocationException e) { 043 } 044 045 return null; 046 } 047 }