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.
-
fBarCorners
- List of points representing data values - they are stored and used for
drawing and hit detection
-
fBarDividerWidth
- Size of space between each bar in the graph
-
fBarWidth
- Width of each bar representing a data value - calculated from size of graph
-
fSelectedBar
- Index of bar selected with a MouseDown event
-
BarChartView()
- Default constructor.
-
calculateBars()
- Calculates the location of the bars representing each data value.
-
handleModelChange(ModelChangeEvent)
- Handles model changes by repainting.
-
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.
-
mouseClicked(MouseEvent)
- Called if the mouse is clicked.
-
mouseDragged(MouseEvent)
- Called if the mouse is dragged (the mouse button is down).
-
mouseEntered(MouseEvent)
- Called if the mouse enters this chart.
-
mouseExited(MouseEvent)
- Called if the mouse leaves this chart.No action is taken.
-
mouseMoved(MouseEvent)
- Called when the mouse moves over this chart.
-
mousePressed(MouseEvent)
- Called if the mouse is down.
-
mouseReleased(MouseEvent)
- Called if the mouse is up.
-
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.
-
paintBars()
- Paint the bars representing each data value.
-
paintLabels()
- Paints the labels under the X axis for each bar.
-
paintValues()
- Paints the values that each bar represents, above the bars.
-
update(Graphics)
- Updates the chart by causing a repaint.
fBarDividerWidth
protected int fBarDividerWidth
- Size of space between each bar in the graph
fSelectedBar
protected int fSelectedBar
- Index of bar selected with a MouseDown event
fBarWidth
protected int fBarWidth
- Width of each bar representing a data value - calculated from size of graph
fBarCorners
protected Point fBarCorners[]
- List of points representing data values - they are stored and used for
drawing and hit detection
BarChartView
public BarChartView()
- Default constructor.
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
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
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
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
mouseClicked
public void mouseClicked(MouseEvent e)
- Called if the mouse is clicked. No action is taken.
- Parameters:
- evt - the mouse event
mouseEntered
public void mouseEntered(MouseEvent e)
- Called if the mouse enters this chart. No action is taken.
- Parameters:
- evt - the mouse event
mouseExited
public void mouseExited(MouseEvent e)
- Called if the mouse leaves this chart.No action is taken.
- Parameters:
- evt - the mouse event
mouseMoved
public void mouseMoved(MouseEvent e)
- Called when the mouse moves over this chart. No action is taken.
- Parameters:
- evt - the mouse event
handleModelChange
public void handleModelChange(ModelChangeEvent event)
- Handles model changes by repainting.
- Parameters:
- event - the ModelChange event
- Overrides:
- handleModelChange in class ChartView
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
update
public void update(Graphics g)
- Updates the chart by causing a repaint.
- Parameters:
- g - the Graphics object
- Overrides:
- update in class ChartView
calculateBars
protected abstract void calculateBars()
- Calculates the location of the bars representing each data value.
paintBars
protected abstract void paintBars()
- Paint the bars representing each data value.
paintLabels
protected abstract void paintLabels()
- Paints the labels under the X axis for each bar.
paintValues
protected abstract void paintValues()
- Paints the values that each bar represents, above the bars.
All Packages Class Hierarchy This Package Previous Next Index