@Override
  protected void configure(BindingContext context) {
    Enablement enablementAvgGridSize =
        context.bindEnabledState(
            GraticuleLayerType.PROPERTY_NAME_RES_PIXELS, true,
            GraticuleLayerType.PROPERTY_NAME_RES_AUTO, true);
    Enablement enablementLatStep =
        context.bindEnabledState(
            GraticuleLayerType.PROPERTY_NAME_RES_LAT, true,
            GraticuleLayerType.PROPERTY_NAME_RES_AUTO, false);
    Enablement enablementLonStep =
        context.bindEnabledState(
            GraticuleLayerType.PROPERTY_NAME_RES_LON, true,
            GraticuleLayerType.PROPERTY_NAME_RES_AUTO, false);

    context
        .getPropertySet()
        .getProperty(GraticuleLayerType.PROPERTY_NAME_RES_AUTO)
        .addPropertyChangeListener(
            evt -> {
              enablementAvgGridSize.apply();
              enablementLatStep.apply();
              enablementLonStep.apply();
            });

    Enablement enablementTextBgTransparency =
        context.bindEnabledState(
            GraticuleLayerType.PROPERTY_NAME_TEXT_BG_TRANSPARENCY, true,
            GraticuleLayerType.PROPERTY_NAME_TEXT_ENABLED, true);

    context
        .getPropertySet()
        .getProperty(GraticuleLayerType.PROPERTY_NAME_TEXT_ENABLED)
        .addPropertyChangeListener(
            evt -> {
              enablementTextBgTransparency.apply();
              for (JComponent component : textFgColorComponents) {
                component.setEnabled(((Boolean) evt.getNewValue()));
              }
              for (JComponent component : textBgColorComponents) {
                component.setEnabled(((Boolean) evt.getNewValue()));
              }
            });

    for (JComponent component : textFgColorComponents) {
      component.setEnabled(true);
    }
    for (JComponent component : textBgColorComponents) {
      component.setEnabled(true);
    }
  }
  private JPanel createOptionsPanel() {
    final JLabel numBinsLabel = new JLabel("#Bins:");
    JTextField numBinsField = new JTextField(Integer.toString(NUM_BINS_DEFAULT));
    numBinsField.setPreferredSize(new Dimension(50, numBinsField.getPreferredSize().height));
    final JCheckBox histoLogCheck = new JCheckBox("Log10 scaled bins");

    histoLogCheck.addActionListener(configChangeListener);

    bindingContext
        .getPropertySet()
        .getDescriptor(PROPERTY_NAME_NUM_BINS)
        .setDescription("Set the number of bins in the histogram");
    bindingContext
        .getPropertySet()
        .getDescriptor(PROPERTY_NAME_NUM_BINS)
        .setValueRange(new ValueRange(2.0, 2048.0));
    bindingContext
        .getPropertySet()
        .getDescriptor(PROPERTY_NAME_NUM_BINS)
        .setDefaultValue(NUM_BINS_DEFAULT);
    bindingContext.bind(PROPERTY_NAME_NUM_BINS, numBinsField);

    bindingContext
        .getPropertySet()
        .getDescriptor(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM)
        .setDescription("Use log-10 scaled values for computation of histogram");
    bindingContext
        .getPropertySet()
        .getDescriptor(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM)
        .setDefaultValue(false);
    bindingContext.bind(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM, histoLogCheck);
    log10HistEnablement =
        bindingContext.bindEnabledState(
            PROPERTY_NAME_LOGARITHMIC_HISTOGRAM,
            true,
            new Enablement.Condition() {
              @Override
              public boolean evaluate(BindingContext bindingContext) {
                return getRaster() != null && getRaster().getStx().getMaximum() > 0;
              }
            });

    PropertyChangeListener logChangeListener = new AxisControlChangeListener();

    xAxisRangeControl.getBindingContext().addPropertyChangeListener(logChangeListener);
    xAxisRangeControl
        .getBindingContext()
        .getPropertySet()
        .addProperty(
            bindingContext.getPropertySet().getProperty(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM));
    xAxisRangeControl
        .getBindingContext()
        .getPropertySet()
        .addProperty(bindingContext.getPropertySet().getProperty(PROPERTY_NAME_LOG_SCALED));
    xAxisRangeControl
        .getBindingContext()
        .getPropertySet()
        .getDescriptor(PROPERTY_NAME_LOG_SCALED)
        .setDescription("Toggle whether to use a logarithmic x-axis");
    log10AxisEnablement =
        xAxisRangeControl
            .getBindingContext()
            .bindEnabledState(
                PROPERTY_NAME_LOG_SCALED,
                true,
                new Enablement.Condition() {
                  @Override
                  public boolean evaluate(BindingContext bindingContext) {
                    HistogramPanelModel.HistogramConfig currentConfig = createHistogramConfig();
                    boolean hasStx = model.hasStx(currentConfig);
                    // log10 xAxis is enabled when current histogram exists and is NOT log10 scaled
                    return dataset != null
                        && hasStx
                        && !model.getStx(currentConfig).isLogHistogram();
                  }
                });

    JPanel dataSourceOptionsPanel = GridBagUtils.createPanel();
    GridBagConstraints dataSourceOptionsConstraints =
        GridBagUtils.createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2");
    GridBagUtils.addToPanel(
        dataSourceOptionsPanel,
        new JLabel(" "),
        dataSourceOptionsConstraints,
        "gridwidth=2,gridy=0,gridx=0,weightx=0");
    GridBagUtils.addToPanel(
        dataSourceOptionsPanel,
        numBinsLabel,
        dataSourceOptionsConstraints,
        "insets.top=2,insets.left=4,gridwidth=1,gridy=1,gridx=0,weightx=1");
    GridBagUtils.addToPanel(
        dataSourceOptionsPanel,
        numBinsField,
        dataSourceOptionsConstraints,
        "insets.top=0,insets.left=0,insets.right=2,gridwidth=1,gridy=1,gridx=1");
    GridBagUtils.addToPanel(
        dataSourceOptionsPanel,
        histoLogCheck,
        dataSourceOptionsConstraints,
        "insets.right=0,gridwidth=2,gridy=2,gridx=0");

    xAxisRangeControl
        .getBindingContext()
        .bind(PROPERTY_NAME_LOG_SCALED, new JCheckBox("Log10 scaled"));
    xAxisRangeControl
        .getBindingContext()
        .addPropertyChangeListener(
            PROPERTY_NAME_LOG_SCALED,
            new PropertyChangeListener() {
              @Override
              public void propertyChange(PropertyChangeEvent evt) {
                ValueAxis oldAxis = chart.getXYPlot().getDomainAxis();
                ValueAxis newAxis =
                    StatisticChartStyling.updateScalingOfAxis(
                        (Boolean) evt.getNewValue(), oldAxis, true);
                chart.getXYPlot().setDomainAxis(newAxis);
              }
            });

    JPanel displayOptionsPanel = GridBagUtils.createPanel();
    GridBagConstraints displayOptionsConstraints =
        GridBagUtils.createConstraints("anchor=SOUTH,fill=HORIZONTAL,weightx=1");
    GridBagUtils.addToPanel(
        displayOptionsPanel, xAxisRangeControl.getPanel(), displayOptionsConstraints, "gridy=2");

    JPanel optionsPanel = GridBagUtils.createPanel();
    GridBagConstraints gbc =
        GridBagUtils.createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1");
    GridBagUtils.addToPanel(optionsPanel, dataSourceOptionsPanel, gbc, "gridy=0");
    GridBagUtils.addToPanel(optionsPanel, new JPanel(), gbc, "gridy=1,fill=VERTICAL,weighty=1");
    GridBagUtils.addToPanel(
        optionsPanel, displayOptionsPanel, gbc, "gridy=2,fill=HORIZONTAL,weighty=0");
    GridBagUtils.addToPanel(optionsPanel, new JPanel(), gbc, "gridy=3,fill=VERTICAL,weighty=1");
    GridBagUtils.addToPanel(
        optionsPanel,
        xAxisRangeControl
            .getBindingContext()
            .getBinding(PROPERTY_NAME_LOG_SCALED)
            .getComponents()[0],
        gbc,
        "gridy=4");
    return optionsPanel;
  }
  private JPanel createInputParameterPanel() {
    final PropertyDescriptor boxSizeDescriptor =
        bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_BOX_SIZE);
    boxSizeDescriptor.setValueRange(new ValueRange(1, 101));
    boxSizeDescriptor.setAttribute("stepSize", 2);
    boxSizeDescriptor.setValidator(
        (property, value) -> {
          if (((Number) value).intValue() % 2 == 0) {
            throw new ValidationException("Only odd values allowed as box size.");
          }
        });
    final JSpinner boxSizeSpinner = new JSpinner();
    bindingContext.bind(PROPERTY_NAME_BOX_SIZE, boxSizeSpinner);

    final JPanel boxSizePanel = new JPanel(new BorderLayout(5, 3));
    boxSizePanel.add(new JLabel("Box size:"), BorderLayout.WEST);
    boxSizePanel.add(boxSizeSpinner);

    correlativeFieldSelector = new CorrelativeFieldSelector(bindingContext);

    final JPanel pointDataSourcePanel = new JPanel(new BorderLayout(5, 3));
    pointDataSourcePanel.add(correlativeFieldSelector.pointDataSourceLabel, BorderLayout.NORTH);
    pointDataSourcePanel.add(correlativeFieldSelector.pointDataSourceList);

    final JPanel pointDataFieldPanel = new JPanel(new BorderLayout(5, 3));
    pointDataFieldPanel.add(correlativeFieldSelector.dataFieldLabel, BorderLayout.NORTH);
    pointDataFieldPanel.add(correlativeFieldSelector.dataFieldList);

    final JCheckBox xLogCheck = new JCheckBox("Log10 scaled");
    bindingContext.bind(PROPERTY_NAME_X_AXIS_LOG_SCALED, xLogCheck);
    final JPanel xAxisOptionPanel = new JPanel(new BorderLayout());
    xAxisOptionPanel.add(xAxisRangeControl.getPanel());
    xAxisOptionPanel.add(xLogCheck, BorderLayout.SOUTH);

    final JCheckBox yLogCheck = new JCheckBox("Log10 scaled");
    bindingContext.bind(PROPERTY_NAME_Y_AXIS_LOG_SCALED, yLogCheck);
    final JPanel yAxisOptionPanel = new JPanel(new BorderLayout());
    yAxisOptionPanel.add(yAxisRangeControl.getPanel());
    yAxisOptionPanel.add(yLogCheck, BorderLayout.SOUTH);

    final JCheckBox acceptableCheck = new JCheckBox("Show tolerance range");
    JLabel fieldPrefix = new JLabel("+/-");
    final JTextField acceptableField = new JTextField();
    acceptableField.setPreferredSize(new Dimension(40, acceptableField.getPreferredSize().height));
    acceptableField.setHorizontalAlignment(JTextField.RIGHT);
    final JLabel percentLabel = new JLabel(" %");
    bindingContext.bind(PROPERTY_NAME_SHOW_ACCEPTABLE_DEVIATION, acceptableCheck);
    bindingContext.bind(PROPERTY_NAME_ACCEPTABLE_DEVIATION, acceptableField);
    bindingContext.getBinding(PROPERTY_NAME_ACCEPTABLE_DEVIATION).addComponent(percentLabel);
    bindingContext.getBinding(PROPERTY_NAME_ACCEPTABLE_DEVIATION).addComponent(fieldPrefix);
    bindingContext.bindEnabledState(
        PROPERTY_NAME_ACCEPTABLE_DEVIATION, true,
        PROPERTY_NAME_SHOW_ACCEPTABLE_DEVIATION, true);

    final JPanel confidencePanel = GridBagUtils.createPanel();
    GridBagConstraints confidencePanelConstraints =
        GridBagUtils.createConstraints(
            "anchor=NORTHWEST,fill=HORIZONTAL,insets.top=5,weighty=0,weightx=1");
    GridBagUtils.addToPanel(
        confidencePanel, acceptableCheck, confidencePanelConstraints, "gridy=0,gridwidth=3");
    GridBagUtils.addToPanel(
        confidencePanel,
        fieldPrefix,
        confidencePanelConstraints,
        "weightx=0,insets.left=22,gridy=1,gridx=0,insets.top=4,gridwidth=1");
    GridBagUtils.addToPanel(
        confidencePanel,
        acceptableField,
        confidencePanelConstraints,
        "weightx=1,gridx=1,insets.left=2,insets.top=2");
    GridBagUtils.addToPanel(
        confidencePanel,
        percentLabel,
        confidencePanelConstraints,
        "weightx=0,gridx=2,insets.left=0,insets.top=4");

    final JCheckBox regressionCheck = new JCheckBox("Show regression line");
    bindingContext.bind(PROPERTY_NAME_SHOW_REGRESSION_LINE, regressionCheck);

    // UI arrangement

    JPanel middlePanel = GridBagUtils.createPanel();
    GridBagConstraints middlePanelConstraints =
        GridBagUtils.createConstraints(
            "anchor=NORTHWEST,fill=HORIZONTAL,insets.top=6,weighty=0,weightx=1");
    GridBagUtils.addToPanel(
        middlePanel, boxSizePanel, middlePanelConstraints, "gridy=0,insets.left=6");
    GridBagUtils.addToPanel(middlePanel, pointDataSourcePanel, middlePanelConstraints, "gridy=1");
    GridBagUtils.addToPanel(middlePanel, pointDataFieldPanel, middlePanelConstraints, "gridy=2");
    GridBagUtils.addToPanel(
        middlePanel, xAxisOptionPanel, middlePanelConstraints, "gridy=3,insets.left=0");
    GridBagUtils.addToPanel(middlePanel, yAxisOptionPanel, middlePanelConstraints, "gridy=4");
    GridBagUtils.addToPanel(
        middlePanel, new JSeparator(), middlePanelConstraints, "gridy=5,insets.left=4");
    GridBagUtils.addToPanel(
        middlePanel,
        confidencePanel,
        middlePanelConstraints,
        "gridy=6,fill=HORIZONTAL,insets.left=-4");
    GridBagUtils.addToPanel(
        middlePanel,
        regressionCheck,
        middlePanelConstraints,
        "gridy=7,insets.left=-4,insets.top=8");

    return middlePanel;
  }
  /**
   * Creates the UI component. The enable state of the UI is controlled via the parameter <code>
   * disableUIProperty</code>. If it matches the value of the property provided in the constructor,
   * the UI will be disabled.
   *
   * @param disableUIProperty Controls the enable state of the UI.
   * @return The UI component.
   */
  public JPanel createBoundsInputPanel(boolean disableUIProperty) {
    final TableLayout layout = new TableLayout(9);
    layout.setTableAnchor(TableLayout.Anchor.WEST);
    layout.setTableFill(TableLayout.Fill.BOTH);
    layout.setTableWeightX(1.0);
    layout.setTableWeightY(1.0);
    layout.setTablePadding(3, 3);
    layout.setColumnWeightX(0, 0.0);
    layout.setColumnWeightX(1, 1.0);
    layout.setColumnWeightX(2, 0.0);
    layout.setColumnWeightX(3, 0.0);
    layout.setColumnWeightX(4, 1.0);
    layout.setColumnWeightX(5, 0.0);
    layout.setColumnWeightX(6, 0.0);
    layout.setColumnWeightX(7, 1.0);
    layout.setColumnWeightX(8, 0.0);
    layout.setColumnPadding(2, new Insets(3, 0, 3, 12));
    layout.setColumnPadding(5, new Insets(3, 0, 3, 12));
    final JPanel panel = new JPanel(layout);
    final DoubleFormatter doubleFormatter = new DoubleFormatter("###0.0##");
    pixelXUnit = new JLabel(NonSI.DEGREE_ANGLE.toString());
    pixelYUnit = new JLabel(NonSI.DEGREE_ANGLE.toString());

    panel.add(new JLabel("West:"));
    final JFormattedTextField westLonField = new JFormattedTextField(doubleFormatter);
    westLonField.setHorizontalAlignment(JTextField.RIGHT);
    bindingContext.bind(PROPERTY_WEST_BOUND, westLonField);
    bindingContext.bindEnabledState(
        PROPERTY_WEST_BOUND, false, enablePropertyKey, disableUIProperty);
    panel.add(westLonField);
    panel.add(new JLabel(NonSI.DEGREE_ANGLE.toString()));
    panel.add(new JLabel("East:"));
    final JFormattedTextField eastLonField = new JFormattedTextField(doubleFormatter);
    eastLonField.setHorizontalAlignment(JTextField.RIGHT);
    bindingContext.bind(PROPERTY_EAST_BOUND, eastLonField);
    bindingContext.bindEnabledState(
        PROPERTY_EAST_BOUND, false, enablePropertyKey, disableUIProperty);
    panel.add(eastLonField);
    panel.add(new JLabel(NonSI.DEGREE_ANGLE.toString()));
    panel.add(new JLabel("Pixel size X:"));
    pixelSizeXField = new JFormattedTextField(doubleFormatter);
    pixelSizeXField.setHorizontalAlignment(JTextField.RIGHT);
    bindingContext.bind(PROPERTY_PIXEL_SIZE_X, pixelSizeXField);
    bindingContext.bindEnabledState(
        PROPERTY_PIXEL_SIZE_X, false, enablePropertyKey, disableUIProperty);
    panel.add(pixelSizeXField);
    panel.add(pixelXUnit);

    panel.add(new JLabel("North:"));
    final JFormattedTextField northLatField = new JFormattedTextField(doubleFormatter);
    northLatField.setHorizontalAlignment(JTextField.RIGHT);
    bindingContext.bind(PROPERTY_NORTH_BOUND, northLatField);
    bindingContext.bindEnabledState(
        PROPERTY_NORTH_BOUND, false, enablePropertyKey, disableUIProperty);
    panel.add(northLatField);
    panel.add(new JLabel(NonSI.DEGREE_ANGLE.toString()));
    panel.add(new JLabel("South:"));
    final JFormattedTextField southLatField = new JFormattedTextField(doubleFormatter);
    southLatField.setHorizontalAlignment(JTextField.RIGHT);
    bindingContext.bind(PROPERTY_SOUTH_BOUND, southLatField);
    bindingContext.bindEnabledState(
        PROPERTY_SOUTH_BOUND, false, enablePropertyKey, disableUIProperty);
    panel.add(southLatField);
    panel.add(new JLabel(NonSI.DEGREE_ANGLE.toString()));
    panel.add(new JLabel("Pixel size Y:"));
    pixelSizeYField = new JFormattedTextField(doubleFormatter);
    pixelSizeYField.setHorizontalAlignment(JTextField.RIGHT);
    bindingContext.bind(PROPERTY_PIXEL_SIZE_Y, pixelSizeYField);
    bindingContext.bindEnabledState(
        PROPERTY_PIXEL_SIZE_Y, false, enablePropertyKey, disableUIProperty);
    panel.add(pixelSizeYField);
    panel.add(pixelYUnit);
    bindingContext.addProblemListener(
        new BindingProblemListener() {

          @Override
          public void problemReported(BindingProblem problem, BindingProblem ignored) {
            final String propertyName = problem.getBinding().getPropertyName();
            final boolean invalidBoundSet =
                propertyName.equals(PROPERTY_NORTH_BOUND)
                    || propertyName.equals(PROPERTY_EAST_BOUND)
                    || propertyName.equals(PROPERTY_SOUTH_BOUND)
                    || propertyName.equals(PROPERTY_WEST_BOUND);
            if (invalidBoundSet) {
              resetTextField(problem);
            }
          }

          private void resetTextField(BindingProblem problem) {
            problem.getBinding().getComponentAdapter().adjustComponents();
          }

          @Override
          public void problemCleared(BindingProblem ignored) {
            // do nothing
          }
        });
    return panel;
  }
