Esempio n. 1
0
 private void computeChartDataIfPossible() {
   // need to do this later: all GUI events must be processed first in order to get the correct
   // state
   SwingUtilities.invokeLater(
       () -> {
         if (scatterPlotModel.pointDataSource != null
             && scatterPlotModel.dataField != null
             && scatterPlotModel.pointDataSource.getFeatureCollection() != null
             && scatterPlotModel.pointDataSource.getFeatureCollection().features() != null
             && scatterPlotModel.pointDataSource.getFeatureCollection().features().hasNext()
             && scatterPlotModel.pointDataSource.getFeatureCollection().features().next() != null
             && scatterPlotModel
                     .pointDataSource
                     .getFeatureCollection()
                     .features()
                     .next()
                     .getAttribute(scatterPlotModel.dataField.getLocalName())
                 != null
             && getRaster() != null) {
           compute(scatterPlotModel.useRoiMask ? scatterPlotModel.roiMask : null);
         } else {
           scatterpointsDataset.removeAllSeries();
           acceptableDeviationDataset.removeAllSeries();
           regressionDataset.removeAllSeries();
           getPlot().removeAnnotation(r2Annotation);
           computedDatas = null;
         }
       });
 }
Esempio n. 2
0
 private void finishScalingUpdate(
     AxisRangeControl axisRangeControl, ValueAxis newAxis, ValueAxis oldAxis) {
   if (axisRangeControl.isAutoMinMax()) {
     newAxis.setAutoRange(false);
     acceptableDeviationDataset.removeAllSeries();
     regressionDataset.removeAllSeries();
     getPlot().removeAnnotation(r2Annotation);
     newAxis.setAutoRange(true);
     axisRangeControl.adjustComponents(newAxis, 3);
     newAxis.setAutoRange(false);
     computeRegressionAndAcceptableDeviationData();
   } else {
     newAxis.setAutoRange(false);
     newAxis.setRange(oldAxis.getRange());
   }
 }
Esempio n. 3
0
 private void computeRegressionAndAcceptableDeviationData() {
   acceptableDeviationDataset.removeAllSeries();
   regressionDataset.removeAllSeries();
   getPlot().removeAnnotation(r2Annotation);
   if (computedDatas != null) {
     final ValueAxis domainAxis = getPlot().getDomainAxis();
     final double min = domainAxis.getLowerBound();
     final double max = domainAxis.getUpperBound();
     acceptableDeviationDataset.addSeries(computeAcceptableDeviationData(min, max));
     if (scatterPlotModel.showRegressionLine) {
       final XYIntervalSeries series = computeRegressionData(min, max);
       if (series != null) {
         regressionDataset.addSeries(series);
         computeCoefficientOfDetermination();
       }
     }
   }
 }
Esempio n. 4
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);
  }
Esempio n. 5
0
  private void updateDataSet() {
    if (!isInitialized) {
      return;
    }

    dataset.removeAllSeries();

    double dx = 0.5 * dataSourceConfig.boxSize;

    if (profileData != null) {
      final float[] sampleValues = profileData.getSampleValues();
      final float[] sampleSigmas = profileData.getSampleSigmas();
      XYIntervalSeries series =
          new XYIntervalSeries(
              getRaster() != null ? getRaster().getName() : DEFAULT_SAMPLE_DATASET_NAME);
      for (int x = 0; x < sampleValues.length; x++) {
        final float y = sampleValues[x];
        final float dy = sampleSigmas[x];
        series.add(x, x - dx, x + dx, y, y - dy, y + dy);
      }
      dataset.addSeries(series);

      if (dataSourceConfig.useCorrelativeData
          && dataSourceConfig.pointDataSource != null
          && dataSourceConfig.dataField != null) {

        XYIntervalSeries corrSeries =
            new XYIntervalSeries(
                getCorrelativeDataLabel(
                    dataSourceConfig.pointDataSource, dataSourceConfig.dataField));
        int[] shapeVertexIndexes = profileData.getShapeVertexIndexes();
        SimpleFeature[] simpleFeatures =
            dataSourceConfig.pointDataSource.getFeatureCollection().toArray(new SimpleFeature[0]);

        if (shapeVertexIndexes.length == simpleFeatures.length) {
          int fieldIndex =
              getAttributeIndex(dataSourceConfig.pointDataSource, dataSourceConfig.dataField);
          if (fieldIndex != -1) {
            for (int i = 0; i < simpleFeatures.length; i++) {
              Number attribute = (Number) simpleFeatures[i].getAttribute(fieldIndex);
              if (attribute != null) {
                final double x = shapeVertexIndexes[i];
                final double y = attribute.doubleValue();
                corrSeries.add(x, x, x, y, y, y);
              }
            }
            dataset.addSeries(corrSeries);
          }
        } else {
          System.out.println("Weird things happened:");
          System.out.println("  shapeVertexIndexes.length = " + shapeVertexIndexes.length);
          System.out.println("  simpleFeatures.length     = " + simpleFeatures.length);
        }
      }

      profilePlotDisplay.restoreAutoBounds();
      xAxisRangeControl
          .getBindingContext()
          .setComponentsEnabled(
              PROPERTY_NAME_MARK_SEGMENTS, profileData.getShapeVertices().length > 2);
    }
  }