/**
* Create the plot from persisted settings if available. Otherwise, create a default plot.
*/
static PlotView createPlot(PlotSettings settings, long currentTime, PlotViewManifestation parentManifestation,
int numberOfSubPlots, PlotView oldPlot, AbbreviatingPlotLabelingAlgorithm plotLabelingAlgorithm, String viewStateTimeSystem) {
PlotView thePlot;
// Insure we always have at least one plot.
numberOfSubPlots = settings.getAxisOrientationSetting() == AxisOrientationSetting.Z_AXIS_AS_TIME ?
1 : Math.max(1,numberOfSubPlots);
if (!settings.isNull()) {
if (settings.getTimeSystemSetting() == null) {
settings.setTimeSystemSetting(viewStateTimeSystem);
}
// The plot has persisted settings so apply them.
if (!settings.getPinTimeAxis()) {
adjustPlotStartAndEndTimeToMatchCurrentTime(settings, currentTime);
}
thePlot = createPlotFromSettings(settings, numberOfSubPlots, plotLabelingAlgorithm);
} else {
// Setup a default plot to view while the user is configuring it.
thePlot = new PlotView.Builder(PlotterPlot.class).
numberOfSubPlots(numberOfSubPlots).
plotLabelingAlgorithm(plotLabelingAlgorithm).build();
}
thePlot.setManifestation(parentManifestation);
thePlot.setPlotLabelingAlgorithm(plotLabelingAlgorithm);
assert thePlot!=null : "Plot labeling algorithm should NOT be NULL at this point.";
logger.debug("plotLabelingAlgorithm.getPanelContextTitleList().size()="
+ plotLabelingAlgorithm.getPanelContextTitleList().size()
+ ", plotLabelingAlgorithm.getCanvasContextTitleList().size()=" + plotLabelingAlgorithm.getCanvasContextTitleList().size());
// Copy across feed mapping from old plot, unless structure is different
if (oldPlot!=null && oldPlot.subPlots.size() == numberOfSubPlots) {
for (String dataSetName: oldPlot.dataSetNameToSubGroupMap.keySet()) {
String nameLower = dataSetName.toLowerCase();
for(AbstractPlottingPackage plot : oldPlot.dataSetNameToSubGroupMap.get(dataSetName)) {
int indexInOldPlot = oldPlot.subPlots.indexOf(plot);
thePlot.addDataSet(indexInOldPlot, dataSetName, oldPlot.dataSetNameToDisplayMap.get(nameLower));
}
}
}
return thePlot;
}