Class TextPanel

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----TextPanel

public class TextPanel
extends Panel
Text panel to display the source code of the animation algorithm. This class is initialized in the TextFrame class construction during the main frame initialization. Each line of the source code starting with /*- will be ignored. The line after /*------- is considered as the first line of text being displayed. The line before //- is the last line of source code being displayed. The text after this line will no longer be parsed. See also AlgThread for special symbol used in displaying source code in text panel.

This method should NOT have to be called manually.

See Also:
TextFrame, AlgAnimFrame

Constructor Index

 o TextPanel(String)
Creates a text panel based on the source file specified in the String passed in as the parameter.
 o TextPanel(URL)
Creates a text frame based on the URL specified by the parameter.

Method Index

 o getLineSpace()
Get the number of pixels used by each line of text.
 o getMinimumSize()
Return the minimum allowed dimension of the text panel.
 o getNumLines()
Get the number of lines of source code to be displayed on the text panel.
 o getPreferredSize()
Returns the initial dimension of the text panel.
 o getStart()
Get the first line of the source code that will be displayed.
 o Highlight(int)
Highlight a certain line of the source code.
 o paint(Graphics)
This method print the source code starting from the first line specified by setStart(int) on the text panel.
 o setStart(int)
Set the first line to display.
 o update(Graphics)
This method is invoked when the repaint() method of the parent class is called.

Constructors

 o TextPanel
 public TextPanel(String fn)
Creates a text panel based on the source file specified in the String passed in as the parameter.

Parameters:
fn - Filename of the source code
 o TextPanel
 public TextPanel(URL sourceURL)
Creates a text frame based on the URL specified by the parameter.

Parameters:
sourceURL - URL of the source code
See Also:
URL

Methods

 o Highlight
 public void Highlight(int h)
Highlight a certain line of the source code. The highlighted line is displayed in RED while the other normal lines are displayed in BLACK. The first line of the source has a line index of 0.

Parameters:
h - The line to be highlighted
 o getPreferredSize
 public Dimension getPreferredSize()
Returns the initial dimension of the text panel. This method will be called by the layout manager during the corresponding frame initialization.

Overrides:
getPreferredSize in class Container
 o getMinimumSize
 public Dimension getMinimumSize()
Return the minimum allowed dimension of the text panel.

Overrides:
getMinimumSize in class Container
 o update
 public void update(Graphics g)
This method is invoked when the repaint() method of the parent class is called. This method eliminates flashing during animation.

Overrides:
update in class Container
 o setStart
 public void setStart(int start)
Set the first line to display.

Parameters:
start - First line to display
See Also:
getStart
 o paint
 public void paint(Graphics g)
This method print the source code starting from the first line specified by setStart(int) on the text panel.

Parameters:
g - Graphical context of the text panel.
Overrides:
paint in class Container
 o getNumLines
 public int getNumLines()
Get the number of lines of source code to be displayed on the text panel.

Returns:
The number of lines of source code to be displayed on the text frame.
 o getLineSpace
 public int getLineSpace()
Get the number of pixels used by each line of text.

Returns:
The number of pixels allocated for each line of text.
 o getStart
 public int getStart()
Get the first line of the source code that will be displayed. This attribute is used to couple the text panel to a vertical scrollbar in the TextFrame.

Returns:
The first line of source code that will be displayed.