@Override
  public PropertySet createLayerConfig(LayerContext ctx) {
    final PropertyContainer configuration = new PropertyContainer();

    // Mandatory Parameters

    configuration.addProperty(
        Property.create(PROPERTY_NAME_FEATURE_COLLECTION, FeatureCollection.class));
    configuration.getDescriptor(PROPERTY_NAME_FEATURE_COLLECTION).setTransient(true);

    configuration.addProperty(Property.create(PROPERTY_NAME_SLD_STYLE, Style.class));
    configuration.getDescriptor(PROPERTY_NAME_SLD_STYLE).setDomConverter(new StyleDomConverter());
    configuration.getDescriptor(PROPERTY_NAME_SLD_STYLE).setNotNull(true);

    // Optional Parameters

    configuration.addProperty(
        Property.create(PROPERTY_NAME_FEATURE_COLLECTION_CLIP_GEOMETRY, Geometry.class));
    configuration
        .getDescriptor(PROPERTY_NAME_FEATURE_COLLECTION_CLIP_GEOMETRY)
        .setDomConverter(new GeometryDomConverter());

    configuration.addProperty(Property.create(PROPERTY_NAME_FEATURE_COLLECTION_URL, URL.class));

    configuration.addProperty(
        Property.create(PROPERTY_NAME_FEATURE_COLLECTION_CRS, CoordinateReferenceSystem.class));
    configuration
        .getDescriptor(PROPERTY_NAME_FEATURE_COLLECTION_CRS)
        .setDomConverter(new CRSDomConverter());

    return configuration;
  }
 @Override
 public PropertySet createLayerConfig(LayerContext ctx) {
   final PropertyContainer propertyContainer = new PropertyContainer();
   propertyContainer.addProperty(
       new Property(
           new PropertyDescriptor("raster", RasterDataNode.class), new DefaultPropertyAccessor()));
   return propertyContainer;
 }
  private BindingContext createBindingContext() {
    final PropertyContainer container =
        PropertyContainer.createObjectBacked(
            variableItem.variableConfig, new ParameterDescriptorFactory());
    final BindingContext context = new BindingContext(container);

    PropertyDescriptor descriptor = container.getDescriptor(PROPERTY_VARIABLE_NAME);
    descriptor.setDescription("The name for the source band.");
    descriptor.setValidator(new VariableNameValidator());
    container.setDefaultValues();

    return context;
  }
  @Override
  protected void initComponents() {
    SnapApp.getDefault()
        .getSelectionSupport(ProductNode.class)
        .addHandler(
            (oldValue, newValue) -> {
              if (newValue != null) {
                handleMasklessProduct(newValue.getProduct());
              }
            });
    SnapApp.getDefault()
        .getProductManager()
        .addListener(
            new ProductManager.Listener() {
              @Override
              public void productAdded(ProductManager.Event event) {
                // do nothing
              }

              @Override
              public void productRemoved(ProductManager.Event event) {
                model.removeStxFromProduct(event.getProduct());
              }
            });
    model = new HistogramPanelModel();
    xAxisRangeControl = new AxisRangeControl("X-Axis");

    histogramPlotConfig = new HistogramPlotConfig();
    bindingContext = new BindingContext(PropertyContainer.createObjectBacked(histogramPlotConfig));
    configChangeListener = new ConfigChangeListener();
    bindingContext.addPropertyChangeListener(configChangeListener);

    createUI();
    updateComponents();
  }
Beispiel #5
0
  private Map<String, Object> convertParameterMap(
      String operatorName, Map<String, String> parameterMap) throws ValidationException {
    HashMap<String, Object> parameters = new HashMap<String, Object>();
    PropertyContainer container =
        ParameterDescriptorFactory.createMapBackedOperatorPropertyContainer(
            operatorName, parameters);
    // explicitly set default values for putting them into the backing map
    container.setDefaultValues();

    // handle xml parameters
    Object parametersObject = metadataResourceEngine.getVelocityContext().get("parameterFile");
    if (parametersObject instanceof Resource) {
      Resource paramatersResource = (Resource) parametersObject;
      if (paramatersResource.isXml()) {
        OperatorSpiRegistry operatorSpiRegistry = GPF.getDefaultInstance().getOperatorSpiRegistry();
        OperatorSpi operatorSpi = operatorSpiRegistry.getOperatorSpi(operatorName);
        Class<? extends Operator> operatorClass = operatorSpi.getOperatorClass();
        DefaultDomConverter domConverter =
            new DefaultDomConverter(operatorClass, new ParameterDescriptorFactory());

        DomElement parametersElement = createDomElement(paramatersResource.getContent());
        try {
          domConverter.convertDomToValue(parametersElement, container);
        } catch (ConversionException e) {
          String msgPattern = "Can not convert XML parameters for operator '%s'";
          throw new RuntimeException(String.format(msgPattern, operatorName));
        }
      }
    }

    for (Entry<String, String> entry : parameterMap.entrySet()) {
      String paramName = entry.getKey();
      String paramValue = entry.getValue();
      final Property property = container.getProperty(paramName);
      if (property != null) {
        property.setValueFromText(paramValue);
      } else {
        throw new RuntimeException(
            String.format("Parameter '%s' is not known by operator '%s'", paramName, operatorName));
      }
    }
    return parameters;
  }
  public TargetProductSelectorModel(String[] formatNames) {
    propertyContainer = PropertyContainer.createObjectBacked(this);
    propertyContainer.addPropertyChangeListener(
        "saveToFileSelected",
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            if (!(Boolean) evt.getNewValue()) {
              setOpenInAppSelected(true);
            }
          }
        });
    propertyContainer.addPropertyChangeListener(
        "openInAppSelected",
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            if (!(Boolean) evt.getNewValue()) {
              setSaveToFileSelected(true);
            }
          }
        });
    PropertyDescriptor productNameDescriptor = propertyContainer.getDescriptor("productName");
    productNameDescriptor.setValidator(new ProductNameValidator());
    productNameDescriptor.setDisplayName("target product name");

    PropertyDescriptor productDirDescriptor = propertyContainer.getDescriptor("productDir");
    productDirDescriptor.setValidator(new NotNullValidator());
    productDirDescriptor.setDisplayName("target product directory");

    setOpenInAppSelected(true);
    setSaveToFileSelected(true);
    this.formatNames = formatNames;
    if (StringUtils.contains(this.formatNames, ProductIO.DEFAULT_FORMAT_NAME)) {
      setFormatName(ProductIO.DEFAULT_FORMAT_NAME);
    } else {
      setFormatName(formatNames[0]);
    }
  }
  private void editSliderSample(MouseEvent evt, final int sliderIndex) {
    final PropertyContainer vc = new PropertyContainer();
    vc.addProperty(Property.create("sample", getSliderSample(sliderIndex)));
    vc.getDescriptor("sample").setDisplayName("sample");
    vc.getDescriptor("sample").setUnit(getModel().getParameterUnit());
    final ValueRange valueRange;
    if (sliderIndex == 0) {
      valueRange = new ValueRange(Double.NEGATIVE_INFINITY, round(getMaxSliderSample(sliderIndex)));
    } else if (sliderIndex == getSliderCount() - 1) {
      valueRange = new ValueRange(round(getMinSliderSample(sliderIndex)), Double.POSITIVE_INFINITY);
    } else {
      valueRange =
          new ValueRange(
              round(getMinSliderSample(sliderIndex)), round(getMaxSliderSample(sliderIndex)));
    }
    vc.getDescriptor("sample").setValueRange(valueRange);

    final BindingContext ctx = new BindingContext(vc);
    final NumberFormatter formatter = new NumberFormatter(new DecimalFormat("#0.0#"));
    formatter.setValueClass(Double.class); // to ensure that double values are returned
    final JFormattedTextField field = new JFormattedTextField(formatter);
    field.setColumns(11);
    field.setHorizontalAlignment(JFormattedTextField.RIGHT);
    ctx.bind("sample", field);

    showPopup(evt, field);

    ctx.addPropertyChangeListener(
        "sample",
        pce -> {
          hidePopup();
          setSliderSample(sliderIndex, (Double) ctx.getBinding("sample").getPropertyValue());
          computeZoomInToSliderLimits();
          applyChanges();
        });
  }
  ScatterPlotPanel(TopComponent parentDialog, String helpId) {
    super(parentDialog, helpId, CHART_TITLE, false);
    userSettingsMap = new HashMap<>();
    productRemovedListener =
        new ProductManager.Listener() {
          @Override
          public void productAdded(ProductManager.Event event) {}

          @Override
          public void productRemoved(ProductManager.Event event) {
            final UserSettings userSettings = userSettingsMap.remove(event.getProduct());
            if (userSettings != null) {
              userSettings.dispose();
            }
          }
        };

    xAxisRangeControl = new AxisRangeControl("X-Axis");
    yAxisRangeControl = new AxisRangeControl("Y-Axis");
    scatterPlotModel = new ScatterPlotModel();
    bindingContext = new BindingContext(PropertyContainer.createObjectBacked(scatterPlotModel));
    scatterpointsDataset = new XYIntervalSeriesCollection();
    acceptableDeviationDataset = new XYIntervalSeriesCollection();
    regressionDataset = new XYIntervalSeriesCollection();
    r2Annotation = new XYTitleAnnotation(0, 0, new TextTitle(""));
    chart =
        ChartFactory.createScatterPlot(
            CHART_TITLE, "", "", scatterpointsDataset, PlotOrientation.VERTICAL, true, true, false);
    chart.getXYPlot().setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    createDomainAxisChangeListener();
    final PropertyChangeListener userSettingsUpdateListener =
        evt -> {
          if (getRaster() != null) {
            final VectorDataNode pointDataSourceValue = scatterPlotModel.pointDataSource;
            final AttributeDescriptor dataFieldValue = scatterPlotModel.dataField;
            final UserSettings userSettings = getUserSettings(getRaster().getProduct());
            userSettings.set(getRaster().getName(), pointDataSourceValue, dataFieldValue);
          }
        };

    bindingContext.addPropertyChangeListener(PROPERTY_NAME_DATA_FIELD, userSettingsUpdateListener);
    bindingContext.addPropertyChangeListener(
        PROPERTY_NAME_POINT_DATA_SOURCE, userSettingsUpdateListener);
  }
Beispiel #9
0
 AxisRangeControl(String axisName) {
   this.axisName = axisName;
   PropertySet propertyContainer = PropertyContainer.createObjectBacked(new Model());
   bindingContext = new BindingContext(propertyContainer);
 }
 private void setValueContainerValue(String name, Object value) {
   propertyContainer.setValue(name, value);
 }
Beispiel #11
0
  @Override
  protected void initComponents() {
    getAlternativeView().initComponents();
    dataset = new XYIntervalSeriesCollection();
    this.chart =
        ChartFactory.createXYLineChart(
            CHART_TITLE,
            "Path in pixels",
            DEFAULT_SAMPLE_DATASET_NAME,
            dataset,
            PlotOrientation.VERTICAL,
            true,
            true,
            false);
    final XYPlot plot = chart.getXYPlot();

    deviationRenderer = new DeviationRenderer();
    deviationRenderer.setUseFillPaint(true);
    deviationRenderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator());
    deviationRenderer.setSeriesLinesVisible(0, true);
    deviationRenderer.setSeriesShapesVisible(0, false);
    deviationRenderer.setSeriesStroke(0, new BasicStroke(1.0f));
    deviationRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    deviationRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);

    pointRenderer = new XYErrorRenderer();
    pointRenderer.setUseFillPaint(true);
    pointRenderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator());
    pointRenderer.setSeriesLinesVisible(0, false);
    pointRenderer.setSeriesShapesVisible(0, true);
    pointRenderer.setSeriesStroke(0, new BasicStroke(1.0f));
    pointRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    pointRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);
    pointRenderer.setSeriesShape(0, StatisticChartStyling.SAMPLE_DATA_POINT_SHAPE);

    configureRendererForCorrelativeData(deviationRenderer);
    configureRendererForCorrelativeData(pointRenderer);

    plot.setNoDataMessage(NO_DATA_MESSAGE);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    plot.setRenderer(deviationRenderer);

    final AxisChangeListener axisListener =
        new AxisChangeListener() {
          @Override
          public void axisChanged(AxisChangeEvent event) {
            adjustAxisControlComponents();
          }
        };

    final ValueAxis domainAxis = plot.getDomainAxis();
    final ValueAxis rangeAxis = plot.getRangeAxis();
    // allow transfer from bounds into min/max fields, if auto min/maxis enabled
    domainAxis.setAutoRange(true);
    rangeAxis.setAutoRange(true);

    domainAxis.addChangeListener(axisListener);
    rangeAxis.addChangeListener(axisListener);

    intervalMarkers = new HashSet<IntervalMarker>();

    xAxisRangeControl = new AxisRangeControl("X-Axis");
    yAxisRangeControl = new AxisRangeControl("Y-Axis");

    final PropertyChangeListener changeListener =
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(PROPERTY_NAME_MARK_SEGMENTS)) {
              updateDataSet();
            }
            if (evt.getPropertyName().equals(PROPERTY_NAME_LOG_SCALED)) {
              updateScalingOfYAxis();
            }
            updateUIState();
          }
        };
    xAxisRangeControl.getBindingContext().addPropertyChangeListener(changeListener);
    xAxisRangeControl
        .getBindingContext()
        .getPropertySet()
        .addProperty(Property.create(PROPERTY_NAME_MARK_SEGMENTS, false));
    xAxisRangeControl
        .getBindingContext()
        .getPropertySet()
        .getDescriptor(PROPERTY_NAME_MARK_SEGMENTS)
        .setDescription("Toggle whether to mark segments");

    yAxisRangeControl.getBindingContext().addPropertyChangeListener(changeListener);
    yAxisRangeControl
        .getBindingContext()
        .getPropertySet()
        .addProperty(Property.create(PROPERTY_NAME_LOG_SCALED, false));
    yAxisRangeControl
        .getBindingContext()
        .getPropertySet()
        .getDescriptor(PROPERTY_NAME_LOG_SCALED)
        .setDescription("Toggle whether to use a logarithmic axis");

    dataSourceConfig = new DataSourceConfig();
    final BindingContext bindingContext =
        new BindingContext(PropertyContainer.createObjectBacked(dataSourceConfig));

    JPanel middlePanel = createMiddlePanel(bindingContext);
    createUI(createChartPanel(chart), middlePanel, bindingContext);

    isInitialized = true;

    updateComponents();
  }
Beispiel #12
0
 public static PropertySet createLayerConfig() {
   final PropertyContainer configuration = new PropertyContainer();
   configuration.addProperty(
       Property.create(VectorDataLayerType.PROPERTY_NAME_VECTOR_DATA, String.class));
   return configuration;
 }