ciips.animation
Class TablePanel

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

public class TablePanel
extends java.awt.Panel
implements DrawingObj

This class creates a panel with a table canvas and a vertical scrollbar to the east of the canvas. Most of its methods are simply directing the method calls to the table canvas (instance of class TableCanvas) with methods of the same name (polymorphism).

Since this class is of type java.awt.Panel and the drawing panel is also of the same type, the layout manager of the drawing panel (DrawingPanel) has to be disabled prior to adding this table panel.

The way of adding the table panel to a drawing panel is similar to adding a histogram (they are of similar nature - both inheriting from java.awt.Panel).

The following line of codes can be used as an example to add a table panel to a drawing panel:

	TablePanel table = new TablePanel(max_table_size);
	drawingPanel.setLayout(null);
	drawingPanel.add(table);
	table.setDrawingPanel(drawingPanel);
	table.reshape(x, y, width, height);
 
drawingPanel is an instance of class DrawingPanel which is normally obtained by calling the getDrawingPanel() method from an instance of the AlgAnimFrame class:
 	drawingPanel = frame.getDrawingPanel();
 
where frame is the instance of the AlgAnimFrame class.

See Also:
TableCanvas, Histogram, 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
TablePanel(int max_elem)
          Create a panel with a table canvas and a scrollbar to the east of the table canvas.
 
Method Summary
 void addTableEntry(java.lang.Object obj, int posn)
          Pass the method call to the corresponding TableCanvas, which 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)
          Pass the method call to the corresponding TableCanvas, which checks if the table contains a certain object specified by the parameter.
 void delay()
          This method causes a delay of 200msec.
 void draw(java.awt.Graphics g)
          Simply call the repaint() method of the table panel.
 void drawClusters(java.awt.Graphics g, int x, int y)
          Pass the method call to the corresponding TableCanvas.
 boolean full()
          Pass the method call to the corresponding TableCanvas, which checks if the table has been fully filled up.
 java.lang.Object getTableEntryAt(int posn)
          Pass the method call to the corresponding TableCanvas, which obtains the object placed at the table row specified by the parameter.
 int getX()
          Get the left most position of the table panel.
 int getY()
          Get the top most position of the table panel.
 boolean handleEvent(java.awt.Event event)
          The main purpose of this method is to handle the scrollbar event.
 void highlightRow(int i)
          Pass the method call to the corresponding TableCanvas, which highlights the table entry with the row specified by the parameter.
 int indexOf(java.lang.Object obj)
          Pass the method call to the corresponding TableCanvas, which gets the location of an object in the table.
 void init(int max_size)
          Set the size of the table and rescale the scrollbar governing the table.
 int numOccupied()
          Pass the method call to the corresponding TableCanvas, which gets the number of rows in the table where the contents are non-null objects.
 boolean occupied(int i)
          Pass the method call to the corresponding TableCanvas, which checks if a particular row in the table has a non-null object.
 void processEvent(java.awt.AWTEvent event)
           
 void restoreRow()
          Pass the method call to the corresponding TableCanvas, which restores any highlighted row.
 void scroll2posn(int posn)
          Scroll the display window of the table to shown the row specified by the parameter.
 void setDrawingPanel(DrawingPanel dpanel)
          Set the parent panel where this table panel is going to reside.
 void setGrey(boolean on)
          Set the grey attribute
 void setHighlight(boolean on)
          Set the highlight attribute
 void setTableEntry(java.lang.Object obj, int posn)
          Pass the method call to the corresponding TableCanvas, which sets the object specified by the first parameter to the table row defined by the second parameter.
 void setTableSize(int i)
          Pass the method call to the corresponding TableCanvas, which sets the size of the table and hence rescale the scrollbar.
 int tableSize()
          Pass the method call to the corresponding TableCanvas, which gets the maximum size of the table.
 
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, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, 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, gotFocus, 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
 
Methods inherited from interface ciips.animation.DrawingObj
move
 

Constructor Detail

TablePanel

public TablePanel(int max_elem)
Create a panel with a table canvas and a scrollbar to the east of the table canvas. The maximum size of the table is initialized according to the parameter of this constructor.

Parameters:
max_elem - The maximum size of the table.
Method Detail

init

public void init(int max_size)
Set the size of the table and rescale the scrollbar governing the table. This method calls the method with the same name in TableCanvas.

Parameters:
max_size - The maximum size of the table.

draw

public void draw(java.awt.Graphics g)
Simply call the repaint() method of the table panel.

Specified by:
draw in interface DrawingObj
Parameters:
g - A reference to the graphical context.

getX

public int getX()
Get the left most position of the table panel.

Specified by:
getX in interface DrawingObj
Returns:
The left most position of the table panel.

getY

public int getY()
Get the top most position of the table panel.

Specified by:
getY in interface DrawingObj
Returns:
The top most position of the table panel.

