All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class COM.ibm.beans.charting.ChartView

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

public class ChartView
extends ModelView
The ChartView is the parent View class of all the charting beans, and extends the ModelView class of the CAF framework. It implements all the view related functionality for the charts. It uses the data contained in ChartModel for the chart, and maintains the viewing properties of the chart, like, whether or not the values and labels, the axes labels, etc. are to be shown on the chart. It uses double-buffering to draw the chart to an image, whose size is determined by the size of the frame that this chart is being displayed in, at any time.


Variable Index

 o fAxesShown
Flag for whether or not the axes should be shown (true for the Bar & Line Charts, false for the Pie)
 o fAxisLabel1
String to be drawn for the chart's scale halfway along the data axis.
 o fAxisLabel2
String to be drawn for the chart's scale at the end of the data axis.
 o fBorderSize
Size of the border of white space around the chart - in actuality the labels for each value, and the X axis label, are drawn in this border space
 o fChartFont
The font for labelling the chart.
 o fChartImage
The Image object that is the off-screen buffer used for drawing the chart
 o fChartWidth
Flag for whether or not the axes should be shown (true for the Bar & Line Charts, false for the Pie)
 o fIg
Graphics object of the off-screen buffer image used for drawing the chart
 o fLabelsShown
Flag to determine whether or not the labels for each value should be shown.
 o fLegendLabels
Array of labels to be drawn in the legend.
 o fMaxValue
Maximum value of all data values - rounded to the nearest tenth.
 o fRatio
Ratio between data values and pixels
 o fTitleFont
The font for the title of the chart.
 o fValuesShown
Flag for whether or not the values for each chart point/bar should be shown.
 o fXAxisLabelShown
Flag for whether or not the X axis label should be shown.
 o fYAxisLabelShown
Flag for whether or not the Y axis label should be shown.

Constructor Index

 o ChartView()
Default constructor.

Method Index

 o getChartFont()
Returns the font used for the chart's labels.
 o getMaxLegendRowSize()
Calculates the maximum size of the legend rows, based on what is to be shown in the legend, i.e., the labels for the different bars/wedges and/or the values of each bar/wedge.
 o getMinimumSize()
Returns the minimum size of the chart.
 o getPreferredSize()
Returns the preferred size of the chart.
 o getTitleFont()
Returns the font used for the chart's title.
 o handleModelChange(ModelChangeEvent)
Handles model changes.
 o initialize()
Initializes the view.
 o isLabelsShown()
Returns true if the flag for showing the labels for the chart data is set to true, false otherwise.
 o isValuesShown()
Returns true if the flag for showing the values of the chart data is set to true, false otherwise.
 o isXAxisLabelShown()
Returns true if the flag for showing the X Axis label for the chart data is set to true, false otherwise.
 o isYAxisLabelShown()
Returns true if the flag for showing the Y Axis label for the chart data is set to true, false otherwise.
 o legendFits()
Checks to see if the legend will fit in the chart's current drawing area.
 o paint(Graphics)
Creates an off-screen buffer for drawing to match the current size of the view area, and sets some default graphics properties for the buffer.
 o paintAxes()
Paints the X and Y axes.
 o paintAxisLabels()
Paints the label under the X axis (incase of a Vertical Bar Chart & Line Chart) or above the Y axis (incase of a Horizontal Bar Chart), if one was specified.
 o paintLegend()
Paints the legend for the chart, based on a) the type of chart, and b) what the user wants to see, viz, the labels and/or the values
 o paintScale()
Paints the scale on the appropriate axis, depending on the orientation of the chart.
 o paintTitle()
Paints the title of the chart, if one was specified.
 o paintXAxisScale()
Paints the scale on the X axis.
 o paintYAxisScale()
Paints the scale on the Y axis.
 o setAxisLabels()
Set the labels to be used on the axes.
 o setChartFont(Font)
Sets the font used for the chart's labels to the specified font.
 o setLabelsShown(boolean)
Sets to true or false, the flag for showing the labels for the chart data.
 o setLegendLabels()
Set the labels to be used in the legend.
 o setTitleFont(Font)
Sets the font for the chart's title to the specified font.
 o setValuesShown(boolean)
Sets to true or false, the flag for showing the values for the chart data on the chart.
 o setXAxisLabelShown(boolean)
Sets to true or false, the flag for showing the X Axis label for the chart data.
 o setYAxisLabelShown(boolean)
Sets to true or false, the flag for showing the Y Axis label for the chart data.
 o update(Graphics)
Updates the view by causing a repaint of the view.

Variables

 o fMaxValue
 protected int fMaxValue
Maximum value of all data values - rounded to the nearest tenth.

 o fAxisLabel1
 protected transient String fAxisLabel1
String to be drawn for the chart's scale halfway along the data axis. (based on fMaxValue)

 o fAxisLabel2
 protected transient String fAxisLabel2
String to be drawn for the chart's scale at the end of the data axis. (based on fMaxValue)

 o fRatio
 protected double fRatio
Ratio between data values and pixels

 o fBorderSize
 protected static int fBorderSize
Size of the border of white space around the chart - in actuality the labels for each value, and the X axis label, are drawn in this border space

 o fIg
 protected transient Graphics fIg
Graphics object of the off-screen buffer image used for drawing the chart

 o fChartImage
 protected transient Image fChartImage
The Image object that is the off-screen buffer used for drawing the chart

 o fLabelsShown
 protected boolean fLabelsShown
Flag to determine whether or not the labels for each value should be shown.

 o fValuesShown
 protected boolean fValuesShown
