|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cs2110.assignment3.ComparisonGUI
public class ComparisonGUI
Base class for implementing the species comparison GUI.
You will subclass ComparisonGUI to make your comparison GUI.
The GUI consists of a table with a picture of each species, and two larger pictures that are intended to show the currently selected species and its closest relative, as computed by your species distance algorithm.
When the user clicks on a cell in the table, the method onSelectCell is called. Your subclass should override onSelectCell to exhibit the behavior described in the assignment.
You will refer to cells by their number, 0 through n-1, where n is the number of species given to the ComparisonGUI's constructor.
Read the documentation for each method to learn what you can do with this class.
Constructor Summary | |
---|---|
ComparisonGUI(int n)
The constructor takes a single argument: the number of species you plan on placing in the GUI's comparison table. |
Method Summary | |
---|---|
int |
getColumns()
Get the number of columns in the species table |
javax.swing.JPanel |
getComparisonPanel()
Optional: For extending the user interface. |
javax.swing.JFrame |
getFrame()
Optional: For extending the user interface. |
javax.swing.JPanel |
getGridPanel()
Optional: For extending the user interface. |
int |
getRows()
Get the number of rows in the species table |
void |
onSelectCell(int cell)
This method will be called when the user clicks a cell in the table. |
void |
run()
|
void |
setCellColor(int cell,
java.awt.Color color)
Sets the background color of a cell, specified as an instance of java.awt.Color |
void |
setCellColor(int cell,
double red,
double green,
double blue)
Sets the background color of a cell. |
void |
setCellImage(int cell,
java.lang.String filename)
Load an image into the desired cell. |
void |
setClosestRelativeInfo(java.lang.String name,
java.lang.String imageFile)
Set the name and image file of the current most closely related species. |
void |
setSelectedInfo(java.lang.String name,
java.lang.String imageFile)
Set the name and image file of the currently selected species. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ComparisonGUI(int n)
After constructing an instance of ComparisonGUI, you should call setCellImage for each cell (numbered 0 through n-1) to place images in the cells.
n
- Number of speciesMethod Detail |
---|
public javax.swing.JFrame getFrame()
public javax.swing.JPanel getComparisonPanel()
public javax.swing.JPanel getGridPanel()
public int getColumns()
public int getRows()
public void onSelectCell(int cell)
cell
- public void setCellImage(int cell, java.lang.String filename) throws InvalidCellNumberException
cell
- Cell numberfilename
- Path to the image file
InvalidCellNumberException
public void setCellColor(int cell, double red, double green, double blue) throws InvalidColorException, InvalidCellNumberException
cell
- Cell numberred
- Red component. Must be between 0 and 1.green
- Green component. Must be between 0 and 1.blue
- Blue component. Must be between 0 and 1.
InvalidColorException
InvalidCellNumberException
public void setCellColor(int cell, java.awt.Color color) throws InvalidCellNumberException
cell
- Cell numbercolor
- Desired background color
InvalidCellNumberException
public void setSelectedInfo(java.lang.String name, java.lang.String imageFile)
name
- Species nameimageFile
- Image file pathpublic void setClosestRelativeInfo(java.lang.String name, java.lang.String imageFile)
name
- Species nameimageFile
- Image file pathpublic void run()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |