List of usage examples for weka.gui ListSelectorDialog showDialog
public int showDialog()
From source file:meka.gui.dataviewer.DataPanel.java
License:Open Source License
/** * deletes the chosen attributes/*from www. j a va 2 s .co m*/ */ public void deleteAttributes() { ListSelectorDialog dialog; DataSortedTableModel model; Object[] atts; int[] indices; int i; JList list; int result; list = new JList(getAttributes()); dialog = new ListSelectorDialog(null, list); result = dialog.showDialog(); if (result != ListSelectorDialog.APPROVE_OPTION) { return; } atts = list.getSelectedValues(); // really? if (ComponentHelper.showMessageBox(getParent(), "Confirm...", "Do you really want to delete these " + atts.length + " attributes?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) { return; } model = (DataSortedTableModel) m_TableData.getModel(); indices = new int[atts.length]; for (i = 0; i < atts.length; i++) { indices[i] = model.getAttributeColumn(atts[i].toString()); } setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); model.deleteAttributes(indices); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }
From source file:meka.gui.dataviewer.DataViewerMainPanel.java
License:Open Source License
/** * displays some properties of the instances */// w ww . j a v a 2s. c om public void showProperties() { DataPanel panel; ListSelectorDialog dialog; Vector<String> props; Instances inst; panel = getCurrentPanel(); if (panel == null) { return; } inst = panel.getInstances(); if (inst == null) { return; } if (inst.classIndex() < 0) { inst.setClassIndex(inst.numAttributes() - 1); } // get some data props = new Vector<String>(); props.add("Filename: " + panel.getFilename()); props.add("Relation name: " + inst.relationName()); props.add("# of instances: " + inst.numInstances()); props.add("# of attributes: " + inst.numAttributes()); props.add("Class attribute: " + inst.classAttribute().name()); props.add("# of class labels: " + inst.numClasses()); dialog = new ListSelectorDialog(getParentFrame(), new JList(props)); dialog.showDialog(); }
From source file:meka.gui.dataviewer.DataViewerMainPanel.java
License:Open Source License
/** * displays all the attributes, returns the selected item or NULL if canceled * * @return the name of the selected attribute *///from w w w .j av a 2 s . c o m public String showAttributes() { DataSortedTableModel model; ListSelectorDialog dialog; int i; JList list; String name; int result; if (!isPanelSelected()) { return null; } list = new JList(getCurrentPanel().getAttributes()); dialog = new ListSelectorDialog(getParentFrame(), list); result = dialog.showDialog(); if (result == ListSelectorDialog.APPROVE_OPTION) { model = (DataSortedTableModel) getCurrentPanel().getTable().getModel(); name = list.getSelectedValue().toString(); i = model.getAttributeColumn(name); JTableHelper.scrollToVisible(getCurrentPanel().getTable(), 0, i); getCurrentPanel().getTable().setSelectedColumn(i); return name; } else { return null; } }
From source file:meka.gui.dataviewer.DataViewerMainPanel.java
License:Open Source License
/** * displays all the distinct values for an attribute *///from ww w . j a va 2 s . c o m public void showValues() { String attribute; DataSortedTableModel model; DataTable table; HashSet<String> values; Vector<String> items; Iterator<String> iter; ListSelectorDialog dialog; int i; int col; // choose attribute to retrieve values for attribute = showAttributes(); if (attribute == null) { return; } table = getCurrentPanel().getTable(); model = (DataSortedTableModel) table.getModel(); // get column index col = -1; for (i = 0; i < table.getColumnCount(); i++) { if (table.getPlainColumnName(i).equals(attribute)) { col = i; break; } } // not found? if (col == -1) { return; } // get values values = new HashSet<String>(); items = new Vector<String>(); for (i = 0; i < model.getRowCount(); i++) { values.add(model.getValueAt(i, col).toString()); } if (values.isEmpty()) { return; } iter = values.iterator(); while (iter.hasNext()) { items.add(iter.next()); } Collections.sort(items); dialog = new ListSelectorDialog(getParentFrame(), new JList(items)); dialog.showDialog(); }
From source file:milk.gui.experiment.MIResultsPanel.java
License:Open Source License
/** * Queries the user enough to make a database query to retrieve experiment * results./*from w w w.j a v a 2 s . com*/ */ protected void setInstancesFromDBaseQuery() { try { if (m_InstanceQuery == null) { m_InstanceQuery = new MIInstanceQuery(); } String dbaseURL = m_InstanceQuery.getDatabaseURL(); dbaseURL = (String) JOptionPane.showInputDialog(this, "Enter the database URL", "Query Database", JOptionPane.PLAIN_MESSAGE, null, null, dbaseURL); if (dbaseURL == null) { m_FromLab.setText("Cancelled"); return; } m_InstanceQuery.setDatabaseURL(dbaseURL); m_InstanceQuery.connectToDatabase(); if (!m_InstanceQuery.experimentIndexExists()) { m_FromLab.setText("No experiment index"); return; } m_FromLab.setText("Getting experiment index"); Instances index = m_InstanceQuery.retrieveInstances("SELECT * FROM " + MIInstanceQuery.EXP_INDEX_TABLE); if (index.numInstances() == 0) { m_FromLab.setText("No experiments available"); return; } m_FromLab.setText("Got experiment index"); DefaultListModel lm = new DefaultListModel(); for (int i = 0; i < index.numInstances(); i++) { lm.addElement(index.instance(i).toString()); } JList jl = new JList(lm); ListSelectorDialog jd = new ListSelectorDialog(null, jl); int result = jd.showDialog(); if (result != ListSelectorDialog.APPROVE_OPTION) { m_FromLab.setText("Cancelled"); return; } Instance selInst = index.instance(jl.getSelectedIndex()); Attribute tableAttr = index.attribute(MIInstanceQuery.EXP_RESULT_COL); String table = MIInstanceQuery.EXP_RESULT_PREFIX + selInst.toString(tableAttr); setInstancesFromDatabaseTable(table); } catch (Exception ex) { m_FromLab.setText("Problem reading database"); } }
From source file:milk.gui.experiment.MIResultsPanel.java
License:Open Source License
public void setResultKeyFromDialog() { ListSelectorDialog jd = new ListSelectorDialog(null, m_ResultKeyList); // Open the dialog int result = jd.showDialog(); // If accepted, update the ttester if (result == ListSelectorDialog.APPROVE_OPTION) { int[] selected = m_ResultKeyList.getSelectedIndices(); String selectedList = ""; for (int i = 0; i < selected.length; i++) { selectedList += "," + (selected[i] + 1); }//from w w w . j a va2s .c o m Range generatorRange = new Range(); if (selectedList.length() != 0) { try { generatorRange.setRanges(selectedList); } catch (Exception ex) { ex.printStackTrace(); System.err.println(ex.getMessage()); } } m_TTester.setResultsetKeyColumns(generatorRange); setTTester(); } }
From source file:milk.gui.experiment.MIResultsPanel.java
License:Open Source License
public void setDatasetKeyFromDialog() { ListSelectorDialog jd = new ListSelectorDialog(null, m_DatasetKeyList); // Open the dialog int result = jd.showDialog(); // If accepted, update the ttester if (result == ListSelectorDialog.APPROVE_OPTION) { int[] selected = m_DatasetKeyList.getSelectedIndices(); String selectedList = ""; for (int i = 0; i < selected.length; i++) { selectedList += "," + (selected[i] + 1); }/*from w w w .ja v a 2s . c o m*/ Range generatorRange = new Range(); if (selectedList.length() != 0) { try { generatorRange.setRanges(selectedList); } catch (Exception ex) { ex.printStackTrace(); System.err.println(ex.getMessage()); } } m_TTester.setDatasetKeyColumns(generatorRange); setTTester(); } }
From source file:milk.gui.experiment.MIResultsPanel.java
License:Open Source License
public void setTestBaseFromDialog() { ListSelectorDialog jd = new ListSelectorDialog(null, m_TestsList); // Open the dialog jd.showDialog(); }