ciips.animation
Class TableCanvas

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended byciips.animation.TableCanvas
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class TableCanvas
extends java.awt.Panel

This class creates a panel to display a table. It is only called from the TablePanel class which adds a scrollbar to the east of the table canvas.

This TableCanvas class should not have to be used manually. All its methods are redirected from the TablePanel class.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TableCanvas(TablePanel parent)
          Constructor method of the TableCanvas class.
 
Method Summary
 void addTableEntry(java.lang.Object obj, int posn)
          Add an entry to the table and push the existing entries after this newly added object one position down.
 boolean contains(java.lang.Object obj)
          Check if the table contains a certain object specified by the parameter.
 void drawBox(java.awt.Graphics g, int x, int y, java.lang.String str, java.awt.Color fg, java.awt.Color bg, int max_length)
          This method is only called by the paint() method to draw each entry of the table as a box.
 void drawClusters(java.awt.Graphics g, int x, int y)
          Display a status summary of the table regarding the percentage of the table being occupied, the number of clusters in the table, and a rough idea of the location of the table being occupied.
 boolean full()
          Check if the table has been fully filled up.
 java.lang.Object getTableEntryAt(int posn)
          Obtain the object placed at the table row specified by the parameter.
 void highlightRow(int i)
          Highlight the table entry with the row specified by the parameter.
 int indexOf(java.lang.Object obj)
          Get the location of an object in the table.
 void init()
          Initialize the table and set all entries to null.
 int numOccupied()
          Get the number of rows in the table where the contents are non-null object.
 boolean occupied(int i)
          Check if a particular row in the table has a non-null object.
 void paint(java.awt.Graphics g)
          Method to draw the table canvas.
 java.awt.Dimension preferredSize()
          Define the default size of the table.
 void restoreRow()
          This method is used to restore any highlighted row.
 void setStart(int start)
          Set the starting row, which will be displayed by the table.
 void setTableEntry(java.lang.Object obj, int posn)
          Set the object specified by the first parameter to the table row defined by the second parameter.
 void setTableSize(int size)
          This method is called to set the size of the table and hence rescale the scrollbar on the panel it resides in.
 int tableSize()
          Get the maximum size of the table (including all null and non-null objects).
 void update(java.awt.Graphics g)
          This method is invoked by the display manager when the repaint() method of the panel is called.
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TableCanvas

public TableCanvas(TablePanel parent)
Constructor method of the TableCanvas class.

Parameters:
parent - The panel with a scrollbar where this table canvas is going to reside.
Method Detail

init

public void init()
Initialize the table and set all entries to null.


setStart

public void setStart(int start)
Set the starting row, which will be displayed by the table.

Parameters:
start - The first row to be shown at any one time.

highlightRow

public void highlightRow(int i)
Highlight the table entry with the row specified by the parameter. There can only be one row highlighted at any one time. If a row has already been highlighted and this highlightRow method is called on another different row, the previously highlighted row will be restored and the new row will be highlighted.

Parameters:
i - The row to be highlighted.

restoreRow

public void restoreRow()
This method is used to restore any highlighted row.


setTableSize

public void setTableSize(int size)
This method is called to set the size of the table and hence rescale the scrollbar on the panel it resides in.

Parameters:
size - The new size of this table.

setTableEntry

public void setTableEntry(java.lang.Object obj,
                          int posn)
Set the object specified by the first parameter to the table row defined by the second parameter.

Parameters:
obj - The object to be added to the table.
posn - The row number where the object is going to be added.

getTableEntryAt

public java.lang.Object getTableEntryAt(int posn)
Obtain the object placed at the table row specified by the parameter.

Parameters:
posn - Table row where the object is to be obtained.
Returns:
The table object at the row specified by the parameter.

full

public boolean full()
Check if the table has been fully filled up.

Returns:
TRUE if all entries in the table is non-null object; FALSE otherwise.

numOccupied

public int numOccupied()
Get the number of rows in the table where the contents are non-null object.

Returns:
The number of non-null object in the table.

occupied

public boolean occupied(int i)
Check if a particular row in the table has a non-null object.

Parameters:
i - The row number of the table to be checked.
Returns:
TRUE if the row specified by the parameter is occupied.

drawClusters

public void drawClusters(java.awt.Graphics g,
                         int x,
                         int y)
Display a status summary of the table regarding the percentage of the table being occupied, the number of clusters in the table, and a rough idea of the location of the table being occupied.

Parameters:
g - Graphical context of the drawing panel where the status information is going to be shown.
x - The left most position of the status information display.
y - The top most position of the status information display.

addTableEntry

public void addTableEntry(java.lang.Object obj,
                          int posn)
Add an entry to the table and push the existing entries after this newly added object one position down.

Parameters:
obj - The new object to be added to the table.
posn - The position in the table (row) where the new object is to be added.

tableSize

public int tableSize()
Get the maximum size of the table (including all null and non-null objects).

Returns:
The maximum size of the table.

contains

public boolean contains(java.lang.Object obj)
Check if the table contains a certain object specified by the parameter.

Parameters:
obj - The object which is going to be checked for existence.
Returns:
TRUE if the object exists; FALSE otherwise.

indexOf

public int indexOf(java.lang.Object obj)
Get the location of an object in the table.

Parameters:
obj - The object which location is being checked.
Returns:
The row number of the object passed in as the parameter. This method will return -1 if the object does not exist within the current table.

preferredSize

public java.awt.Dimension preferredSize()
Define the default size of the table.

Returns:
The dimension of the table. By default is: 480x320.

update

public void update(java.awt.Graphics g)
This method is invoked by the display manager when the repaint() method of the panel is called. This method is overridden here to eliminate the flashing characteristic during the panel update.


paint

public void paint(java.awt.Graphics g)
Method to draw the table canvas.


drawBox

public void drawBox(java.awt.Graphics g,
                    int x,
                    int y,
                    java.lang.String str,
                    java.awt.Color fg,
                    java.awt.Color bg,
                    int max_length)
This method is only called by the paint() method to draw each entry of the table as a box.

Parameters:
g - Graphical context.
x - The left most position of the box.
y - The top most position of the box.
str - The String object to be drawn inside the box.
fg - Foreground color (i.e. the text color) of the box.
bg - Background color of the box.
max_length - The max_length of the string to be displayed in the box.