Crossfire JXClient, Trunk
SortItem Class Reference
+ Inheritance diagram for SortItem:
+ Collaboration diagram for SortItem:

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)
 

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.

◆ 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.

◆ 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.

◆ update()

void SortItem.update ( Graphics  g)

Update without erasing the background.

Definition at line 238 of file SortItem.java.

Member Data Documentation

◆ 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: