amber.awt
Class ComplexList

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--amber.awt.ComplexList
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.AdjustmentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable

public class ComplexList
extends java.awt.Panel
implements java.awt.event.AdjustmentListener, java.awt.ItemSelectable

This is the base functionality required to handle the extended requirements in a multi-item list.

Version:
1.0.0
Author:
Dr. David J. Knowles
See Also:
ApplicationHandler, ComponentHandler, Serialized Form

Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static int ArrowDown
           
static int ArrowNone
          The arrow value for the selected column.
static int ArrowUp
           
static int CENTER
          The text alignment is centred.
protected  java.util.Vector columnAlignments
           
protected  java.util.Vector columnSizes
           
protected  int headerHeight
           
protected  java.util.Vector headers
           
protected  int itemHeight
           
protected  java.util.Vector items
           
static int LEFT
          The text alignment is left justified.
protected  java.util.Vector lineType
           
protected  boolean multipleMode
           
static int RIGHT
          The text alignment is right justified.
protected  int selectedIndex
           
protected  int selectedRowIndex
           
protected  int[] selectedRows
           
protected  int startingColumn
           
protected  int startingRow
           
protected  int visibleRows
           
 
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
ComplexList()
          Default constructor.
 
Method Summary
 void add(java.util.Vector item)
          Adds a line to the end of the list.
 void add(java.util.Vector item, int type)
          Adds a line to the end of the list.
 void addActionListener(java.awt.event.ActionListener l)
           
 void addItemListener(java.awt.event.ItemListener l)
           
 void addSubItem(java.lang.Object data, int rowIndex)
          Adds a new column item to the end of the specified line in the list.
 void adjustmentValueChanged(java.awt.event.AdjustmentEvent e)
           
protected  void componentSetUp()
          This function sets up the various sub items in the control and sets their default state.
protected  void createHScrollIfRequired()
           
protected  void createVScrollIfRequired()
           
 void deselect(int index)
          Deselects the specified line.
protected  void fireActionPerformed(java.awt.event.ActionEvent e)
           
protected  void fireItemStateChanged(java.awt.event.ItemEvent e)
           
 int getItemCount()
          Returns the number of lines in the list.
 int getLineType(int index)
          Returns the type of the line in the list.
 int getSelectedColumn()
          Returns the column index of the selected column if any.
 int getSelectedColumnState()
          Returns the column state of the selected column if any.
 int getSelectedIndex()
          Returns the index of the selected line in the list.
 int[] getSelectedIndexes()
          Returns an array of the selected indexes as an array of ints.
 java.util.Vector getSelectedItem()
          Returns the line items of the selected line in the list.
 java.util.Vector[] getSelectedItems()
          Returns an array of Vectors which are the items in the selected line.
 java.lang.Object[] getSelectedObjects()
          Gets all the selected items in the list.
 void insert(java.util.Vector item, int index)
          Inserts a line at the specified location in the list.
 void insert(java.util.Vector item, int index, int type)
          Inserts a line at the specified location in the list.
 void insertSubItem(java.lang.Object data, int rowIndex, int columnIndex)
          Inserts a new column item into a specified column location of the specified line in the list.
 boolean isFocusTraversable()
          Defines whether this control can be focused.
 boolean isIndexSelected(int index)
          This function determines if the specified line is selected.
 boolean isMultipleMode()
          Returns the multi-line selection state.
 int locationToColumn(java.awt.Point listPoint)
          Returns the column index of the item at a Point.
 int locationToIndex(java.awt.Point listPoint)
          Returns the index of the item at a Point.
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void paint(java.awt.Graphics g)
          Primary painting function.
protected  void processComponentEvent(java.awt.event.ComponentEvent e)
          This handles the case where the component is resized.
protected  void processHScroll(java.awt.event.AdjustmentEvent e)
           
protected  void processKeyEvent(java.awt.event.KeyEvent e)
          This function handles the key events in the list.
protected  void processMouseEvent(java.awt.event.MouseEvent parm1)
           