Beispiel #5
0
  private JPanel createPanel() {
    final JCheckBox autoMinMaxBox = new JCheckBox("Auto min/max");
    final JLabel minLabel = new JLabel("Min:");
    final JLabel maxLabel = new JLabel("Max:");
    final JTextField minTextField = new JTextField();
    final JTextField maxTextField = new JTextField();

    final JPanel panel = GridBagUtils.createPanel();
    final GridBagConstraints gbc = GridBagUtils.createConstraints("anchor=WEST,fill=HORIZONTAL");

    GridBagUtils.setAttributes(gbc, "gridwidth=2,insets.top=2,weightx=1");

    titledSeparator = new TitledSeparator(axisName, SwingConstants.CENTER);
    GridBagUtils.addToPanel(panel, titledSeparator, gbc, "gridy=0,insets.right=-2");
    GridBagUtils.addToPanel(panel, autoMinMaxBox, gbc, "gridy=1");

    GridBagUtils.setAttributes(gbc, "gridwidth=1");

    GridBagUtils.addToPanel(panel, minLabel, gbc, "insets.left=22,gridx=0,gridy=2,weightx=0");
    GridBagUtils.addToPanel(panel, minTextField, gbc, "insets=2,gridx=1,gridy=2,weightx=1");

    GridBagUtils.addToPanel(panel, maxLabel, gbc, "insets.left=22,gridx=0,gridy=3,weightx=0");
    GridBagUtils.addToPanel(panel, maxTextField, gbc, "insets=2,gridx=1,gridy=3,weightx=1");

    bindingContext.bind("autoMinMax", autoMinMaxBox);
    bindingContext.bind("min", minTextField);
    bindingContext.bind("max", maxTextField);

    bindingContext
        .getPropertySet()
        .getDescriptor("min")
        .setDescription("Minimum display value for " + axisName);
    bindingContext
        .getPropertySet()
        .getDescriptor("max")
        .setDescription("Maximum display value for " + axisName);

    bindingContext
        .getPropertySet()
        .getDescriptor("min")
        .setValidator(
            new Validator() {
              @Override
              public void validateValue(Property property, Object value)
                  throws ValidationException {
                final Double max = bindingContext.getPropertySet().getValue("max");
                if ((Double) value >= max) {
                  throw new ValidationException("min value has to be less than " + max);
                }
              }
            });

    bindingContext
        .getPropertySet()
        .getDescriptor("max")
        .setValidator(
            new Validator() {
              @Override
              public void validateValue(Property property, Object value)
                  throws ValidationException {
                final Double min = bindingContext.getPropertySet().getValue("min");
                if ((Double) value <= min) {
                  throw new ValidationException("max value has to be greater than " + min);
                }
              }
            });

    bindingContext.getBinding("min").addComponent(minLabel);
    bindingContext.getBinding("max").addComponent(maxLabel);

    bindingContext.bindEnabledState("min", true, "autoMinMax", false);
    bindingContext.bindEnabledState("max", true, "autoMinMax", false);

    return panel;
  }
