Example usage for weka.core Capabilities forInstances

List of usage examples for weka.core Capabilities forInstances

Introduction

In this page you can find the example usage for weka.core Capabilities forInstances.

Prototype

public static Capabilities forInstances(Instances data) throws Exception 

Source Link

Document

returns a Capabilities object specific for this data.

Usage

From source file:meka.gui.dataviewer.DataViewerMainPanel.java

License:Open Source License

/**
 * saves the current data into a new file
 *//* www .  j  av a 2s.c  o  m*/
public void saveFileAs() {
    int retVal;
    DataPanel panel;

    // no panel? -> exit
    panel = getCurrentPanel();
    if (panel == null) {
        System.out.println("nothing selected!");
        return;
    }

    if (!getCurrentFilename().equals("")) {
        try {
            m_FileChooser.setSelectedFile(new File(getCurrentFilename()));
        } catch (Exception e) {
            // ignore
        }
    }

    // set filter for savers
    try {
        m_FileChooser.setCapabilitiesFilter(Capabilities.forInstances(panel.getInstances()));
    } catch (Exception e) {
        m_FileChooser.setCapabilitiesFilter(null);
    }

    retVal = m_FileChooser.showSaveDialog(this);
    if (retVal != ConverterFileChooser.APPROVE_OPTION) {
        return;
    }

    panel.setChanged(false);
    setCurrentFilename(m_FileChooser.getSelectedFile().getAbsolutePath());
    // saveFile();

    AbstractFileSaver saver = m_FileChooser.getSaver();
    saver.setInstances(panel.getInstances());
    try {
        saver.writeBatch();
        panel.setChanged(false);
    } catch (IOException e) {
        e.printStackTrace();
    }
}