Flag for whether or not the values for each chart point/bar should be shown.

 o fXAxisLabelShown
 protected boolean fXAxisLabelShown
Flag for whether or not the X axis label should be shown.

 o fYAxisLabelShown
 protected boolean fYAxisLabelShown
Flag for whether or not the Y axis label should be shown.

 o fAxesShown
 protected transient boolean fAxesShown
Flag for whether or not the axes should be shown (true for the Bar & Line Charts, false for the Pie)

 o fChartWidth
 protected int fChartWidth
Flag for whether or not the axes should be shown (true for the Bar & Line Charts, false for the Pie)

 o fLegendLabels
 protected String fLegendLabels[]
Array of labels to be drawn in the legend. The strings actually displayed depend on, e.g. what the user wants to see (in a pie chart, the labels and/or the values, in a bar chart, the labels only)

 o fTitleFont
 protected Font fTitleFont
The font for the title of the chart.

 o fChartFont
 protected Font fChartFont
The font for labelling the chart.

Constructors

 o ChartView
 public ChartView()
Default constructor.

Methods

 o initialize
 public void initialize()
Initializes the view. This method is called after the Model, View, and ComponentController are constructed.

Overrides:
initialize in class ModelView
 o handleModelChange
 public void handleModelChange(ModelChangeEvent event)
Handles model changes.

Overrides:
handleModelChange in class ModelView
 o update
 public void update(Graphics g)
Updates the view by causing a repaint of the view.

Overrides:
update in class Component
 o paint
 public void paint(Graphics gr)
Creates an off-screen buffer for drawing to match the current size of the view area, and sets some default graphics properties for the buffer. The background color is set, and the title and axes are drawn..

Overrides:
paint in class Container
 o paintTitle
 protected void paintTitle()
Paints the title of the chart, if one was specified.

 o paintAxisLabels
 protected void paintAxisLabels()
Paints the label under the X axis (incase of a Vertical Bar Chart & Line Chart) or above the Y axis (incase of a Horizontal Bar Chart), if one was specified.

 o paintLegend
 public void paintLegend()
Paints the legend for the chart, based on a) the type of chart, and b) what the user wants to see, viz, the labels and/or the values

 o legendFits
 protected boolean legendFits()
Checks to see if the legend will fit in the chart's current drawing area. The size of the legend depends on what is to be shown in the legend; the labels and / or the values in the ChartModel.

 o setLegendLabels
 protected void setLegendLabels()
Set the labels to be used in the legend. In the case of Bar Charts, these are the same as the labels and / or the data values in the ChartModel.

 o getMaxLegendRowSize
 protected int getMaxLegendRowSize()
Calculates the maximum size of the legend rows, based on what is to be shown in the legend, i.e., the labels for the different bars/wedges and/or the values of each bar/wedge. This length is used to determine whether or not the legend can be shown.

 o paintAxes
 protected void paintAxes()
Paints the X and Y axes.

 o paintScale
 protected void paintScale()
Paints the scale on the appropriate axis, depending on the orientation of the chart.

 o setAxisLabels
 protected void setAxisLabels()
Set the labels to be used on the axes.

 o paintYAxisScale
 protected void paintYAxisScale()
Paints the scale on the Y axis.

 o paintXAxisScale
 protected void paintXAxisScale()
Paints the scale on the X axis.

 o getPreferredSize
 public Dimension getPreferredSize()
Returns the preferred size of the chart.

Overrides:
getPreferredSize in class Container
 o getMinimumSize
 public Dimension getMinimumSize()
Returns the minimum size of the chart.

Overrides:
getMinimumSize in class Container
 o getTitleFont
 public Font getTitleFont()
Returns the font used for the chart's title.

 o setTitleFont
 public void setTitleFont(Font font)
Sets the font for the chart's title to the specified font.

Parameters:
font - the font for the chart's title
 o getChartFont
 public Font getChartFont()
Returns the font used for the chart's labels.

 o setChartFont
 public void setChartFont(Font font)
Sets the font used for the chart's labels to the specified font.

Parameters:
font - the font for the chart's labels
 o isLabelsShown
 public boolean isLabelsShown()
Returns true if the flag for showing the labels for the chart data is set to true, false otherwise.

 o setLabelsShown
 public void setLabelsShown(boolean show)
Sets to true or false, the flag for showing the labels for the chart data.

Parameters:
show - if true, the labels for the bars/points are shown, if false, they are hidden
 o isValuesShown
 public boolean isValuesShown()
Returns true if the flag for showing the values of the chart data is set to true, false otherwise.

 o setValuesShown
 public void setValuesShown(boolean show)
Sets to true or false, the flag for showing the values for the chart data on the chart.

Parameters:
show - if true, the values of the bars/points are shown, if false, they are hidden
 o isXAxisLabelShown
 public boolean isXAxisLabelShown()
Returns true if the flag for showing the X Axis label for the chart data is set to true, false otherwise.

 o setXAxisLabelShown
 public void setXAxisLabelShown(boolean show)
Sets to true or false, the flag for showing the X Axis label for the chart data.

Parameters:
show - if true, the label under the X axis is shown, if false, it is hidden
 o isYAxisLabelShown
 public boolean isYAxisLabelShown()
Returns true if the flag for showing the Y Axis label for the chart data is set to true, false otherwise.

 o setYAxisLabelShown
 public void setYAxisLabelShown(boolean show)
Sets to true or false, the flag for showing the Y Axis label for the chart data.

Parameters:
show - if true, the label above the Y axis is shown, if false, it is hidden

All Packages  Class Hierarchy  This Package  Previous  Next  Index