All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class COM.ibm.beans.charting.BarChartView

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----COM.ibm.desktop.ModelView
                                   |
                                   +----COM.ibm.beans.charting.ChartView
                                           |
                                           +----COM.ibm.beans.charting.BarChartView

public abstract class BarChartView
extends ChartView
implements MouseListener, MouseMotionListener
BarChartView is an abstract class, that implements a bar chart representation of the data in ChartModel, and responds to mouse events to allow alteration of the data, whenever a bar is dragged to a new length. Subclasses must override, and provide implementations of all the paint methods and the mouse event handling, for specific types of BarCharts.


Variable Index

 o fBarCorners
List of points representing data values - they are stored and used for drawing and hit detection
 o fBarDividerWidth
Size of space between each bar in the graph
 o fBarWidth
Width of each bar representing a data value - calculated from size of graph
 o fSelectedBar
Index of bar selected with a MouseDown event

Constructor Index

 o BarChartView()
Default constructor.

Method Index

 o calculateBars()
Calculates the location of the bars representing each data value.
 o handleModelChange(ModelChangeEvent)
Handles model changes by repainting.
 o initialize()
Initializes the view, and registers itself as a MouseListener and a MouseMotionListener, so as to catch mouse drag events, and update the chart accordingly.
 o mouseClicked(MouseEvent)
Called if the mouse is clicked.
 o mouseDragged(MouseEvent)
Called if the mouse is dragged (the mouse button is down).
 o mouseEntered(MouseEvent)
Called if the mouse enters this chart.
 o mouseExited(MouseEvent)
Called if the mouse leaves this chart.No action is taken.
 o mouseMoved(MouseEvent)
Called when the mouse moves over this chart.
 o mousePressed(MouseEvent)
Called if the mouse is down.
 o mouseReleased(MouseEvent)
Called if the mouse is up.
 o paint(Graphics)
Paints the entire Bar Chart by painting the bars, the values and labels, and the legend, and draws the off-screen buffer to the the current graphics context.
 o paintBars()
Paint the bars representing each data value.
 o paintLabels()
Paints the labels under the X axis for each bar.
 o paintValues()
Paints the values that each bar represents, above the bars.
 o update(Graphics)
Updates the chart by causing a repaint.

Variables

 o fBarDividerWidth
 protected int fBarDividerWidth
Size of space between each bar in the graph

 o fSelectedBar
 protected int fSelectedBar
Index of bar selected with a MouseDown event

 o fBarWidth
 protected int fBarWidth
Width of each bar representing a data value - calculated from size of graph

 o fBarCorners
 protected Point fBarCorners[]
List of points representing data values - they are stored and used for drawing and hit detection

Constructors

 o BarChartView
 public BarChartView()
Default constructor.

Methods

 o initialize
 public void initialize()
Initializes the view, and registers itself as a MouseListener and a MouseMotionListener, so as to catch mouse drag events, and update the chart accordingly. This method is called after the Model, View, and ComponentController are constructed.

Overrides:
initialize in class ChartView
 o mousePressed
 public void mousePressed(MouseEvent evt)
Called if the mouse is down. Subclasses should check to see if the user clicked anywhere near the tip of a bar. If so, the relevant information is recorded, inorder to track the user dragging the mouse to change a bar's height/width.

Parameters:
evt - the mouse event
 o mouseDragged
 public void mouseDragged(MouseEvent evt)
Called if the mouse is dragged (the mouse button is down). The mouse position is tracked, and the view is updated to change the selected bar's height. Subclasses of BarChart must implement the handling of this event for tracking the mouse position, and updating the view and model accordingly.

Parameters:
evt - the mouse event
 o mouseReleased
 public void mouseReleased(MouseEvent evt)
Called if the mouse is up. At this time, the data in the model is updated for the new value that the selected bar's height/width represents.

Parameters:
evt - the mouse event
 o mouseClicked
 public void mouseClicked(MouseEvent e)
Called if the mouse is clicked. No action is taken.

Parameters:
evt - the mouse event
 o mouseEntered
 public void mouseEntered(MouseEvent e)
Called if the mouse enters this chart. No action is taken.

Parameters:
evt - the mouse event
 o mouseExited
 public void mouseExited(MouseEvent e)
Called if the mouse leaves this chart.No action is taken.

Parameters:
evt - the mouse event
 o mouseMoved
 public void mouseMoved(MouseEvent e)
Called when the mouse moves over this chart. No action is taken.

Parameters:
evt - the mouse event
 o handleModelChange
 public void handleModelChange(ModelChangeEvent event)
Handles model changes by repainting.

Parameters:
event - the ModelChange event
Overrides:
handleModelChange in class ChartView
 o paint
 public void paint(Graphics g)
Paints the entire Bar Chart by painting the bars, the values and labels, and the legend, and draws the off-screen buffer to the the current graphics context.

Parameters:
g - the Graphics object
Overrides:
paint in class ChartView
 o update
 public void update(Graphics g)
Updates the chart by causing a repaint.

Parameters:
g - the Graphics object
Overrides:
update in class ChartView
 o calculateBars
 protected abstract void calculateBars()
Calculates the location of the bars representing each data value.

 o paintBars
 protected abstract void paintBars()
Paint the bars representing each data value.

 o paintLabels
 protected abstract void paintLabels()
Paints the labels under the X axis for each bar.

 o paintValues
 protected abstract void paintValues()
Paints the values that each bar represents, above the bars.


All Packages  Class Hierarchy  This Package  Previous  Next  Index