List of usage examples for weka.gui ExtensionFileFilter ExtensionFileFilter
public ExtensionFileFilter(String[] extensions, String description)
From source file:meka.gui.core.ResultHistoryList.java
License:Open Source License
/** * Initializes the list./*from w w w . jav a 2s. c om*/ */ public ResultHistoryList() { super(new ResultHistoryModel()); addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (MouseUtils.isRightClick(e)) { JPopupMenu menu = createPopup(e); if (menu != null) menu.show(ResultHistoryList.this, e.getX(), e.getY()); } else { super.mouseClicked(e); } } }); addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { int[] indices = getSelectedIndices(); if ((indices.length > 0) && (e.getKeyCode() == KeyEvent.VK_DELETE)) { for (int i = indices.length - 1; i >= 0; i--) removeItem(indices[i]); e.consume(); } else { super.keyTyped(e); } } }); m_FileChooser = GUIHelper.newFileChooser(); ExtensionFileFilter filter = new ExtensionFileFilter("txt", "Meka results format (*.txt)"); m_FileChooser.addChoosableFileFilter(filter); m_FileChooser.setFileFilter(filter); m_FileChooser.setMultiSelectionEnabled(false); m_PopupMenuCustomizer = null; }
From source file:meka.gui.experimenter.LogTab.java
License:Open Source License
/** * Initializes the members./* w ww . ja va2 s. co m*/ */ @Override protected void initialize() { ExtensionFileFilter filter; super.initialize(); m_Formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); m_FileChooser = GUIHelper.newFileChooser(); filter = new ExtensionFileFilter(".log", "Log files"); m_FileChooser.addChoosableFileFilter(filter); m_FileChooser.setFileFilter(filter); m_FileChooser.setAcceptAllFileFilterUsed(true); }
From source file:meka.gui.explorer.classify.OpenModel.java
License:Open Source License
/** * Returns the action lister to use in the menu. * * @return the listener/* ww w. j a va 2 s .c o m*/ */ public ActionListener getActionListener(final ClassifyTab owner) { return new ActionListener() { @Override public void actionPerformed(ActionEvent e) { MekaFileChooser filechooser; if (!hasSessionValue(owner, SESSION_KEY_MODELCHOOSER)) { filechooser = new MekaFileChooser(); ExtensionFileFilter filter = new ExtensionFileFilter(".model", "Model files (*.model)"); filechooser.addChoosableFileFilter(filter); filechooser.setFileFilter(filter); filechooser.setAcceptAllFileFilterUsed(true); setSessionValue(owner, SESSION_KEY_MODELCHOOSER, filechooser); } else { filechooser = (MekaFileChooser) getSessionValue(owner, SESSION_KEY_MODELCHOOSER); } int retVal = filechooser.showOpenDialog(owner.getOwner()); if (retVal != MekaFileChooser.APPROVE_OPTION) return; File model = filechooser.getSelectedFile(); try { Object[] objs = SerializationHelper.readAll(model.getAbsolutePath()); MultiLabelClassifier classifier = (MultiLabelClassifier) objs[0]; Instances data = null; if (objs.length > 1) data = (Instances) objs[1]; Result result = new Result(); owner.addResultToHistory(result, new Object[] { classifier, new Instances(data, 0) }, classifier.getClass().getName().replace("meka.classifiers.", "")); } catch (Exception ex) { owner.handleException("Loading of model '" + model + "' failed:", ex); JOptionPane.showMessageDialog(owner, "Loading of model '" + model + "' failed:\n" + ex, "Error", JOptionPane.ERROR_MESSAGE); } } }; }
From source file:meka.gui.explorer.classify.OpenTestData.java
License:Open Source License
/** * Returns the action lister to use in the menu. * * @return the listener//from w ww . jav a 2s. c o m */ public ActionListener getActionListener(final ClassifyTab owner) { return new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ConverterFileChooser filechooser; if (!hasSessionValue(owner, SESSION_KEY_FILECHOOSER)) { filechooser = GUIHelper.newConverterFileChooser(); ExtensionFileFilter filter = new ExtensionFileFilter(".model", "Model files (*.model)"); filechooser.addChoosableFileFilter(filter); filechooser.setFileFilter(filter); filechooser.setAcceptAllFileFilterUsed(true); setSessionValue(owner, SESSION_KEY_FILECHOOSER, filechooser); } else { filechooser = (ConverterFileChooser) getSessionValue(owner, SESSION_KEY_FILECHOOSER); } if (filechooser.showOpenDialog(owner) != ConverterFileChooser.APPROVE_OPTION) return; AbstractFileLoader loader = filechooser.getLoader(); try { Instances data = loader.getDataSet(); if (data != null) owner.setTestData(data); } catch (Exception ex) { String msg = "Failed to load file: " + filechooser.getSelectedFile(); System.err.println(msg); ex.printStackTrace(); JOptionPane.showMessageDialog(owner, msg + "\n" + ex, "Error", JOptionPane.ERROR_MESSAGE); } } }; }
From source file:meka.gui.explorer.classify.SaveCSV.java
License:Open Source License
/** * Returns the file chooser to use for the data. * * @return the file chooser/* w w w . ja v a2 s.co m*/ */ protected MekaFileChooser getFileChooser() { MekaFileChooser result; ExtensionFileFilter filter; if (!hasSessionValue(KEY_FILECHOOSER)) { result = new MekaFileChooser(); filter = new ExtensionFileFilter(".csv", "CSV file (*.csv)"); result.addChoosableFileFilter(filter); result.setFileFilter(filter); setSessionValue(KEY_FILECHOOSER, result); } return (MekaFileChooser) getSessionValue(KEY_FILECHOOSER); }
From source file:meka.gui.explorer.classify.SaveGraphs.java
License:Open Source License
/** * Returns the file chooser to use for the graphs. * * @return the file chooser/*from w w w.ja v a 2s .c om*/ */ protected MekaFileChooser getFileChooser() { MekaFileChooser result; ExtensionFileFilter filter; if (!hasSessionValue(KEY_FILECHOOSER)) { result = new MekaFileChooser(); filter = new ExtensionFileFilter(".txt", "Text file (*.txt)"); result.addChoosableFileFilter(filter); result.setFileFilter(filter); setSessionValue(KEY_FILECHOOSER, result); } return (MekaFileChooser) getSessionValue(KEY_FILECHOOSER); }
From source file:meka.gui.explorer.classify.SaveModel.java
License:Open Source License
/** * Returns the file chooser to use for the models. * * @return the file chooser//from w w w . ja v a2s. c o m */ protected MekaFileChooser getFileChooser() { MekaFileChooser result; ExtensionFileFilter filter; if (!hasSessionValue(KEY_FILECHOOSER)) { result = new MekaFileChooser(); filter = new ExtensionFileFilter(".model", "Model file (*.model)"); result.addChoosableFileFilter(filter); result.setFileFilter(filter); setSessionValue(KEY_FILECHOOSER, result); } return (MekaFileChooser) getSessionValue(KEY_FILECHOOSER); }
From source file:meka.gui.modelviewer.ModelViewer.java
License:Open Source License
/** * Initializes the members./* w w w .j a va 2 s .c o m*/ */ @Override protected void initialize() { ExtensionFileFilter filter; super.initialize(); m_FileChooser = GUIHelper.newFileChooser(); filter = new ExtensionFileFilter(".model", "Model files (*.model)"); m_FileChooser.addChoosableFileFilter(filter); m_FileChooser.setFileFilter(filter); }
From source file:net.sf.jclal.experiment.RunExperiment.java
License:Open Source License
/** * <p>//from ww w. j av a2 s . co m * Utility method to extract the arguments of the configuration, number * of processors and configuration files</p> * * @param args the main arguments */ public static void extractArguments(String[] args) { for (String arg : args) { if (arg.startsWith("-processors")) { StringTokenizer tokens = new StringTokenizer(arg, "="); tokens.nextToken(); String pro = tokens.nextToken(); if (pro.equalsIgnoreCase("all")) { numberOfProcessors = Runtime.getRuntime().availableProcessors(); } else { numberOfProcessors = Integer.parseInt(pro); } continue; } if (arg.startsWith("-cfg")) { StringTokenizer tokens = new StringTokenizer(arg, "="); tokens.nextToken(); tokens = new StringTokenizer(tokens.nextToken(), ";"); int index = 0; cfgs = new String[tokens.countTokens()]; while (tokens.hasMoreTokens()) { cfgs[index++] = tokens.nextToken(); } continue; } if (arg.startsWith("-d")) { StringTokenizer tokens = new StringTokenizer(arg, "="); tokens.nextToken(); String directory = tokens.nextToken(); File a = new File(directory); if (a.exists() && a.isDirectory()) { FilenameFilter filter = new ExtensionFileFilter(".cfg", "The experiment configuration files"); List<File> files = new ArrayList<File>(); FileUtil.getFilesInDirectory(a, filter, files); FileUtil.orderFilesByPathName(files, true); int index = 0; cfgs = new String[files.size()]; for (File file : files) { cfgs[index++] = file.getPath(); } } else { System.err.println("The directory does not exist"); System.exit(1); } } } }