Beispiel #1
0
  private void updateUIState() {
    if (!isInitialized) {
      return;
    }

    xAxisRangeControl
        .getBindingContext()
        .setComponentsEnabled(
            PROPERTY_NAME_MARK_SEGMENTS,
            profileData != null && profileData.getShapeVertices().length > 2);
    xAxisRangeControl.setComponentsEnabled(profileData != null);
    yAxisRangeControl.setComponentsEnabled(profileData != null);
    adjustPlotAxes();

    if (dataSourceConfig.computeInBetweenPoints) {
      chart.getXYPlot().setRenderer(deviationRenderer);
    } else {
      chart.getXYPlot().setRenderer(pointRenderer);
    }

    chart
        .getXYPlot()
        .getRangeAxis()
        .setLabel(
            StatisticChartStyling.getAxisLabel(getRaster(), DEFAULT_SAMPLE_DATASET_NAME, false));

    boolean markSegments =
        (Boolean)
            (xAxisRangeControl
                .getBindingContext()
                .getPropertySet()
                .getValue(PROPERTY_NAME_MARK_SEGMENTS));
    if (markSegments && profileData != null && profileData.getNumShapeVertices() > 1) {
      final int[] shapeVertexIndexes = profileData.getShapeVertexIndexes();
      removeIntervalMarkers();
      for (int i = 0; i < shapeVertexIndexes.length - 1; i++) {
        if (i % 2 != 0) {
          final IntervalMarker marker =
              new IntervalMarker(shapeVertexIndexes[i], shapeVertexIndexes[i + 1]);
          marker.setPaint(new Color(120, 122, 125));
          marker.setAlpha(0.3F);
          chart.getXYPlot().addDomainMarker(marker, Layer.BACKGROUND);
          intervalMarkers.add(marker);
        }
      }
    } else {
      removeIntervalMarkers();
    }

    pointDataSourceEnablement.apply();
    dataFieldEnablement.apply();
  }
Beispiel #2
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);
    }
  }