private void calculateANOVA() throws SignificanceCalculationException { double alpha = -1; String alphaString = alphaField.getText(); try { alpha = Double.parseDouble(alphaString); } catch (NumberFormatException e) { SwingTools.showVerySimpleErrorMessage("Significance level must be a number between 0 and 1."); } if ((alpha < 0) || (alpha > 1)) { SwingTools.showVerySimpleErrorMessage("Significance level must be a number between 0 and 1."); } else { this.calculator.clearGroups(); this.calculator.setAlpha(alpha); for (int i = 0; i < tableModel.getRowCount(); i++) { int number = ((Integer) tableModel.getValueAt(i, 2)).intValue(); double mean = ((Double) tableModel.getValueAt(i, 0)).doubleValue(); double variance = ((Double) tableModel.getValueAt(i, 1)).doubleValue(); calculator.addGroup(number, mean, variance); } if (tableModel.getRowCount() < 2) { SwingTools.showVerySimpleErrorMessage( "You need to add at least two rows in order to calculate an ANOVA test."); return; } SignificanceTestResult result = calculator.performSignificanceTest(); JOptionPane.showMessageDialog( this, result.getVisualizationComponent(null), "ANOVA result", JOptionPane.PLAIN_MESSAGE); } }
@Override public void apply() { RepositoryLocation absLoc; try { absLoc = operator.getParameterAsRepositoryLocation(key); final RepositoryLocation processLoc = operator.getProcess().getRepositoryLocation().parent(); if (processLoc == null) { SwingTools.showVerySimpleErrorMessage( "quickfix_failed", "Process is not stored in repository."); } else { String relative = absLoc.makeRelative(processLoc); operator.setParameter(key, relative); } } catch (UserError e) { // Should not happen. Parameter should be set, otherwise we would not have created this // prefix. SwingTools.showVerySimpleErrorMessage("quickfix_failed", e.toString()); } }
/** * The given operators will be inserted at the last position of the currently selected operator * chain. */ public void insert(List<Operator> newOperators) { Object selectedNode = getSelectedOperator(); if (selectedNode == null) { SwingTools.showVerySimpleErrorMessage("cannot_insert_operator"); return; } else if (mainFrame.getProcessPanel().getProcessRenderer().getModel().getDisplayedChain() == selectedNode) { for (Operator newOperator : newOperators) { int index = mainFrame .getProcessPanel() .getProcessRenderer() .getProcessIndexUnder( mainFrame .getProcessPanel() .getProcessRenderer() .getModel() .getCurrentMousePosition()); if (index == -1) { index = 0; } ((OperatorChain) selectedNode).getSubprocess(index).addOperator(newOperator); } } else { int i = 0; Operator selectedOperator = (Operator) selectedNode; ExecutionUnit process = selectedOperator.getExecutionUnit(); int parentIndex = process.getOperators().indexOf(selectedOperator) + 1; for (Operator newOperator : newOperators) { process.addOperator(newOperator, parentIndex + i); i++; } } AutoWireThread.autoWireInBackground(newOperators, true); mainFrame.selectOperators(newOperators); }
private void storeInFolder(final Folder folder) { // get current process name (if present) String currentName = null; if (RapidMinerGUI.getMainFrame().getProcess().getProcessLocation() != null) { currentName = RapidMinerGUI.getMainFrame().getProcess().getProcessLocation().getShortName(); } final String name = SwingTools.showRepositoryEntryInputDialog("store_process", currentName); if (name != null) { if (name.isEmpty()) { SwingTools.showVerySimpleErrorMessage("please_enter_non_empty_name"); return; } try { // check if folder already contains entry with said name RepositoryLocation entryLocation = new RepositoryLocation(folder.getLocation(), name); if (folder.containsEntry(name)) { Entry existingEntry = entryLocation.locateEntry(); if (!(existingEntry instanceof ProcessEntry)) { // existing entry is not a ProcessEntry, cannot overwrite SwingTools.showVerySimpleErrorMessage("repository_entry_already_exists", name); return; } else { // existing entry is ProcessEntry,let #overwriteProcess() handle it overwriteProcess((ProcessEntry) existingEntry); return; } } } catch (RepositoryException e1) { SwingTools.showSimpleErrorMessage("cannot_store_process_in_repository", e1, name); return; } catch (MalformedRepositoryLocationException e1) { SwingTools.showSimpleErrorMessage("cannot_store_process_in_repository", e1, name); return; } ProgressThread storeProgressThread = new ProgressThread("store_process") { public void run() { getProgressListener().setTotal(100); Process process = RapidMinerGUI.getMainFrame().getProcess(); RepositoryProcessLocation processLocation = null; try { processLocation = new RepositoryProcessLocation( new RepositoryLocation(folder.getLocation(), name)); getProgressListener().setCompleted(10); Process.checkIfSavable(process); folder.createProcessEntry(name, process.getRootOperator().getXML(false)); process.setProcessLocation(processLocation); tree.expandPath(tree.getSelectionPath()); RapidMinerGUI.addToRecentFiles(process.getProcessLocation()); RapidMinerGUI.getMainFrame().processHasBeenSaved(); } catch (Exception e) { SwingTools.showSimpleErrorMessage( "cannot_save_process", e, processLocation, e.getMessage()); RapidMinerGUI.getMainFrame().getProcess().setProcessLocation(null); } finally { getProgressListener().setCompleted(10); getProgressListener().complete(); } } }; storeProgressThread.start(); } }