Exemple #1
0
  @Override
  public void populate(XYPlot plot, AROTraceData analysis) {
    if (analysis != null) {
      gpsData.removeAllSeries();
      // create the GPS dataset...
      Map<GpsState, XYIntervalSeries> seriesMap =
          new EnumMap<GpsState, XYIntervalSeries>(GpsState.class);
      for (GpsState eventType : GpsState.values()) {
        XYIntervalSeries series = new XYIntervalSeries(eventType);
        seriesMap.put(eventType, series);
        gpsData.addSeries(series);
      }

      Iterator<GpsInfo> iter =
          analysis.getAnalyzerResult().getTraceresult().getGpsInfos().iterator();
      if (iter.hasNext()) {
        while (iter.hasNext()) {
          GpsInfo gpsEvent = iter.next();
          if (gpsEvent.getGpsState() != GpsState.GPS_DISABLED) {
            seriesMap
                .get(gpsEvent.getGpsState())
                .add(
                    gpsEvent.getBeginTimeStamp(),
                    gpsEvent.getBeginTimeStamp(),
                    gpsEvent.getEndTimeStamp(),
                    0.5,
                    0,
                    1);
          }
        }
      }

      XYItemRenderer renderer = plot.getRenderer();
      renderer.setSeriesPaint(gpsData.indexOf(GpsState.GPS_STANDBY), Color.YELLOW);
      renderer.setSeriesPaint(gpsData.indexOf(GpsState.GPS_ACTIVE), new Color(34, 177, 76));

      // Assign ToolTip to renderer
      renderer.setBaseToolTipGenerator(
          new XYToolTipGenerator() {
            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {
              GpsState eventType = (GpsState) gpsData.getSeries(series).getKey();
              return MessageFormat.format(
                  ResourceBundleHelper.getMessageString("gps.tooltip"),
                  dataset.getX(series, item),
                  ResourceBundleHelper.getEnumString(eventType));
            }
          });
    }
    plot.setDataset(gpsData);
  }