@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);
    }
  }
Ejemplo n.º 2
0
 public void setComponentsEnabled(boolean enabled) {
   if (!enabled) {
     for (Property property : bindingContext.getPropertySet().getProperties()) {
       bindingContext.setComponentsEnabled(property.getName(), enabled);
     }
   } else {
     for (Property property : bindingContext.getPropertySet().getProperties()) {
       if (property.getName().equals("min") || property.getName().equals("max")) {
         bindingContext.setComponentsEnabled(property.getName(), !isAutoMinMax());
       } else {
         bindingContext.setComponentsEnabled(property.getName(), enabled);
       }
     }
   }
 }
  @Test
  public void variablesProperty() {
    final JTable table = new JTable();
    bindingContext.bind("conditions", new ConditionsTableAdapter(table));
    assertTrue(table.getModel() instanceof DefaultTableModel);

    final DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
    tableModel.addRow((Object[]) null);
    tableModel.addRow((Object[]) null);

    assertEquals(2, table.getRowCount());

    table.setValueAt("a", 0, 0);
    assertEquals("a", table.getValueAt(0, 0));
    table.setValueAt("A", 0, 1);
    assertEquals("A", table.getValueAt(0, 1));
    table.setValueAt(true, 0, 2);
    assertEquals(true, table.getValueAt(0, 2));

    table.setValueAt("b", 1, 0);
    assertEquals("b", table.getValueAt(1, 0));
    table.setValueAt("B", 1, 1);
    assertEquals("B", table.getValueAt(1, 1));
    table.setValueAt(false, 1, 2);
    assertEquals(false, table.getValueAt(1, 2));

    bindingContext
        .getPropertySet()
        .setValue("conditions", new MosaicOp.Condition[] {new MosaicOp.Condition("d", "D", true)});

    assertEquals(1, table.getRowCount());
    assertEquals("d", table.getValueAt(0, 0));
    assertEquals("D", table.getValueAt(0, 1));
    assertEquals(true, table.getValueAt(0, 2));
  }
Ejemplo n.º 4
0
 private JComponent[] createComponents(
     String propertyName, Class<? extends PropertyEditor> editorClass) {
   PropertyDescriptor descriptor = bindingContext.getPropertySet().getDescriptor(propertyName);
   PropertyEditor editor =
       PropertyEditorRegistry.getInstance().getPropertyEditor(editorClass.getName());
   return editor.createComponents(descriptor, bindingContext);
 }
Ejemplo n.º 5
0
 private void handleMasklessProduct(Product product) {
   if (product != null && product.getMaskGroup().getNodeCount() == 0) {
     try {
       bindingContext.getPropertySet().getProperty("useRoiMask").setValue(Boolean.FALSE);
     } catch (ValidationException e) {
       throw new IllegalStateException("Cannot come here");
     }
   }
 }
Ejemplo n.º 6
0
  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;
  }
Ejemplo n.º 7
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;
  }
