com.bluemarsh.jswat.view
Class ColorSourceView

java.lang.Object
  |
  +--com.bluemarsh.jswat.view.JSwatView
        |
        +--com.bluemarsh.jswat.view.BasicView
              |
              +--com.bluemarsh.jswat.view.SourceView
                    |
                    +--com.bluemarsh.jswat.view.ColorSourceView
All Implemented Interfaces:
BreakpointListener, com.bluemarsh.config.ConfigureListener, ContextListener, java.util.EventListener, SessionListener

public class ColorSourceView
extends SourceView

Class ColorSourceView is responsible for displaying the source file on the screen. This class displays a row header down the left side of the source view, indicating the line numbers. A popup menu is attached to the view for setting breakpoints.

Additionally, this class colorizes the Java source code.

Author:
Nathan Fiedler

Fields inherited from class com.bluemarsh.jswat.view.SourceView
headerPopup, owningSession, sourceFile, textPopup, viewHeader, viewScroller
 
Fields inherited from class com.bluemarsh.jswat.view.BasicView
highlightTag, logCategory, textComponent, textHighlightPainter, viewContent, viewTitle
 
Constructor Summary
ColorSourceView(java.io.File source)
          Creates a ColorSourceView object.
 
Method Summary
protected  javax.swing.text.Document createDefaultDocument()
          Creates a new SourceDocument with all of the necessary styles.
protected  javax.swing.text.JTextComponent createTextComponent()
          Create the text component with the default document.
 int getLineCount()
          Returns the number of lines in this document.
protected  int getLineEndOffset(int line)
          Get the offset of the end of the given line.
protected  int getLineOfOffset(int offset)
          Find the line containing the given offset.
protected  int getLineStartOffset(int line)
          Get the offset of the start of the given line.
protected  int getTabSize()
          Gets the number of characters used to expand tabs.
protected  void setTabSize(int size)
          Sets the tab width of the source document.
protected  void setTextContent()
          Set the content of the text component using the String defined by viewContent.
 
Methods inherited from class com.bluemarsh.jswat.view.SourceView
activate, breakpointAdded, breakpointModified, breakpointRemoved, close, configurationChanged, contextChanged, deactivate, getBreakpointColor, getUI, init, matches, matches, parseClassDefs, refresh, refresh, setBreakpoint, setBreakpoints, setPreferences
 
Methods inherited from class com.bluemarsh.jswat.view.BasicView
findString, foundString, removeHighlight, scrollToLine, setTextComponent, showHighlight
 
Methods inherited from class com.bluemarsh.jswat.view.JSwatView
refresh
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorSourceView

public ColorSourceView(java.io.File source)
Creates a ColorSourceView object.
Parameters:
source - source code file to display
Method Detail

createDefaultDocument

protected javax.swing.text.Document createDefaultDocument()
Creates a new SourceDocument with all of the necessary styles.
Overrides:
createDefaultDocument in class SourceView
Returns:
source document.

createTextComponent

protected javax.swing.text.JTextComponent createTextComponent()
Create the text component with the default document.
Overrides:
createTextComponent in class SourceView
Returns:
text component.
See Also:
createDefaultDocument()

getLineCount

public int getLineCount()
Returns the number of lines in this document. Lines are sequences of text separated by carriage return, line feed, or the pair of carriage return and line feed.
Overrides:
getLineCount in class SourceView
Returns:
line count.

getLineEndOffset

protected int getLineEndOffset(int line)
                        throws javax.swing.text.BadLocationException
Get the offset of the end of the given line.
Overrides:
getLineEndOffset in class SourceView
Parameters:
line - zero-based line for which to find the end.
Returns:
offset of end of line.
Throws:
javax.swing.text.BadLocationException - Thrown if line is invalid.

getLineOfOffset

protected int getLineOfOffset(int offset)
                       throws javax.swing.text.BadLocationException
Find the line containing the given offset.
Overrides:
getLineOfOffset in class SourceView
Parameters:
offset - offset within document >= 0.
Returns:
zero-based line containing that offset.
Throws:
javax.swing.text.BadLocationException - Thrown if offset is invalid.

getLineStartOffset

protected int getLineStartOffset(int line)
                          throws javax.swing.text.BadLocationException
Get the offset of the start of the given line.
Overrides:
getLineStartOffset in class SourceView
Parameters:
line - zero-based line for which to find the start.
Returns:
offset of start of line.
Throws:
javax.swing.text.BadLocationException - Thrown if line is invalid.

getTabSize

protected int getTabSize()
Gets the number of characters used to expand tabs. If the document is null or doesn't have a tab setting, return a default of 8.
Overrides:
getTabSize in class SourceView
Returns:
the number of characters.

setTabSize

protected void setTabSize(int size)
Sets the tab width of the source document.
Overrides:
setTabSize in class SourceView
Parameters:
size - number of spaces for a tab character.

setTextContent

protected void setTextContent()
Set the content of the text component using the String defined by viewContent. This implementation applies styles to the Java source to colorize it syntactically.
Overrides:
setTextContent in class SourceView