protected  void processVScroll(java.awt.event.AdjustmentEvent e)
           
 void remove(int index)
          Removes a specified line in the list.
 void removeActionListener(java.awt.event.ActionListener l)
           
 void removeAll()
          Removes all the lines in the list.
 void removeItemListener(java.awt.event.ItemListener l)
           
 void removeSubItem(int rowIndex, int columnIndex)
          Removes a specified line/column item in the list.
 void replaceItem(java.util.Vector item, int index)
          Replaces the specified line in the list with the new line.
 void replaceItem(java.util.Vector item, int index, int type)
          Replaces the specified line in the list with the new line.
 void select(int index)
          Selects the specified line.
 void setColumnAlignment(int index, int alignment)
          Sets the alignment of the column text in the list.
 void setColumnAlignments(java.util.Vector alignments)
          This function is used to set the various text alignments of the columns in the list.
 void setColumnHeaders(java.util.Vector newHeaders)
          This function is used to set the various headers of the columns in the list.
 void setColumnSizes(java.util.Vector sizes)
          This function is used to set the various widths of the columns in the list.
 void setDrawHeaders(boolean on)
          This function turns the rendering of the list headers on and off.
 void setHeaderHeight(int height)
          Normally the header height is specified by the size of the font.
 void setItemHeight(int height)
          Normally the line item height is specified by the size of the font.
 void setLineType(int index, int type)
          Sets the type of the line in the list.
 void setMultipleMode(boolean mode)
          Sets the multi-line selection state.
 void setSelectedColumn(int index, int value)
          Sets the selected Column.
 void setSubItem(java.lang.Object data, int rowIndex, int columnIndex)
          Replaces a column item with a new item at a specified column location of the specified line in the list.
 void showColumn(int index)
          Shows the specified column number.
 void showLine(int index)
          Shows the specified line number.
 void update(java.awt.Graphics g)
          Overridden to remove the buffer clearing.
protected  void updateCanvas()
          Updates the entire window and adds the scroll bars if necessary.
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeContainerListener, removeNotify, setFont, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, 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, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LEFT

public static final int LEFT
The text alignment is left justified.

CENTER

public static final int CENTER
The text alignment is centred.

RIGHT

public static final int RIGHT
The text alignment is right justified.

ArrowNone

public static final int ArrowNone
The arrow value for the selected column.

ArrowDown

public static final int ArrowDown

ArrowUp

public static final int ArrowUp

items

protected java.util.Vector items

itemHeight

protected int itemHeight

headerHeight

protected int headerHeight

selectedRowIndex

protected int selectedRowIndex

headers

protected java.util.Vector headers

columnSizes

protected java.util.Vector columnSizes

columnAlignments

protected java.util.Vector columnAlignments

lineType

protected java.util.Vector lineType

selectedRows

protected int[] selectedRows

startingColumn

protected int startingColumn

startingRow

protected int startingRow

visibleRows

protected int visibleRows

multipleMode

protected boolean multipleMode

selectedIndex

protected int selectedIndex
Constructor Detail

ComplexList

public ComplexList()
Default constructor.
Method Detail

setColumnAlignments

public void setColumnAlignments(java.util.Vector alignments)
This function is used to set the various text alignments of the columns in the list.
Parameters:
sizes - Vector containing Integers with the alignments.

setColumnSizes

public void setColumnSizes(java.util.Vector sizes)
This function is used to set the various widths of the columns in the list.
Parameters:
sizes - Vector containing Integers with the widths in pixels.

setColumnHeaders

public void setColumnHeaders(java.util.Vector newHeaders)
This function is used to set the various headers of the columns in the list.
Parameters:
newHeaders - Vector containing Objects to put into the headers.

add

public void add(java.util.Vector item)
Adds a line to the end of the list.
Parameters:
item - Vector containing Objects which are to be displayed in the columns of the line.

add

public void add(java.util.Vector item,
                int type)
Adds a line to the end of the list.
Parameters:
item - Vector containing Objects which are to be displayed in the columns of the line.
type - int containing the type of line, larger values reduce the size.

insert

public void insert(java.util.Vector item,
                   int index)
Inserts a line at the specified location in the list.
Parameters:
item - Vector containing Objects which are to be displayed in the columns of the line.
index - int containing the line index to insert at.

insert

public void insert(java.util.Vector item,
                   int index,
                   int type)
Inserts a line at the specified location in the list.
Parameters:
item - Vector containing Objects which are to be displayed in the columns of the line.
type - int containing the type of line, larger values reduce the size.
index - int containing the line index to insert at.

remove

public void remove(int index)
Removes a specified line in the list.
Overrides:
remove in class java.awt.Container
Parameters:
index - int containing the line index to remove.

removeAll

