diff --git a/src/org/aavso/tools/vstar/ui/mediator/DocumentManager.java b/src/org/aavso/tools/vstar/ui/mediator/DocumentManager.java index 486fce70..56c9d51f 100644 --- a/src/org/aavso/tools/vstar/ui/mediator/DocumentManager.java +++ b/src/org/aavso/tools/vstar/ui/mediator/DocumentManager.java @@ -73,42 +73,7 @@ public class DocumentManager { public DocumentManager() { mediator = Mediator.getInstance(); - rawDataModelComponents = new HashMap>(); - phasedModelComponents = new HashMap>(); - - rawDataResidualComponents = new HashMap>(); - phasedResidualComponents = new HashMap>(); - - phasePlotExists = false; - epoch = 0; - period = 0; - - showErrorBars = new HashMap() {{ - put(AnalysisType.RAW_DATA, true); - put(AnalysisType.PHASE_PLOT, true); - }}; - - showCrossHairs = new HashMap() {{ - put(AnalysisType.RAW_DATA, true); - put(AnalysisType.PHASE_PLOT, true); - }}; - - invertRange = new HashMap() {{ - put(AnalysisType.RAW_DATA, true); - put(AnalysisType.PHASE_PLOT, true); - }}; - - invertSeriesOrder = new HashMap() {{ - put(AnalysisType.RAW_DATA, true); - put(AnalysisType.PHASE_PLOT, true); - }}; - - joinMeans = new HashMap() {{ - put(AnalysisType.RAW_DATA, true); - put(AnalysisType.PHASE_PLOT, true); - }}; - - statsInfo = new TreeMap(); + init(); } // ** phase, epoch, period methods ** @@ -348,6 +313,73 @@ private String getPhasedModelKey(IModel model) { period); } + /** + * Initialise (or reset) data members + */ + public void init() { + phasePlotExists = false; + epoch = 0; + period = 0; + + // model maps + if (rawDataModelComponents == null) { + rawDataModelComponents = new HashMap>(); + } + rawDataModelComponents.clear(); + + if (phasedModelComponents == null) { + phasedModelComponents = new HashMap>(); + } + phasedModelComponents.clear(); + + if (rawDataResidualComponents == null) { + rawDataResidualComponents = new HashMap>(); + } + rawDataResidualComponents.clear(); + + if (phasedResidualComponents == null) { + phasedResidualComponents = new HashMap>(); + } + phasedResidualComponents.clear(); + + // Boolean maps + if (showErrorBars == null) { + showErrorBars = new HashMap(); + } + showErrorBars.put(AnalysisType.RAW_DATA, true); + showErrorBars.put(AnalysisType.PHASE_PLOT, true); + + if (showCrossHairs == null) { + showCrossHairs = new HashMap(); + } + showCrossHairs.put(AnalysisType.RAW_DATA, true); + showCrossHairs.put(AnalysisType.PHASE_PLOT, true); + + if (invertRange == null) { + invertRange = new HashMap(); + } + invertRange.put(AnalysisType.RAW_DATA, true); + invertRange.put(AnalysisType.PHASE_PLOT, true); + + if (invertSeriesOrder == null) { + invertSeriesOrder = new HashMap(); + } + invertSeriesOrder.put(AnalysisType.RAW_DATA, true); + invertSeriesOrder.put(AnalysisType.PHASE_PLOT, true); + + if (joinMeans == null) { + joinMeans = new HashMap(); + } + joinMeans.put(AnalysisType.RAW_DATA, true); + joinMeans.put(AnalysisType.PHASE_PLOT, true); + + // stats info map + if (statsInfo == null) { + statsInfo = new TreeMap(); + } + statsInfo.clear(); + } + /** * Return a phase change listener that updates epoch and period information * in preparation for creating or retrieving phase plot components.
@@ -371,26 +403,6 @@ public boolean canBeRemoved() { }; } - /** - * Return a new star listener that clears the maps. - */ - public Listener createNewStarListener() { - return new Listener() { - @Override - public void update(NewStarMessage info) { - rawDataModelComponents.clear(); - rawDataResidualComponents.clear(); - phasedModelComponents.clear(); - phasedResidualComponents.clear(); - } - - @Override - public boolean canBeRemoved() { - return false; - } - }; - } - /** * Find and return the active window or null if one does not exist, e.g. the * case where the UI is that of an applet. diff --git a/src/org/aavso/tools/vstar/ui/mediator/Mediator.java b/src/org/aavso/tools/vstar/ui/mediator/Mediator.java index a3510e1a..5fa90c09 100644 --- a/src/org/aavso/tools/vstar/ui/mediator/Mediator.java +++ b/src/org/aavso/tools/vstar/ui/mediator/Mediator.java @@ -956,7 +956,6 @@ public DocumentManager getDocumentManager() { if (documentManager == null) { documentManager = new DocumentManager(); phaseChangeNotifier.addListener(documentManager.createPhaseChangeListener(), true); - newStarNotifier.addListener(documentManager.createNewStarListener(), true); } return documentManager; @@ -1174,7 +1173,7 @@ public void createNewStarObservationArtefacts(NewStarType newStarType, StarInfo // table and plot models, along with corresponding GUI components. // Handle additive load if requested and observations are already - // loaded. + // loaded, otherwise, initialise the document manager. if (addObs && getLatestNewStarMessage() != null) { // convertObsToHJD(starInfo); @@ -1192,6 +1191,8 @@ public void createNewStarObservationArtefacts(NewStarType newStarType, StarInfo break; } } + } else { + getDocumentManager().init(); } List validObsList = starInfo.getRetriever().getValidObservations();