Java Reference
In-Depth Information
Figure 6.10 A
demonstration of
histogram plotting with
the HistPanel class.
Figure 6.10 shows an example of a Gaussian random number distribution dis-
played with HistPanel .
PlotPanel and HistPanel help to illustrate both the graphics capabilities
of Java and also the modularity of its objected-oriented design. A HistPanel
object can be added whenever we need to look at the distribution of values of
some quantity. Multiple HistPanel instances can be used when we want to look
at multiple quantities. We also see in later chapters and in the Web Course that
PlotPanel can be extended by other classes that draw different types of plots
and graphs besides histograms.
To simplify our histogram class hierarchy, we created a new base class called
Histogram . This class combines the attributes and methods of the earlier
BasicHist (see Chapter 3) and BetterHist (see Chapter 4) classes, which
were used to illustrate class and inheritance concepts. We added several new
methods to our histogram class to get and set values describing the histogram.
We provide the full code listing of Histogram.java here:
/** This class provides the bare essentials for a
* histogram. **/
public class Histogram
{
protected String fTitle ="Histogram";
protected String fXLabel ="Data";
protected int[] fBins;
protected int fNumBins;
protected int fUnderflows;
protected int fOverflows;
protected double fLo;
protected double fHi;
protected double fRange;
Search WWH ::




Custom Search