|
Histogram Project | |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Histogram
Environment-Based Applications:
The Histogram class constructs a histogram of a set of integer values.
Constructor Summary | |
Histogram(java.lang.String title,
int[] values,
int maxValue)
Constructs a histogram for the specified values and displays it. |
|
Histogram(java.lang.String title,
int numValues,
int maxValue)
Constructs a histogram for a certain number of values. |
Method Summary | |
void |
display()
Displays the histogram. |
void |
labelColumns()
Label the "x-axis" of the histogram with the values represented by each column. |
void |
labelColumns(int periodicity)
Label the "x-axis" of the histogram with the values represented by the columns; which columns are labeled depends on the periodicity . |
void |
plot(int row,
int value)
Plots a row in the histogram; assumes that the histogram was created with the first constructor. |
void |
plot(java.lang.String label,
int row,
int value)
Plots a labeled row in the histogram; assumes that the histogram was created with the first constructor. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Histogram(java.lang.String title, int numValues, int maxValue)
numValues < 20
.)title
- title for top of window displaying histogramnumValues
- the number of values to plotmaxValue
- the maximum value that could be plotted;
the histogram is scaled so that a full row
represents this valuepublic Histogram(java.lang.String title, int[] values, int maxValue)
values.length < 20
and
every value in values
is less than or equal
to maxValue
.)title
- title for top of window displaying histogramvalues
- the list of values to plotmaxValue
- the maximum value that could be plotted;
the histogram is scaled so that a full row
represents this valueMethod Detail |
public void plot(int row, int value)
0 <= row < numValues
and
0 <= value <= maxValue
, where numValues
and maxValue
are the values specified when the histogram was constructed.)
row
- the row in which a value is to be plotted (0 represents
the first row, 1 represents the second row, and so forth)
value
- the value to be plotted
public void plot(java.lang.String label, int row, int value)
0 <= row < numValues
and 0 <= value <= maxValue
, where numValues
and
maxValue
are the values specified when the histogram was constructed.
Also, label
is a short enough string to be displayed in a single
cell in the histogram grid.)
label
- the label for the row
row
- the row in which a value is to be plotted
value
- the value to be plotted
public void labelColumns()
public void labelColumns(int periodicity)
periodicity
. If the periodicity
is 1
then every column is labeled; if the periodicity
is 2
then every other column is labeled; it it's 3 then every third
column is labeled; etc. The first and last columns, however,
are always labeled, regardless of the periodicity
.public void display()
|
Histogram Project | |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |