Ejemplo n.º 1
0
  /** sets the enabled/disabled state of the menu items */
  private void setMenu() {
    boolean isNumeric;
    boolean hasColumns;
    boolean hasRows;
    boolean attSelected;
    ArffSortedTableModel model;
    boolean isNull;

    model = (ArffSortedTableModel) m_TableArff.getModel();
    isNull = (model.getInstances() == null);
    hasColumns = !isNull && (model.getInstances().numAttributes() > 0);
    hasRows = !isNull && (model.getInstances().numInstances() > 0);
    attSelected = hasColumns && (m_CurrentCol > 0);
    isNumeric = attSelected && (model.getAttributeAt(m_CurrentCol).isNumeric());

    menuItemUndo.setEnabled(canUndo());
    menuItemCopy.setEnabled(true);
    menuItemSearch.setEnabled(true);
    menuItemClearSearch.setEnabled(true);
    menuItemMean.setEnabled(isNumeric);
    menuItemSetAllValues.setEnabled(attSelected);
    menuItemSetMissingValues.setEnabled(attSelected);
    menuItemReplaceValues.setEnabled(attSelected);
    menuItemRenameAttribute.setEnabled(attSelected);
    menuItemDeleteAttribute.setEnabled(attSelected);
    menuItemDeleteAttributes.setEnabled(attSelected);
    menuItemSortInstances.setEnabled(hasRows && attSelected);
    menuItemDeleteSelectedInstance.setEnabled(hasRows && m_TableArff.getSelectedRow() > -1);
    menuItemDeleteAllSelectedInstances.setEnabled(
        hasRows && (m_TableArff.getSelectedRows().length > 0));
  }
Ejemplo n.º 2
0
  /** sets the relation name */
  private void createName() {
    ArffSortedTableModel model;

    model = (ArffSortedTableModel) m_TableArff.getModel();
    if ((model != null) && (model.getInstances() != null))
      m_LabelName.setText("Relation: " + model.getInstances().relationName());
    else m_LabelName.setText("");
  }
Ejemplo n.º 3
0
  /** calculates the mean of the given numeric column */
  private void calcMean() {
    ArffSortedTableModel model;
    int i;
    double mean;

    // no column selected?
    if (m_CurrentCol == -1) return;

    model = (ArffSortedTableModel) m_TableArff.getModel();

    // not numeric?
    if (!model.getAttributeAt(m_CurrentCol).isNumeric()) return;

    mean = 0;
    for (i = 0; i < model.getRowCount(); i++)
      mean += model.getInstances().instance(i).value(m_CurrentCol - 1);
    mean = mean / model.getRowCount();

    // show result
    ComponentHelper.showMessageBox(
        getParent(),
        "Mean for attribute...",
        "Mean for attribute '"
            + m_TableArff.getPlainColumnName(m_CurrentCol)
            + "':\n\t"
            + Utils.doubleToString(mean, 3),
        JOptionPane.OK_CANCEL_OPTION,
        JOptionPane.PLAIN_MESSAGE);
  }