Java Examples for weka.gui.FileEditor
The following java examples will help you to understand the usage of weka.gui.FileEditor. These source code samples are taken from different open source projects.
Example 1
Project: wekax-master File: GenericObjectEditor.java View source code |
/**
* Tests out the Object editor from the command line.
*
* @param args may contain the class name of a Object to edit
*/
public static void main(String[] args) {
try {
System.err.println("---Registering Weka Editors---");
java.beans.PropertyEditorManager.registerEditor(weka.experiment.ResultProducer.class, GenericObjectEditor.class);
java.beans.PropertyEditorManager.registerEditor(weka.experiment.SplitEvaluator.class, GenericObjectEditor.class);
java.beans.PropertyEditorManager.registerEditor(weka.classifiers.Classifier.class, GenericObjectEditor.class);
java.beans.PropertyEditorManager.registerEditor(weka.attributeSelection.ASEvaluation.class, GenericObjectEditor.class);
java.beans.PropertyEditorManager.registerEditor(weka.attributeSelection.ASSearch.class, GenericObjectEditor.class);
java.beans.PropertyEditorManager.registerEditor(SelectedTag.class, SelectedTagEditor.class);
java.beans.PropertyEditorManager.registerEditor(java.io.File.class, FileEditor.class);
GenericObjectEditor ce = new GenericObjectEditor(true);
ce.setClassType(weka.classifiers.Classifier.class);
Object initial = new weka.classifiers.rules.ZeroR();
if (args.length > 0) {
ce.setClassType(Class.forName(args[0]));
if (args.length > 1) {
initial = (Object) Class.forName(args[1]).newInstance();
ce.setValue(initial);
} else
ce.setDefaultValue();
} else
ce.setValue(initial);
PropertyDialog pd = new PropertyDialog(ce, 100, 100);
pd.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
PropertyEditor pe = ((PropertyDialog) e.getSource()).getEditor();
Object c = (Object) pe.getValue();
String options = "";
if (c instanceof OptionHandler) {
options = Utils.joinOptions(((OptionHandler) c).getOptions());
}
System.out.println(c.getClass().getName() + " " + options);
System.exit(0);
}
});
} catch (Exception ex) {
ex.printStackTrace();
System.err.println(ex.getMessage());
}
}