public void removeAll()
Removes all the lines in the list.
Overrides:
removeAll in class java.awt.Container

replaceItem

public void replaceItem(java.util.Vector item,
                        int index)
Replaces the specified line in the list with the new line. The type of the line is kept intact.
Parameters:
item - Vector containing Objects which are to be displayed in the columns of the line.
index - int containing the line index of the line to replace.

replaceItem

public void replaceItem(java.util.Vector item,
                        int index,
                        int type)
Replaces the specified line in the list with the new line.
Parameters:
item - Vector containing Objects which are to be displayed in the columns of the line.
index - int containing the line index of the line to replace.
type - int containing the type of line, larger values reduce the size.

addSubItem

public void addSubItem(java.lang.Object data,
                       int rowIndex)
Adds a new column item to the end of the specified line in the list.
Parameters:
data - Object containing the data to add to a new column at the end of the line. If there are insufficient columns to display this item it is ignored.
rowIndex - int containing the line index of the line to add the column to.

insertSubItem

public void insertSubItem(java.lang.Object data,
                          int rowIndex,
                          int columnIndex)
Inserts a new column item into a specified column location of the specified line in the list.
Parameters:
data - Object containing the data to insert in the specified column at the specified line. If there are insufficient columns to display this item it is ignored.
rowIndex - int containing the line index of the line to insert the column into.
columnIndex - int containing the column index of the column to insert the data into.

setSubItem

public void setSubItem(java.lang.Object data,
                       int rowIndex,
                       int columnIndex)
Replaces a column item with a new item at a specified column location of the specified line in the list.
Parameters:
data - Object containing the data to replace the specified column item with.
rowIndex - int containing the line index of the line containing the column to change.
columnIndex - int containing the column index of the column to alter.

removeSubItem

public void removeSubItem(int rowIndex,
                          int columnIndex)
Removes a specified line/column item in the list.
Parameters:
rowIndex - int containing the line index of the line/column item to remove.
columnIndex - int containing the column index of the column to remove.

setDrawHeaders

public void setDrawHeaders(boolean on)
This function turns the rendering of the list headers on and off.
Parameters:
on - boolean which turns on the header rendering when true.

setItemHeight

public void setItemHeight(int height)
Normally the line item height is specified by the size of the font. This function allows the height of the lines to be specified in pixels.
Parameters:
height - int size of each line vertically. Setting the height to a negative value reverts to the font height.

setHeaderHeight

public void setHeaderHeight(int height)
Normally the header height is specified by the size of the font. This function allows the height of the header to be specified in pixels.
Parameters:
height - int size of each header vertically. The function accepts the following type of variables:
  • Positive numbers. The header height is set to this number of pixels.
  • 0. The current font height is used.
  • Negative numbers. The header height uses the current item height.

getItemCount

public int getItemCount()
Returns the number of lines in the list.
Returns:
int containing the number of lines in the list.

getLineType

public int getLineType(int index)
Returns the type of the line in the list.
Parameters:
index - int containing the line index of the line.
Returns:
int containing the type.

setLineType

public void setLineType(int index,
                        int type)
Sets the type of the line in the list.
Parameters:
index - int containing the line index of the line.
type - int containing the type.

setColumnAlignment

public void setColumnAlignment(int index,
                               int alignment)
Sets the alignment of the column text in the list.
Parameters:
index - int containing the column index.
alignment - int containing the alignment.

getSelectedIndex

public int getSelectedIndex()
Returns the index of the selected line in the list.
Returns:
int containing the selected line index -1 means no line is selected.

getSelectedColumn

public int getSelectedColumn()
Returns the column index of the selected column if any.
Returns:
int containing the selected column index -1 means no column is selected.

getSelectedColumnState

public int getSelectedColumnState()
Returns the column state of the selected column if any.
Returns:
int containing the selected column state.

getSelectedItem

public java.util.Vector getSelectedItem()
Returns the line items of the selected line in the list.
Returns:
Vector containing the selected line items. If no line is selected the function returns null.

getSelectedIndexes

public int[] getSelectedIndexes()
Returns an array of the selected indexes as an array of ints.
Returns:
int array containing the selected indexes.

getSelectedItems

public java.util.Vector[] getSelectedItems()
Returns an array of Vectors which are the items in the selected line.
Returns:
Vector array containing the selected lines.

isMultipleMode

public boolean isMultipleMode()
Returns the multi-line selection state.

