本文整理汇总了Java中weka.gui.ExtensionFileFilter类的典型用法代码示例。如果您正苦于以下问题:Java ExtensionFileFilter类的具体用法?Java ExtensionFileFilter怎么用?Java ExtensionFileFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExtensionFileFilter类属于weka.gui包,在下文中一共展示了ExtensionFileFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import weka.gui.ExtensionFileFilter; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent ae) {
JFileChooser fc = new JFileChooser(System.getProperty("user.dir"));
ExtensionFileFilter ef1 = new ExtensionFileFilter(".arff", "ARFF files");
ExtensionFileFilter ef2 = new ExtensionFileFilter(".xml", "XML BIF files");
fc.addChoosableFileFilter(ef1);
fc.addChoosableFileFilter(ef2);
fc.setDialogTitle("Load Graph");
int rval = fc.showOpenDialog(GUI.this);
if (rval == JFileChooser.APPROVE_OPTION) {
String sFileName = fc.getSelectedFile().toString();
if (sFileName.endsWith(ef1.getExtensions()[0])) {
initFromArffFile(sFileName);
} else {
try {
readBIFFromFile(sFileName);
} catch (Exception e) {
e.printStackTrace();
}
}
m_jStatusBar.setText("Loaded " + sFileName);
updateStatus();
}
}
示例2: checkExtension
import weka.gui.ExtensionFileFilter; //导入依赖的package包/类
/**
* Checks whether the extension of the file is a known one.
*
* @param file the file to check
* @return true if the exetnsion is known
*/
protected boolean checkExtension(File file) {
boolean result;
int i;
int n;
ExtensionFileFilter[] filters;
String[] exts;
result = false;
filters = getFilters();
for (i = 0; i < filters.length; i++) {
exts = filters[i].getExtensions();
for (n = 0; n < exts.length; n++) {
if (file.getName().endsWith(exts[n])) {
result = true;
break;
}
}
if (result) {
break;
}
}
return result;
}
示例3: actionPerformed
import weka.gui.ExtensionFileFilter; //导入依赖的package包/类
public void actionPerformed(ActionEvent ae) {
JFileChooser fc = new JFileChooser(System.getProperty("user.dir"));
ExtensionFileFilter ef1 = new ExtensionFileFilter(".arff", "ARFF files");
ExtensionFileFilter ef2 = new ExtensionFileFilter(".xml", "XML BIF files");
fc.addChoosableFileFilter(ef1);
fc.addChoosableFileFilter(ef2);
fc.setDialogTitle("Load Graph");
int rval = fc.showOpenDialog(GUI.this);
if (rval == JFileChooser.APPROVE_OPTION) {
String sFileName = fc.getSelectedFile().toString();
if (sFileName.endsWith(ef1.getExtensions()[0])) {
initFromArffFile(sFileName);
} else {
try {
readBIFFromFile(sFileName);
} catch (Exception e) {
e.printStackTrace();
}
}
m_jStatusBar.setText("Loaded " + sFileName);
updateStatus();
}
}
示例4: checkExtension
import weka.gui.ExtensionFileFilter; //导入依赖的package包/类
/**
* Checks whether the extension of the file is a known one.
*
* @param file the file to check
* @return true if the exetnsion is known
*/
protected boolean checkExtension(File file) {
boolean result;
int i;
int n;
ExtensionFileFilter[] filters;
String[] exts;
result = false;
filters = getFilters();
for (i = 0; i < filters.length; i++) {
exts = filters[i].getExtensions();
for (n = 0; n < exts.length; n++) {
if (file.getName().endsWith(exts[n])) {
result = true;
break;
}
}
if (result)
break;
}
return result;
}
示例5: getFilters
import weka.gui.ExtensionFileFilter; //导入依赖的package包/类
/**
* Returns the extension filters for this type of script.
*
* @return the filters
*/
public ExtensionFileFilter[] getFilters() {
ExtensionFileFilter[] result;
result = new ExtensionFileFilter[1];
result[0] = new ExtensionFileFilter(getDefaultExtension(), "Groovy script (*" + getDefaultExtension() + ")");
return result;
}
示例6: getFilters
import weka.gui.ExtensionFileFilter; //导入依赖的package包/类
/**
* Returns the extension filters for this type of script.
*
* @return the filters
*/
@Override
public ExtensionFileFilter[] getFilters() {
ExtensionFileFilter[] result;
result = new ExtensionFileFilter[1];
result[0] = new ExtensionFileFilter(getDefaultExtension(),
"Jython script (*" + getDefaultExtension() + ")");
return result;
}
示例7: initFinish
import weka.gui.ExtensionFileFilter; //导入依赖的package包/类
/**
* Finishes up after initializing members and setting up the GUI.
*/
protected void initFinish() {
ExtensionFileFilter[] filters;
int i;
super.initFinish();
m_Script = newScript(m_TextCode.getDocument());
m_Script.addScriptFinishedListener(this);
filters = m_Script.getFilters();
for (i = filters.length - 1; i >= 0; i--)
m_FileChooser.addChoosableFileFilter(filters[i]);
m_Actions = createActionTable(m_TextCode);
// file
m_NewAction = new NewAction();
m_OpenAction = new OpenAction();
m_SaveAction = new SaveAction("Save", false);
m_SaveAsAction = new SaveAction("Save As...", true);
m_PrintAction = new PrintAction();
m_ClearOutputAction = new ClearOutputAction();
m_ExitAction = new ExitAction();
// edit
m_UndoAction = new UndoAction();
m_RedoAction = new RedoAction();
m_CutAction = updateAction(m_Actions.get(DefaultEditorKit.cutAction), "Cut", "cut.gif", "ctrl X", 'C');
m_CopyAction = updateAction(m_Actions.get(DefaultEditorKit.copyAction), "Copy", "copy.gif", "ctrl C", 'o');
m_PasteAction = updateAction(m_Actions.get(DefaultEditorKit.pasteAction), "Paste", "paste.gif", "ctrl V", 'P');
// script
m_StartAction = new StartAction();
m_StopAction = new StopAction();
m_ArgsAction = new CommandlineArgsAction();
// help
m_AboutAction = new AboutAction();
}
示例8: saveModel
import weka.gui.ExtensionFileFilter; //导入依赖的package包/类
public void saveModel() {
try {
if (m_fileChooser == null) {
// i.e. after de-serialization
m_fileChooser = new JFileChooser(new File(
System.getProperty("user.dir")));
ExtensionFileFilter ef = new ExtensionFileFilter("model",
"Serialized weka clusterer");
m_fileChooser.setFileFilter(ef);
}
int returnVal = m_fileChooser.showSaveDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File saveTo = m_fileChooser.getSelectedFile();
String fn = saveTo.getAbsolutePath();
if (!fn.endsWith(".model")) {
fn += ".model";
saveTo = new File(fn);
}
ObjectOutputStream os = new ObjectOutputStream(
new BufferedOutputStream(new FileOutputStream(saveTo)));
os.writeObject(m_Clusterer);
if (m_trainingSet != null) {
Instances header = new Instances(m_trainingSet, 0);
os.writeObject(header);
}
os.close();
if (m_log != null) {
m_log.logMessage("[Clusterer] Saved clusterer " + getCustomName());
}
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(Clusterer.this,
"Problem saving clusterer.\n", "Save Model", JOptionPane.ERROR_MESSAGE);
if (m_log != null) {
m_log.logMessage("[Clusterer] Problem saving clusterer. "
+ getCustomName() + ex.getMessage());
}
}
}
示例9: ConnectionPanel
import weka.gui.ExtensionFileFilter; //导入依赖的package包/类
/**
* initializes the panel.
*
* @param parent the parent of this panel
*/
public ConnectionPanel(JFrame parent) {
super();
m_Parent = parent;
m_ConnectionListeners = new HashSet<ConnectionListener>();
m_HistoryChangedListeners = new HashSet<HistoryChangedListener>();
m_SetupFileChooser = new JFileChooser();
m_SetupFileChooser.setDialogTitle("Switch database setup");
m_SetupFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
m_SetupFileChooser.setMultiSelectionEnabled(false);
m_SetupFileChooser.setAcceptAllFileFilterUsed(true);
ExtensionFileFilter filter = new ExtensionFileFilter(".props",
"Properties file");
m_SetupFileChooser.addChoosableFileFilter(filter);
m_SetupFileChooser.setFileFilter(filter);
try {
m_DbUtils = new DbUtils();
m_URL = m_DbUtils.getDatabaseURL();
m_User = m_DbUtils.getUsername();
m_Password = m_DbUtils.getPassword();
} catch (Exception e) {
e.printStackTrace();
m_URL = "";
m_User = "";
m_Password = "";
}
createPanel();
}
示例10: getFilters
import weka.gui.ExtensionFileFilter; //导入依赖的package包/类
/**
* Returns the extension filters for this type of script.
*
* @return the filters
*/
public ExtensionFileFilter[] getFilters() {
ExtensionFileFilter[] result;
result = new ExtensionFileFilter[1];
result[0] = new ExtensionFileFilter(getDefaultExtension(), "Jython script (*" + getDefaultExtension() + ")");
return result;
}
示例11: ConnectionPanel
import weka.gui.ExtensionFileFilter; //导入依赖的package包/类
/**
* initializes the panel.
*
* @param parent the parent of this panel
*/
public ConnectionPanel(JFrame parent) {
super();
m_Parent = parent;
m_ConnectionListeners = new HashSet();
m_HistoryChangedListeners = new HashSet();
m_SetupFileChooser = new JFileChooser();
m_SetupFileChooser.setDialogTitle("Switch database setup");
m_SetupFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
m_SetupFileChooser.setMultiSelectionEnabled(false);
m_SetupFileChooser.setAcceptAllFileFilterUsed(true);
ExtensionFileFilter filter = new ExtensionFileFilter(".props", "Properties file");
m_SetupFileChooser.addChoosableFileFilter(filter);
m_SetupFileChooser.setFileFilter(filter);
try {
m_DbUtils = new DbUtils();
m_URL = m_DbUtils.getDatabaseURL();
m_User = m_DbUtils.getUsername();
m_Password = m_DbUtils.getPassword();
}
catch (Exception e) {
e.printStackTrace();
m_URL = "";
m_User = "";
m_Password = "";
}
createPanel();
}
示例12: saveModel
import weka.gui.ExtensionFileFilter; //导入依赖的package包/类
public void saveModel() {
try {
if (m_fileChooser == null) {
// i.e. after de-serialization
m_fileChooser =
new JFileChooser(new File(System.getProperty("user.dir")));
ExtensionFileFilter ef = new ExtensionFileFilter("model", "Serialized weka clusterer");
m_fileChooser.setFileFilter(ef);
}
int returnVal = m_fileChooser.showSaveDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File saveTo = m_fileChooser.getSelectedFile();
String fn = saveTo.getAbsolutePath();
if (!fn.endsWith(".model")) {
fn += ".model";
saveTo = new File(fn);
}
ObjectOutputStream os =
new ObjectOutputStream(new BufferedOutputStream(
new FileOutputStream(saveTo)));
os.writeObject(m_Clusterer);
if (m_trainingSet != null) {
Instances header = new Instances(m_trainingSet, 0);
os.writeObject(header);
}
os.close();
if (m_log != null) {
m_log.logMessage("[Clusterer] Saved clusterer " + getCustomName());
}
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(Clusterer.this,
"Problem saving clusterer.\n",
"Save Model",
JOptionPane.ERROR_MESSAGE);
if (m_log != null) {
m_log.logMessage("[Clusterer] Problem saving clusterer. "
+ getCustomName() + ex.getMessage());
}
}
}
示例13: saveModel
import weka.gui.ExtensionFileFilter; //导入依赖的package包/类
public void saveModel() {
try {
if (m_fileChooser == null) {
// i.e. after de-serialization
m_fileChooser =
new JFileChooser(new File(System.getProperty("user.dir")));
ExtensionFileFilter ef = new ExtensionFileFilter("model", "Serialized weka clusterer");
m_fileChooser.setFileFilter(ef);
}
int returnVal = m_fileChooser.showSaveDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File saveTo = m_fileChooser.getSelectedFile();
String fn = saveTo.getAbsolutePath();
if (!fn.endsWith(".model")) {
fn += ".model";
saveTo = new File(fn);
}
ObjectOutputStream os =
new ObjectOutputStream(new BufferedOutputStream(
new FileOutputStream(saveTo)));
os.writeObject(m_Clusterer);
if (m_trainingSet != null) {
Instances header = new Instances(m_trainingSet, 0);
os.writeObject(header);
}
os.close();
if (m_log != null) {
m_log.logMessage(Messages.getInstance().getString("Clusterer_SaveModel_LogMessage_Text_Fourth") + getCustomName());
}
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(Clusterer.this,
Messages.getInstance().getString("Clusterer_SaveModel_JOptionPane_ShowMessageDialog_Text_First"),
Messages.getInstance().getString("Clusterer_SaveModel_JOptionPane_ShowMessageDialog_Text_Second"),
JOptionPane.ERROR_MESSAGE);
if (m_log != null) {
m_log.logMessage(Messages.getInstance().getString("Clusterer_SaveModel_LogMessage_Text_Fifth")
+ getCustomName() + ex.getMessage());
}
}
}
示例14: setUpFile
import weka.gui.ExtensionFileFilter; //导入依赖的package包/类
public void setUpFile() {
removeAll();
File tmp = ((FileSourcedConverter)m_dsLoader.getLoader()).retrieveFile();
tmp = new File(tmp.getAbsolutePath());
if (tmp.isDirectory()) {
m_fileChooser.setCurrentDirectory(tmp);
} else {
m_fileChooser.setSelectedFile(tmp);
}
FileSourcedConverter loader = (FileSourcedConverter) m_dsLoader.getLoader();
String[] ext = loader.getFileExtensions();
ExtensionFileFilter firstFilter = null;
for (int i = 0; i < ext.length; i++) {
ExtensionFileFilter ff =
new ExtensionFileFilter(
ext[i], loader.getFileDescription() + " (*" + ext[i] + ")");
if (i == 0)
firstFilter = ff;
m_fileChooser.addChoosableFileFilter(ff);
}
if (firstFilter != null)
m_fileChooser.setFileFilter(firstFilter);
JPanel about = m_LoaderEditor.getAboutPanel();
if (about != null) {
add(about, BorderLayout.NORTH);
}
add(m_fileChooser, BorderLayout.CENTER);
m_relativeFilePath = new JCheckBox(Messages.getInstance().getString("LoaderCustomizer_SetUpDatabase_RelativeFilePath_JCheckBox_Text"));
m_relativeFilePath.
setSelected(((FileSourcedConverter)m_dsLoader.getLoader()).getUseRelativePath());
m_relativeFilePath.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
((FileSourcedConverter)m_dsLoader.getLoader()).
setUseRelativePath(m_relativeFilePath.isSelected());
}
});
JPanel holderPanel = new JPanel();
holderPanel.setLayout(new FlowLayout());
holderPanel.add(m_relativeFilePath);
add(holderPanel, BorderLayout.SOUTH);
}
示例15: getFilters
import weka.gui.ExtensionFileFilter; //导入依赖的package包/类
/**
* Returns the extension filters for this type of script.
*
* @return the filters
*/
public abstract ExtensionFileFilter[] getFilters();