amber.awt
Class TreeList

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--amber.awt.TreeList
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 TreeList
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 tree list.

See Also:
ApplicationHandler, ComponentHandler, BaseComponent, 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
protected  boolean defaultOpen
           
protected  java.util.Vector images
           
protected  int itemHeight
           
protected  java.util.Vector items
           
protected  int[] lineOpen
           
protected  java.util.Vector lineType
           
protected  int maxLineLength
           
protected  boolean multipleMode
           
protected  int selectedIndex
           
protected  int selectedRow
           
protected  int selectedRowIndex
           
protected  int startingOffset
           
protected  int startingRow
           
protected  java.util.Vector visibleLines
           
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
TreeList()
          Default constructor.
 
Method Summary
 void add(java.lang.String item)
          Adds a line to the end of the list.
 void add(java.lang.String item, java.awt.Image image, int type)
          Adds a line to the end of the list.
 void add(java.lang.String 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 addNotify()
          This function overrides the standard addNotify to allow this control to compute the maximum length of the lines in the control at start up.
 void adjustmentValueChanged(java.awt.event.AdjustmentEvent e)
           
protected  void createHScrollIfRequired()
           
protected  void createVScrollIfRequired()
           
 void deselect()
          Deselects the currently selected line if any.
protected  void fireActionPerformed(java.awt.event.ActionEvent e)
           
protected  void fireItemStateChanged(java.awt.event.ItemEvent e)
           
protected  void generateVisibleLines()
          This function works out which of the item lines are ever visible at this time.
 int getItemCount()
          Returns the number of lines in the list.
 int getLineType(int index)
          Returns the type of the line in the list.
 int getParentLine(int index)
          This function returns the index of the parent line for this line.
 int getSelectedIndex()
          Returns the index of the selected line in the list.
 int[] getSelectedIndexes()
           
 java.lang.String getSelectedItem()
          Returns the line items of the selected line in the list.
 java.lang.String[] getSelectedItems()
           
 java.lang.Object[] getSelectedObjects()
          Gets all the selected items in the list.
 void insert(java.lang.String item, java.awt.Image image, int index, int type)
          Inserts a line at the specified location in the list.
 void insert(java.lang.String item, int index)
          Inserts a line at the specified location in the list.
 void insert(java.lang.String item, int index, int type)
          Inserts a line at the specified location in the list.
 boolean isFocusTraversable()
           
 boolean isIndexOpen(int index)
          This function determines if the line at the specified index is a parent line which is also open (i.e.
 boolean isIndexSelected(int index)
          This function determines if the line at the specified index is selected or not.
 int locationToIndex(java.awt.Point listPoint)
          Returns the index of the item at a Point.
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void paint(java.awt.Graphics g)
          The paint function which is concerned with rendering the visible items to the Canvas.
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 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 replaceItem(java.lang.String item, java.awt.Image image, int index, int type)
          Replaces the specified line in the list with the new line.
 void replaceItem(java.lang.String item, int index)
          Replaces the specified line in the list with the new line.
 void replaceItem(java.lang.String item, int index, int type)
          Replaces the specified line in the list with the new line.
 void select(int index)
          Sets the selected line in the tree.
 void setDefaultOpen(boolean state)
          Sets the default state when a child node is added.
 void setLineType(int index, int type)
          Sets the type of the line in the list.
 void setOpenState(int index, boolean state)
          Sets the line state of a parent line open/closed depending on the state of the input argument.
 void toggleOpenState(int index)
          Toggles the line state of a parent line from open to closed and vice versa.
 void update(java.awt.Graphics g)
          Overriden update function which stops the background being drawn for no purpose.
protected  void updateCanvas()
           
 
Methods inherited from class java.awt.Panel
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, processKeyEvent, 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

itemHeight

protected int itemHeight

selectedRowIndex

protected int selectedRowIndex

selectedIndex

protected int selectedIndex

items

protected java.util.Vector items

images

protected java.util.Vector images

lineType

protected java.util.Vector lineType

visibleLines

protected java.util.Vector visibleLines

lineOpen

protected int[] lineOpen

selectedRow

protected int selectedRow

startingOffset

protected int startingOffset

startingRow

protected int startingRow

visibleRows

protected int visibleRows

multipleMode

protected boolean multipleMode

defaultOpen

protected boolean defaultOpen

maxLineLength

protected int maxLineLength
Constructor Detail

TreeList

public TreeList()
Default constructor.
Method Detail

add

public void add(java.lang.String item)
Adds a line to the end of the list.
Parameters:
item - String to be displayed at the end of the tree.

add

public void add(java.lang.String item,
                int type)
Adds a line to the end of the list.
Parameters:
item - String to be displayed at the end of the tree.
type - int containing the type of line, larger values reduce the size.

add

public void add(java.lang.String item,
                java.awt.Image image,
                int type)
Adds a line to the end of the list.
Parameters:
item - String to be displayed at the end of the tree.
image - Image to be displayed before the text.
type - int containing the type of line, larger values reduce the size.

insert

public void insert(java.lang.String item,
                   int index)
Inserts a line at the specified location in the list.
Parameters:
item - String to be displayed at the specified location.
index - int containing the line index to insert at.

insert

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

insert

public void insert(java.lang.String item,
                   java.awt.Image image,
                   int index,
                   int type)
Inserts a line at the specified location in the list.
Parameters:
item - String to be displayed at the specified location.
image - Image to be displayed at the specified location in front of the text.
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.lang.String item,
                        int index)
Replaces the specified line in the list with the new line. The type of the line is kept intact.
Parameters:
item - New String to be displayed at the specified location.
index - int containing the line index of the line to replace.

replaceItem

public void replaceItem(java.lang.String item,
                        int index,
                        int type)
Replaces the specified line in the list with the new line.
Parameters:
item - New String to be displayed at the specified location.
index - int containing the line index of the line to replace.
type - int containing the type of line, larger values reduce the size.

replaceItem

public void replaceItem(java.lang.String item,
                        java.awt.Image image,
                        int index,
                        int type)
Replaces the specified line in the list with the new line.
Parameters:
item - New String to be displayed at the specified location.
image - New Image to be displayed at the specified location before the text.
index - int containing the line index of the line to replace.
type - int containing the type of line, larger values reduce the size.

setDefaultOpen

public void setDefaultOpen(boolean state)
Sets the default state when a child node is added. If the state is true then the parent node opens to display the child node.
Parameters:
state - boolean state to set the default open to.

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.

getParentLine

public int getParentLine(int index)
This function returns the index of the parent line for this line.
Parameters:
index - int index of the line to find the parent of.
Returns:
int index of the parent line or -1 if there is no such thing.

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.
int - containing the type.

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.

getSelectedItem

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

getSelectedIndexes

public int[] getSelectedIndexes()

getSelectedItems

public java.lang.String[] getSelectedItems()

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 Strings which are the selected lines.

updateCanvas

protected void updateCanvas()

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)

