package net.sf.xpontus.view.editor; import javax.swing.text.Element; import javax.swing.text.PlainView; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.io.Reader; import java.io.StringReader; import java.util.List; import java.util.Map; import javax.swing.text.Element; import javax.swing.text.MutableAttributeSet; import javax.swing.text.PlainView; import javax.swing.text.Segment; import javax.swing.text.Utilities; import net.sf.xpontus.view.editor.syntax.CharStream; import net.sf.xpontus.view.editor.syntax.FastCharStream; import net.sf.xpontus.view.editor.syntax.StyleInfo; import net.sf.xpontus.view.editor.syntax.SyntaxSupport; import net.sf.xpontus.view.editor.syntax.Token; import net.sf.xpontus.view.editor.syntax.TokenMgrError; import net.sf.xpontus.view.editor.syntax.java.JavaParser; /** * A Swing view implementation that colorizes lines of a SyntaxDocument using a * TokenMarker. * * This class should not be used directly; a SyntaxEditorKit should be used * instead. * * * @author Yves Zoundi * * @version $Id: SyntaxView.java,v 1.1.1.1 2005/12/08 01:34:34 yveszoundi Exp $ */ public class SyntaxView2 extends PlainView { private Segment line; private Segment seg = new Segment(); private ILexer lexer; private Color defaultColor = Color.BLACK; private Map styleMap; /** * @param e * @param provider * @param lexer */ public SyntaxView2(Element e, SyntaxSupport syntaxSupport) { super(e); line = new Segment(); this.styleMap = syntaxSupport.getColorProvider().getStyles(); this.lexer = syntaxSupport.getLexer(); } /* * (non-Javadoc) * * @see javax.swing.text.PlainView#drawLine(int, java.awt.Graphics, int, * int) */ protected void drawLine(int lineIndex, Graphics g, int x, int y) { Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.BLACK); try { Element lineElement = getElement().getElement(lineIndex); int start = lineElement.getStartOffset(); int end = lineElement.getEndOffset(); int last = start; int realStart; int thisStart; boolean gotMatch = false; Token token = null; List tokenList = (List)((MutableAttributeSet)lineElement.getAttributes()).getAttribute("tokenList"); for(int i=0;i