setMultipleMode

public void setMultipleMode(boolean mode)
Sets the multi-line selection state.
Parameters:
mode - boolean true if multiple lines in the list can be selected at once.

getSelectedObjects

public java.lang.Object[] getSelectedObjects()
Gets all the selected items in the list.
Specified by:
getSelectedObjects in interface java.awt.ItemSelectable
Returns:
Object array containing a number of Vectors which are the selected lines.

isFocusTraversable

public boolean isFocusTraversable()
Defines whether this control can be focused.
Overrides:
isFocusTraversable in class java.awt.Component
Returns:
boolean true as this control can be focused.

setSelectedColumn

public void setSelectedColumn(int index,
                              int value)
Sets the selected Column. This has no effect on the list itself however the corresponding column header recesses.
Parameters:
index - int index of the column to select.
value - int arrow display state for the selected column.

select

public void select(int index)
Selects the specified line.
Parameters:
index - int containing the line index of the line to select. A value of -1 deselects all the items in the list.

deselect

public void deselect(int index)
Deselects the specified line.
Parameters:
index - int containing the line index of the line to deselect.

showLine

public void showLine(int index)
Shows the specified line number.
Parameters:
index - int line to display.

showColumn

public void showColumn(int index)
Shows the specified column number.
Parameters:
index - int line to display.

isIndexSelected

public boolean isIndexSelected(int index)
This function determines if the specified line is selected.
Parameters:
index - int line number to check.
Returns:
boolean true if the specified line is selected.

update

public void update(java.awt.Graphics g)
Overridden to remove the buffer clearing.
Overrides:
update in class java.awt.Container
Parameters:
g - Graphics context to update.

paint

public void paint(java.awt.Graphics g)
Primary painting function.
Overrides:
paint in class java.awt.Container
Parameters:
g - Graphics context to paint into.

locationToIndex

public int locationToIndex(java.awt.Point listPoint)
Returns the index of the item at a Point.
Parameters:
listPoint - Point containing a point in the list where 0,0 is the top left of the list.
Returns:
int containing the selected line index -1 means no line is selected.

locationToColumn

public int locationToColumn(java.awt.Point listPoint)
Returns the column index of the item at a Point.
Parameters:
listPoint - Point containing a point in the list where 0,0 is the top left of the list.
Returns:
int containing the selected column index, -1 means no column is selected.

componentSetUp

protected void componentSetUp()
                       throws java.lang.Exception
This function sets up the various sub items in the control and sets their default state.

updateCanvas

protected void updateCanvas()
Updates the entire window and adds the scroll bars if necessary.

createVScrollIfRequired

protected void createVScrollIfRequired()

createHScrollIfRequired

protected void createHScrollIfRequired()

processHScroll

protected void processHScroll(java.awt.event.AdjustmentEvent e)

processVScroll

protected void processVScroll(java.awt.event.AdjustmentEvent e)

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent parm1)
Overrides:
processMouseEvent in class java.awt.Component

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)

processKeyEvent

protected void processKeyEvent(java.awt.event.KeyEvent e)
This function handles the key events in the list. This is done primarily to handle the arrow down and up events which move up and down the list.
Overrides:
processKeyEvent in class java.awt.Component
Parameters:
e - the key event to handle.

processComponentEvent

protected void processComponentEvent(java.awt.event.ComponentEvent e)
This handles the case where the component is resized. This recomputes the sliders etc.
Overrides:
processComponentEvent in class java.awt.Component
Parameters:
e - the component event to handle.

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)

adjustmentValueChanged

public void adjustmentValueChanged(java.awt.event.AdjustmentEvent e)
Specified by:
adjustmentValueChanged in interface java.awt.event.AdjustmentListener

removeActionListener

public void removeActionListener(java.awt.event.ActionListener l)

addActionListener

public void addActionListener(java.awt.event.ActionListener l)

fireActionPerformed

protected void fireActionPerformed(java.awt.event.ActionEvent e)

removeItemListener

public void removeItemListener(java.awt.event.ItemListener l)
Specified by:
removeItemListener in interface java.awt.ItemSelectable

addItemListener

public void addItemListener(java.awt.event.ItemListener l)
Specified by:
addItemListener in interface java.awt.ItemSelectable

fireItemStateChanged

protected void fireItemStateChanged(java.awt.event.ItemEvent e)


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.