All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class GraphicPlotter.LegendPane

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----GraphicPlotter.LegendPane

public final class LegendPane
extends Container
implements KeyListener, AdjustmentListener
A container designed to hold lightweight components used as legend objects of a visualization.

The size of this container is restricted to a percentage of the width and height of either 1) the outermost container or 2) the innermost Applet that this object is contained in. In either case, the size of the limiting container is externally controlled, by the native windowing system or the applet viewer. When the size of this container is not large enough to show all the components, a vertical scrollbar is added to allow scrolling.

This class contains two components: a container that holds the acutal components and a scrollbar. The container that holds the acutal components is retruned by the getBody() method. For convenience, this class implements some container methods that forward the method to the body container. For example, the implementation of the add method of this class is essentially

    public Container add(Component comp) {
       return getBody().add(comp);
    }
 

The default layout manager used for the body is FlowLayout(FlowLayout.LEFT).

This container implements the KeyListener interface to adjust the scrollbar position in response to Page Up, Page Down, Cursor Up, and Cursor Down key events. Each instance of this class automatically makes itself a KeyListener of itself. However, it is up to each program that uses this class to have key events dispatched to it. There are two concerns.

  1. Each instance of this class should have the keyboard focus when appropriate. It is up to the program that uses an instance of this class to give it the keyboard focus. For example, a program may establish a mouseListener for an instance of this class and have the mouseEntered() method of the listener invoke the requestFocus() on the instance of this class.
  2. Each component contained in an instance of this class that responds to key events should forward to its parent container key events that the component is not interested in. One way to do this it to have each component contained in an instance of this class override the processKeyEvent method to do the following.

        public void processKeyEvent(KeyEvent e) {
           super.processKeyEvent(e);
           if (!e.isConsumed()) {
              Container parent = getParent();
              if (parent instanceof KeyEventProcessor) {
                 ((KeyEventProcessor)parent).processKeyEvent(e);
              }
           }
       }
     


    Variable Index

     o HORIZONTAL_DEFAULT
    The default limit on the width of this container as a percentage of the width of the limiting container.
     o PERCENT_MAX
    The maximum percent value allowed.
     o PERCENT_MIN
    The minimum percent value allowed.
     o VERTICAL_DEFAULT
    The default limit on the height of this container as a percentage of the height of the limiting container.

    Constructor Index

     o LegendPane()
    Construct a LegendPane where the width and height are at most the default percent of the width and height of the outermost container.
     o LegendPane(int, int)
    Construct a LegendPane where the width and height are at most the given percent of the width and height of the innermost heavyweight container.

    Method Index

     o add(Component)
    Have add forwarded request to the body container.
     o adjustmentValueChanged(AdjustmentEvent)
    Implement the AdjustmentListener interface.
     o doLayout()
    Override doLayout() to add a horizontal scrollbar when necessary.
     o getBlockIncrementPercent()
    Return the percent of the height of this container scrolled by a block increment.
     o getBody()
    Return the body container.
     o getHorizontalPercentLimit()
    Return the horizontal percent limit.
     o getMinimumSize()
    Override getMinimumSize to return the preferred size.
     o getPreferredSize()
    Override getPreferredSize() to return a size limited to percentages of the available width and height of the limiting enclosing container (innermost Applet or outermost Container)
     o getUnitIncrement()
    Return the number of pixels scrolled by a unit increment.
     o getVerticalPercentLimit()
    Return the vertical percent limit.
     o keyPressed(KeyEvent)
    Implement KeyListener.keyPressed.
     o keyReleased(KeyEvent)
    Implement KeyListener.keyReleased.
     o keyTyped(KeyEvent)
    Implement KeyListener.keyTyped.
     o processKeyEvent(KeyEvent)
    Override processKeyEvent to make it visible to inner Body class.
     o remove(Component)
    Have remove forwarded request to the body containter.
     o removeAll()
    Have removeAll request forwarded to the body container.
     o repaint(long, int, int, int, int)
    Override repaint for implementation reasons.
     o setBlockIncrementPrecent(int)
    Set the percent of the height of this container scrolled by a block increment.
     o setHorizontalPercentLimit(int)
    Set the horizontal percent limit.
     o setUnitIncrement(int)
    Set the number of pixels scrolled by a unit increment.
     o setVerticalPercentLimit(int)
    Set the veritcal percent limit.
     o update(Graphics)
    Override update for implementation reasons.

    Variables

     o HORIZONTAL_DEFAULT
     public static final int HORIZONTAL_DEFAULT
    
    The default limit on the width of this container as a percentage of the width of the limiting container.

     o VERTICAL_DEFAULT
     public static final int VERTICAL_DEFAULT
    
    The default limit on the height of this container as a percentage of the height of the limiting container.

     o PERCENT_MIN
     public static final int PERCENT_MIN
    
    The minimum percent value allowed.

     o PERCENT_MAX
     public static final int PERCENT_MAX
    
    The maximum percent value allowed.

    Constructors

     o LegendPane
     public LegendPane(int horzPercent,
                       int vertPercent)
    
    Construct a LegendPane where the width and height are at most the given percent of the width and height of the innermost heavyweight container. The percentages are rounded to the allowable range of values.

    Parameters:
    horzPercent - the maximum percent width
    vertPercent - the maximum percent height
     o LegendPane
     public LegendPane()
    
    Construct a LegendPane where the width and height are at most the default percent of the width and height of the outermost container.

    Methods

     o getBody
     public final Container getBody()
    
    Return the body container.

     o getBlockIncrementPercent
     public int getBlockIncrementPercent()
    
    Return the percent of the height of this container scrolled by a block increment.

     o setBlockIncrementPrecent
     public void setBlockIncrementPrecent(int percent)
    
    Set the percent of the height of this container scrolled by a block increment. A percent argument value less than 1 treated as if it were 1; a percent argument value greater than 100 is treated as if it were 100.

    Parameters:
    precent - the percent to use
     o getUnitIncrement
     public int getUnitIncrement()
    
    Return the number of pixels scrolled by a unit increment.

     o setUnitIncrement
     public void setUnitIncrement(int crement)
    
    Set the number of pixels scrolled by a unit increment.

    Parameters:
    crement - the amount to increment or decrement the scrollbar's value
     o add
     public Component add(Component comp)
    
    Have add forwarded request to the body container.

    Overrides:
    add in class Container
     o remove
     public void remove(Component comp)
    
    Have remove forwarded request to the body containter.

    Overrides:
    remove in class Container
     o removeAll
     public void removeAll()
    
    Have removeAll request forwarded to the body container.

    Overrides:
    removeAll in class Container
     o getHorizontalPercentLimit
     public int getHorizontalPercentLimit()
    
    Return the horizontal percent limit.

     o setHorizontalPercentLimit
     public void setHorizontalPercentLimit(int horzPercent)
    
    Set the horizontal percent limit.

    Parameters:
    horzPercent - the maximum percent width
     o getVerticalPercentLimit
     public int getVerticalPercentLimit()
    
    Return the vertical percent limit.

     o setVerticalPercentLimit
     public void setVerticalPercentLimit(int vertPercent)
    
    Set the veritcal percent limit.

    Parameters:
    vertPercent - the maximum percent width
     o doLayout
     public void doLayout()
    
    Override doLayout() to add a horizontal scrollbar when necessary.

    Overrides:
    doLayout in class Container
     o getMinimumSize
     public Dimension getMinimumSize()
    
    Override getMinimumSize to return the preferred size.

    Overrides:
    getMinimumSize in class Container
     o getPreferredSize
     public synchronized Dimension getPreferredSize()
    
    Override getPreferredSize() to return a size limited to percentages of the available width and height of the limiting enclosing container (innermost Applet or outermost Container)

    Overrides:
    getPreferredSize in class Container
     o processKeyEvent
     protected void processKeyEvent(KeyEvent e)
    
    Override processKeyEvent to make it visible to inner Body class.

    Overrides:
    processKeyEvent in class Component
     o repaint
     public void repaint(long tm,
                         int x,
                         int y,
                         int width,
                         int height)
    
    Override repaint for implementation reasons.

    Overrides:
    repaint in class Component
     o update
     public void update(Graphics g)
    
    Override update for implementation reasons.

    Overrides:
    update in class Container
     o adjustmentValueChanged
     public void adjustmentValueChanged(AdjustmentEvent e)
    
    Implement the AdjustmentListener interface.

     o keyPressed
     public void keyPressed(KeyEvent e)
    
    Implement KeyListener.keyPressed.

     o keyReleased
     public void keyReleased(KeyEvent e)
    
    Implement KeyListener.keyReleased.

     o keyTyped
     public void keyTyped(KeyEvent e)
    
    Implement KeyListener.keyTyped.


    All Packages  Class Hierarchy  This Package  Previous  Next  Index