List of usage examples for javax.swing.table DefaultTableModel DefaultTableModel
public DefaultTableModel(Object[][] data, Object[] columnNames)
DefaultTableModel
and initializes the table by passing data
and columnNames
to the setDataVector
method. From source file:gtu._work.mvn.MavenRepositoryUI.java
void resetUIStatus() { {//from ww w . ja v a 2s. c o m DefaultListModel model = new DefaultListModel(); for (PomFile pom : pomFileList) { model.addElement(pom); } scanList.setModel(model); } { DefaultListModel model = new DefaultListModel(); for (PomFile pom : pomFileJarList) { model.addElement(pom); } scanList2.setModel(model); } { Object[] header = new Object[] { "pom", "lastModified", "jar", "parent", "modelVersion", " groupId", " artifactId", " packaging", " name", " version", " url", " description" }; DefaultTableModel model = new DefaultTableModel(new Object[][] {}, header) { private static final long serialVersionUID = 1L; public boolean isCellEditable(int row, int column) { return false; } }; for (PomFile pom : pomFileList) { model.addRow(new Object[] { // pom, // DateFormatUtils.format(pom.xmlFile.lastModified(), "yyyy/MM/dd HH:mm:ss"), // (pom.jarFile == null ? "" : DateFormatUtils.format(pom.jarFile.lastModified(), "yyyy/MM/dd HH:mm:ss") + "(" + (pom.jarFile.length() / 1024) + ")"), // (pom.pom.parent == null ? "" : "Y"), // pom.pom.modelVersion, // pom.pom.groupId, // pom.pom.artifactId, // pom.pom.packaging, // pom.pom.name, // pom.pom.version, // pom.pom.url, // pom.pom.description // }); } scanTable.setModel(model); } scanText.getDocument().addDocumentListener(getDocumentListener(scanList, pomFileList)); scanText2.getDocument().addDocumentListener(getDocumentListener(scanList2, pomFileJarList)); }
From source file:canreg.client.gui.dataentry.ImportView.java
/** * *//*from w ww . j av a2 s . co m*/ @Action public void previewAction() { // show the contents of the file BufferedReader br = null; try { changeFile(); // numberOfRecordsTextField.setText(""+(canreg.common.Tools.numberOfLinesInFile(inFile.getAbsolutePath())-1)); FileInputStream fis = new FileInputStream(inFile); br = new BufferedReader(new InputStreamReader(fis, (Charset) charsetsComboBox.getSelectedItem())); CSVFormat csvFormat = CSVFormat.DEFAULT.withFirstRecordAsHeader().withDelimiter(getSeparator()); CSVParser csvParser = new CSVParser(br, csvFormat); int linesToRead = Globals.NUMBER_OF_LINES_IN_IMPORT_PREVIEW; int numberOfLinesRead = 0; Vector<Vector<String>> data = new Vector<Vector<String>>(); String[] headers = csvParser.getHeaderMap().keySet().toArray(new String[0]); for (CSVRecord csvRecord : csvParser) { csvRecord.toMap(); Vector vec = new Vector(); Iterator<String> iterator = csvRecord.iterator(); while (iterator.hasNext()) { vec.add(iterator.next()); } data.add(vec); numberOfLinesRead++; if (numberOfLinesRead >= linesToRead) { break; } } numberOfRecordsShownTextField.setText(numberOfLinesRead + ""); // previewTextArea.setText(headers + "\n" + dataText); // previewTextArea.setCaretPosition(0); previewPanel.setVisible(true); Vector columnNames = new Vector(Arrays.asList(headers)); previewTable.setModel(new DefaultTableModel(data, columnNames)); } catch (FileNotFoundException fileNotFoundException) { JOptionPane.showInternalMessageDialog(CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("COULD_NOT_PREVIEW_FILE:") + " \'" + fileNameTextField.getText().trim() + "\'.", java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("ERROR"), JOptionPane.ERROR_MESSAGE); Logger.getLogger(ImportView.class.getName()).log(Level.SEVERE, null, fileNotFoundException); } catch (IOException ex) { JOptionPane.showInternalMessageDialog(CanRegClientApp.getApplication().getMainFrame().getContentPane(), java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("COULD_NOT_PREVIEW_FILE:") + " \'" + fileNameTextField.getText().trim() + "\'.", java.util.ResourceBundle.getBundle("canreg/client/gui/dataentry/resources/ImportView") .getString("ERROR"), JOptionPane.ERROR_MESSAGE); Logger.getLogger(ImportView.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (br != null) { br.close(); } } catch (IOException ex) { Logger.getLogger(ImportView.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:semaforo.Semaforo.java
public void core() { // double cfd=0, bull=0, bear=0; // if(finalcountCfd!=0)cfd = ((finalcountCfd*100)/(finalcountBear+finalcountBull+finalcountCfd)); // if(finalcountBull!=0)bull = ((finalcountBull*100)/(finalcountBear+finalcountBull+finalcountCfd)); // if(finalcountBear!=0)bear = ((finalcountBear*100)/(finalcountBear+finalcountBull+finalcountCfd)); // Semaforo.l1.setText("CFD ("+cfd+"%)"); if (countCfd > 0 && !cfd) { Semaforo.l1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/redL.png"))); cfd = true;//from w ww . j av a2 s . c o m } else if (countBull > 0 && !bull) { Semaforo.l2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/redL.png"))); bull = true; } else if (countBear > 0 && !bear) { Semaforo.l3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/redL.png"))); bear = true; } if (countCfd > 0 && !cfd) { Semaforo.l1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/blueL.png"))); cfd = true; } else if (countBull > 0 && !bull) { Semaforo.l2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/blueL.png"))); bull = true; } else if (countBear > 0 && !bear) { Semaforo.l3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/blueL.png"))); bear = true; } if (countCfd > 0 && !cfd) { Semaforo.l1 .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/greenL.png"))); cfd = true; } else if (countBull > 0 && !bull) { Semaforo.l2 .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/greenL.png"))); bull = true; } else if (countBear > 0 && !bear) { Semaforo.l3 .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/greenL.png"))); bear = true; } if (countCfd <= 0) { Semaforo.l1 .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/blackL.png"))); } if (countBull <= 0) { Semaforo.l2 .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/blackL.png"))); } if (countBear <= 0) { Semaforo.l3 .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/blackL.png"))); } // try { refrescarPorcentajeGroups(); } catch (SQLException ex) { Logger.getLogger(Semaforo.class.getName()).log(Level.SEVERE, null, ex); } Random r = new Random(System.currentTimeMillis()); //Mcol = r.nextInt(8) + 1; while (update == 2) { try { Thread.sleep(50); } catch (InterruptedException ex) { Logger.getLogger(Semaforo.class.getName()).log(Level.SEVERE, null, ex); } } synchronized (updateLock) { update = 0; } final Settings settings = Controller.getSettings(); Hashtable<String, List<Integer>> ht = Controller.getTickersValue(); while (Controller.isCalculatingColor) { try { Thread.sleep(100); } catch (InterruptedException ex) { Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex); } } synchronized (calculateColorLock) { Controller.isCalculatingColor = true; } for (int t = 0; t < settings.getTickers().size(); t++) { Controller.calcular_color(settings.getTickers().get(t).getName(), settings.getTickers().get(t).getCurrentPrice()); } synchronized (Controller.calculateColorLock) { Controller.isCalculatingColor = false; } //Aqu se aplica el ordenamiento final Map<String, List<Integer>> map = sortByValues(ht); maP = map; TableModel temp = TableTicker.getModel(); // updatePanelSemaforo(); //$$$ SE SETEA LAS COLUMNAS DE TICKER int capital = 0; Object obje = null; Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -1); SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd"); String fechaAyer = format1.format(cal.getTime()); Calendar cal2 = Calendar.getInstance(); SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); String fechaHoy = format2.format(cal2.getTime()); int compradasOld, compradasHoy; String columnsTitle[] = { "Ticker", "Price", "To Invest", "CFD", "Bought", "Remain", "LOW DAY", "Comprar?" }; Object rows[][] = new Object[settings.getTickers().size()][9]; rowsCopy tablaCopia = new rowsCopy(settings.getTickers().size(), 7, 2); Object TablaConHedge[][] = new Object[500][8]; int[] numerosEstado = new int[500]; TablaConHedge = tablaCopia.retornaCopiaTabla(); numerosEstado = tablaCopia.retornaNumerosEstado(); //int size = TableTicker.getRowCount(); int fila = 0; int cuentaTickersBaja = 0; int cuentaTickersValidos = 0; boolean actualizar = false; Iterator iterator = map.entrySet().iterator(); while (iterator.hasNext()) { Entry entry = (Entry) iterator.next(); for (Ticker ticker : settings.getTickers()) { if (ticker.getName().equalsIgnoreCase(entry.getKey().toString())) { //$$$ 0 Nombre del Ticker rows[fila][0] = ticker.getName(); //$$$ 1 Valor del Ticker currentSym = rows[fila][0].toString(); Thread t = new Thread(new Runnable() { public String t = currentSym; @Override public void run() { Curl.jsonDecode(Curl.preciosTicker(t), t); } }); t.start(); rows[fila][1] = String.format("%.2f", ticker.getCurrentPrice()); DDBB.updatePriceTicker(rows[fila][0].toString(), rows[fila][1].toString()); ResultSet resTickers = DDBB.lowHigh(rows[fila][0].toString()); try { if (resTickers.next()) { // String low=resTickers.getString("low_low").toString().replace(",", "."); // String high=resTickers.getString("high_high").toString().replace(",", "."); rows[fila][6] = resTickers.getString("low_low").toString().replace(",", "."); // String pre=rows[fila][1].toString().replace(",", "."); // if(pre.isEmpty())pre=rows[fila][1].toString(); // double precio = Float.parseFloat(pre); // double low_low = Float.parseFloat(low); // double high_high = Float.parseFloat(high); //kobytest.KobyTest.pedir_historico(Settings.getTickerID(rows[fila][0].toString()), rows[fila][0].toString(), kobytest.KobyTest.total_weeks_ago); // if(precio>high_high){ // DDBB.updateHighHighTicker(rows[fila][0].toString(), rows[fila][1].toString()); // } // if(precio<low_low){ // DDBB.updateLowLowTicker(rows[fila][0].toString(), rows[fila][1].toString()); // } } //$$$ 2 CAPITAL } catch (SQLException ex) { Logger.getLogger(Semaforo.class.getName()).log(Level.SEVERE, null, ex); } //$$$ rutina para precarga de DDBB //int capitalDB = Controller.getSettings().getCapital(ticker.getName()); //valoresTickerCapital.put(ticker.getName(), capitalDB); //System.out.println("***************************** CAPITAL HASHMAP " + valoresTickerCapital.size() + " " + valoresTickerCapital.toString()); int tempFila = getFilaTickerFrontEnd(temp, ticker.getName()); if (tempFila > -1) { obje = temp.getValueAt(tempFila, 2); } try { capital = Integer .parseInt((obje == null || obje.toString().isEmpty()) ? "0" : obje.toString()); ElementoCapitalDB elemCapitalDB = valoresTickerCapital.get(ticker.getName()); if ((elemCapitalDB != null) && !(valoresTickerCapital.get(ticker.getName()).isChequeado)) { if (semaforo.Semaforo.isDebugMode) { System.out.println( "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Lectura de DDBB " + elemCapitalDB); } if (semaforo.Semaforo.isDebugMode) { System.out.println(""); } if (semaforo.Semaforo.isDebugMode) { System.out.println(""); } rows[fila][2] = valoresTickerCapital.get(ticker.getName()).getCapital(); valoresTickerCapital.get(ticker.getName()).setIsChequeado(true); } else { rows[fila][2] = (capital == 0) ? "" : capital; } if (semaforo.Semaforo.isDebugMode) { System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ROWS FILA " + fila + " COLUMNA 2 VALE: " + rows[fila][2]); } elemCapitalDB = valoresTickerCapital.get(ticker.getName()); if (elemCapitalDB == null) { elemCapitalDB = new ElementoCapitalDB(); elemCapitalDB.setCapital(0); elemCapitalDB.setIsChequeado(true); } int capitalDB = elemCapitalDB.getCapital(); //rows[fila][2] = capitalDB; if ((capitalDB != capital)) { Controller.getSettings().setCapital(ticker.getName(), capital); elemCapitalDB.setCapital(capital); elemCapitalDB.setIsChequeado(true); valoresTickerCapital.put(ticker.getName(), elemCapitalDB); } } catch (Exception e) { e.printStackTrace(); rows[fila][2] = ""; } //rows[fila][2] //..... //$$$ 3 CFD rows[fila][3] = String.format("", Math.round((capital / ticker.getCurrentPrice()))); if ( /*!rows[fila][2].equals(null) ||*/!rows[fila][2].toString().isEmpty()) { rows[fila][3] = String.format("%.0f", Math.floor(capital / ticker.getCurrentPrice())); } //$$$ Bought Map misPosiciones = Controller.getSettings().getValorPosiciones(); rows[fila][4] = 0; if (misPosiciones != null) { Iterator iterator2 = misPosiciones.keySet().iterator(); while (iterator2.hasNext()) { String key = iterator2.next().toString(); int value = (Integer) misPosiciones.get(key); if (ticker.getName().equals(key)) { rows[fila][4] = value; } System.out.println(key + " " + value); } } //rows[fila][4] = ticker.getCurrentPrice(); try { //if(rows[fila][3] != "" || rows[fila][4] != ""){ if (rows[fila][3] != null && !rows[fila][3].toString().isEmpty()) { if (rows[fila][4] != null && !rows[fila][4].toString().isEmpty()) { //tempStr = TableTicker.getModel().getValueAt(row, 3).toString().replace(",", "."); // Remain rows[fila][5] = Integer.parseInt(rows[fila][3].toString()) - Integer.parseInt(rows[fila][4].toString()); } else { rows[fila][5] = rows[fila][3]; } } } catch (Exception e) { e.printStackTrace(); } // byte ptext[] = "֎".getBytes(ISO_8859_1); // String value = new String(ptext, UTF_8); // rows[fila][6] = value; //rows[fila][6] = "<>"; rows[fila][7] = "O"; String compradasDDBB = "0"; String id_ticker = rows[fila][0].toString(); String compradasString; compradasString = rows[fila][4] + ""; rows[fila][8] = 1; // COMPRADAS HOY SI O NO DDBB.deleteComprasFecha(fechaHoy); ResultSet resCompras = DDBB.BuscarComprasFecha(id_ticker, fechaHoy); try { if (resCompras.next()) { rows[fila][8] = resCompras.getInt("compro"); tablaCopia.cambiarCopiaTabla(fila, 8, resCompras.getInt("compro")); //JOptionPane.showMessageDialog(null,resCompras.getInt("compradas")+"", "", JOptionPane.ERROR_MESSAGE); compradasDDBB = resCompras.getString("compradas"); if (!compradasDDBB.isEmpty() && !compradasString.isEmpty()) { compradasOld = Integer.parseInt(compradasDDBB); compradasHoy = Integer.parseInt(compradasString); //JOptionPane.showMessageDialog(null,compradasOld+"", "", JOptionPane.ERROR_MESSAGE); // if (compradasHoy > compradasOld) { // JOptionPane.showMessageDialog(null,compradasOld+"-"+compradasHoy+"-"+resCompras.getInt("compro"), "", JOptionPane.ERROR_MESSAGE); //ROJO DDBB.deleteCompras(id_ticker); DDBB.insertCompras(id_ticker, compradasString, fechaHoy, 0); rows[fila][8] = 0; tablaCopia.cambiarCopiaTabla(fila, 8, "0"); // tablaCopia.cambiarNumerosComprar(fila, 0); } else if (compradasHoy == compradasOld) { DDBB.deleteCompras(id_ticker); DDBB.insertCompras(id_ticker, compradasString, fechaHoy, 1); rows[fila][8] = 1; tablaCopia.cambiarCopiaTabla(fila, 8, "1"); } //DDBB.insertCompras(id_ticker, compradasString, fechaHoy); } else { } } else { DDBB.insertCompras(id_ticker, compradasString, fechaHoy, 1); rows[fila][8] = 1; tablaCopia.cambiarCopiaTabla(fila, 8, "1"); //JOptionPane.showMessageDialog(null,"", "", JOptionPane.ERROR_MESSAGE); } } catch (SQLException ex) { Logger.getLogger(Semaforo.class.getName()).log(Level.SEVERE, null, ex); } //System.out.println("INIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIITTTTT"); Map misCierres = Controller.getSettings().getValorCierres(); if (misCierres != null) { try { Double restaCierre = (Double) misCierres.get(ticker.getName()) - ticker.getCurrentPrice(); //System.out.println("RESTAAAA ################# " + restaCierre); cuentaTickersValidos++; cuentaTickersBaja = cuentaTickersBaja + (restaCierre > 0 ? 1 : 0); // System.out.println("TICKER " + ticker.getName() + " CIERRE " + misCierres.get(ticker.getName()) + " PRECIO: " + ticker.getCurrentPrice() ); // System.out.println("#################### PROMEDIO " + ((1.00 * cuentaTickersBaja) / (1.00 * cuentaTickersValidos)) *100 + " VALIDOS " + cuentaTickersValidos + " BAJAS " + cuentaTickersBaja); } catch (Exception e) { } // Iterator iterator3 = misCierres.keySet().iterator(); // // while (iterator3.hasNext()) { // String key = iterator3.next().toString(); // Double valueDouble = (Double)misCierres.get(key); // // // // System.out.println(key + " " + valueDouble); // } } //System.out.println("FIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIINN"); fila++; } } } double promedioBajasTickers; promedioBajasTickers = ((1.00 * cuentaTickersBaja) / (1.00 * cuentaTickersValidos) * 100); String promedio = Double.toString(promedioBajasTickers); promedio = promedio.substring(0, promedio.indexOf(".") + 2); if (semaforo.Semaforo.isDebugMode) { System.out.println("#################### PROMEDIO " + promedioBajasTickers); } if (promedioBajasTickers < 50.0) { jLabelLuzPrincipal .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/verdep.png"))); jLabelLuzPrincipal.setText(promedio + "%"); // jLabelSemaphore.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/SemVERDE_HOR.png"))); } else if (promedioBajasTickers < 70.0) { jLabelLuzPrincipal.setIcon( new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/amarillop.png"))); jLabelLuzPrincipal.setText(promedio + "%"); // jLabelSemaphore.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/SemAMARILLO_HOR.png"))); } else { jLabelLuzPrincipal .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/rojop.png"))); jLabelLuzPrincipal.setText(promedio + "%"); // jLabelSemaphore.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/SemROJO_HOR.png"))); } // $$$ GENERACION DEL MODELO CON LA MEJORA DE NO EDICION DE LAS OTRAS COLUMNAS TableModel newModel = new DefaultTableModel(rows, columnsTitle) { boolean[] canEdit = new boolean[] { false, false, true, false, false, false, false, false }; public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }; //$$$ RUTINA ESPECIAL PARA EL MANEJO DEL MODELO QUE SE BORRA Y LA EDICION DEL CAMPO CASH if (!TableTicker.isEditing()) { TableTicker.setModel(newModel); formateaCabeceroTicker(); } int num = Math.min(settings.getTickers().size(), TableWeek1.getModel().getRowCount()); int[] my_positions = new int[num]; int[] my_positions_old = new int[500]; rowsCopy doblePosiciones = new rowsCopy(0, 0, 2); my_positions_old = doblePosiciones.getPosiciones(); doblePosiciones.setPosiciones(my_positions); for (int row = 0; row < num; row++) { if (map.get(TableTicker.getValueAt(row, 0)) != null) { List<Integer> listInt = map .get(TableTicker.getValueAt(row, 0) /*settings.getTickers().get(row).getName()*/); my_positions[row] = -1; if (!listInt.isEmpty() && settings.getTickers().get(row).isHistory()) { // int col = ht.get(TableTicker.getValueAt(row, 0)).get(index) + 1; int col = map.get(TableTicker.getValueAt(row, 0)).get(0); my_positions[row] = col; if (my_positions_old.length > 0) { String id_ticker = rows[row][0].toString(); // JOptionPane.showMessageDialog(null, id_ticker+""); //if(col == my_positions_old[row]){DDBB.deleteParpadeo(id_ticker);} if (col < my_positions_old[row] && col <= 7) { DDBB.insertParpadeo(id_ticker, 30); try { /*al hacer el ejecutable se debe cambiar a solo notificacion.mp3*/ //fis = new FileInputStream("C:\\Users\\maikolleon\\Documents\\NetBeansProjects\\s2m1f4r4\\src\\semaforo\\resources\\notificacion.mp3"); fis = new FileInputStream("notificacion.mp3"); bis = new BufferedInputStream(fis); player = new Player(bis); player.play(); // fis2 = new FileInputStream("notificacion.mp3"); // bis2 = new BufferedInputStream(fis2); // player2 = new Player(bis2); // player2.play(); // // fis3 = new FileInputStream("notificacion.mp3"); // bis3 = new BufferedInputStream(fis3); // player3 = new Player(bis3); // player3.play(); } catch (JavaLayerException ex) { Logger.getLogger(Semaforo.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Semaforo.class.getName()).log(Level.SEVERE, null, ex); } hiloParpadeo(id_ticker, row, col); } } } } } updateTableTickers(); updateTableWeek(TableWeek1, settings.getVaribable("rango_1"), 17); loadTableCells(TableWeek1, WEEK1, map, 17); updateTableWeek(TableWeek2, settings.getVaribable("rango_2"), 17); loadTableCells(TableWeek2, WEEK2, map, 17); updateTableWeek(TableWeek3, settings.getVaribable("rango_3"), 17); loadTableCells(TableWeek3, WEEK3, map, 17); TableTicker.getColumnModel().getColumn(7).setMaxWidth(0); TableTicker.getColumnModel().getColumn(7).setMinWidth(0); TableTicker.getColumnModel().getColumn(7).setPreferredWidth(0); // TableTicker.getColumnModel().getColumn(6).setMaxWidth(0); // TableTicker.getColumnModel().getColumn(6).setMinWidth(0); // TableTicker.getColumnModel().getColumn(6).setPreferredWidth(0); //Redraw the window synchronized (updateLock) { update = 1; } validate(); repaint(); }
From source file:com.pianobakery.complsa.MainGui.java
private void createUIComponents() { this.indexTypeComboBox = new JComboBox(indexType); this.termComboBox = new JComboBox(termweights); //docSearchTitles = new String[]{"%Similarity","Path","Show"}; docSearchResModel = new DocSearchModel(); docSearchResTable = new JTable(docSearchResModel); docSearchResTable.setShowHorizontalLines(false); docSearchResTable.setShowVerticalLines(true); docSearchResTable.setFillsViewportHeight(true); docSearchResTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); docSearchResTable.setShowGrid(false); docSearchResTable.setGridColor(Color.DARK_GRAY); docSearchResTable.setAutoscrolls(true); docSearchResTable.getColumn("%Similarities:").setPreferredWidth(100); docSearchResTable.getColumn("%Similarities:").setWidth(25); docSearchResTable.getColumn("Filename:").setPreferredWidth(600); docSearchResTable.getColumn("Filename:").setWidth(100); docSearchResTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); DefaultTableCellRenderer leftRenderer = new DefaultTableCellRenderer(); leftRenderer.setHorizontalAlignment(JLabel.LEFT); docSearchResTable.getColumnModel().getColumn(0).setCellRenderer(leftRenderer); termSearchTitles = new String[] { "%Similarities:", "Terms:" }; termSearchResModel = new DefaultTableModel(termSearchTitles, 0) { @Override//from w ww .j av a2 s . c o m public boolean isCellEditable(int row, int column) { return false; } }; termSearchResTable = new JTable(termSearchResModel); termSearchResTable.setShowVerticalLines(true); termSearchResTable.setShowHorizontalLines(false); termSearchResTable.setFillsViewportHeight(true); termSearchResTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); termSearchResTable.setShowGrid(false); termSearchResTable.setGridColor(Color.DARK_GRAY); termSearchResTable.setAutoscrolls(true); termSearchResTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); termSearchResTable.getColumnModel().getColumn(0).setPreferredWidth(80); termSearchResTable.getColumnModel().getColumn(0).setWidth(80); termSearchResTable.getColumnModel().getColumn(0).setCellRenderer(leftRenderer); termSearchResTable.getColumnModel().getColumn(1).setPreferredWidth(120); termSearchResTable.getColumnModel().getColumn(1).setWidth(120); //docSearchResTable.getColumnModel().getColumn(0).setPreferredWidth(50); //docSearchResTable.getColumnModel().getColumn(1).sizeWidthToFit(); }
From source file:gskproject.Analyze.java
public void resetFields() {//for reset the fields in the text area Vector<String> columnNames = new Vector<String>();// columnNames.add("Department"); columnNames.add("First Aid"); columnNames.add("LTI"); columnNames.add("Near Miss"); columnNames.add("Total"); tblDepartmentAccident.setModel(new DefaultTableModel(null, columnNames)); dtDAFrom.setDate(null);/* w w w. j a v a 2 s. c o m*/ dtDATo.setDate(null); ddDTimePeriod.setSelectedIndex(0); lblOpen.setText(""); lblClosed.setText(""); lblTotal.setText(""); lblTime.setText(""); }
From source file:org.esa.beam.visat.toolviews.stat.StatisticsPanel.java
private JPanel createStatPanel(Stx stx, final Mask regionalMask, final Mask qualityMask, int stxIdx, RasterDataNode raster) {//from w w w . j a v a 2 s.c om final Histogram histogram = stx.getHistogram(); final int row = stxIdx + 1; // account for header boolean includeFileMetaData = statisticsCriteriaPanel.isIncludeFileMetaData(); boolean includeMaskMetaData = statisticsCriteriaPanel.isIncludeMaskMetaData(); boolean includeBandMetaData = statisticsCriteriaPanel.isIncludeBandMetaData(); boolean includeBinningInfo = statisticsCriteriaPanel.isIncludeBinningInfo(); ; boolean includeTimeMetaData = statisticsCriteriaPanel.isIncludeTimeMetaData(); boolean isIncludeTimeSeriesMetaData = statisticsCriteriaPanel.isIncludeTimeSeriesMetaData(); boolean includeProjectionParameters = statisticsCriteriaPanel.isIncludeProjectionParameters(); boolean includeColumnBreaks = statisticsCriteriaPanel.isIncludeColBreaks(); // Initialize all spreadsheet table indices to -1 (default don't use value) if (stxIdx == 0 || metaDataFieldsHashMap == null || primaryStatisticsFieldsHashMap == null) { initHashMaps(); } XIntervalSeries histogramSeries = new XIntervalSeries("Histogram"); double histDomainBounds[] = { histogram.getLowValue(0), histogram.getHighValue(0) }; double histRangeBounds[] = { Double.NaN, Double.NaN }; if (!fixedHistDomainAllPlots || (fixedHistDomainAllPlots && !fixedHistDomainAllPlotsInitialized)) { if (!statisticsCriteriaPanel.isLogMode()) { if (statisticsCriteriaPanel.plotsThreshDomainSpan()) { if (statisticsCriteriaPanel.plotsThreshDomainLow() >= 0.1) { histDomainBounds[0] = histogram .getPTileThreshold((statisticsCriteriaPanel.plotsThreshDomainLow()) / 100)[0]; } if (statisticsCriteriaPanel.plotsThreshDomainHigh() <= 99.9) { histDomainBounds[1] = histogram .getPTileThreshold(statisticsCriteriaPanel.plotsThreshDomainHigh() / 100)[0]; } } else if (statisticsCriteriaPanel.plotsDomainSpan()) { if (!Double.isNaN(statisticsCriteriaPanel.plotsDomainLow())) { histDomainBounds[0] = statisticsCriteriaPanel.plotsDomainLow(); } if (!Double.isNaN(statisticsCriteriaPanel.plotsDomainHigh())) { histDomainBounds[1] = statisticsCriteriaPanel.plotsDomainHigh(); } } } else { histDomainBounds[0] = histogram.getBinLowValue(0, 0); histDomainBounds[1] = histogram.getHighValue(0); } // if (!LogMode && plotsThreshDomainSpan && plotsThreshDomainLow >= 0.1 && plotsThreshDomainHigh <= 99.9) { // histDomainBounds[0] = histogram.getPTileThreshold((plotsThreshDomainLow) / 100)[0]; // histDomainBounds[1] = histogram.getPTileThreshold(plotsThreshDomainHigh / 100)[0]; // // } else { // histDomainBounds[0] = histogram.getBinLowValue(0, 0); // histDomainBounds[1] = histogram.getHighValue(0); // } if (fixedHistDomainAllPlots && !fixedHistDomainAllPlotsInitialized) { histDomainBoundsAllPlots[0] = histDomainBounds[0]; histDomainBoundsAllPlots[1] = histDomainBounds[1]; fixedHistDomainAllPlotsInitialized = true; } } else { histDomainBounds[0] = histDomainBoundsAllPlots[0]; histDomainBounds[1] = histDomainBoundsAllPlots[1]; } int[] bins = histogram.getBins(0); for (int j = 0; j < bins.length; j++) { histogramSeries.add(histogram.getBinLowValue(0, j), histogram.getBinLowValue(0, j), j < bins.length - 1 ? histogram.getBinLowValue(0, j + 1) : histogram.getHighValue(0), bins[j]); } String logTitle = (statisticsCriteriaPanel.isLogMode()) ? "Log10 of " : ""; ChartPanel histogramPanel = createChartPanel(histogramSeries, logTitle + raster.getName() + " (" + raster.getUnit() + ")", "Frequency in #Pixels", new Color(0, 0, 127), histDomainBounds, histRangeBounds); // histogramPanel.setPreferredSize(new Dimension(300, 200)); if (statisticsCriteriaPanel.exactPlotSize()) { histogramPanel.setMinimumSize(new Dimension(statisticsCriteriaPanel.plotSizeWidth(), statisticsCriteriaPanel.plotSizeHeight())); histogramPanel.setPreferredSize(new Dimension(statisticsCriteriaPanel.plotSizeWidth(), statisticsCriteriaPanel.plotSizeHeight())); histogramPanel.setMaximumSize(new Dimension(statisticsCriteriaPanel.plotSizeWidth(), statisticsCriteriaPanel.plotSizeHeight())); } else { histogramPanel.setMinimumSize(new Dimension(plotMinWidth, plotMinHeight)); histogramPanel.setPreferredSize(new Dimension(plotMinWidth, plotMinHeight)); } XIntervalSeries percentileSeries = new XIntervalSeries("Percentile"); // if (1 == 2 && LogMode) { // percentileSeries.add(0, // 0, // 1, // Math.pow(10, histogram.getLowValue(0))); // for (int j = 1; j < 99; j++) { // percentileSeries.add(j, // j, // j + 1, // Math.pow(10, histogram.getPTileThreshold(j / 100.0)[0])); // } // percentileSeries.add(99, // 99, // 100, // Math.pow(10, histogram.getHighValue(0))); // // } else { // percentileSeries.add(0, // 0, // 0.25, // histogram.getLowValue(0)); // // for (double j = 0.25; j < 99.75; j += .25) { // percentileSeries.add(j, // j, // j + 1, // histogram.getPTileThreshold(j / 100.0)[0]); // } // percentileSeries.add(99.75, // 99.75, // 100, // histogram.getHighValue(0)); // } // // double fraction = 0; // for (int j = 0; j < bins.length; j++) { // // fraction = (1.0) * j / bins.length; // // if (fraction > 0 && fraction < 1) { // percentileSeries.add(histogram.getBinLowValue(0, j), // histogram.getBinLowValue(0, j), // j < bins.length - 1 ? histogram.getBinLowValue(0, j + 1) : histogram.getHighValue(0), // histogram.getPTileThreshold(fraction)[0]); // } // // // } // // double test = fraction; double[] percentileDomainBounds = { Double.NaN, Double.NaN }; double[] percentileRangeBounds = { Double.NaN, Double.NaN }; ChartPanel percentilePanel = null; if (invertPercentile) { double increment = .01; for (double j = 0; j < 100; j += increment) { double fraction = j / 100.0; double nextFraction = (j + increment) / 100.0; if (fraction > 0.0 && fraction < 1.0 && nextFraction > 0.0 && nextFraction < 1.0) { double thresh = histogram.getPTileThreshold(fraction)[0]; double nextThresh = histogram.getPTileThreshold(nextFraction)[0]; percentileSeries.add(thresh, thresh, nextThresh, j); } } if (!statisticsCriteriaPanel.isLogMode()) { percentileDomainBounds[0] = histDomainBounds[0]; percentileDomainBounds[1] = histDomainBounds[1]; } percentileRangeBounds[0] = 0; percentileRangeBounds[1] = 100; percentilePanel = createScatterChartPanel(percentileSeries, logTitle + raster.getName() + " (" + raster.getUnit() + ")", "Percent Threshold", new Color(0, 0, 0), percentileDomainBounds, percentileRangeBounds); } else { percentileSeries.add(0, 0, 0.25, histogram.getLowValue(0)); for (double j = 0.25; j < 99.75; j += .25) { percentileSeries.add(j, j, j + 1, histogram.getPTileThreshold(j / 100.0)[0]); } percentileSeries.add(99.75, 99.75, 100, histogram.getHighValue(0)); percentileDomainBounds[0] = 0; percentileDomainBounds[1] = 100; percentileRangeBounds[0] = histDomainBounds[0]; percentileRangeBounds[1] = histDomainBounds[1]; percentilePanel = createScatterChartPanel(percentileSeries, "Percent_Threshold", logTitle + raster.getName() + " (" + raster.getUnit() + ")", new Color(0, 0, 0), percentileDomainBounds, percentileRangeBounds); } // percentilePanel.setPreferredSize(new Dimension(300, 200)); if (statisticsCriteriaPanel.exactPlotSize()) { percentilePanel.setMinimumSize(new Dimension(statisticsCriteriaPanel.plotSizeWidth(), statisticsCriteriaPanel.plotSizeHeight())); percentilePanel.setPreferredSize(new Dimension(statisticsCriteriaPanel.plotSizeWidth(), statisticsCriteriaPanel.plotSizeHeight())); percentilePanel.setMaximumSize(new Dimension(statisticsCriteriaPanel.plotSizeWidth(), statisticsCriteriaPanel.plotSizeHeight())); } else { percentilePanel.setMinimumSize(new Dimension(plotMinWidth, plotMinHeight)); percentilePanel.setPreferredSize(new Dimension(plotMinWidth, plotMinHeight)); } int size = raster.getRasterHeight() * raster.getRasterWidth(); int validPixelCount = histogram.getTotals()[0]; int dataRows = 0; // new Object[]{"RasterSize(Pixels)", size}, // new Object[]{"SampleSize(Pixels)", histogram.getTotals()[0]}, Object[][] totalPixels = null; if (statisticsCriteriaPanel.includeTotalPixels()) { int totalPixelCount = stx.getRawTotal(); double percentFilled = (totalPixelCount > 0) ? (1.0 * validPixelCount / totalPixelCount) : 0; totalPixels = new Object[][] { new Object[] { "Regional_Pixels", stx.getRawTotal() }, new Object[] { "Valid_Pixels", validPixelCount }, new Object[] { "Fraction_Valid", percentFilled } }; } else { totalPixels = new Object[][] { new Object[] { "Valid_Pixels", validPixelCount } }; } dataRows += totalPixels.length; Object[][] firstData = new Object[][] { new Object[] { "Mean", stx.getMean() } }; dataRows += firstData.length; Object[][] minMaxData = null; if (statisticsCriteriaPanel.includeMinMax()) { minMaxData = new Object[][] { new Object[] { "Minimum", stx.getMinimum() }, new Object[] { "Maximum", stx.getMaximum() } }; dataRows += minMaxData.length; } Object[] medianObject = null; if (statisticsCriteriaPanel.includeMedian()) { medianObject = new Object[] { "Median", stx.getMedianRaster() }; dataRows++; } Object[][] secondData = new Object[][] { new Object[] { "Standard_Deviation", stx.getStandardDeviation() }, new Object[] { "Variance", getVariance(stx) }, new Object[] { "Coefficient_of_Variation", getCoefficientOfVariation(stx) } }; dataRows += secondData.length; Object[][] binningInfo = null; if (statisticsCriteriaPanel.isIncludeBinningInfo()) { binningInfo = new Object[][] { new Object[] { "Total_Bins", histogram.getNumBins()[0] }, new Object[] { "Bin_Width", getBinSize(histogram) }, new Object[] { "Bin_Min", histogram.getLowValue(0) }, new Object[] { "Bin_Max", histogram.getHighValue(0) } }; dataRows += binningInfo.length; } Object[][] histogramStats = null; if (statisticsCriteriaPanel.includeHistogramStats()) { if (statisticsCriteriaPanel.isLogMode()) { histogramStats = new Object[][] { new Object[] { "Mean(LogBinned)", Math.pow(10, histogram.getMean()[0]) }, new Object[] { "Median(LogBinned)", Math.pow(10, stx.getMedian()) }, new Object[] { "StandardDeviation(LogBinned)", Math.pow(10, histogram.getStandardDeviation()[0]) } }; } else { histogramStats = new Object[][] { new Object[] { "Mean(Binned)", histogram.getMean()[0] }, new Object[] { "Median(Binned)", stx.getMedian() }, new Object[] { "StandardDeviation(Binned)", histogram.getStandardDeviation()[0] } }; } dataRows += histogramStats.length; } Object[][] percentData = new Object[statisticsCriteriaPanel.getPercentThresholdsList().size()][]; for (int i = 0; i < statisticsCriteriaPanel.getPercentThresholdsList().size(); i++) { int value = statisticsCriteriaPanel.getPercentThresholdsList().get(i); double percent = value / 100.0; String percentString = Integer.toString(value); Object[] pTileThreshold; if (statisticsCriteriaPanel.isLogMode()) { pTileThreshold = new Object[] { percentString + "%Threshold(Log)", Math.pow(10, histogram.getPTileThreshold(percent)[0]) }; } else { pTileThreshold = new Object[] { percentString + "%Threshold", histogram.getPTileThreshold(percent)[0] }; } percentData[i] = pTileThreshold; } dataRows += percentData.length; Object[][] tableData = new Object[dataRows][]; int tableDataIdx = 0; if (totalPixels != null) { for (int i = 0; i < totalPixels.length; i++) { tableData[tableDataIdx] = totalPixels[i]; tableDataIdx++; } } if (firstData != null) { for (int i = 0; i < firstData.length; i++) { tableData[tableDataIdx] = firstData[i]; tableDataIdx++; } } if (medianObject != null) { tableData[tableDataIdx] = medianObject; tableDataIdx++; } if (minMaxData != null) { for (int i = 0; i < minMaxData.length; i++) { tableData[tableDataIdx] = minMaxData[i]; tableDataIdx++; } } if (secondData != null) { for (int i = 0; i < secondData.length; i++) { tableData[tableDataIdx] = secondData[i]; tableDataIdx++; } } if (binningInfo != null) { for (int i = 0; i < binningInfo.length; i++) { tableData[tableDataIdx] = binningInfo[i]; tableDataIdx++; } } if (histogramStats != null) { for (int i = 0; i < histogramStats.length; i++) { tableData[tableDataIdx] = histogramStats[i]; tableDataIdx++; } } if (percentData != null) { for (int i = 0; i < percentData.length; i++) { tableData[tableDataIdx] = percentData[i]; tableDataIdx++; } } numStxFields = tableData.length; int fieldIdx = 0; // Initialize indices if (stxIdx == 0) { primaryStatisticsFieldsHashMap.put(PrimaryStatisticsFields.FileRefNum, fieldIdx); fieldIdx++; primaryStatisticsFieldsHashMap.put(PrimaryStatisticsFields.BandName, fieldIdx); fieldIdx++; primaryStatisticsFieldsHashMap.put(PrimaryStatisticsFields.MaskName, fieldIdx); fieldIdx++; primaryStatisticsFieldsHashMap.put(PrimaryStatisticsFields.QualityMaskName, fieldIdx); fieldIdx++; stxFieldsStartIdx = fieldIdx; fieldIdx += numStxFields; stxFieldsEndIdx = fieldIdx - 1; if (includeBandMetaData) { if (includeColumnBreaks) { metaDataFieldsHashMap.put(MetaDataFields.BandMetaDataBreak, fieldIdx); fieldIdx++; } metaDataFieldsHashMap.put(MetaDataFields.BandName, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.BandUnit, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.BandValidExpression, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.BandDescription, fieldIdx); fieldIdx++; } if (includeMaskMetaData) { if (includeColumnBreaks) { metaDataFieldsHashMap.put(MetaDataFields.RegionalMaskMetaDataBreak, fieldIdx); fieldIdx++; } metaDataFieldsHashMap.put(MetaDataFields.RegionalMaskName, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.RegionalMaskDescription, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.RegionalMaskExpression, fieldIdx); fieldIdx++; if (includeColumnBreaks) { metaDataFieldsHashMap.put(MetaDataFields.QualityMaskMetaDataBreak, fieldIdx); fieldIdx++; } metaDataFieldsHashMap.put(MetaDataFields.QualityMaskName, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.QualityMaskDescription, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.QualityMaskExpression, fieldIdx); fieldIdx++; } if (includeTimeMetaData || isIncludeTimeSeriesMetaData) { if (includeColumnBreaks) { metaDataFieldsHashMap.put(MetaDataFields.TimeMetaDataBreak, fieldIdx); fieldIdx++; } if (includeTimeMetaData) { metaDataFieldsHashMap.put(MetaDataFields.StartDate, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.StartTime, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.EndDate, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.EndTime, fieldIdx); fieldIdx++; } if (isIncludeTimeSeriesMetaData) { metaDataFieldsHashMap.put(MetaDataFields.TimeSeriesDate, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.TimeSeriesTime, fieldIdx); fieldIdx++; } } if (includeFileMetaData) { if (includeColumnBreaks) { metaDataFieldsHashMap.put(MetaDataFields.FileMetaDataBreak, fieldIdx); fieldIdx++; } metaDataFieldsHashMap.put(MetaDataFields.FileName, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.FileType, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.FileFormat, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.FileWidth, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.FileHeight, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.Sensor, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.Platform, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.Resolution, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.DayNight, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.Orbit, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.ProcessingVersion, fieldIdx); fieldIdx++; metaDataFieldsHashMap.put(MetaDataFields.Projection, fieldIdx); fieldIdx++; } if (includeProjectionParameters) { metaDataFieldsHashMap.put(MetaDataFields.ProjectionParameters, fieldIdx); fieldIdx++; } } if (statsSpreadsheet == null) { statsSpreadsheet = new Object[numStxRegions + 2][fieldIdx]; // add 1 row to account for the header and 1 more empty row because JTable for some reason displays // only half of the last row when row count is large } String startDateString = ""; String startTimeString = ""; String endDateString = ""; String endTimeString = ""; if (includeTimeMetaData) { ProductData.UTC startDateTimeCorrected; ProductData.UTC endDateTimeCorrected; // correct time (invert start and end time if end time later than start time if (getProduct().getStartTime() != null && getProduct().getEndTime() != null) { if (getProduct().getStartTime().getMJD() <= getProduct().getEndTime().getMJD()) { startDateTimeCorrected = getProduct().getStartTime(); endDateTimeCorrected = getProduct().getEndTime(); } else { startDateTimeCorrected = getProduct().getEndTime(); endDateTimeCorrected = getProduct().getStartTime(); } if (startDateTimeCorrected != null) { String[] startDateTimeStringArray = startDateTimeCorrected.toString().split(" "); if (startDateTimeStringArray.length >= 2) { startDateString = startDateTimeStringArray[0].trim(); startTimeString = startDateTimeStringArray[1].trim(); } } if (endDateTimeCorrected != null) { String[] endDateTimeStringArray = endDateTimeCorrected.toString().split(" "); if (endDateTimeStringArray.length >= 2) { endDateString = endDateTimeStringArray[0].trim(); endTimeString = endDateTimeStringArray[1].trim(); } } } } String timeSeriesDate = ""; String timeSeriesTime = ""; if (isIncludeTimeSeriesMetaData) { String bandName = raster.getName(); String productDateTime = convertBandNameToProductTime(bandName); if (productDateTime != null) { String[] endDateTimeStringArray = productDateTime.split(" "); if (endDateTimeStringArray.length >= 2) { timeSeriesDate = endDateTimeStringArray[0].trim(); timeSeriesTime = endDateTimeStringArray[1].trim(); } } } String maskName = ""; String maskDescription = ""; String maskExpression = ""; if (regionalMask != null) { maskName = regionalMask.getName(); maskDescription = regionalMask.getDescription(); maskExpression = regionalMask.getImageConfig().getValue("expression"); } String qualityMaskName = ""; String qualityMaskDescription = ""; String qualityMaskExpression = ""; if (qualityMask != null) { qualityMaskName = qualityMask.getName(); qualityMaskDescription = qualityMask.getDescription(); qualityMaskExpression = qualityMask.getImageConfig().getValue("expression"); } addFieldToSpreadsheet(row, PrimaryStatisticsFields.FileRefNum, getProduct().getRefNo()); addFieldToSpreadsheet(row, PrimaryStatisticsFields.BandName, raster.getName()); addFieldToSpreadsheet(row, PrimaryStatisticsFields.MaskName, maskName); addFieldToSpreadsheet(row, PrimaryStatisticsFields.QualityMaskName, qualityMaskName); addFieldToSpreadsheet(row, MetaDataFields.TimeMetaDataBreak, COLUMN_BREAK); addFieldToSpreadsheet(row, MetaDataFields.StartDate, startDateString); addFieldToSpreadsheet(row, MetaDataFields.StartTime, startTimeString); addFieldToSpreadsheet(row, MetaDataFields.EndDate, endDateString); addFieldToSpreadsheet(row, MetaDataFields.EndTime, endTimeString); addFieldToSpreadsheet(row, MetaDataFields.TimeSeriesDate, timeSeriesDate); addFieldToSpreadsheet(row, MetaDataFields.TimeSeriesTime, timeSeriesTime); addFieldToSpreadsheet(row, MetaDataFields.FileMetaDataBreak, COLUMN_BREAK); addFieldToSpreadsheet(row, MetaDataFields.FileName, getProduct().getName()); addFieldToSpreadsheet(row, MetaDataFields.FileType, getProduct().getProductType()); addFieldToSpreadsheet(row, MetaDataFields.FileWidth, getProduct().getSceneRasterWidth()); addFieldToSpreadsheet(row, MetaDataFields.FileFormat, getProductFormatName(getProduct())); addFieldToSpreadsheet(row, MetaDataFields.FileHeight, getProduct().getSceneRasterHeight()); addFieldToSpreadsheet(row, MetaDataFields.Sensor, ProductUtils.getMetaData(getProduct(), ProductUtils.METADATA_POSSIBLE_SENSOR_KEYS)); addFieldToSpreadsheet(row, MetaDataFields.Platform, ProductUtils.getMetaData(getProduct(), ProductUtils.METADATA_POSSIBLE_PLATFORM_KEYS)); addFieldToSpreadsheet(row, MetaDataFields.Resolution, ProductUtils.getMetaData(getProduct(), ProductUtils.METADATA_POSSIBLE_RESOLUTION_KEYS)); addFieldToSpreadsheet(row, MetaDataFields.DayNight, ProductUtils.getMetaData(getProduct(), ProductUtils.METADATA_POSSIBLE_DAY_NIGHT_KEYS)); addFieldToSpreadsheet(row, MetaDataFields.Orbit, ProductUtils.getMetaDataOrbit(getProduct())); addFieldToSpreadsheet(row, MetaDataFields.ProcessingVersion, ProductUtils.getMetaData(getProduct(), ProductUtils.METADATA_POSSIBLE_PROCESSING_VERSION_KEYS)); // Determine projection String projection = ""; String projectionParameters = ""; GeoCoding geo = getProduct().getGeoCoding(); // determine if using class CrsGeoCoding otherwise display class if (geo != null) { if (geo instanceof CrsGeoCoding) { projection = geo.getMapCRS().getName().toString() + "(obtained from CrsGeoCoding)"; projectionParameters = geo.getMapCRS().toString().replaceAll("\n", " ").replaceAll(" ", ""); } else if (geo.toString() != null) { String projectionFromMetaData = ProductUtils.getMetaData(getProduct(), ProductUtils.METADATA_POSSIBLE_PROJECTION_KEYS); if (projectionFromMetaData != null && projectionFromMetaData.length() > 0) { projection = projectionFromMetaData + "(obtained from MetaData)"; } else { projection = "unknown (" + geo.getClass().toString() + ")"; } } } addFieldToSpreadsheet(row, MetaDataFields.Projection, projection); addFieldToSpreadsheet(row, MetaDataFields.ProjectionParameters, projectionParameters); addFieldToSpreadsheet(row, MetaDataFields.BandMetaDataBreak, COLUMN_BREAK); addFieldToSpreadsheet(row, MetaDataFields.BandName, raster.getName()); addFieldToSpreadsheet(row, MetaDataFields.BandUnit, raster.getUnit()); addFieldToSpreadsheet(row, MetaDataFields.BandValidExpression, raster.getValidPixelExpression()); addFieldToSpreadsheet(row, MetaDataFields.BandDescription, raster.getDescription()); addFieldToSpreadsheet(row, MetaDataFields.RegionalMaskMetaDataBreak, COLUMN_BREAK); addFieldToSpreadsheet(row, MetaDataFields.RegionalMaskName, maskName); addFieldToSpreadsheet(row, MetaDataFields.RegionalMaskDescription, maskDescription); addFieldToSpreadsheet(row, MetaDataFields.RegionalMaskExpression, maskExpression); addFieldToSpreadsheet(row, MetaDataFields.QualityMaskMetaDataBreak, COLUMN_BREAK); addFieldToSpreadsheet(row, MetaDataFields.QualityMaskName, qualityMaskName); addFieldToSpreadsheet(row, MetaDataFields.QualityMaskDescription, qualityMaskDescription); addFieldToSpreadsheet(row, MetaDataFields.QualityMaskExpression, qualityMaskExpression); // Add Header first time through if (row <= 1) { int k = stxFieldsStartIdx; for (int i = 0; i < tableData.length; i++) { Object value = tableData[i][0]; if (k < statsSpreadsheet[0].length && k <= stxFieldsEndIdx) { statsSpreadsheet[0][k] = value; k++; } } } // account for header as added row if (row < statsSpreadsheet.length) { int k = stxFieldsStartIdx; for (int i = 0; i < tableData.length; i++) { Object value = tableData[i][1]; if (k < statsSpreadsheet[row].length && k <= stxFieldsEndIdx) { statsSpreadsheet[row][k] = value; k++; } } } int numPlots = 0; if (statisticsCriteriaPanel.showPercentPlots()) { numPlots++; } if (statisticsCriteriaPanel.showHistogramPlots()) { numPlots++; } JPanel plotContainerPanel = null; if (numPlots > 0) { plotContainerPanel = new JPanel(new GridLayout(1, numPlots)); if (statisticsCriteriaPanel.showHistogramPlots()) { plotContainerPanel.add(histogramPanel); } if (statisticsCriteriaPanel.showPercentPlots()) { plotContainerPanel.add(percentilePanel); } } TableModel tableModel = new DefaultTableModel(tableData, new String[] { "Name", "Value" }) { @Override public Class<?> getColumnClass(int columnIndex) { return columnIndex == 0 ? String.class : Number.class; } @Override public boolean isCellEditable(int row, int column) { return false; } }; final JTable table = new JTable(tableModel); table.setDefaultRenderer(Number.class, new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { final Component label = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (value instanceof Float || value instanceof Double) { setHorizontalTextPosition(RIGHT); setText(getFormattedValue((Number) value)); } return label; } private String getFormattedValue(Number value) { if (value.doubleValue() < 0.001 && value.doubleValue() > -0.001 && value.doubleValue() != 0.0) { return new DecimalFormat("0.####E0").format(value.doubleValue()); } String format = "%." + Integer.toString(statisticsCriteriaPanel.decimalPlaces()) + "f"; return String.format(format, value.doubleValue()); } }); table.addMouseListener(popupHandler); // TEST CODE generically preferred size of each column based on longest expected entry // fails a bit because decimal formatting is not captured // stub of code commented out in case we want to make it work // meanwhile longest entry is being used SEE below // int column0Length = 0; // int column1Length = 0; // FontMetrics fm = table.getFontMetrics(table.getFont()); // for (int rowIndex = 0; rowIndex < table.getRowCount(); rowIndex++) { // String test = table.getValueAt(rowIndex,0).toString(); // int currColumn0Length = fm.stringWidth(table.getValueAt(rowIndex,0).toString()); // if (currColumn0Length > column0Length) { // column0Length = currColumn0Length; // } // // String test2 = table.getValueAt(rowIndex,1).toString(); // int currColumn1Length = fm.stringWidth(table.getValueAt(rowIndex,1).toString()); // if (currColumn1Length > column1Length) { // column1Length = currColumn1Length; // } // } // Set preferred size of each column based on longest expected entry FontMetrics fm = table.getFontMetrics(table.getFont()); TableColumn column = null; int col1PreferredWidth = -1; if (statisticsCriteriaPanel.isLogMode()) { col1PreferredWidth = fm.stringWidth("StandardDeviation(LogBinned):") + 10; } else { col1PreferredWidth = fm.stringWidth("StandardDeviation(Binned):") + 10; } // int col1PreferredWidth = fm.stringWidth("wwwwwwwwwwwwwwwwwwwwwwwwww"); int col2PreferredWidth = fm.stringWidth("1234567890") + 10; int tablePreferredWidth = col1PreferredWidth + col2PreferredWidth; for (int i = 0; i < 2; i++) { column = table.getColumnModel().getColumn(i); if (i == 0) { column.setPreferredWidth(col1PreferredWidth); column.setMaxWidth(col1PreferredWidth); } else { column.setPreferredWidth(col2PreferredWidth); } } JPanel textContainerPanel = new JPanel(new BorderLayout(2, 2)); // textContainerPanel.setBackground(Color.WHITE); textContainerPanel.add(table, BorderLayout.CENTER); textContainerPanel.addMouseListener(popupHandler); JPanel statsPane = GridBagUtils.createPanel(); GridBagConstraints gbc = GridBagUtils.createConstraints(""); gbc.gridy = 0; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.weightx = 1; gbc.weighty = 1; Dimension dim = table.getPreferredSize(); table.setPreferredSize(new Dimension(tablePreferredWidth, dim.height)); statsPane.add(table, gbc); statsPane.setPreferredSize(new Dimension(tablePreferredWidth, dim.height)); JPanel plotsPane = null; if (plotContainerPanel != null) { plotsPane = GridBagUtils.createPanel(); plotsPane.setBackground(Color.WHITE); // plotsPane.setBorder(UIUtils.createGroupBorder(" ")); /*I18N*/ GridBagConstraints gbcPlots = GridBagUtils.createConstraints(""); gbcPlots.gridy = 0; if (statisticsCriteriaPanel.exactPlotSize()) { gbcPlots.fill = GridBagConstraints.NONE; } else { gbcPlots.fill = GridBagConstraints.BOTH; } gbcPlots.anchor = GridBagConstraints.NORTHWEST; gbcPlots.weightx = 0.5; gbcPlots.weighty = 1; plotsPane.add(plotContainerPanel, gbcPlots); } JPanel mainPane = GridBagUtils.createPanel(); mainPane.setBorder(UIUtils.createGroupBorder(getSubPanelTitle(regionalMask, qualityMask, raster))); /*I18N*/ GridBagConstraints gbcMain = GridBagUtils.createConstraints(""); gbcMain.gridx = 0; gbcMain.gridy = 0; gbcMain.anchor = GridBagConstraints.NORTHWEST; if (plotsPane != null) { gbcMain.fill = GridBagConstraints.VERTICAL; gbcMain.weightx = 0; } else { gbcMain.fill = GridBagConstraints.BOTH; gbcMain.weightx = 1; } if (statisticsCriteriaPanel.showStatsList()) { gbcMain.weighty = 1; mainPane.add(statsPane, gbcMain); gbcMain.gridx++; } gbcMain.weightx = 1; gbcMain.weighty = 1; gbcMain.fill = GridBagConstraints.BOTH; if (plotsPane != null) { mainPane.add(plotsPane, gbcMain); } return mainPane; }
From source file:hw.java
public static DefaultTableModel buildTableModel(ResultSet rs) throws SQLException { ResultSetMetaData metaData = rs.getMetaData(); Vector<String> columnNames = new Vector<String>(); int columnCount = metaData.getColumnCount(); for (int column = 1; column <= columnCount; column++) { columnNames.add(metaData.getColumnName(column)); }//from w ww . ja va 2 s .com Vector<Vector<Object>> data = new Vector<Vector<Object>>(); while (rs.next()) { Vector<Object> vector = new Vector<Object>(); for (int columnIndex = 1; columnIndex <= columnCount; columnIndex++) { vector.add(rs.getObject(columnIndex)); } data.add(vector); } return new DefaultTableModel(data, columnNames); }
From source file:gskproject.Analyze.java
public void personWiseTableload() { multiMap = new HashMap<Object, Object[]>(); userList = new ArrayList<User>(); if (ddDepartment.getSelectedIndex() == 0) { userList = dbOps.getUser();//from w ww . j av a 2s . c o m } else { userList = dbOps.getUser(ddDepartment.getSelectedIndex()); } java.sql.Date from; java.sql.Date to; if (dtPFrom.getDate() == null && dtPTo.getDate() == null) { from = null; to = null; } else if (dtPFrom.getDate() == null) { from = null; to = new java.sql.Date(dtPTo.getDate().getTime()); } else if (dtPTo.getDate() == null) { from = new java.sql.Date(dtPFrom.getDate().getTime()); to = null; } else { from = new java.sql.Date(dtPFrom.getDate().getTime()); to = new java.sql.Date(dtPTo.getDate().getTime()); } Vector<String> columnNames = new Vector<String>(); columnNames.addElement("Person"); columnNames.addElement("Total No: of Cases"); columnNames.addElement("No:of Cases(Responsible Party)"); columnNames.addElement("Open Cases(Responsible party)"); columnNames.addElement("Open Cases Percentage(Resposible Party)"); columnNames.addElement("No:of Cases(Observer)"); columnNames.addElement("Open Cases(Observer)"); columnNames.addElement("Open Cases Percentage(Observer)"); if (from != null && to != null) { if (to.after(from)) { tableObservation = dbOps.getAnalyzeObservation(from, to); if (tableObservation.size() > 0) { for (User user : userList) { Object[] array = new Object[6]; array[0] = user.getUsername(); array[1] = 0; array[2] = 0; array[3] = 0; array[4] = 0; array[5] = 0; multiMap.put(user.getUserID(), array); } for (Vector row : tableObservation) { Object[] arrayRes = multiMap.get(row.get(7)); if (arrayRes != null) { arrayRes[2] = (int) arrayRes[2] + 1; arrayRes[1] = (int) arrayRes[1] + 1; if (row.get(8).equals("Open")) { arrayRes[3] = (int) arrayRes[3] + 1; } } Object[] arrayOb = multiMap.get(row.get(6)); if (arrayOb != null) { arrayOb[4] = (int) arrayOb[4] + 1; arrayOb[1] = (int) arrayOb[1] + 1; if (row.get(8).equals("Open")) { arrayOb[5] = (int) arrayOb[5] + 1; } } } tablePersonWise = new Vector<Vector>(); for (int i = 0; i < multiMap.size(); i++) { Vector<Object> row = new Vector<Object>(); int userID = userList.get(i).getUserID(); row.addElement(multiMap.get(userID)[0]); row.addElement((int) multiMap.get(userID)[2] + (int) multiMap.get(userID)[4]); row.addElement(multiMap.get(userID)[2]); row.addElement(multiMap.get(userID)[3]); if ((int) multiMap.get(userID)[2] != 0) { row.addElement(((Double.parseDouble(multiMap.get(userID)[3].toString()) / (int) multiMap.get(userID)[2]) * 100) + "%"); } else { row.addElement(0); } row.addElement(multiMap.get(userID)[4]); row.addElement(multiMap.get(userID)[5]); if ((int) multiMap.get(userID)[4] != 0) { row.addElement(((Double.parseDouble(multiMap.get(userID)[5].toString()) / (int) multiMap.get(userID)[4]) * 100) + "%"); } else { row.addElement(0); } tablePersonWise.addElement(row); } tblPersonVise.setModel(new DefaultTableModel(tablePersonWise, columnNames)); } else { JOptionPane.showMessageDialog(this, "There are no observation between above days!"); dtPFrom.setDate(null); dtPTo.setDate(null); } } else { JOptionPane.showMessageDialog(this, "Wrong Date Entry (from date > to date)!"); dtPFrom.setDate(null); dtPTo.setDate(null); } } else { tableObservation = dbOps.getAnalyzeObservation(from, to); if (tableObservation.size() > 0) { for (User user : userList) { Object[] array = new Object[6]; array[0] = user.getUsername(); array[1] = 0; array[2] = 0; array[3] = 0; array[4] = 0; array[5] = 0; multiMap.put(user.getUserID(), array); } for (Vector row : tableObservation) { Object[] arrayRes = multiMap.get(row.get(7)); if (arrayRes != null) { arrayRes[2] = (int) arrayRes[2] + 1; arrayRes[1] = (int) arrayRes[1] + 1; if (row.get(8).equals("Open")) { arrayRes[3] = (int) arrayRes[3] + 1; } } Object[] arrayOb = multiMap.get(row.get(6)); if (arrayOb != null) { arrayOb[4] = (int) arrayOb[4] + 1; arrayOb[1] = (int) arrayOb[1] + 1; if (row.get(8).equals("Open")) { arrayOb[5] = (int) arrayOb[5] + 1; } } } tablePersonWise = new Vector<Vector>(); for (int i = 0; i < multiMap.size(); i++) { Vector<Object> row = new Vector<Object>(); int userID = userList.get(i).getUserID(); row.addElement(multiMap.get(userID)[0]); row.addElement((int) multiMap.get(userID)[2] + (int) multiMap.get(userID)[4]); row.addElement(multiMap.get(userID)[2]); row.addElement(multiMap.get(userID)[3]); if ((int) multiMap.get(userID)[2] != 0) { row.addElement(((Double.parseDouble(multiMap.get(userID)[3].toString()) / (int) multiMap.get(userID)[2]) * 100) + "%"); } else { row.addElement(0); } row.addElement(multiMap.get(userID)[4]); row.addElement(multiMap.get(userID)[5]); if ((int) multiMap.get(userID)[4] != 0) { row.addElement(((Double.parseDouble(multiMap.get(userID)[5].toString()) / (int) multiMap.get(userID)[4]) * 100) + "%"); } else { row.addElement(0); } tablePersonWise.addElement(row); } tblPersonVise.setModel(new DefaultTableModel(tablePersonWise, columnNames)); } else { JOptionPane.showMessageDialog(this, "There are no observation between above days!"); dtPFrom.setDate(null); dtPTo.setDate(null); } } }
From source file:com.declarativa.interprolog.gui.ListenerWindow.java
public void drawFragments() { java.util.List<String> args = new ArrayList<>(); ArgBuildManager manag = new ArgBuildManager(); args = manag.RetrieveArguments();/*from ww w . j av a 2s.com*/ jTextArea1.append("List of built arguments:\n"); for (Iterator<String> it = args.iterator(); it.hasNext();) { String string = it.next(); jTextArea1.append("\t" + string + "\n"); } DefaultTableModel defaultModel = (DefaultTableModel) jTable1.getModel(); Object[][] rowData = { { "Hello", "World" } }; Object[] columnNames = { "A", "B" }; DefaultTableModel model = new DefaultTableModel(rowData, columnNames); //table = new JTable(); jTable1.setModel(model); /* Vector newRow = new Vector(); newRow.add("Total Amount Spend"); newRow.add("G"); newRow.add("SDFG"); newRow.add("KASDPF"); newRow.add("E9JASK"); newRow.add("09DFJ SLD JI"); */ int sizearg = args.size(); for (int j = 0; j < args.size(); j++) { Vector newRow = new Vector(); newRow.add(" "); newRow.add(args.get(j)); model.addRow(newRow); } // model.addRow(newRow); }
From source file:gskproject.Analyze.java
public boolean departmentAccidentTableLoad(Date from1, Date to1) { depHashMap = new HashMap<Object, Object[]>(); ArrayList<Object[]> depNameID = dbOps.getDepartmentNameID(); java.sql.Date from;/*from w ww . j a v a 2 s. c o m*/ java.sql.Date to; if (from1 == null && to1 == null) { from = null; to = null; } else if (from1 == null) { from = null; to = new java.sql.Date(to1.getTime()); } else if (to1 == null) { from = new java.sql.Date(from1.getTime()); to = null; } else { from = new java.sql.Date(from1.getTime()); to = new java.sql.Date(to1.getTime()); } Vector<String> columnNames = new Vector<String>(); columnNames.add("Department"); columnNames.add("First Aid"); columnNames.add("LTI"); columnNames.add("Near Miss"); columnNames.add("Open Cases"); columnNames.add("Closed Cases"); columnNames.add("Total"); //int[][] depAccident=new int[3][3]; int DAOpen = 0; int DAClose = 0; int firstAidTotal = 0; int LTITotal = 0; int nearMissTotal = 0; //int openTotal=0; //int closeTotal=0; int totalTotal = 0; if (from != null && to != null) { if (to.after(from) || to.equals(from)) { tableObservation = dbOps.getAnalyzeObservation(from, to); if (tableObservation.size() > 0) { for (Object[] row : depNameID) { Object[] array = new Object[6]; array[0] = row[1]; array[1] = 0; array[2] = 0; array[3] = 0; array[4] = 0; array[5] = 0; depHashMap.put(row[0], array); } for (Vector row : tableObservation) { Object[] array = depHashMap.get((int) row.get(5)); if (row.get(11).equals("First Aid")) { array[1] = (int) array[1] + 1; firstAidTotal++; } else if (row.get(11).equals("LTI")) { array[2] = (int) array[2] + 1; LTITotal++; } else { array[3] = (int) array[3] + 1; nearMissTotal++; } if (row.get(8).equals("Open")) { array[4] = (int) array[4] + 1; DAOpen++; } else { array[5] = (int) array[5] + 1; DAClose++; } } tableDepartmentAccident = new Vector<Vector>(); for (Object[] array : depNameID) { Vector<Object> row1 = new Vector<Object>(); row1.add(array[1]); row1.add((int) depHashMap.get(array[0])[1]); row1.add((int) depHashMap.get(array[0])[2]); row1.add((int) depHashMap.get(array[0])[3]); row1.add((int) depHashMap.get(array[0])[4]); row1.add((int) depHashMap.get(array[0])[5]); row1.add((int) depHashMap.get(array[0])[1] + (int) depHashMap.get(array[0])[2] + (int) depHashMap.get(array[0])[3]); tableDepartmentAccident.add(row1); } Vector<Object> row1 = new Vector<Object>(); row1.add("Total -->"); row1.add(firstAidTotal); row1.add(LTITotal); row1.add(nearMissTotal); row1.add(DAOpen); row1.add(DAClose); row1.add(firstAidTotal + LTITotal + nearMissTotal); tableDepartmentAccident.add(row1); tblDepartmentAccident.setModel(new DefaultTableModel(tableDepartmentAccident, columnNames)); lblTotal.setText(Integer.toString(DAClose + DAOpen)); lblOpen.setText(Integer.toString(DAOpen)); lblClosed.setText(Integer.toString(DAClose)); return true; } else { JOptionPane.showMessageDialog(this, "There are no observations!"); tableDepartmentAccident = null; return false; } } else { JOptionPane.showMessageDialog(this, "Wrong Date Entry (from date > to date)!"); tableDepartmentAccident = null; return false; } } else { tableObservation = dbOps.getAnalyzeObservation(from, to); if (tableObservation.size() > 0) { for (Object[] row : depNameID) { Object[] array = new Object[6]; array[0] = row[1]; array[1] = 0; array[2] = 0; array[3] = 0; array[4] = 0; array[5] = 0; depHashMap.put(row[0], array); } for (Vector row : tableObservation) { Object[] array = depHashMap.get((int) row.get(5)); if (row.get(11).equals("First Aid")) { array[1] = (int) array[1] + 1; firstAidTotal++; } else if (row.get(11).equals("LTI")) { array[2] = (int) array[2] + 1; LTITotal++; } else { array[3] = (int) array[3] + 1; nearMissTotal++; } if (row.get(8).equals("Open")) { array[4] = (int) array[4] + 1; DAOpen++; } else { array[5] = (int) array[5] + 1; DAClose++; } } tableDepartmentAccident = new Vector<Vector>(); for (Object[] array : depNameID) { Vector<Object> row1 = new Vector<Object>(); row1.add(array[1]); row1.add((int) depHashMap.get(array[0])[1]); row1.add((int) depHashMap.get(array[0])[2]); row1.add((int) depHashMap.get(array[0])[3]); row1.add((int) depHashMap.get(array[0])[4]); row1.add((int) depHashMap.get(array[0])[5]); row1.add((int) depHashMap.get(array[0])[1] + (int) depHashMap.get(array[0])[2] + (int) depHashMap.get(array[0])[3]); tableDepartmentAccident.add(row1); } Vector<Object> row1 = new Vector<Object>(); row1.add("Total -->"); row1.add(firstAidTotal); row1.add(LTITotal); row1.add(nearMissTotal); row1.add(DAOpen); row1.add(DAClose); row1.add(firstAidTotal + LTITotal + nearMissTotal); tableDepartmentAccident.add(row1); tblDepartmentAccident.setModel(new DefaultTableModel(tableDepartmentAccident, columnNames)); lblTotal.setText(Integer.toString(DAClose + DAOpen)); lblOpen.setText(Integer.toString(DAOpen)); lblClosed.setText(Integer.toString(DAClose)); return true; } else { JOptionPane.showMessageDialog(this, "There are no observations!"); tableDepartmentAccident = null; return false; } } }