|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
ciips.animation.TablePanel
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:
where
drawingPanel = frame.getDrawingPanel();
frame
is the instance of the AlgAnimFrame
class.
TableCanvas
,
Histogram
,
Serialized FormNested 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 |
public TablePanel(int max_elem)
max_elem
- The maximum size of the table.Method Detail |
public void init(int max_size)
TableCanvas
.
max_size
- The maximum size of the table.public void draw(java.awt.Graphics g)
repaint()
method of the table panel.
draw
in interface DrawingObj
g
- A reference to the graphical context.public int getX()
getX
in interface DrawingObj
public int getY()
getY
in interface DrawingObj
public boolean full()
TableCanvas
,
which checks if the table has been fully filled up.
TableCanvas.full()
public int numOccupied()
TableCanvas
,
which gets the number of rows in the table where the contents are
non-null objects.
TableCanvas.numOccupied()
public boolean occupied(int i)
TableCanvas
,
which checks if a particular row in the table has a non-null object.
i
- The row number of the table to be checked.
TableCanvas.occupied(int)
public void drawClusters(java.awt.Graphics g, int x, int y)
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:
Adding an instance of this
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);
}
}
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)
.
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.TableCanvas.drawClusters(java.awt.Graphics, int, int)
public boolean contains(java.lang.Object obj)
TableCanvas
,
which checks if the table contains a certain object specified by
the parameter.
obj
- The object that is going to be checked for existence.
TableCanvas.contains(java.lang.Object)
public int indexOf(java.lang.Object obj)
TableCanvas
,
which gets the location of an object in the table.
obj
- The object which location is being checked.
TableCanvas.indexOf(java.lang.Object)
public void addTableEntry(java.lang.Object obj, int posn)
TableCanvas
,
which add an entry to the table and push the existing entries after
this newly added object one position down.
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.TableCanvas.addTableEntry(java.lang.Object, int)
public void scroll2posn(int posn)
posn
- The row number of the table that will be displayed.public java.lang.Object getTableEntryAt(int posn)
TableCanvas
,
which obtains the object placed at the table row specified by the
parameter.
posn
- Table row where the object is to be obtained.
TableCanvas.getTableEntryAt(int)
public void setTableEntry(java.lang.Object obj, int posn)
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.
obj
- The object to be added to the table.posn
- The row number where the object is going to be added.TableCanvas.setTableEntry(java.lang.Object, int)
public void setTableSize(int i)
TableCanvas
,
which sets the size of the table and hence rescale the scrollbar.
TableCanvas.setTableSize(int)
public int tableSize()
TableCanvas
,
which gets the maximum size of the table.
TableCanvas.tableSize()
public void highlightRow(int i)
TableCanvas
,
which highlights the table entry with the row specified by the
parameter. There can only be one row highlighted at any one time.
i
- The row to be highlighted.TableCanvas.highlightRow(int)
public void restoreRow()
TableCanvas
,
which restores any highlighted row.
TableCanvas.restoreRow()
public void setDrawingPanel(DrawingPanel dpanel)
dpanel
- The parent drawing panel which this table panel resides.public boolean handleEvent(java.awt.Event event)
event
- The event captured.public void processEvent(java.awt.AWTEvent event)
public void delay()
public void setHighlight(boolean on)
DrawingObj
setHighlight
in interface DrawingObj
public void setGrey(boolean on)
DrawingObj
setGrey
in interface DrawingObj
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |