public abstract class AbstractDataViewFixture extends Fixture
A fixture for previewing a kind of DataView
.
(See Fixture
for more information about fixtures in general.)
Concrete implementations need only specify
how to create a series,
and this class will create a set of previews.
Data views that also expect shared data should also specify
how to create the shared data.
For complete control over the data displayed,
implementations may choose to override the behavior of generateDatasets()
;
by default, this makes a few calls
to generateSeries(Random, String)
and generateSharedData(Random)
with different numbers of series.
Fixture.Title
Constructor and Description |
---|
AbstractDataViewFixture() |
Modifier and Type | Method and Description |
---|---|
protected abstract DataView |
createView()
Create a data view that will be previewed in this fixture.
|
protected java.util.Map<java.lang.String,Data> |
generateDatasets()
Create the data sets to display in the preview.
|
protected abstract Series |
generateSeries(java.util.Random rnd,
java.lang.String seriesName)
Generate a series of the given name,
using the provided source of randomness if necessary.
|
protected java.util.Map<ColumnSpecification,Column> |
generateSharedData(java.util.Random rnd)
Generate shared data for a
Data set,
using the provided source of randomness if necessary. |
protected java.util.Random |
getRandomSource()
Get a source of randomness to use throughout the data generation process.
|
protected void |
setUp(javax.swing.JFrame frame)
Configure the provided frame to set up the fixture.
|
protected java.util.Random getRandomSource()
protected java.util.Map<java.lang.String,Data> generateDatasets()
"Empty data (no series)"
or "Data with extreme outliers"
)protected abstract Series generateSeries(java.util.Random rnd, java.lang.String seriesName)
rnd
- the random number generator to use for any randomness needed;
avoid calls to Math.random()
,
as they necessarily introduce nondeterminismseriesName
- the name of the series to createprotected java.util.Map<ColumnSpecification,Column> generateSharedData(java.util.Random rnd)
Data
set,
using the provided source of randomness if necessary.
Because most views do not require shared data,
the default implementation returns the empty map.rnd
- the random number generator to use for any randomness needed;
avoid calls to Math.random()
,
as they necessarily introduce nondeterminismprotected abstract DataView createView()
protected void setUp(javax.swing.JFrame frame)
Fixture
Configure the provided frame to set up the fixture.
A subclass of Fixture
should override this method
to add components to the frame as desired by the fixture,
but does not need to perform any other operations on the frame,
such as pack
ing it or setting the default close operation.
These are handled automatically by Fixture.runMain()
.
If this method does not change the size of the frame,
it will be pack
ed automatically.
Otherwise, the size set by this method will be respected.