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
-
TextPanel(String)
- Creates a text panel based on the source file specified in the String
passed in as the parameter.
-
TextPanel(URL)
- Creates a text frame based on the URL specified by
the parameter.
-
getLineSpace()
- Get the number of pixels used by each line of text.
-
getMinimumSize()
- Return the minimum allowed dimension of the text panel.
-
getNumLines()
- Get the number of lines of source code to be displayed on the text panel.
-
getPreferredSize()
- Returns the initial dimension of the text panel.
-
getStart()
- Get the first line of the source code that will be displayed.
-
Highlight(int)
- Highlight a certain line of the source code.
-
paint(Graphics)
- This method print the source code starting from the first line specified
by
setStart(int)
on the text panel.
-
setStart(int)
- Set the first line to display.
-
update(Graphics)
- This method is invoked when the
repaint()
method of the
parent class is called.
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
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
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
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
getMinimumSize
public Dimension getMinimumSize()
- Return the minimum allowed dimension of the text panel.
- Overrides:
- getMinimumSize in class Container
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
setStart
public void setStart(int start)
- Set the first line to display.
- Parameters:
- start - First line to display
- See Also:
- getStart
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
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.
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.
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.