_chartPanel = new ChartPanel[_categories.length];
}
Dimension dim = new Dimension();
for (int i = 0; i < _categories.length; i++) {
IntervalCategoryDataset dataset = _model.getIntervalCategoryDataset(_categories[i]);
if (_chart[i] == null) {
_chartPanel[i] = _makeObservationChart(dataset, i);
_tabbedPane.add(new JScrollPane(_chartPanel[i]), _categories[i]);
} else {
// Can't change the date axis timezone, so create a new one
DateAxis dateAxis = _makeDateAxis();
CategoryPlot plot = _chart[i].getCategoryPlot();
plot.setRangeAxis(0, dateAxis);
plot.setDataset(dataset);
}
_chart[i].setTitle(_model.getTitle() + " (" + _categories[i] + ")");
// Force the full range on the X axis
CategoryPlot plot = (CategoryPlot) _chart[i].getPlot();
DateAxis axis = (DateAxis) plot.getRangeAxis();
axis.setRange(_model.getStartDate(), _model.getEndDate());
axis.setLabel(_getXAxisLabel());
// mark the ranges of twilight and darkness
plot.clearRangeMarkers();
_addDarknessMarker(plot, _model.getNauticalTwilightStart(),
_model.getNauticalTwilightEnd(), TWILIGHT_ALPHA, Color.gray);
_addDarknessMarker(plot, _model.getAstronomicalTwilightStart(),
_model.getAstronomicalTwilightEnd(), DARKNESS_ALPHA, Color.black);
// Make sure labels are readable, use scrollbar if needed
int numTargets = dataset.getColumnCount();
if (numTargets <= 20) {
_chartPanel[i].setPreferredSize(null);
} else {
_chartPanel[i].getSize(dim);
dim.height = 50 + numTargets * 24;