예제 #1
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();
        });
  }
예제 #2
0
 private String getAxisLabel() {
   boolean logScaled =
       (Boolean) bindingContext.getBinding(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM).getPropertyValue();
   return StatisticChartStyling.getAxisLabel(getRaster(), "X", logScaled);
 }
예제 #3
0
  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;
  }
예제 #4
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;
  }
예제 #5
0
 public boolean isAutoMinMax() {
   return (Boolean) bindingContext.getBinding("autoMinMax").getPropertyValue();
 }