Crossfire JXClient, Trunk
Public Member Functions | Package Functions | Package Attributes | Private Member Functions | Private Attributes | List of all members
SortItem Class Reference
Inheritance diagram for SortItem:
Inheritance graph
Collaboration diagram for SortItem:
Collaboration graph

Public Member Functions

void destroy ()
 
String getAppletInfo ()
 
String[][] getParameterInfo ()
 
void init ()
 
void mouseClicked (MouseEvent e)
 
void mouseEntered (MouseEvent e)
 
void mouseExited (MouseEvent e)
 
void mousePressed (MouseEvent e)
 
void mouseReleased (MouseEvent e)
 
void paint (Graphics g)
 
void run ()
 
void start ()
 
synchronized void stop ()
 
void update (Graphics g)
 

Package Functions

void pause ()
 
void pause (int H1)
 
void pause (int H1, int H2)
 
void scramble ()
 

Package Attributes

String algName
 
SortAlgorithm algorithm
 
int arr []
 
int h1 = -1
 
int h2 = -1
 
Dimension initialSize = null
 

Private Member Functions

synchronized void startSort ()
 

Private Attributes

Thread kicker
 

Detailed Description

A simple applet class to demonstrate a sort algorithm. You can specify a sorting algorithm using the "alg" attribute. When you click on the applet, a thread is forked which animates the sorting algorithm.

Author
James Gosling

Definition at line 58 of file SortItem.java.

Member Function Documentation

◆ destroy()

void SortItem.destroy ( )

Deallocate resources of applet.

Definition at line 168 of file SortItem.java.

◆ getAppletInfo()

String SortItem.getAppletInfo ( )

Definition at line 319 of file SortItem.java.

◆ getParameterInfo()

String [][] SortItem.getParameterInfo ( )

Definition at line 324 of file SortItem.java.

◆ init()

void SortItem.init ( )

Initialize the applet.

Definition at line 143 of file SortItem.java.

◆ mouseClicked()

void SortItem.mouseClicked ( MouseEvent  e)

Definition at line 293 of file SortItem.java.

◆ mouseEntered()

void SortItem.mouseEntered ( MouseEvent  e)

Definition at line 311 of file SortItem.java.

◆ mouseExited()

void SortItem.mouseExited ( MouseEvent  e)

Definition at line 315 of file SortItem.java.

◆ mousePressed()

void SortItem.mousePressed ( MouseEvent  e)

Definition at line 298 of file SortItem.java.

◆ mouseReleased()

void SortItem.mouseReleased ( MouseEvent  e)

The user clicked in the applet. Start the clock!

Definition at line 305 of file SortItem.java.

◆ paint()

void SortItem.paint ( Graphics  g)

Paint the array of numbers as a list of horizontal lines of varying lengths.

Definition at line 177 of file SortItem.java.

References a.

◆ pause() [1/3]

void SortItem.pause ( )
package

Pause a while.

See also
SortAlgorithm

Definition at line 111 of file SortItem.java.

Referenced by SortAlgorithm.pause().

Here is the caller graph for this function:

◆ pause() [2/3]

void SortItem.pause ( int  H1)
package

Pause a while, and draw the high water mark.

See also
SortAlgorithm

Definition at line 119 of file SortItem.java.

◆ pause() [3/3]

void SortItem.pause ( int  H1,
int  H2 
)
package

Pause a while, and draw the low&high water marks.

See also
SortAlgorithm

Definition at line 127 of file SortItem.java.

◆ run()

void SortItem.run ( )

Run the sorting algorithm. This method is called by class Thread once the sorting algorithm is started.

See also
java.lang.Thread::run
SortItem::mouseUp

Definition at line 250 of file SortItem.java.

References SortAlgorithm.init(), SortAlgorithm.setParent(), and SortAlgorithm.sort().

Here is the call graph for this function:

◆ scramble()

void SortItem.scramble ( )
package

Fill the array with random numbers from 0..n-1.

Definition at line 90 of file SortItem.java.

References a, and t.

◆ start()

void SortItem.start ( )

Definition at line 157 of file SortItem.java.

◆ startSort()

synchronized void SortItem.startSort ( )
private

For a Thread to actually do the sorting. This routine makes sure we do not simultaneously start several sorts if the user repeatedly clicks on the sort item. It needs to be synchronized with the stop() method because they both manipulate the common kicker variable.

Definition at line 285 of file SortItem.java.

◆ stop()

synchronized void SortItem.stop ( )

Stop the applet. Kill any sorting algorithm that is still sorting.

Definition at line 267 of file SortItem.java.

References SortAlgorithm.stop().

Here is the call graph for this function:

◆ update()

void SortItem.update ( Graphics  g)

Update without erasing the background.

Definition at line 238 of file SortItem.java.

Member Data Documentation

◆ algName

String SortItem.algName
package

The name of the algorithm.

Definition at line 80 of file SortItem.java.

◆ algorithm

SortAlgorithm SortItem.algorithm
package

The sorting algorithm (or null).

Definition at line 84 of file SortItem.java.

◆ arr

int SortItem.arr[]
package

The array that is being sorted.

Definition at line 68 of file SortItem.java.

◆ h1

int SortItem.h1 = -1
package

The high water mark.

Definition at line 72 of file SortItem.java.

Referenced by SortAlgorithm.pause().

◆ h2

int SortItem.h2 = -1
package

The low water mark.

Definition at line 76 of file SortItem.java.

Referenced by SortAlgorithm.pause().

◆ initialSize

Dimension SortItem.initialSize = null
package

Definition at line 85 of file SortItem.java.

◆ kicker

Thread SortItem.kicker
private

The thread that is sorting (or null).

Definition at line 64 of file SortItem.java.


The documentation for this class was generated from the following file: