Exemplo n.º 1
0
  @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();
  }
Exemplo n.º 2
0
  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;
  }
Exemplo n.º 3
0
  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);
  }
Exemplo n.º 4
0
  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]);
    }
  }
Exemplo n.º 5
0
 AxisRangeControl(String axisName) {
   this.axisName = axisName;
   PropertySet propertyContainer = PropertyContainer.createObjectBacked(new Model());
   bindingContext = new BindingContext(propertyContainer);
 }
Exemplo n.º 6
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();
  }