Ejemplo n.º 1
0
  private void doTextFieldActionPerformed(JTextField source) {
    if (isUpdating) return;
    try {
      String inputText = source.getText().trim();
      NumberValue nv;
      nv = app.getKernel().getAlgebraProcessor().evaluateToNumeric(inputText, false);
      double value = nv.getDouble();

      // TODO better validation

      if (source == fldXMin) {
        settings.xMin = value;
        firePropertyChange("settings", true, false);
      } else if (source == fldXMax) {
        settings.xMax = value;
        firePropertyChange("settings", true, false);
      } else if (source == fldYMax) {
        settings.yMax = value;
        firePropertyChange("settings", true, false);
      } else if (source == fldYMin) {
        settings.yMin = value;
        firePropertyChange("settings", true, false);
      } else if (source == fldXInterval && value >= 0) {
        settings.xAxesInterval = value;
        firePropertyChange("settings", true, false);
      } else if (source == fldYInterval && value >= 0) {
        settings.yAxesInterval = value;
        firePropertyChange("settings", true, false);
      } else if (source == fldBarWidth && value >= 0) {
        settings.setBarWidth(value);
        firePropertyChange("settings", true, false);
      }
      updateGUI();

    } catch (NumberFormatException e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
  public void actionPerformed(ActionEvent e) {

    if (isUpdating) return;

    Object source = e.getSource();
    if (source instanceof JTextField) {
      doTextFieldActionPerformed((JTextField) source);
    } else if (source == ckManual) {
      settings.setUseManualClasses(ckManual.isSelected());
      firePropertyChange("settings", true, false);
    } else if (source == ckCumulative) {
      settings.setCumulative(ckCumulative.isSelected());
      firePropertyChange("settings", true, false);
    } else if (source == rbFreq) {
      settings.setFrequencyType(StatPanelSettings.TYPE_COUNT);
      firePropertyChange("settings", true, false);
    } else if (source == rbRelative) {
      settings.setFrequencyType(StatPanelSettings.TYPE_RELATIVE);
      firePropertyChange("settings", true, false);
    } else if (source == rbNormalized) {
      settings.setFrequencyType(StatPanelSettings.TYPE_NORMALIZED);
      firePropertyChange("settings", true, false);
    } else if (source == ckOverlayNormal) {
      settings.setHasOverlayNormal(ckOverlayNormal.isSelected());
      firePropertyChange("settings", true, false);
    } else if (source == ckOverlayPolygon) {
      settings.setHasOverlayPolygon(ckOverlayPolygon.isSelected());
      firePropertyChange("settings", true, false);
    } else if (source == ckShowGrid) {
      settings.showGrid = ckShowGrid.isSelected();
      firePropertyChange("settings", true, false);
    } else if (source == ckAutoWindow) {
      settings.setAutomaticWindow(ckAutoWindow.isSelected());
      settings.xAxesIntervalAuto = ckAutoWindow.isSelected();
      settings.yAxesIntervalAuto = ckAutoWindow.isSelected();
      firePropertyChange("settings", true, false);
    } else if (source == ckShowFrequencyTable) {
      settings.setShowFrequencyTable(ckShowFrequencyTable.isSelected());
      firePropertyChange("settings", true, false);
    } else if (source == ckShowHistogram) {
      settings.setShowHistogram(ckShowHistogram.isSelected());
      firePropertyChange("settings", true, false);
    } else if (source == rbLeftRule || source == rbRightRule) {
      settings.setLeftRule(rbLeftRule.isSelected());
      firePropertyChange("settings", true, false);
    } else if (source == ckShowLines) {
      settings.setShowScatterplotLine(ckShowLines.isSelected());
      firePropertyChange("settings", true, false);
    } else if (source == ckShowOutliers) {
      settings.setShowOutliers(ckShowOutliers.isSelected());
      firePropertyChange("settings", true, false);
    } else if (source == ckAutoBarWidth) {
      settings.setAutomaticBarWidth(ckAutoBarWidth.isSelected());
      firePropertyChange("settings", true, false);
    } else if (source == rbStandToStand) {
      settings.setCoordMode(StatPanelSettings.CoordMode.STANDTOSTAND);
      firePropertyChange("settings", true, false);
    } else if (source == rbLogToStand) {
      settings.setCoordMode(StatPanelSettings.CoordMode.LOGTOSTAND);
      firePropertyChange("settings", true, false);
    } else if (source == rbStandToLog) {
      settings.setCoordMode(StatPanelSettings.CoordMode.STANDTOLOG);
      firePropertyChange("settings", true, false);
    } else if (source == rbLogToLog) {
      settings.setCoordMode(StatPanelSettings.CoordMode.LOGTOLOG);
      firePropertyChange("settings", true, false);
    } else {
      firePropertyChange("settings", true, false);
    }

    updateGUI();
  }
Ejemplo n.º 3
0
  private void updateGUI() {

    // set updating flag so we don't have to add/remove action listeners
    isUpdating = true;

    // histogram/barchart
    ckManual.setSelected(settings.isUseManualClasses());
    rbFreq.setSelected(settings.getFrequencyType() == StatPanelSettings.TYPE_COUNT);
    rbRelative.setSelected(settings.getFrequencyType() == StatPanelSettings.TYPE_RELATIVE);
    rbNormalized.setSelected(settings.getFrequencyType() == StatPanelSettings.TYPE_NORMALIZED);
    rbLeftRule.setSelected(settings.isLeftRule());
    ckCumulative.setSelected(settings.isCumulative());
    ckOverlayNormal.setSelected(settings.isHasOverlayNormal());
    ckOverlayPolygon.setSelected(settings.isHasOverlayPolygon());
    ckShowGrid.setSelected(settings.showGrid);
    ckAutoWindow.setSelected(settings.isAutomaticWindow());
    ckShowFrequencyTable.setSelected(settings.isShowFrequencyTable());
    ckShowHistogram.setSelected(settings.isShowHistogram());

    if (settings.dataSource != null) {
      ckManual.setVisible(settings.getDataSource().getGroupType() != GroupType.CLASS);
      freqPanel.setVisible(settings.getDataSource().getGroupType() == GroupType.RAWDATA);
    }
    // normal overlay
    ckOverlayNormal.setEnabled(settings.getFrequencyType() == StatPanelSettings.TYPE_NORMALIZED);

    // bar chart width
    ckAutoBarWidth.setSelected(settings.isAutomaticBarWidth());
    fldBarWidth.setText("" + settings.getBarWidth());
    fldBarWidth.setEnabled(!ckAutoBarWidth.isSelected());

    // window dimension
    lblYMin.setVisible(showYAxisSettings);
    fldYMin.setVisible(showYAxisSettings);
    lblYMax.setVisible(showYAxisSettings);
    fldYMax.setVisible(showYAxisSettings);
    lblYInterval.setVisible(showYAxisSettings);
    fldYInterval.setVisible(showYAxisSettings);

    dimPanel.setEnabled(!ckAutoWindow.isSelected());
    fldXMin.setEnabled(!ckAutoWindow.isSelected());
    fldXMax.setEnabled(!ckAutoWindow.isSelected());
    fldXInterval.setEnabled(!ckAutoWindow.isSelected());
    fldYMin.setEnabled(!ckAutoWindow.isSelected());
    fldYMax.setEnabled(!ckAutoWindow.isSelected());
    fldYInterval.setEnabled(!ckAutoWindow.isSelected());

    lblXMin.setEnabled(!ckAutoWindow.isSelected());
    lblXMax.setEnabled(!ckAutoWindow.isSelected());
    lblXInterval.setEnabled(!ckAutoWindow.isSelected());
    lblYMin.setEnabled(!ckAutoWindow.isSelected());
    lblYMax.setEnabled(!ckAutoWindow.isSelected());
    lblYInterval.setEnabled(!ckAutoWindow.isSelected());

    // coordinate mode
    rbStandToStand.setSelected(settings.getCoordMode() == StatPanelSettings.CoordMode.STANDTOSTAND);
    rbLogToStand.setSelected(settings.getCoordMode() == StatPanelSettings.CoordMode.LOGTOSTAND);
    rbStandToLog.setSelected(settings.getCoordMode() == StatPanelSettings.CoordMode.STANDTOLOG);
    rbLogToLog.setSelected(settings.getCoordMode() == StatPanelSettings.CoordMode.LOGTOLOG);

    // update automatic dimensions
    fldXMin.setText("" + daModel.format(settings.xMin));
    fldXMax.setText("" + daModel.format(settings.xMax));
    fldXInterval.setText("" + daModel.format(settings.xAxesInterval));

    fldYMin.setText("" + daModel.format(settings.yMin));
    fldYMax.setText("" + daModel.format(settings.yMax));
    fldYInterval.setText("" + daModel.format(settings.yAxesInterval));

    // show outliers
    ckShowOutliers.setSelected(settings.isShowOutliers());

    isUpdating = false;
    repaint();
  }