Ejemplo n.º 1
0
  /**
   * Draws a time sync line on the plot at the specified time. We take the approach of plotting the
   * time sync line like another data series in preference to using Quinn-Curtis' line drawing
   * function.
   *
   * @param time at which to draw the time sync line.
   */
  void drawTimeSyncLineAtTime(GregorianCalendar time) {
    assert time != null;

    // Peg timesync line to the plot area by setting the time
    // parameter to be on the plot max or plot min.
    if (time.before(plot.getCurrentTimeAxisMin())) {
      time = plot.getCurrentTimeAxisMin();
    } else if (time.after(plot.getCurrentTimeAxisMax())) {
      time = plot.getCurrentTimeAxisMax();
    }

    syncTime = time;

    if (timeSyncLinePlot == null) {
      AbstractAxis timeAxis = plot.getTimeAxis();
      if (timeAxis instanceof XYAxis) { // Only decorate time-like axes; TODO: move to AbstractAxis?
        timeSyncLinePlot = new XYMarkerLine((XYAxis) timeAxis, time.getTimeInMillis());
        timeSyncLinePlot.setForeground(PlotConstants.TIME_SYNC_LINE_COLOR);
        XYPlotContents contents = plot.getPlotView().getContents();
        contents.add(timeSyncLinePlot);
        contents.revalidate();
      }
    } else {
      timeSyncLinePlot.setValue(time.getTimeInMillis());
    }
  }
Ejemplo n.º 2
0
 /** Remove the time sync line from the plot. */
 void removeTimeSyncLine() {
   if (timeSyncLinePlot != null) {
     plot.setUserOperationLockedState(false);
     XYPlotContents contents = plot.getPlotView().getContents();
     contents.remove(timeSyncLinePlot);
     contents.repaint(); // TODO: Only repaint the relevant portion
     //			plot.refreshDisplay();
     timeSyncLinePlot = null;
     syncTime = null;
   }
 }