示例#1
0
  /////////////////////////////////////////////////////////////
  // constructor
  ////////////////////////////////////////////////////////////
  public StepControl(final ToolParent parent) {

    // sort out the small & large time steps
    initialiseTimeStepSizes();

    _listeners = new Vector<StepperListener>(0, 1);
    _participants = new Hashtable<Object, somePeriod>();

    /** the timer-related settings */
    _theTimer = new MWC.Utilities.Timer.Timer();
    _theTimer.stop();
    setAutoStep(1000);
    _theTimer.addTimerListener(this);

    _goingForward = true;
    _largeSteps = true;

    // create our default highlighter
    _defaultHighlighter =
        new Debrief.GUI.Tote.Painters.Highlighters.PlotHighlighter.RectangleHighlight();

    if (_myHighlighters == null) {
      _myHighlighters = new Vector<PlotHighlighter>(0, 1);
      _myHighlighters.add(_defaultHighlighter);
      _myHighlighters.add(new Debrief.GUI.Tote.Painters.Highlighters.RangeHighlighter());
      _myHighlighters.add(new Debrief.GUI.Tote.Painters.Highlighters.SymbolHighlighter());
    }

    _currentHighlighter = _myHighlighters.elementAt(0);

    // initialise the date format
    _dateFormatter =
        new java.text.SimpleDateFormat(MWC.Utilities.TextFormatting.FormatRNDateTime.getExample());
    _dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT"));
  }
示例#2
0
  public final void setDateFormat(final String val) {
    // update the formatter
    _dateFormatter.applyPattern(val);

    // has our date been set?
    final HiResDate tNow = this.getCurrentTime();
    if (tNow != null) {
      // and update the form
      updateForm(tNow);
    }
  }
示例#3
0
  /**
   * private method to produce a time string from the indicated DTG we've moved it out of the
   * newTime box so that we can access it from a tester
   */
  public String getNewTime(final HiResDate DTG) {
    final String pattern = _dateFormatter.toPattern();

    String res = "";

    if (pattern.startsWith("'T+'")) {
      // hey, we're doing our "Special format".
      res = "T ";

      // get the T-zero time
      final HiResDate theTZero = getTimeZero();
      if (theTZero == null) {
        // no, return an error message
        return "N/A";
      }

      final long Tzero = theTZero.getMicros();

      // what's the elapsed time
      final long elapsed = DTG.getMicros() - Tzero;

      if (Math.abs(elapsed) > 1000000000000l) {
        res = "N/A";
      } else {

        // how many seconds is this?
        long secs = (long) (elapsed / 1000000d);

        // are we +ve?
        if (secs > 0) {
          res += "+";
        } else {
          res += "-";
        }

        // ok, we've handled the +ve/-ve make it absolute
        secs = Math.abs(secs);

        // which format do they want?
        String format = pattern.substring(pattern.indexOf(" "));

        // strip the format string
        format = format.trim();

        if (format.equals("SSS")) {
          // do we have our number formatter?
          if (_secondsFormat == null) _secondsFormat = new java.text.DecimalFormat("000s");

          res += _secondsFormat.format(secs);
        } else if (format.equals("MM:SS")) {
          // how many mins?
          final long mins = secs / 60;

          // and the seconds
          secs -= mins * 60;

          res += mins;

          res += ":";

          res += MWC.Utilities.TextFormatting.BriefFormatLocation.df2.format(secs);

        } else {
          MWC.Utilities.Errors.Trace.trace("Step control: invalid TZero format found:" + format);
        }
      }
    } else {
      // are we in hi-res mode or not?
      if (HiResDate.inHiResProcessingMode()) res = DebriefFormatDateTime.formatMicros(DTG);
      else res = _dateFormatter.format(DTG.getDate());
    }

    return res;
  }
示例#4
0
 public final String getDateFormat() {
   return _dateFormatter.toPattern();
 }