full

public boolean full()
Pass the method call to the corresponding TableCanvas, which checks if the table has been fully filled up.

Returns:
TRUE if all entries in the corresponding table canvas is non-null object; FALSE otherwise.
See Also:
TableCanvas.full()

numOccupied

public int numOccupied()
Pass the method call to the corresponding TableCanvas, which gets the number of rows in the table where the contents are non-null objects.

Returns:
The number of non-null object in the table.
See Also:
TableCanvas.numOccupied()

occupied

public boolean occupied(int i)
Pass the method call to the corresponding TableCanvas, which checks 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.
See Also:
TableCanvas.occupied(int)

drawClusters

public void drawClusters(java.awt.Graphics g,
                         int x,
                         int y)
Pass the method call to the corresponding TableCanvas. 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.

This method should be called from the draw method of one of the drawing object, which has been added to the drawing panel. For example, if an object class Eg has been defined to implement the DrawingObj interface, such that:

  class Eg implements DrawingObj {
      TablePanel table;
      ....

      public Eg(TablePanel table, ... ) {
          ....
          this.table = table;
      }

      ....

      public void draw(Graphics g) {
          ....
          if (table != null)
              table.drawClusters(g, x, y);
      }
  }
 
Adding an instance of this Eg class into the drawing panel (by using addDrawingObj) should result in drawing of the table status summary in the drawing panel with its top left corner at position (x, y).

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.
See Also:
TableCanvas.drawClusters(java.awt.Graphics, int, int)

contains

public boolean contains(java.lang.Object obj)
Pass the method call to the corresponding TableCanvas, which checks if the table contains a certain object specified by the parameter.

Parameters:
obj - The object that is going to be checked for existence.
Returns:
TRUE if the object exists; FALSE otherwise.
See Also:
TableCanvas.contains(java.lang.Object)

indexOf

public int indexOf(java.lang.Object obj)
Pass the method call to the corresponding TableCanvas, which gets 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 a -1 if the object does not exist.
See Also:
TableCanvas.indexOf(java.lang.Object)

addTableEntry

public void addTableEntry(java.lang.Object obj,
                          int posn)
Pass the method call to the corresponding TableCanvas, which 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.
See Also:
TableCanvas.addTableEntry(java.lang.Object, int)

scroll2posn

public void scroll2posn(int posn)
Scroll the display window of the table to shown the row specified by the parameter. If the parameter indicates a row that has already been in the current view window, nothing will happen.

Parameters:
posn - The row number of the table that will be displayed.

getTableEntryAt

public java.lang.Object getTableEntryAt(int posn)
Pass the method call to the corresponding TableCanvas, which obtains 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.
See Also:
TableCanvas.getTableEntryAt(int)

setTableEntry

public void setTableEntry(java.lang.Object obj,
                          int posn)
Pass the method call to the corresponding TableCanvas, which sets the object specified by the first parameter to the table row defined by the second parameter. The display window will scroll to include the row that has been newly added.

Parameters:
obj - The object to be added to the table.
posn - The row number where the object is going to be added.
See Also:
TableCanvas.setTableEntry(java.lang.Object, int)

setTableSize

public void setTableSize(int i)
Pass the method call to the corresponding TableCanvas, which sets the size of the table and hence rescale the scrollbar.

See Also:
TableCanvas.setTableSize(int)

tableSize

public int tableSize()
Pass the method call to the corresponding TableCanvas, which gets the maximum size of the table.

Returns:
The maximum size of the table.
See Also:
TableCanvas.tableSize()

highlightRow

public void highlightRow(int i)
Pass the method call to the corresponding TableCanvas, which highlights the table entry with the row specified by the parameter. There can only be one row highlighted at any one time.

Parameters:
i - The row to be highlighted.
See Also:
TableCanvas.highlightRow(int)

restoreRow

public void restoreRow()
Pass the method call to the corresponding TableCanvas, which restores any highlighted row.

See Also:
TableCanvas.restoreRow()

setDrawingPanel

public void setDrawingPanel(DrawingPanel dpanel)
Set the parent panel where this table panel is going to reside.

Parameters:
dpanel - The parent drawing panel which this table panel resides.

handleEvent

public boolean handleEvent(java.awt.Event event)
The main purpose of this method is to handle the scrollbar event. The position of the scrollbar is obtained and used to position the view window of the table canvas.

Parameters:
event - The event captured.

processEvent

public void processEvent(java.awt.AWTEvent event)

delay

public void delay()
This method causes a delay of 200msec.


setHighlight

public void setHighlight(boolean on)
Description copied from interface: DrawingObj
Set the highlight attribute

Specified by:
setHighlight in interface DrawingObj

setGrey

public void setGrey(boolean on)
Description copied from interface: DrawingObj
Set the grey attribute

Specified by:
setGrey in interface DrawingObj