Ejemplo n.º 8
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;
  }
  @Override
  protected JPanel createPanel(BindingContext context) {
    TableLayout tableLayout = new TableLayout(2);
    tableLayout.setTableAnchor(TableLayout.Anchor.NORTHWEST);
    tableLayout.setTablePadding(new Insets(4, 10, 0, 0));
    tableLayout.setTableFill(TableLayout.Fill.BOTH);
    tableLayout.setColumnWeightX(1, 1.0);
    tableLayout.setCellColspan(0, 0, 2);
    tableLayout.setCellColspan(1, 0, 2);
    tableLayout.setCellColspan(8, 0, 2);

    JPanel pageUI = new JPanel(tableLayout);

    PropertyEditorRegistry registry = PropertyEditorRegistry.getInstance();
    Property computeLatLonSteps =
        context.getPropertySet().getProperty(GraticuleLayerType.PROPERTY_NAME_RES_AUTO);
    Property avgGridSize =
        context.getPropertySet().getProperty(GraticuleLayerType.PROPERTY_NAME_RES_PIXELS);
    Property latStep =
        context.getPropertySet().getProperty(GraticuleLayerType.PROPERTY_NAME_RES_LAT);
    Property lonStep =
        context.getPropertySet().getProperty(GraticuleLayerType.PROPERTY_NAME_RES_LON);
    Property lineColor =
        context.getPropertySet().getProperty(GraticuleLayerType.PROPERTY_NAME_LINE_COLOR);
    Property lineWidth =
        context.getPropertySet().getProperty(GraticuleLayerType.PROPERTY_NAME_LINE_WIDTH);
    Property lineTransparency =
        context.getPropertySet().getProperty(GraticuleLayerType.PROPERTY_NAME_LINE_TRANSPARENCY);
    Property showTextLabels =
        context.getPropertySet().getProperty(GraticuleLayerType.PROPERTY_NAME_TEXT_ENABLED);
    Property textFgColor =
        context.getPropertySet().getProperty(GraticuleLayerType.PROPERTY_NAME_TEXT_FG_COLOR);
    Property textBgColor =
        context.getPropertySet().getProperty(GraticuleLayerType.PROPERTY_NAME_TEXT_BG_COLOR);
    Property textBgTransparency =
        context.getPropertySet().getProperty(GraticuleLayerType.PROPERTY_NAME_TEXT_BG_TRANSPARENCY);

    JComponent[] computeLatLonStepsComponents =
        registry
            .findPropertyEditor(computeLatLonSteps.getDescriptor())
            .createComponents(computeLatLonSteps.getDescriptor(), context);
    JComponent[] avgGridSizeComponents =
        registry
            .findPropertyEditor(avgGridSize.getDescriptor())
            .createComponents(avgGridSize.getDescriptor(), context);
    JComponent[] latStepComponents =
        registry
            .findPropertyEditor(latStep.getDescriptor())
            .createComponents(latStep.getDescriptor(), context);
    JComponent[] lonStepComponents =
        registry
            .findPropertyEditor(lonStep.getDescriptor())
            .createComponents(lonStep.getDescriptor(), context);
    JComponent[] lineColorComponents = PreferenceUtils.createColorComponents(lineColor);
    JComponent[] lineWidthComponents =
        registry
            .findPropertyEditor(lineWidth.getDescriptor())
            .createComponents(lineWidth.getDescriptor(), context);
    JComponent[] lineTransparencyComponents =
        registry
            .findPropertyEditor(lineTransparency.getDescriptor())
            .createComponents(lineTransparency.getDescriptor(), context);
    JComponent[] showTextLabelsComponents =
        registry
            .findPropertyEditor(showTextLabels.getDescriptor())
            .createComponents(showTextLabels.getDescriptor(), context);
    textFgColorComponents = PreferenceUtils.createColorComponents(textFgColor);
    textBgColorComponents = PreferenceUtils.createColorComponents(textBgColor);
    JComponent[] textBgTransparencyComponents =
        registry
            .findPropertyEditor(textBgTransparency.getDescriptor())
            .createComponents(textBgTransparency.getDescriptor(), context);

    pageUI.add(computeLatLonStepsComponents[0]);
    addNote(
        pageUI,
        "<html>Note: Deselect this option only very carefully. The latitude and longitude<br>"
            + "steps you enter will be used for low and high resolution products.</html>");
    pageUI.add(avgGridSizeComponents[1]);
    pageUI.add(avgGridSizeComponents[0]);
    pageUI.add(latStepComponents[1]);
    pageUI.add(latStepComponents[0]);
    pageUI.add(lonStepComponents[1]);
    pageUI.add(lonStepComponents[0]);
    pageUI.add(lineColorComponents[0]);
    pageUI.add(lineColorComponents[1]);
    pageUI.add(lineWidthComponents[1]);
    pageUI.add(lineWidthComponents[0]);
    pageUI.add(lineTransparencyComponents[1]);
    pageUI.add(lineTransparencyComponents[0]);
    pageUI.add(showTextLabelsComponents[0]);
    pageUI.add(textFgColorComponents[0]);
    pageUI.add(textFgColorComponents[1]);
    pageUI.add(textBgColorComponents[0]);
    pageUI.add(textBgColorComponents[1]);
    pageUI.add(textBgTransparencyComponents[1]);
    pageUI.add(textBgTransparencyComponents[0]);

    pageUI.add(tableLayout.createVerticalSpacer());

    JPanel parent = new JPanel(new BorderLayout());
    parent.add(pageUI, BorderLayout.CENTER);
    parent.add(Box.createHorizontalStrut(100), BorderLayout.EAST);
    return parent;
  }
Ejemplo n.º 10
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;
  }