Beispiel #1
0
  private void setRegressionLabels() {

    for (Regression r : Regression.values()) {

      regressionLabels[r.ordinal()] = app.getMenu(r.getLabel());
    }
  }
Beispiel #2
0
  private JPanel createRegressionPanel() {

    // components
    String[] orders = {"2", "3", "4", "5", "6", "7", "8", "9"};
    cbPolyOrder = new JComboBox(orders);
    cbPolyOrder.setSelectedIndex(0);
    cbPolyOrder.addActionListener(this);
    cbPolyOrder.setFocusable(false);

    regressionLabels = new String[Regression.values().length];
    setRegressionLabels();
    cbRegression = new JComboBox(regressionLabels);
    cbRegression.addActionListener(this);
    cbRegression.setFocusable(false);

    lblRegEquation = new JLabel();
    lblEqn = new JLabel();

    // regression combo panel
    JPanel cbPanel = new JPanel();
    cbPanel.setLayout(new BoxLayout(cbPanel, BoxLayout.Y_AXIS));
    cbPanel.add(LayoutUtil.flowPanel(cbRegression));
    cbPanel.add(LayoutUtil.flowPanel(cbPolyOrder));

    // regression label panel
    JPanel eqnPanel = new JPanel(new BorderLayout());
    eqnPanel.add(lblRegEquation, BorderLayout.CENTER);
    JScrollPane scroller = new JScrollPane(eqnPanel);
    scroller.setBorder(BorderFactory.createEmptyBorder());

    // prediction panel
    createPredictionPanel();

    // model panel: equation + prediction
    JPanel modelPanel = new JPanel();
    modelPanel.setLayout(new BoxLayout(modelPanel, BoxLayout.Y_AXIS));
    modelPanel.add(scroller);
    modelPanel.add(predictionPanel);

    // put it all together
    regressionPanel = new JPanel(new BorderLayout(30, 0));
    regressionPanel.add(modelPanel, BorderLayout.CENTER);
    regressionPanel.add(cbPanel, loc.borderWest());
    regressionPanel.setBorder(BorderFactory.createTitledBorder(loc.getMenu("RegressionModel")));

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(regressionPanel, BorderLayout.CENTER);

    return mainPanel;
  }
Beispiel #3
0
  /** Sets the labels according to current locale */
  public void setLabels() {
    regressionLabels = new String[Regression.values().length];
    setRegressionLabels();

    // we need to remove old labels from combobox and we don't want the
    // listener to
    // be operational since it will call unnecessary Construction updates
    int j = cbRegression.getSelectedIndex();
    ActionListener al = cbRegression.getActionListeners()[0];
    cbRegression.removeActionListener(al);
    cbRegression.removeAllItems();

    for (int i = 0; i < regressionLabels.length; i++) {
      cbRegression.addItem(regressionLabels[i]);
    }

    cbRegression.setSelectedIndex(j);
    cbRegression.addActionListener(al);
    ((TitledBorder) regressionPanel.getBorder()).setTitle(app.getMenu("RegressionModel"));
    lblEqn.setText(app.getMenu("Equation") + ":");

    lblEvaluate.setText(app.getMenu("Evaluate") + ": ");
  }