feud.testgame.gui
Class Table

java.lang.Object
  extended byfeud.testgame.gui.GUIComponent
      extended byfeud.testgame.gui.Table
Direct Known Subclasses:
Highscores

public class Table
extends GUIComponent

A simple table component with no borders, no resizing, no nothing...just data organized in rows and columns.


Field Summary
 
Fields inherited from class feud.testgame.gui.GUIComponent
visible
 
Constructor Summary
Table(java.lang.String name, int rows, int cols, int xs, int ys, int xe, int ye)
          Create a new table.
 
Method Summary
 void clear()
          Clears the table.
 void draw(com.threed.jpct.FrameBuffer buffer)
          Draws this component and all of its childs.
 boolean evaluateInput(MouseMapper mouse, com.threed.jpct.util.KeyMapper keyMapper)
          Processes key and mouse events in the context of this component.
 java.lang.Object getCell(int row, int col)
          Gets the content object of a cell.
 void insertCell(int row, int col, java.lang.Object content)
          Inserts a cell by inserting a row at the given position.
 void setCell(int row, int col, java.lang.Object content)
          Sets the content object of a cell.
 void setColumnSize(int col, int size)
          Sets the width of a column.
 void setListener(GUIListener bl)
          Sets a listener that will be informed of clicks into a cell.
 void setRowSize(int row, int size)
          Sets the height of a row.
 
Methods inherited from class feud.testgame.gui.GUIComponent
add, getParent, getParentX, getParentY, getX, getY, isVisible, setVisible, setX, setY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Table

public Table(java.lang.String name,
             int rows,
             int cols,
             int xs,
             int ys,
             int xe,
             int ye)
Create a new table. The rows and columns will be sized according to the size of the actual table.

Parameters:
name - the name of the table (not displayed)
rows - the number of rows
cols - the number of columns
xs - x-value of the upper left corner
ys - y-value of the upper left corner
xe - x-value of the lower right corner
ye - y-value of the lower right corner
Method Detail

setCell

public void setCell(int row,
                    int col,
                    java.lang.Object content)
Sets the content object of a cell. The object's value will be displayed using its toString()-method.

Parameters:
row - the row of the cell
col - the column of the cell
content - the cell's content

getCell

public java.lang.Object getCell(int row,
                                int col)
Gets the content object of a cell.

Parameters:
row - the row of the cell
col - the column of the cell
Returns:
Object the cell's content

insertCell

public void insertCell(int row,
                       int col,
                       java.lang.Object content)
Inserts a cell by inserting a row at the given position.

Parameters:
row - the row of the cell
col - the column of the cell
content - the new cell's content

setRowSize

public void setRowSize(int row,
                       int size)
Sets the height of a row.

Parameters:
row - the row
size - the new height

setColumnSize

public void setColumnSize(int col,
                          int size)
Sets the width of a column.

Parameters:
col - the column
size - the new width

clear

public void clear()
Clears the table. Rows and columns will remain but the data will be cleared.


setListener

public void setListener(GUIListener bl)
Sets a listener that will be informed of clicks into a cell.

Parameters:
bl - the GUIListener

evaluateInput

public boolean evaluateInput(MouseMapper mouse,
                             com.threed.jpct.util.KeyMapper keyMapper)
Description copied from class: GUIComponent
Processes key and mouse events in the context of this component. It then continues processing on the child components until the event got comsumed by one or the last child has been processed.

Overrides:
evaluateInput in class GUIComponent
Parameters:
mouse - the MouseMapper used to process mouse events
keyMapper - the KeyMapper used to process key events
Returns:
boolean true, if an event occured in the context of this component or one of its child components.

draw

public void draw(com.threed.jpct.FrameBuffer buffer)
Description copied from class: GUIComponent
Draws this component and all of its childs. Drawing in this "toolkit" is limited to label and text rendering. Rendering the actual component isn't done by this toolkit, but can be added easily.

Overrides:
draw in class GUIComponent
Parameters:
buffer - the FrameBuffer on which to draw to