kawigi.editor
Class VBView

java.lang.Object
  |
  +--javax.swing.text.View
        |
        +--javax.swing.text.PlainView
              |
              +--kawigi.editor.GenericView
                    |
                    +--kawigi.editor.VBView
All Implemented Interfaces:
javax.swing.SwingConstants, javax.swing.text.TabExpander

public class VBView
extends GenericView

Implementation of a Visual Basic implementation of a View that hilights syntax attributes.


Field Summary
protected static java.awt.Color classColor
           
protected static java.util.Hashtable colorHash
           
protected static java.awt.Color commentColor
           
protected static java.awt.Color directiveColor
           
protected static java.awt.Color keywordColor
           
protected static java.awt.Color operatorColor
           
protected static java.awt.Color stringColor
           
protected static java.awt.Color typeColor
           
 
Fields inherited from class kawigi.editor.GenericView
highlightKey1, highlightKey2, lineIndex, parseIndex
 
Fields inherited from class javax.swing.text.PlainView
metrics
 
Fields inherited from class javax.swing.text.View
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
VBView(javax.swing.text.Element e)
          Creates an instance of VBView and passes along the Element.
 
Method Summary
protected  int drawSelectedText(java.awt.Graphics g, int x, int y, int p0, int p1)
          Overridden from PlainView - this method gets called to render every element of selected text, so that I could change how it's displayed if I want.
protected  int drawTabbedText(java.lang.String s, int x, int y, java.awt.Graphics g, int startOffset, boolean selected)
          Renders the text segment onto the given Grapnics context.
protected  int drawUnselectedText(java.awt.Graphics g, int x, int y, int p0, int p1)
          Overridden from PlainView - this method gets called to render every element of unselected text.
protected  void findIntervals(java.util.ArrayList list, java.lang.String text, java.lang.String[] startEnd)
          Helper function to help with getIntervals.
protected  java.awt.Color getColor(java.lang.String word)
          Returns the color to use on the given token.
 java.util.ArrayList getIntervals()
          Returns an ArrayList of Interval objects representing code block intervals in the document.
static void initColors()
          Somone who knows VB better than me should hack this up sometime, I probably have it all messed up.
 
Methods inherited from class kawigi.editor.GenericView
findName, getTabSize, paint, resetTabStop
 
Methods inherited from class javax.swing.text.PlainView
changedUpdate, damageLineRange, drawLine, getLineBuffer, getPreferredSpan, insertUpdate, lineToRect, modelToView, nextTabStop, removeUpdate, setSize, updateDamage, updateMetrics, viewToModel
 
Methods inherited from class javax.swing.text.View
append, breakView, createFragment, forwardUpdate, forwardUpdateToView, getAlignment, getAttributes, getBreakWeight, getChildAllocation, getContainer, getDocument, getElement, getEndOffset, getGraphics, getMaximumSpan, getMinimumSpan, getNextVisualPositionFrom, getParent, getResizeWeight, getStartOffset, getToolTipText, getView, getViewCount, getViewFactory, getViewIndex, getViewIndex, insert, isVisible, modelToView, modelToView, preferenceChanged, remove, removeAll, replace, setParent, updateChildren, updateLayout, viewToModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colorHash

protected static java.util.Hashtable colorHash

keywordColor

protected static java.awt.Color keywordColor

typeColor

protected static java.awt.Color typeColor

operatorColor

protected static java.awt.Color operatorColor

classColor

protected static java.awt.Color classColor

stringColor

protected static java.awt.Color stringColor

commentColor

protected static java.awt.Color commentColor

directiveColor

protected static java.awt.Color directiveColor
Constructor Detail

VBView

public VBView(javax.swing.text.Element e)
Creates an instance of VBView and passes along the Element.

Method Detail

initColors

public static void initColors()
Somone who knows VB better than me should hack this up sometime, I probably have it all messed up. Particularly in the "class" section, I added several standard function names that I don't think were keywords, but are still "language features", and that might have been overboard.


drawUnselectedText

protected int drawUnselectedText(java.awt.Graphics g,
                                 int x,
                                 int y,
                                 int p0,
                                 int p1)
                          throws javax.swing.text.BadLocationException
Overridden from PlainView - this method gets called to render every element of unselected text.

Overrides:
drawUnselectedText in class javax.swing.text.PlainView
javax.swing.text.BadLocationException

drawSelectedText

protected int drawSelectedText(java.awt.Graphics g,
                               int x,
                               int y,
                               int p0,
                               int p1)
                        throws javax.swing.text.BadLocationException
Overridden from PlainView - this method gets called to render every element of selected text, so that I could change how it's displayed if I want.

Overrides:
drawSelectedText in class javax.swing.text.PlainView
javax.swing.text.BadLocationException

drawTabbedText

protected int drawTabbedText(java.lang.String s,
                             int x,
                             int y,
                             java.awt.Graphics g,
                             int startOffset,
                             boolean selected)
Renders the text segment onto the given Grapnics context. Originally, this looked a lot like javax.swing.text.Utilities.drawTabbedText with a little bit of tokenizing, but now it's pretty much modified to my own style. Unfortunately, at some point in time, my indentation got all weird (probably as a result of me using tabs and the original implementation mixing spaces and tabs), so there may be some weird-looking parts left in the code. This is the magic of my syntax hilighting.


getColor

protected java.awt.Color getColor(java.lang.String word)
Returns the color to use on the given token. This will return the default foreground color, if no special color is assigned to that token.


getIntervals

public java.util.ArrayList getIntervals()
Returns an ArrayList of Interval objects representing code block intervals in the document. This version is specifically for finding blocks in the Visual Basic language.

Overrides:
getIntervals in class GenericView

findIntervals

protected void findIntervals(java.util.ArrayList list,
                             java.lang.String text,
                             java.lang.String[] startEnd)
Helper function to help with getIntervals. Puts the intervals into the list in an in-order traversal of blocks between startEnd[0] and startEnd[1]. This is modified from the C-syntax-based one in GenericView to work better with VB's string and comment syntax.

Overrides:
findIntervals in class GenericView