adjustmentValueChanged

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

select

public void select(int index)
Sets the selected line in the tree.
Parameters:
index - int line number to select.

toggleOpenState

public void toggleOpenState(int index)
Toggles the line state of a parent line from open to closed and vice versa.
Parameters:
index - int line number to open.

setOpenState

public void setOpenState(int index,
                         boolean state)
Sets the line state of a parent line open/closed depending on the state of the input argument.
Parameters:
index - int line number to open.
state - boolean which sets the line to open when true.

deselect

public void deselect()
Deselects the currently selected line if any.

isIndexSelected

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

isIndexOpen

public boolean isIndexOpen(int index)
This function determines if the line at the specified index is a parent line which is also open (i.e. the child lines are visible).
Parameters:
index - int index of the line to check.
Returns:
boolean true if the line is an open parent.

update

public void update(java.awt.Graphics g)
Overriden update function which stops the background being drawn for no purpose.
Overrides:
update in class java.awt.Container
Parameters:
g - Graphics context to draw on.

addNotify

public void addNotify()
This function overrides the standard addNotify to allow this control to compute the maximum length of the lines in the control at start up.
Overrides:
addNotify in class java.awt.Panel

paint

public void paint(java.awt.Graphics g)
The paint function which is concerned with rendering the visible items to the Canvas.
Overrides:
paint in class java.awt.Container
Parameters:
g - Graphics object to draw on.

generateVisibleLines

protected void generateVisibleLines()
This function works out which of the item lines are ever visible at this time. This array is used when rendering the items to the Canvas

processMouseEvent

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

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.

mousePressed

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

mouseReleased

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

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)

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.

isFocusTraversable

public boolean isFocusTraversable()
Overrides:
isFocusTraversable in class java.awt.Component


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.