예제 #1
0
 private void setStx(Stx stx) {
   if (stx != null) {
     HistogramPanelModel.HistogramConfig config = createHistogramConfig();
     if (config == null) {
       return;
     }
     if (!model.hasStx(config)) {
       model.setStx(config, stx);
     }
     dataset = new XIntervalSeriesCollection();
     final int[] binCounts = stx.getHistogramBins();
     final RasterDataNode raster = getRaster();
     final XIntervalSeries series = new XIntervalSeries(raster.getName());
     final Histogram histogram = stx.getHistogram();
     for (int i = 0; i < binCounts.length; i++) {
       final double xMin = histogram.getBinLowValue(0, i);
       final double xMax =
           i < binCounts.length - 1
               ? histogram.getBinLowValue(0, i + 1)
               : histogram.getHighValue(0);
       series.add(xMin, xMin, xMax, binCounts[i]);
     }
     dataset.addSeries(series);
   }
   handleStxChange();
 }
 @Override
 public void disposeLayer() {
   if (raster != null) {
     raster.getProduct().removeProductNodeListener(maskPNL);
     raster = null;
   }
 }
  private synchronized void updateChildren() {

    // Collect all current mask layers
    LayerFilter layerFilter =
        layer -> {
          PropertySet conf = layer.getConfiguration();
          return conf.isPropertyDefined(MaskLayerType.PROPERTY_NAME_MASK)
              && conf.getValue(MaskLayerType.PROPERTY_NAME_MASK) != null;
        };
    List<Layer> maskLayers =
        LayerUtils.getChildLayers(
            LayerUtils.getRootLayer(this), LayerUtils.SEARCH_DEEP, layerFilter);
    HashMap<Mask, Layer> currentLayers = new HashMap<>();
    for (Layer maskLayer : maskLayers) {
      Mask mask = maskLayer.getConfiguration().getValue(MaskLayerType.PROPERTY_NAME_MASK);
      currentLayers.put(mask, maskLayer);
    }

    // Allign mask layers with available masks
    if (raster != null && getProduct() != null) {
      Mask[] availableMasks = getProduct().getMaskGroup().toArray(new Mask[0]);
      HashSet<Layer> unusedLayers = new HashSet<>(maskLayers);
      for (Mask availableMask : availableMasks) {
        // todo add all mask layers as soon as the masks have been scaled to fit the raster
        if (raster.getRasterSize().equals(availableMask.getRasterSize())) {
          Layer layer = currentLayers.get(availableMask);
          if (layer != null) {
            unusedLayers.remove(layer);
          } else {
            layer = createLayer(availableMask);
            getChildren().add(layer);
          }
          layer.setVisible(raster.getOverlayMaskGroup().contains(availableMask));
        }
      }

      // Remove unused layers
      for (Layer layer : unusedLayers) {
        layer.dispose();
        Layer layerParent = layer.getParent();
        if (layerParent != null) {
          layerParent.getChildren().remove(layer);
        }
      }
    }
  }
예제 #4
0
  @Override
  protected void updateComponents() {
    super.updateComponents();
    if (!isVisible()) {
      return;
    }
    final AttributeDescriptor dataField = scatterPlotModel.dataField;
    xAxisRangeControl.setTitleSuffix(dataField != null ? dataField.getLocalName() : null);

    final RasterDataNode raster = getRaster();
    yAxisRangeControl.setTitleSuffix(raster != null ? raster.getName() : null);

    if (raster != null) {
      final Product product = getProduct();
      final String rasterName = raster.getName();

      final UserSettings userSettings = getUserSettings(product);
      final VectorDataNode userSelectedPointDataSource =
          userSettings.getPointDataSource(rasterName);
      final AttributeDescriptor userSelectedDataField = userSettings.getDataField(rasterName);

      correlativeFieldSelector.updatePointDataSource(product);
      correlativeFieldSelector.updateDataField();

      if (userSelectedPointDataSource != null) {
        correlativeFieldSelector.tryToSelectPointDataSource(userSelectedPointDataSource);
      }
      if (userSelectedDataField != null) {
        correlativeFieldSelector.tryToSelectDataField(userSelectedDataField);
      }
    }

    if (isRasterChanged()) {
      getPlot().getRangeAxis().setLabel(StatisticChartStyling.getAxisLabel(raster, "X", false));
      computeChartDataIfPossible();
    }
  }
 private Product getProduct() {
   return raster.getProduct();
 }