List of usage examples for javax.swing JOptionPane showInputDialog
public static String showInputDialog(Object message) throws HeadlessException
From source file:regresiones.RegresionSimple.java
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("calcular")) {//podemos comparar por el contenido del boton String sx1 = this.cajaVariableX1.getText(); prediccionEfect = Double.parseDouble(this.combo.getSelectedItem() + ""); if (isDouble(sx1)) { prediccionX1 = Double.parseDouble(sx1); Integer gradosLibertad = N - 2; TDistribution td = new TDistribution(gradosLibertad); Double distribucionT = td.inverseCumulativeProbability(((100.0 - prediccionEfect) / 2.0) / 100.0) * -1.0;/* www.ja va2s .c o m*/ prediccionYestimada = b0 + b1 * prediccionX1; prediccionLi = prediccionYestimada - distribucionT * Se; prediccionLs = prediccionYestimada + distribucionT * Se; String[] titulos2 = { "Y estimada", "Li", "Ls" };//los titulos de la tabla String[][] pruebaIntervalos = { { prediccionYestimada + "", prediccionLi + "", prediccionLs + "" } }; DefaultTableModel TableModel = new DefaultTableModel(pruebaIntervalos, titulos2); jtable2.setModel(TableModel); } else { JOptionPane.showMessageDialog(null, "Valores no validos."); } System.out.println("imprimir" + e.getActionCommand()); //comentario } if (e.getActionCommand().equals("Exportar a PDF")) { try { String nombrePDF = JOptionPane.showInputDialog("Escribe el nombre del PDF (sin extension)"); Double[] prediccionValores = { prediccionX1, prediccionEfect, prediccionYestimada, prediccionLi, prediccionLs }; PDFsimple.crearPDF("Regresion simple", arregloFinal, nombrePDF, N, b0, b1, Se, dx, dy, dxy, r, prediccionValores); JOptionPane.showMessageDialog(jtable, "Se creo el PDF"); } catch (DocumentException | FileNotFoundException ex) { Logger.getLogger(RegresionMultiple.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:regresiones.RegresionMultiple.java
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("calcular")) {//podemos comparar por el contenido del boton String sx1 = this.cajaVariableX1.getText(); String sx2 = this.cajaVariableX2.getText(); prediccionEfect = Double.parseDouble(this.combo.getSelectedItem() + ""); if (isDouble(sx1) && isDouble(sx2)) { prediccionX1 = Double.parseDouble(sx1); prediccionX2 = Double.parseDouble(sx2); Integer gradosLibertad = N - 3; TDistribution td = new TDistribution(gradosLibertad); Double distribucionT = td.inverseCumulativeProbability(((100.0 - prediccionEfect) / 2.0) / 100.0) * -1.0;/*from w w w . j a v a 2 s .com*/ prediccionYestimada = b0 + b1 * prediccionX1 + b2 * prediccionX2; prediccionLi = prediccionYestimada - distribucionT * Se; prediccionLs = prediccionYestimada + distribucionT * Se; String[] titulos2 = { "Y estimada", "Li", "Ls" };//los titulos de la tabla String[][] pruebaIntervalos = { { prediccionYestimada + "", prediccionLi + "", prediccionLs + "" } }; DefaultTableModel TableModel = new DefaultTableModel(pruebaIntervalos, titulos2); jtable2.setModel(TableModel); } else { JOptionPane.showMessageDialog(null, "Valores no validos."); } System.out.println("imprimir" + e.getActionCommand()); } if (e.getActionCommand().equals("Exportar a PDF")) { try { String nombrePDF = JOptionPane.showInputDialog("Escribe el nombre del PDF (sin extension)"); Double[] prediccionValores = { prediccionX1, prediccionX2, prediccionEfect, prediccionYestimada, prediccionLi, prediccionLs }; PDFmultiple.crearPDF("Regresion multiple", arregloFinal, nombrePDF, N, b0, b1, b2, Se, prediccionValores); JOptionPane.showMessageDialog(jtable, "Se creo el PDF"); } catch (DocumentException | FileNotFoundException ex) { Logger.getLogger(RegresionMultiple.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:regresiones.EstadisticaDescriptiva.java
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("Exportar a PDF")) { try {//w w w . j a v a 2s.c o m String nombrePDF = JOptionPane.showInputDialog("Escribe el nombre del PDF (sin extension)"); String[] datosVariables = { MAXIMO + "", MINIMO + "", RANGO + "", INTERVALOS + "", AMPLITUD + "", RANGOAMPLIADO + "", DIFERENCIARANGOS + "", LIPI + "", LSUI + "", DM + "", VARIANZA + "", DE + "", MEDIA + "", MEDIANA + "", MODA + "" }; PDFdescriptiva.crearPDF("Estadistica descriptiva", formato(tablaCompleta), nombrePDF, N, datosVariables); JOptionPane.showMessageDialog(jtable, "Se creo el PDF"); } catch (FileNotFoundException ex) { Logger.getLogger(RegresionMultiple.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(EstadisticaDescriptiva.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.joey.software.regionSelectionToolkit.controlers.ImageProfileTool.java
public void estimateSurface() { if (true) {//from www . j a v a2 s .com return; } int threshold = Integer.parseInt(JOptionPane.showInputDialog("Number :")); boolean found = true; int val = 0; int rgb = 0; int[] pos; if (axis == AXIS_Y) { pos = new int[panel.getImage().getWidth()]; for (int x = 0; x < panel.getImage().getWidth(); x++) { for (int y = 0; y < panel.getImage().getHeight(); y++) { rgb = panel.getImage().getRGB(x, y); val = ImageOperations.getPlaneFromRGBA(rgb, ImageOperations.PLANE_GRAY); if (val > threshold) { pos[x] = y; y = panel.getImage().getHeight(); } } } } else if (axis == AXIS_X) { } for (int i = 0; i < selectionData.length; i++) { selectionData[i] = 0.9f; } for (int i = 0; i < value.length; i++) { value[i] = 0.9f; } panel.repaint(); }
From source file:com.g2inc.scap.editor.gui.windows.EditorMainWindow.java
private void initFilemenu() { final EditorMainWindow parentWinRef = this; exitMenuItem.addActionListener(new ActionListener() { @Override// ww w . ja va 2s.c o m public void actionPerformed(ActionEvent e) { parentWinRef.dispose(); } }); openOvalMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { final JFileChooser fc = new JFileChooser(); fc.setDialogType(JFileChooser.OPEN_DIALOG); File lastOpenedFrom = guiProps.getLastOpenedFromFile(); // Set current directory fc.setCurrentDirectory(lastOpenedFrom); FileFilter ff = new OcilOrOvalFilesFilter("OVAL"); fc.setFileFilter(ff); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); int ret = fc.showOpenDialog(EditorMainWindow.getInstance()); if (ret == JFileChooser.APPROVE_OPTION) { File f = fc.getSelectedFile(); File parent = f.getAbsoluteFile().getParentFile(); guiProps.setLastOpenedFrom(parent.getAbsolutePath()); guiProps.save(); openFile(f, SCAPDocumentClassEnum.OVAL); } } }); saveMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { // get the currently open window JInternalFrame selectedWin = desktopPane.getSelectedFrame(); if (selectedWin != null) { SCAPDocument scapDoc = null; Document dom = null; String filename = null; if (selectedWin instanceof OvalEditorForm) { OvalEditorForm oef = (OvalEditorForm) selectedWin; scapDoc = oef.getDocument(); dom = scapDoc.getDoc(); filename = scapDoc.getFilename(); } else if (selectedWin instanceof CPEDictionaryEditorForm) { CPEDictionaryEditorForm cef = (CPEDictionaryEditorForm) selectedWin; scapDoc = cef.getDocument(); dom = scapDoc.getDoc(); filename = scapDoc.getFilename(); } if (dom != null) { // since this is a save operation, not save as, we won't // prompt the user for where to store the file try { scapDoc.save(); ((EditorForm) selectedWin).setDirty(false); } catch (Exception e) { String message = "An error occured trying to save to file " + filename + ": " + e.getMessage(); EditorUtil.showMessageDialog(parentWinRef, message, EditorMessages.SAVE_ERROR_DIALOG_TITLE, JOptionPane.ERROR_MESSAGE); } } } } }); saveAsMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { // get the currently open window JInternalFrame selectedWin = desktopPane.getSelectedFrame(); if (selectedWin != null) { SCAPDocument scapDoc = null; Document dom = null; String filename = null; String windowTitle = null; if (selectedWin instanceof OvalEditorForm) { windowTitle = OvalEditorForm.WINDOW_TITLE_BASE; OvalEditorForm oef = (OvalEditorForm) selectedWin; scapDoc = oef.getDocument(); dom = scapDoc.getDoc(); filename = scapDoc.getFilename(); } else if (selectedWin instanceof CPEDictionaryEditorForm) { windowTitle = CPEDictionaryEditorForm.WINDOW_TITLE_BASE; CPEDictionaryEditorForm cef = (CPEDictionaryEditorForm) selectedWin; scapDoc = cef.getDocument(); dom = scapDoc.getDoc(); filename = scapDoc.getFilename(); } else { return; } if (dom != null) { String newFilename = null; SCAPDocumentTypeEnum docType = scapDoc.getDocumentType(); FileSaveAsWizard saveAsWiz = new FileSaveAsWizard(EditorMainWindow.getInstance(), true, docType); //saveAsWiz.pack(); saveAsWiz.setLocationRelativeTo(EditorMainWindow.getInstance()); saveAsWiz.setVisible(true); if (saveAsWiz.wasCancelled()) { return; } newFilename = saveAsWiz.getFilename(); try { scapDoc.setFilename(newFilename); scapDoc.saveAs(newFilename); EditorUtil.markActiveWindowDirty(EditorMainWindow.getInstance(), false); ((EditorForm) selectedWin).refreshRootNode(); } catch (Exception e) { LOG.error(e.getMessage(), e); EditorUtil.showMessageDialog(parentWinRef, "An error occured trying to save to file " + newFilename + ": " + e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE); return; } SCAPContentManager scm = SCAPContentManager.getInstance(); if (scm != null) { scm.removeDocument(filename); scm.addDocument(newFilename, scapDoc); selectedWin.setTitle(windowTitle + (new File(newFilename)).getAbsolutePath()); } else { LOG.error("SCM instance is null here!"); } } } } }); newXCCDFFromOvalMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { //generateXccdfFromOvalOrOcil("OVAL"); final JFileChooser fc = new JFileChooser(); fc.setDialogType(JFileChooser.OPEN_DIALOG); File lastOpenedFrom = guiProps.getLastOpenedFromFile(); // Set current directory fc.setCurrentDirectory(lastOpenedFrom); FileFilter ff = new OcilOrOvalFilesFilter("OVAL"); fc.setFileFilter(ff); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); int ret = fc.showOpenDialog(EditorMainWindow.getInstance()); if (ret == JFileChooser.APPROVE_OPTION) { File f = fc.getSelectedFile(); File parent = f.getAbsoluteFile().getParentFile(); guiProps.setLastOpenedFrom(parent.getAbsolutePath()); guiProps.save(); try { InputStream is = this.getClass().getClassLoader().getResourceAsStream("oval-to-xccdf.xsl"); File xsltfile = new File("oval-to-xccdf.xsl"); OutputStream outputStream = new FileOutputStream(xsltfile); IOUtils.copy(is, outputStream); outputStream.close(); OvalToXCCDF1.ovalToXccdf(f, xsltfile); xsltfile.delete(); String reverseDNS = JOptionPane.showInputDialog("reverse_DNS:"); if (reverseDNS == null || reverseDNS.length() == 0) { JOptionPane.showMessageDialog(null, "Enter the reverse_DNS", "alert", JOptionPane.ERROR_MESSAGE); } else { JFileChooser fc1 = new JFileChooser(); fc1.setCurrentDirectory(f); int ret1 = fc1.showSaveDialog(EditorMainWindow.getInstance()); if (ret1 == JFileChooser.APPROVE_OPTION) { File savefile = fc1.getSelectedFile(); is = this.getClass().getClassLoader().getResourceAsStream("xccdf_1.1_to_1.2.xsl"); xsltfile = new File("oval-to-xccdf.xsl"); outputStream = new FileOutputStream(xsltfile); IOUtils.copy(is, outputStream); outputStream.close(); File temp = new File("temp.xml"); XCCDF1to2.xccdf12(savefile, reverseDNS, xsltfile, temp); JOptionPane.showMessageDialog(null, "XCCDF File Created: " + savefile.getAbsolutePath(), "XCCDF Created", JOptionPane.PLAIN_MESSAGE); xsltfile.delete(); temp.delete(); temp = null; } } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TransformerException e) { // TODO Auto-generated catch block e.printStackTrace(); } // openFile(f, SCAPDocumentClassEnum.OVAL); } } }); newOvalMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { CreateOvalWizard wiz = new CreateOvalWizard(true); wiz.setName("create_oval_wizard"); wiz.pack(); wiz.setVisible(true); if (!wiz.wasCancelled()) { // User has been through the wizard to select // 1. an Oval schema version (eg, OVAL55) // 2. one or more platforms (eg, "windows", "solaris", etc) // 3. a file name for the new Oval file // Now we are ready to actually create the file String createdFilename = createNewOvalDocument(wiz); if (createdFilename == null) { LOG.error("newOvalMenuItem.actionlistener: Created filename was null!"); return; } File f = new File(createdFilename); guiProps.setLastOpenedFromFile(f.getParentFile()); guiProps.save(); SCAPContentManager scm = SCAPContentManager.getInstance(); if (scm != null) { OvalDefinitionsDocument dd = (OvalDefinitionsDocument) scm.getDocument(f.getAbsolutePath()); openFile(dd); } } wiz.setVisible(false); wiz.dispose(); } }); /* wizModeMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { WizardModeWindow wizModeWin = new WizardModeWindow(); EditorMainWindow emw = EditorMainWindow.getInstance(); JDesktopPane emwDesktopPane = emw.getDesktopPane(); wizModeWin.setTitle("Wizard Mode"); wizModeWin.pack(); wizModeWin.addInternalFrameListener(new WeakInternalFrameListener(EditorMainWindow.getInstance())); Dimension dpDim = emwDesktopPane.getSize(); int x = (dpDim.width - wizModeWin.getWidth()) / 2; int y = (dpDim.height - wizModeWin.getHeight()) / 2; wizModeWin.setLocation(x, y); emwDesktopPane.add(wizModeWin); wizModeWin.setVisible(true); setWizMode(true); } });*/ ugMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); InputStream resource = this.getClass().getResourceAsStream("/User_Guide.pdf"); try { File userGuideFile = File.createTempFile("UserGuide", ".pdf"); userGuideFile.deleteOnExit(); OutputStream out = new FileOutputStream(userGuideFile); try { // copy contents from resource to out IOUtils.copy(resource, out); } catch (IOException ex) { JOptionPane.showMessageDialog(null, "Couldn't copy between streams."); } finally { out.close(); } desktop.open(userGuideFile); } catch (IOException ex) { JOptionPane.showMessageDialog(null, "Could not call Open on desktop object."); } finally { try { if (resource != null) { resource.close(); } } catch (IOException ex) { LOG.error("Error displaying user guide", ex); JOptionPane.showMessageDialog(null, "Desktop not supported. Cannot open user guide."); } } } else { JOptionPane.showMessageDialog(null, "Desktop not supported. Cannot open user guide."); } } }); }
From source file:com.floreantpos.ui.views.payment.PaymentView.java
public void addMyKalaId() { String loyaltyid = JOptionPane.showInputDialog(Messages.getString("PaymentView.64")); //$NON-NLS-1$ if (StringUtils.isEmpty(loyaltyid)) { return;/*from w w w .j a va2 s . c o m*/ } Ticket ticket = settleTicketView.getTicket(); ticket.addProperty(SettleTicketDialog.LOYALTY_ID, loyaltyid); TicketDAO.getInstance().saveOrUpdate(ticket); POSMessageDialog.showMessage(Messages.getString("PaymentView.65")); //$NON-NLS-1$ }
From source file:org.simbrain.plot.projection.ProjectionGui.java
/** * Creates the menu bar./*from ww w . j a v a 2 s .c o m*/ */ private void createAttachMenuBar() { final JMenuBar bar = new JMenuBar(); final JMenu fileMenu = new JMenu("File"); for (Action action : actionManager.getOpenSavePlotActions()) { fileMenu.add(action); } fileMenu.addSeparator(); final JMenu exportImport = new JMenu("Export/Import..."); fileMenu.add(exportImport); exportImport.add(ProjectionPlotActions.getImportData(getWorkspaceComponent().getProjectionModel())); exportImport.addSeparator(); exportImport.add(ProjectionPlotActions.getExportDataHi(getWorkspaceComponent().getProjectionModel())); exportImport.add(ProjectionPlotActions.getExportDataLow(getWorkspaceComponent().getProjectionModel())); fileMenu.addSeparator(); fileMenu.add(new CloseAction(this.getWorkspaceComponent())); final JMenu editMenu = new JMenu("Edit"); final JMenuItem preferencesGeneral = new JMenuItem("General Preferences..."); preferencesGeneral.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { ProjectionPreferencesDialog dialog = new ProjectionPreferencesDialog( getWorkspaceComponent().getProjectionModel().getProjector()); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); } }); editMenu.add(preferencesGeneral); final JMenuItem colorPrefs = new JMenuItem("Datapoint Coloring..."); colorPrefs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { DataPointColoringDialog dialog = new DataPointColoringDialog( getWorkspaceComponent().getProjectionModel()); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); } }); editMenu.add(colorPrefs); final JMenuItem dims = new JMenuItem("Set dimensions..."); dims.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { String dimensions = JOptionPane.showInputDialog("Dimensions:"); if (dimensions != null) { getWorkspaceComponent().getProjectionModel().getProjector().init(Integer.parseInt(dimensions)); } } }); // editMenu.add(dims); JMenu helpMenu = new JMenu("Help"); JMenuItem helpItem = new JMenuItem(helpAction); helpMenu.add(helpItem); bar.add(fileMenu); bar.add(editMenu); bar.add(helpMenu); getParentFrame().setJMenuBar(bar); }
From source file:MetaFramework.Bayesian.java
public ArrayList<String> calculateDiff(Bicluster bicluster, int chosenColumn, Dataset dataset, double threshold) { ArrayList<String> res = new ArrayList<String>(); int[] genes = bicluster.getGenes(); if (chosenColumn == -1) { // Differential gene expression // Only need this one as the other option is still to be implemented // Let's do grouping/based on the conditions. However, we need that as being an input or something // There might be many groups // First ask for the groups/conditions if (!done) { String first = JOptionPane .showInputDialog("Enter the columns of first group/condition (comma separated)"); String second = JOptionPane .showInputDialog("Enter the columns of second group/condition (comma separated)"); String[] words = first.split(","); String[] words2 = second.split(","); ArrayList<Integer> tmp = new ArrayList<Integer>(); // firstColumns = new int[words.length]; // secondColumns = new int[words2.length]; done = true;/*from ww w.ja v a 2s. c o m*/ for (int i = 0; i < words.length; i++) { String[] range = words[i].split("-"); if (range.length == 1) tmp.add(Integer.parseInt(words[i].replaceAll("\\s+", ""))); // Just a number else { int left = Integer.parseInt(range[0].replaceAll("\\s+", "")); int right = Integer.parseInt(range[1].replaceAll("\\s+", "")); for (int j = left; j <= right; j++) tmp.add(j); } //range } firstColumns = new int[tmp.size()]; for (int i = 0; i < tmp.size(); i++) firstColumns[i] = tmp.get(i); System.out.println("First columns size : " + firstColumns.length); tmp = new ArrayList<Integer>(); for (int i = 0; i < words2.length; i++) { String[] range = words2[i].split("-"); if (range.length == 1) tmp.add(Integer.parseInt(words2[i].replaceAll("\\s+", ""))); // Just a number else { int left = Integer.parseInt(range[0].replaceAll("\\s+", "")); int right = Integer.parseInt(range[1].replaceAll("\\s+", "")); for (int j = left; j <= right; j++) tmp.add(j); } //range } secondColumns = new int[tmp.size()]; for (int i = 0; i < tmp.size(); i++) { secondColumns[i] = tmp.get(i); } System.out.println("Second columns size : " + secondColumns.length); } float[][] data = dataset.getData(); // Let's compute the means first Double[] allP = new Double[genes.length]; for (int i = 0; i < genes.length; i++) { // double meanA = 0.0, meanB = 0.0, mean = 0.0; // // for (int j = 0; j < data[0].length; j++) // mean += data[genes[i]][j]; // // mean = mean / data[0].length; // // for (int j = 0; j < firstColumns.length; j++) // meanA += data[genes[i]][firstColumns[j]]; // for (int j = 0; j < secondColumns.length; j++) // meanB += data[genes[i]][secondColumns[j]]; // //// mean = (meanA + meanB) / (firstColumns.length + secondColumns.length); // meanA = meanA / firstColumns.length; // meanB = meanB / secondColumns.length; // double sum1 = 0.0, sum2 = 0.0, sum3 = 0.0, sum4 = 0.0; // for (int j = 0; j < firstColumns.length; j++) { // sum1 += Math.pow(data[genes[i]][firstColumns[j]] - meanA, 2); // sum3 += Math.pow(data[genes[i]][firstColumns[j]] - mean, 2); // } // for (int j = 0; j < secondColumns.length; j++) { // sum2 += Math.pow(data[genes[i]][secondColumns[j]] - meanB, 2); // sum4 += Math.pow(data[genes[i]][secondColumns[j]] - mean, 2); // } // double t = 2.0 * (sum1 + sum2) / (sum3 + sum4); // DecimalFormat formatter = new DecimalFormat("#0.00"); // t = Double.parseDouble(formatter.format(t)); // Bonferroni correction (multiply by sample size) // double pValue = computePValue(t, 1); // double toCheck = Math.min(1.0, pValue * genes.length); double[] aValues = new double[firstColumns.length]; double[] bValues = new double[secondColumns.length]; for (int j = 0; j < firstColumns.length; j++) { aValues[j] = data[genes[i]][firstColumns[j]]; // System.out.print(aValues[j] + ","); } // System.out.println(); for (int j = 0; j < secondColumns.length; j++) { bValues[j] = data[genes[i]][secondColumns[j]]; // System.out.print(bValues[j] + ","); } TTest tTest = new TTest(); // Using apache common math library. This seems to be more stable double apacheP = tTest.tTest(aValues, bValues); double toCheck = apacheP * genes.length; // System.out.println("Apache adapted P value : " + toCheck); if (toCheck <= 0.1) { // System.out.println("Diff expressed!"); res.add(dataset.getGeneName(genes[i])); } // Benjamini-Hochberg: // allP[i] = computePValue(t, 1); } // Benjamini - Hochberg: // TODO : CHECK WITH MATLAB T-TEST FUNCTION! // Arrays.sort(allP); // for (int i = 0; i < allP.length; i++) // System.out.print(allP[i] + " "); // double[] adjustedP = new double[allP.length]; // double min = 1.0; // for (int i = allP.length; i > 0; i--) // { // double tmp = (allP.length * allP[i - 1]) / (i + 0.0); // if (tmp < min) // min = tmp; // adjustedP[i - 1] = min; // System.out.println(adjustedP[i - 1]); // if (tmp <= 0.05) // { // res.add(dataset.getGeneName) // } // } } else { // Based on the column // This part is easy as it will be just about grouping genes into two values if (threshold == Double.MAX_VALUE) { // Means column was actually binary (so, 2 possible values) // This is the case for our test case int[][] discrData = dataset.getDiscrData(); System.out.println("For debugging!"); for (int i = 0; i < genes.length; i++) { if (discrData[genes[i]][chosenColumn] > 0.5) // 0.5 is used as in binary columns I expect 0/1 values res.add(dataset.getGeneName(genes[i])); // TODO : Change this to min/max } } else { // Based on the threshold. Higher than threshold is diff float[][] discrData = dataset.getData(); for (int i = 0; i < genes.length; i++) { if (discrData[genes[i]][chosenColumn] > threshold) res.add(dataset.getGeneName(genes[i])); } } } return res; }
From source file:com.commander4j.db.JDBUserReport.java
public boolean runReport() { PreparedStatement prepStatement; boolean result = true; try {//w w w .j av a 2 s. c o m prepStatement = Common.hostList.getHost(getHostID()).getConnection(getSessionID()) .prepareStatement(getSQL(), ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); prepStatement.setFetchSize(25); if (isParamDateRequired()) { prepStatement.setTimestamp(1, getParamFromDate()); prepStatement.setTimestamp(2, getParamToDate()); } if (getDestination().equals("SYSTEM")) { for (int x = 0; x < systemParams.size(); x++) { String type = systemParams.get(x).parameterType; if (type.toLowerCase().equals("string")) { prepStatement.setString(systemParams.get(x).parameterPosition, systemParams.get(x).parameterStringValue); } if (type.toLowerCase().equals("integer")) { prepStatement.setInt(systemParams.get(x).parameterPosition, systemParams.get(x).parameterIntegerValue); } if (type.toLowerCase().equals("long")) { prepStatement.setLong(systemParams.get(x).parameterPosition, systemParams.get(x).parameterLongValue); } if (type.toLowerCase().equals("timestamp")) { prepStatement.setTimestamp(systemParams.get(x).parameterPosition, systemParams.get(x).parameterTimestampValue); } } } ResultSet tempResult = prepStatement.executeQuery(); boolean dataReturned = true; if (!tempResult.next()) { dataReturned = false; } tempResult.beforeFirst(); if (dataReturned) { if (getDestination().equals("EXCEL")) { generateExcel(tempResult); } if (getDestination().equals("JASPER_REPORTS")) { generateJasper(prepStatement); } if (getDestination().equals("PDF")) { generatePDF(prepStatement); } if (getDestination().equals("ACCESS")) { generateAccess(tempResult); } if (getDestination().equals("CSV")) { generateCSV(tempResult); } if (getDestination().equals("SYSTEM")) { generateSYSTEM(tempResult); } if (isPreviewRequired()) { try { Desktop.getDesktop().open(new File(getExportFilename())); } catch (IOException e) { e.printStackTrace(); } } if (isEmailEnabled()) { String emailaddresses = getEmailAddresses(); if (isEmailPromptEnabled()) { emailaddresses = JUtility.replaceNullStringwithBlank( JOptionPane.showInputDialog(lang.get("lbl_Email_Addresses"))); } StringConverter stringConverter = new StringConverter(); ArrayConverter arrayConverter = new ArrayConverter(String[].class, stringConverter); arrayConverter.setDelimiter(';'); arrayConverter.setAllowedChars(new char[] { '@', '_' }); String[] emailList = (String[]) arrayConverter.convert(String[].class, emailaddresses); if (emailList.length > 0) { String shortFilename = JUtility.getFilenameFromPath(getExportFilename()); mail.postMail(emailList, "Commande4j User Report requested by " + Common.userList.getUser(Common.sessionID).getUserId() + " from [" + Common.hostList.getHost(getHostID()).getSiteDescription() + "] on " + JUtility.getClientName(), "See attached report.\n", shortFilename, getExportFilename()); com.commander4j.util.JWait.milliSec(2000); } } } else { result = false; setErrorMessage("No data returned by query."); } } catch (Exception ex) { setErrorMessage(ex.getMessage()); result = false; } return result; }
From source file:com.mycompany.zad1.MainWindow.java
private void medianFilterButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_medianFilterButtonActionPerformed MedianfIlter medianfIlter = new MedianfIlter(); consloleOut();//from w w w . j a v a2 s .c o m int maskSize = Integer.parseInt(JOptionPane.showInputDialog("Input maskSize")); try { imageBuff = medianfIlter.computeImage(imageBuff, maskSize); } catch (Exception ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); } imageMoiffayLabel.setIcon(new ImageIcon(imageBuff.getImage())); consloleOut(); }