support.Flight
Interface UserInterface

All Known Implementing Classes:
GUI

public abstract interface UserInterface

Specifies the services that a user interface provides to student code for the Flight assignment. The interface can be implemented with a visual user interface (see GUI.java) or with a text-based user interface.

Author:
Mark Handy

Field Summary
static java.awt.Color BLACK
          When colors are needed, use these constants, or just make a java.awt.Color using the java.awt.Color class itself.
static java.awt.Color BLUE
           
static java.awt.Color GRAY
           
static java.awt.Color GREEN
           
static java.awt.Color INVISIBLE
           
static java.awt.Color RED
           
 
Method Summary
 void buildingGraph()
          Displays a status report for the user.
 void clearAirports()
          Erases all airport vertices and flight edges displayed.
 void clearFlights()
          Erases all flight edges displayed.
 void drawAirport(AirportSpecs a, java.awt.Color c)
          Draws or redraws an airport, with the specified color.
 void drawAllAirports(java.awt.Color c)
          Colors all airports the same color
 void drawFlight(FlightSpecs f, java.awt.Color c)
          Draws or redraws a flight, with the specified color.
 void exit()
          Call this just before your mainline exits.
 void initializingGraph()
          Displays a status report for the user.
 void otherMessage(java.lang.String message)
          You can use this to give your own status reports or your own prompts.
 void parsing()
          Displays a status report for the user.
 void pause(long milliseconds)
          Freeze the GUI for a bit.
 void processingQuery()
          Displays a status report for the user.
 java.lang.String readAirport()
          Once called, this method doesn't return until the user has selected an airport.
 java.lang.String readText()
          Once called, this method doesn't return until the user has typed in some text and hit enter.
 void waitingForAirport()
          Prompts the user to select an airport.
 void waitingForText()
          Prompts the user to type something.
 void writeText(java.lang.String message)
          Prints the specified text for the user.
 

Field Detail

BLACK

public static final java.awt.Color BLACK
When colors are needed, use these constants, or just make a java.awt.Color using the java.awt.Color class itself.

BLUE

public static final java.awt.Color BLUE

GREEN

public static final java.awt.Color GREEN

RED

public static final java.awt.Color RED

GRAY

public static final java.awt.Color GRAY

INVISIBLE

public static final java.awt.Color INVISIBLE
Method Detail

drawAirport

public void drawAirport(AirportSpecs a,
                        java.awt.Color c)
Draws or redraws an airport, with the specified color.
Parameters:
a - This provides the x,y for the vertex
c - Any old java.awt.Color you choose

drawFlight

public void drawFlight(FlightSpecs f,
                       java.awt.Color c)
Draws or redraws a flight, with the specified color.
Parameters:
f - This provides the codes for the endpoints of the edge
c - Any old java.awt.Color you choose

clearFlights

public void clearFlights()
Erases all flight edges displayed.

clearAirports

public void clearAirports()
Erases all airport vertices and flight edges displayed.

drawAllAirports

public void drawAllAirports(java.awt.Color c)
Colors all airports the same color
Parameters:
c - Color for all airports

writeText

public void writeText(java.lang.String message)
Prints the specified text for the user. (You should use this for genuine user interaction; continue to use System.err.println(.) for debugging output.)
Parameters:
message - Text to print out

readText

public java.lang.String readText()
Once called, this method doesn't return until the user has typed in some text and hit enter.
Returns:
The text typed in

readAirport

public java.lang.String readAirport()
Once called, this method doesn't return until the user has selected an airport.
Returns:
The three-letter code of the airport selected

parsing

public void parsing()
Displays a status report for the user. You should call this only at the beginning of your program, when you are initially having the Parser parse the files.

buildingGraph

public void buildingGraph()
Displays a status report for the user. You should call this only at the beginning of your program, when you are initially building the graph.

initializingGraph

public void initializingGraph()
Displays a status report for the user. You will need to reinitialize the graph after each query, and you should call this method before you start the reinitialization.

processingQuery

public void processingQuery()
Displays a status report for the user. You should call this method before you begin the graph algorithm that will result in the answer to the user's query.

waitingForText

public void waitingForText()
Prompts the user to type something. You should call this, after printing out a question with writeText(.), when you expect some keyboard input.

waitingForAirport

public void waitingForAirport()
Prompts the user to select an airport. You should call this, after printing out a question with writeText(.), when you expect a click on an airport.

otherMessage

public void otherMessage(java.lang.String message)
You can use this to give your own status reports or your own prompts. Don't use it when one of the specialized methods above applies, though; the grading code may need the calls above. You can clear the status display by giving this method the empty string ("").
Parameters:
message - Text to be displayed temporarily

pause

public void pause(long milliseconds)
Freeze the GUI for a bit.
Parameters:
milliseconds - how long to pause (so 250 freezes for a quarter second)

exit

public void exit()
Call this just before your mainline exits. The user interface will be destroyed.