PlotViewFactory { static PlotView createPlot(PlotSettings settings, long currentTime, PlotViewManifestation parentManifestation, int numberOfSubPlots, PlotView oldPlot, AbbreviatingPlotLabelingAlgorithm plotLabelingAlgorithm, String viewStateTimeSystem) { PlotView thePlot; numberOfSubPlots = settings.getAxisOrientationSetting() == AxisOrientationSetting.Z_AXIS_AS_TIME ? 1 : Math.max(1,numberOfSubPlots); if (!settings.isNull()) { if (settings.getTimeSystemSetting() == null) { settings.setTimeSystemSetting(viewStateTimeSystem); } if (!settings.getPinTimeAxis()) { adjustPlotStartAndEndTimeToMatchCurrentTime(settings, currentTime); } thePlot = createPlotFromSettings(settings, numberOfSubPlots, plotLabelingAlgorithm); } else { 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()); 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; }    }
@Test(dataProvider="plotViewFactoryData") public void testCreatePlot(PlotSettings settings, long currentTime, long expectedMinTime, long expectedMaxTime, boolean pinned) { PlotView plotView = PlotViewFactory.createPlot(settings, currentTime, plotManifestation, 1, null, labelingAlgorithm, PlotConstants.DEFAULT_TIME_SYSTEM); Assert.assertEquals(plotView.getTimeAxisUserPin().isPinned(), pinned); Assert.assertEquals(plotView.getMinTime(), expectedMinTime); Assert.assertEquals(plotView.getMaxTime(), expectedMaxTime); }