Search in sources :

Example 1 with FeatureDisplay

use of jAudioFeatureExtractor.GeneralTools.FeatureDisplay in project jAudioGIT by dmcennis.

the class FeatureSelectorPanel method setUpFeatureTable.

/**
 * Initialize the table displaying the features which can be extracted.
 */
private void setUpFeatureTable() {
    controller.fstm_.fillTable(controller.dm_.featureDefinitions, controller.dm_.defaults, controller.dm_.is_primary);
    decorator = new SortingTableModelDecorator(controller.fstm_);
    features_table = new JTable(decorator);
    multipleToggleAction = new MultipleToggleAction(features_table);
    String key = "MultipleToggleAction";
    features_table.getInputMap().put(KeyStroke.getKeyStroke(' '), key);
    features_table.getActionMap().put(key, multipleToggleAction);
    int[] width = new int[3];
    width[0] = decorator.getRealPrefferedWidth(features_table, 0);
    width[1] = decorator.getRealPrefferedWidth(features_table, 1);
    width[1] -= 100;
    width[2] = decorator.getRealPrefferedWidth(features_table, 2);
    for (int i = 0; i < width.length; ++i) {
        features_table.getColumnModel().getColumn(i).setPreferredWidth(width[i]);
    }
    // add handler for sorting panel
    JTableHeader header = (JTableHeader) features_table.getTableHeader();
    header.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 1) {
                TableColumnModel tcm = features_table.getColumnModel();
                int column = features_table.convertColumnIndexToModel(tcm.getColumnIndexAtX(e.getX()));
                decorator.sort(column);
            } else {
                decorator.resetIndeci();
            }
        }
    });
    // Set up and display the table
    features_scroll_pane = new JScrollPane(features_table);
    features_panel = new JPanel(new GridLayout(1, 1));
    features_panel.add(features_scroll_pane);
    add(features_panel, BorderLayout.CENTER);
    controller.fstm_.fireTableDataChanged();
    TableColumn tableColumn = features_table.getColumn(features_table.getColumnName(1));
    tableColumn.setCellRenderer(new FeatureDisplay());
    features_table.removeColumn(features_table.getColumn(features_table.getColumnName(3)));
    repaint();
    outer_frame.repaint();
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) JTableHeader(javax.swing.table.JTableHeader) TableColumnModel(javax.swing.table.TableColumnModel) FeatureDisplay(jAudioFeatureExtractor.GeneralTools.FeatureDisplay) MultipleToggleAction(jAudioFeatureExtractor.actions.MultipleToggleAction) TableColumn(javax.swing.table.TableColumn)

Aggregations

FeatureDisplay (jAudioFeatureExtractor.GeneralTools.FeatureDisplay)1 MultipleToggleAction (jAudioFeatureExtractor.actions.MultipleToggleAction)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 JTableHeader (javax.swing.table.JTableHeader)1 TableColumn (javax.swing.table.TableColumn)1 TableColumnModel (javax.swing.table.TableColumnModel)1