/** get ready to close, set all local references to null, to assist garbage collection */
  public void close() {
    // we'll also try to remove all of the tools
    final Enumeration<MenuItemInfo> iter = _theTools.elements();
    while (iter.hasMoreElements()) {
      final MenuItemInfo mn = iter.nextElement();
      mn.close();
    }

    // clear the dangling reference to the undo buffer
    _rightClicker.closeMe();
    _toteAdapter = null;

    // clear the file drop listener
    if (_dropSupport != null) _dropSupport.removeComponent(getChart().getPanel());

    _dropSupport.removeFileDropListener(this);

    // now remove references to the tools themselves
    _theTools.removeAllElements();

    _theChart.close();
    _theChart = null;

    if (_theTote != null) {
      _theTote.closeMe();
      _theTote = null;
    }
    if (_theToolbar != null) _theToolbar.close();
    _theToolbar = null;
    _theProperties = null;
    _theStatusBar = null;

    _theSession = null;
  }
Exemple #2
0
  public final void makeThis(
      final Debrief.ReaderWriter.XML.GUIHandler.ComponentDetails details,
      final Debrief.GUI.Views.AnalysisView _analysisView) {
    String val = null;

    if (_analysisView == null) {
      System.err.println("Analysis view missing from Stepper Handler");
      return;
    }

    // right. just do some quick checking to ensure we have the right data
    final AnalysisTote theTote = _analysisView.getTote();

    //////////////////////////////////////////////////////////////
    final String cursor = (String) details.properties.get("Cursor");
    if (cursor != null) {
      // set the cursor
      theTote.getStepper().setPainter(cursor);

      //////////////////////////////////////////////////////////////
      // is this the snail cursor?
      if (cursor.equals(SnailPainter.SNAIL_NAME)) {
        final String vector_stretch = (String) details.properties.get("VectorStretch");
        if (vector_stretch != null) {
          // set the cursor
          final SnailPainter sp = (SnailPainter) theTote.getStepper().getCurrentPainter();
          try {
            sp.setVectorStretch(MWCXMLReader.readThisDouble(vector_stretch));
          } catch (final ParseException pe) {
            MWC.Utilities.Errors.Trace.trace(
                pe, "Reader: Whilst reading in VectorStretch value of :" + vector_stretch);
          }
        }
      }
    }

    //////////////////////////////////////////////////////////////
    final String dateFormat = (String) details.properties.get("DateFormat");
    if (dateFormat != null) {
      // set the cursor
      _analysisView.getTote().getStepper().setDateFormat(dateFormat);
    }

    //////////////////////////////////////////////////////////////
    final String highlighter = (String) details.properties.get("Highlighter");
    if (highlighter != null) {
      // set the cursor
      _analysisView.getTote().getStepper().setHighlighter(highlighter);
    }

    //////////////////////////////////////////////////////////////
    final String start_time = (String) details.properties.get("Toolbox_Start_Time");
    if (start_time != null) {
      HiResDate startTime = null;
      // get a date from this
      startTime = DebriefFormatDateTime.parseThis(start_time);

      // set the cursor
      _analysisView.getTote().getStepper().setToolboxStartTime(startTime);
    }

    //////////////////////////////////////////////////////////////
    final String end_time = (String) details.properties.get("Toolbox_End_Time");
    if (end_time != null) {
      HiResDate endTime = null;

      // get a date from this
      endTime = DebriefFormatDateTime.parseThis(end_time);

      // set the cursor
      _analysisView.getTote().getStepper().setToolboxEndTime(endTime);
    }

    //////////////////////////////////////////////////////////////
    final String tZero = (String) details.properties.get("TimeZero");
    if (tZero != null) {
      // get a date from this
      final HiResDate dt = DebriefFormatDateTime.parseThis(tZero);

      // set the cursor
      _analysisView.getTote().getStepper().setTimeZero(dt);
    }
    //////////////////////////////////////////////////////////////
    final String currentTime = (String) details.properties.get("CurrentTime");
    if (currentTime != null) {
      // and set the time
      final HiResDate dtg = DebriefFormatDateTime.parseThis(currentTime);

      // did we find a valid dtg?
      if (dtg != null) _analysisView.getTote().getStepper().changeTime(dtg);
    }
    //////////////////////////////////////////////////////////////
    val = (String) details.properties.get("AutoStep");
    if (val != null) {
      // set the auto step to this number of millis
      final int len = Integer.valueOf(val).intValue();
      _analysisView.getTote().getStepper().setAutoStep(len);
    }

    ///////////////////////////////////////////////////////////////
    val = (String) details.properties.get("StepLarge");
    if (val != null) {
      // set the large step to this number of millis
      try {
        final double len = MWCXMLReaderWriter.readThisDouble(val);
        _analysisView.getTote().getStepper().setStepLarge((long) len * 1000);
      } catch (final java.text.ParseException pe) {
        MWC.Utilities.Errors.Trace.trace(pe, "Failed reading large step size value is:" + val);
      }
    }

    ///////////////////////////////////////////////////////////////
    val = (String) details.properties.get("StepSmall");
    if (val != null) {
      try {
        // set the small step to this number of millis
        final double len = MWCXMLReaderWriter.readThisDouble(val);
        _analysisView.getTote().getStepper().setStepSmall((long) len * 1000);
      } catch (final java.text.ParseException pe) {
        MWC.Utilities.Errors.Trace.trace(pe, "Failed reading small step size value is:" + val);
      }
    }

    ///////////////////////////////////////////////////////////////
    val = (String) details.properties.get("StepLargeMicros");
    if (val != null) {
      // set the large step to this number of millis
      try {
        final double len = MWCXMLReaderWriter.readThisDouble(val);
        _analysisView.getTote().getStepper().setStepLarge((long) len);
      } catch (final java.text.ParseException pe) {
        MWC.Utilities.Errors.Trace.trace(pe, "Failed reading large step size value is:" + val);
      }
    }

    ///////////////////////////////////////////////////////////////
    val = (String) details.properties.get("StepSmallMicros");
    if (val != null) {
      try {
        // set the small step to this number of millis
        final double len = MWCXMLReaderWriter.readThisDouble(val);
        _analysisView.getTote().getStepper().setStepSmall((long) len);
      } catch (final java.text.ParseException pe) {
        MWC.Utilities.Errors.Trace.trace(pe, "Failed reading small step size value is:" + val);
      }
    }

    // just do some minor tidying here, to check we have start & end times for the slider
    if ((_analysisView.getTote().getStepper().getStartTime() == null)
        || (_analysisView.getTote().getStepper().getEndTime() == null)) {
      _analysisView.getTote().getStepper().recalcTimes();
    }
  }
 /** data has been modified, update panes as necesary */
 public final void update() {
   // check they are valid
   if (_theChart != null) _theChart.update();
   if (_theTote != null) _theTote.update();
 }