Beispiel #6
0
  protected JPanel createMiddlePanel(BindingContext bindingContext) {
    final JLabel boxSizeLabel = new JLabel("Box size: ");
    final JSpinner boxSizeSpinner = new JSpinner();
    final JCheckBox computeInBetweenPoints = new JCheckBox("Compute in-between points");
    final JCheckBox useCorrelativeData = new JCheckBox("Use correlative data");

    correlativeFieldSelector = new CorrelativeFieldSelector(bindingContext);
    final PropertyDescriptor boxSizeDescriptor =
        bindingContext.getPropertySet().getProperty("boxSize").getDescriptor();
    boxSizeDescriptor.setValueRange(new ValueRange(1, 101));
    boxSizeDescriptor.setAttribute("stepSize", 2);
    boxSizeDescriptor.setValidator(
        new Validator() {
          @Override
          public void validateValue(Property property, Object value) throws ValidationException {
            if (((Number) value).intValue() % 2 == 0) {
              throw new ValidationException("Only odd values allowed as box size.");
            }
          }
        });
    bindingContext.bind("boxSize", boxSizeSpinner);
    bindingContext.bind("computeInBetweenPoints", computeInBetweenPoints);
    bindingContext.bind("useCorrelativeData", useCorrelativeData);
    EnablePointDataCondition condition = new EnablePointDataCondition();
    pointDataSourceEnablement = bindingContext.bindEnabledState("pointDataSource", true, condition);
    dataFieldEnablement = bindingContext.bindEnabledState("dataField", true, condition);

    bindingContext.addPropertyChangeListener(
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            updateDataSource();
            updateDataSet();
            updateUIState();
          }
        });

    JPanel dataSourceOptionsPanel = GridBagUtils.createPanel();
    GridBagConstraints dataSourceOptionsConstraints =
        GridBagUtils.createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2");
    GridBagUtils.addToPanel(
        dataSourceOptionsPanel,
        boxSizeLabel,
        dataSourceOptionsConstraints,
        "gridwidth=1,gridy=0,gridx=0,weightx=0,insets.left=4");
    GridBagUtils.addToPanel(
        dataSourceOptionsPanel,
        boxSizeSpinner,
        dataSourceOptionsConstraints,
        "gridwidth=1,gridy=0,gridx=1,weightx=1,insets.left=0");
    GridBagUtils.addToPanel(
        dataSourceOptionsPanel,
        computeInBetweenPoints,
        dataSourceOptionsConstraints,
        "gridwidth=2,gridy=1,gridx=0,weightx=2");
    GridBagUtils.addToPanel(
        dataSourceOptionsPanel,
        useCorrelativeData,
        dataSourceOptionsConstraints,
        "gridy=2,insets.top=16");
    GridBagUtils.addToPanel(
        dataSourceOptionsPanel,
        correlativeFieldSelector.pointDataSourceLabel,
        dataSourceOptionsConstraints,
        "gridy=3,insets.top=0,insets.left=4");
    GridBagUtils.addToPanel(
        dataSourceOptionsPanel,
        correlativeFieldSelector.pointDataSourceList,
        dataSourceOptionsConstraints,
        "gridy=4,insets.left=4");
    GridBagUtils.addToPanel(
        dataSourceOptionsPanel,
        correlativeFieldSelector.dataFieldLabel,
        dataSourceOptionsConstraints,
        "gridy=5,insets.left=4");
    GridBagUtils.addToPanel(
        dataSourceOptionsPanel,
        correlativeFieldSelector.dataFieldList,
        dataSourceOptionsConstraints,
        "gridy=6,insets.left=4");

    xAxisRangeControl
        .getBindingContext()
        .bind(PROPERTY_NAME_MARK_SEGMENTS, new JCheckBox("Mark segments"));
    yAxisRangeControl
        .getBindingContext()
        .bind(PROPERTY_NAME_LOG_SCALED, new JCheckBox("Log10 scaled"));

    JPanel displayOptionsPanel = GridBagUtils.createPanel();
    GridBagConstraints displayOptionsConstraints =
        GridBagUtils.createConstraints("anchor=SOUTH,fill=HORIZONTAL,weightx=1");
    GridBagUtils.addToPanel(
        displayOptionsPanel, xAxisRangeControl.getPanel(), displayOptionsConstraints, "gridy=0");
    GridBagUtils.addToPanel(
        displayOptionsPanel,
        xAxisRangeControl
            .getBindingContext()
            .getBinding(PROPERTY_NAME_MARK_SEGMENTS)
            .getComponents()[0],
        displayOptionsConstraints,
        "gridy=1");
    GridBagUtils.addToPanel(
        displayOptionsPanel, yAxisRangeControl.getPanel(), displayOptionsConstraints, "gridy=2");
    GridBagUtils.addToPanel(
        displayOptionsPanel,
        yAxisRangeControl
            .getBindingContext()
            .getBinding(PROPERTY_NAME_LOG_SCALED)
            .getComponents()[0],
        displayOptionsConstraints,
        "gridy=3");

    JPanel middlePanel = GridBagUtils.createPanel();
    GridBagConstraints middlePanelConstraints =
        GridBagUtils.createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1");
    GridBagUtils.addToPanel(middlePanel, dataSourceOptionsPanel, middlePanelConstraints, "gridy=0");
    GridBagUtils.addToPanel(
        middlePanel, new JPanel(), middlePanelConstraints, "gridy=1,fill=VERTICAL,weighty=1");
    GridBagUtils.addToPanel(
        middlePanel,
        displayOptionsPanel,
        middlePanelConstraints,
        "gridy=2,fill=HORIZONTAL,weighty=0");

    return middlePanel;
  }