List of usage examples for javax.swing.table DefaultTableModel setRowCount
public void setRowCount(int rowCount)
From source file:Interface.FoodCollectionSupervisor.FoodCollectionWorkArea.java
private void populateCompletedRequestTable() { DefaultTableModel model = (DefaultTableModel) tblCompletedRequests.getModel(); model.setRowCount(0); for (WorkRequest request : organization.getWorkQueue().getWorkRequestList()) { //request = (FoodCollectionWorkRequest) request; if (request.getStatus().equalsIgnoreCase("Food Delivered to Standard Authority")) { Object[] row = new Object[7]; row[0] = ((FoodCollectionWorkRequest) request); row[1] = ((FoodCollectionWorkRequest) request).getFood().getFoodType(); row[2] = ((FoodCollectionWorkRequest) request).getSender().getEmployee(); row[3] = ((FoodCollectionWorkRequest) request).getFood().getFoodPriority(); row[4] = ((FoodCollectionWorkRequest) request).getSender().getEmployee().getAddress(); row[5] = ((FoodCollectionWorkRequest) request).getDriverName(); row[6] = request.getStatus(); model.addRow(row);// w w w .j a v a 2s .c o m } } }
From source file:cish.CISH.java
/** * Updates the CISH table in this plugin window. */// w w w . j av a 2s . co m void updateCISHTable() { DefaultTableModel tm = (DefaultTableModel) jXTable1.getModel(); tm.setRowCount(0); for (int i = 0; i < tss.size(); i++) { int n_cep = 0; int n_gene = 0; for (int[] cp : ps[i]) { if (cp[2] == COLORS[0][0] && cp[3] == COLORS[0][1] && cp[4] == COLORS[0][2]) { n_cep++; } else if (cp[2] == COLORS[1][0] && cp[3] == COLORS[1][1] && cp[4] == COLORS[1][2]) { n_gene++; } else if (cp[2] == COLORS[4][0] && cp[3] == COLORS[4][1] && cp[4] == COLORS[4][2]) { n_cep++; n_gene++; } } tm.addRow(new Object[] { tss.get(i).getName(), n_cep, n_gene, gRatios[i], lRatios[i] }); } }
From source file:userinterface.Citizen.CitizenWorkAreaJPanel.java
public void populateInhalerSensorData() { DefaultTableModel dtm = (DefaultTableModel) inhalerTable.getModel(); dtm.setRowCount(0); ArrayList<Date> keyList = new ArrayList<>( account.getCitizen().getHealthReport().getAsthamaInhalerSensor().getUsageHistory().keySet()); Collections.sort(keyList);//from w w w . java 2 s . co m for (Date d : keyList) { Area area = account.getCitizen().getHealthReport().getAsthamaInhalerSensor().getUsageHistory().get(d); if (null != area) { Object row[] = new Object[2]; row[0] = d.toString(); row[1] = area; dtm.addRow(row); } } }
From source file:userinterface.Citizen.CitizenWorkAreaJPanel.java
public void populatePollutionLevelTable() { DefaultTableModel dtm = (DefaultTableModel) pollutionLevelTable.getModel(); dtm.setRowCount(0); ArrayList<Date> keyList = new ArrayList<>( account.getCitizen().getResidence().getPollutionMonitorSensor().getUsageHistory().keySet()); Collections.sort(keyList);/*w w w . ja v a 2 s .co m*/ for (Date d : keyList) { PollutionMonitorSensorUsage usage = account.getCitizen().getResidence().getPollutionMonitorSensor() .getUsageHistory().get(d); if (null != usage && null != usage.getDate()) { Object row[] = new Object[2]; row[0] = usage; if (usage.isPolluted()) { row[1] = "Polluted"; } else { row[1] = "Clean"; } dtm.addRow(row); } } }
From source file:Interface.FoodCollectionSupervisor.FoodCollectionWorkArea.java
private void btnFindingDriversActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFindingDriversActionPerformed // TODO add your handling code here: int selectedRow = tblNewRequest.getSelectedRow(); int nearestMiles = 0; if (selectedRow < 0) { JOptionPane.showMessageDialog(null, "Please select the row from the table."); return;// w w w . ja v a 2s. c o m } btnAssignRequest.setEnabled(false); btnFindingDrivers.setName("Finding closest drivers..."); btnFindingDrivers.setEnabled(false); jScrollPane6.setVisible(true); FoodCollectionWorkRequest request = (FoodCollectionWorkRequest) tblNewRequest.getValueAt(selectedRow, 0); String pickupAddress = request.getSender().getEmployee().getAddress(); DefaultTableModel model = (DefaultTableModel) tblRecommendationDriver.getModel(); model.setRowCount(0); for (UserAccount ua : organization.getUserAccountDirectory().getUserAccountList()) { Employee ee = ua.getEmployee(); if (ee instanceof FoodCollectionDriverEmployee) { try { if (nearestMiles == 3) { break; } String driverCurrentLocation = ((FoodCollectionDriverEmployee) (ee)).getDriverCurrentAddress(); String sourceAddress = pickupAddress; String myKey = "AIzaSyDxQT-LVz0VhlZN_4FZ4NaKoa63zeGIge0"; driverCurrentLocation = driverCurrentLocation.replace(" ", "+"); sourceAddress = sourceAddress.replace(" ", "+"); String url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=#ORIGIN&destinations=#DESTINATION&mode=driving&units=imperial&language=fr-FR&key=#KEY"; url = url.replace("#ORIGIN", driverCurrentLocation); url = url.replace("#DESTINATION", sourceAddress); url = url.replace("#KEY", myKey); // HttpURLConnectionExample http = new HttpURLConnectionExample(); // System.out.println("Testing 1 - Send Http GET request"); String json = sendGet(url); String a = StringUtils.substringBefore(json, "miles"); String b = StringUtils.substringAfterLast(a, "\""); b = b.replace(",", "."); String distance = b + "miles"; //System.out.println("Distance : " + b +" miles."); Double bInMiles = Double.parseDouble(b); if (bInMiles < 2.0) { nearestMiles++; } Object[] row = new Object[3]; row[0] = ua.getEmployee().getName(); row[1] = ((FoodCollectionDriverEmployee) (ee)).getDriverCurrentAddress(); row[2] = distance; model.addRow(row); } catch (Exception e) { System.out.println("Message :" + e.getMessage()); } } } btnAssignRequest.setEnabled(true); btnFindingDrivers.setName("Recommendation for closest driver >>"); btnFindingDrivers.setEnabled(true); }
From source file:statisticslabro.StatisticsLabr.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed List<String> Temp = new ArrayList<String>(); List<String> check = new ArrayList<String>(); List<Double> fnl = new ArrayList<>(); List<String> frame = new ArrayList<String>(); List<String> name = new ArrayList<String>(); List<String> name2 = new ArrayList<String>(); List<Double> frame2 = new ArrayList<Double>(); List<Double> limitLeft = new ArrayList<>(); List<Double> limitRight = new ArrayList<>(); List<Double> trueLimitLeft = new ArrayList<>(); List<Double> trueLimitRight = new ArrayList<>(); List<Double> midpoint = new ArrayList<>(); List<Integer> frequency = new ArrayList<>(); List<Double> percent = new ArrayList<>(); List<Integer> cf = new ArrayList<>(); List<Double> cp = new ArrayList<>(); Integer freq = 0;//w w w .j a v a 2 s .c om Double freqtot = 0.0; if (Categorical.isSelected() == true && Numerical.isSelected() == false) { for (int i = 0; i < jTable1.getRowCount(); i++) { frame.add((String) jTable1.getModel().getValueAt(i, 0)); } Collections.sort(frame); Integer size = frame.size(); System.out.println(size); for (Object b : frame) { String c = b + ""; Temp.add(c); } for (int i = 0; i < jTable1.getRowCount(); i++) { for (int j = 0; j < jTable1.getColumnCount(); j++) { jTable1.setValueAt("", i, j); } } int ct = 0; for (Object z : frame) { String a = z + ""; System.out.print(check.contains(a)); if (!(check.contains(a))) { for (int i = 0; i < Temp.size(); i++) { if (a.equals(Temp.get(i))) { freq++; } } Double freque = (((freq + .0) / size) * 100); fnl.add(freque); name.add(a); freqtot += freque; jTable1.getModel().setValueAt(a, ct, 0); jTable1.getModel().setValueAt(String.format("%1.1f", freque) + "%", ct, 1); ct++; freq = 0; check.add(a); } total.setText("Total :" + String.format("%1.1f", freqtot)); } if (Chart.isSelected() == true) { DefaultPieDataset chart = new DefaultPieDataset(); int h = 0; for (Double z : fnl) { chart.setValue(name.get(h) + "", new Double(z)); h++; } JFreeChart mychart = ChartFactory.createPieChart3D(Desc.getText() + "", chart, true, true, true); PiePlot3D p = (PiePlot3D) mychart.getPlot(); ChartFrame charteuFrame = new ChartFrame(Desc.getText(), mychart); charteuFrame.setVisible(true); charteuFrame.setSize(450, 500); } } else if (Numerical.isSelected() == true && Categorical.isSelected() == false) { double subtrahend = 0.5; for (int i = 0; i < jTable1.getRowCount();) { double d = Double.parseDouble((String) jTable1.getModel().getValueAt(i, 0)); frame2.add(d); i++; } double max = 0; double min = frame2.get(0); for (int j = 0; j < frame2.size(); j++) { System.out.print("Sulod"); if (max < frame2.get(j)) { max = frame2.get(j); } if (min > frame2.get(j)) { min = frame2.get(j); } } System.out.print(frame2); double range = max - min; double k = Math.ceil(1 + 3.322 * Math.log10(frame2.size())); int width = (int) Math.ceil(range / k); System.out.println("char: " + max + " " + min + " " + range + " " + k + " width: " + width); double limit = min; while (limit < max) { limitLeft.add(limit); limit += width; } for (int j = 0; j < limitLeft.size(); j++) { System.out.print(limitLeft.get(j) + " "); } double limit2 = min + width - 1; while (limit2 <= max) { limitRight.add(limit2); limit2 += width; } if (limitRight.get(limitRight.size() - 1) != max) { limitRight.add(max); } System.out.println(); for (int j = 0; j < limitRight.size(); j++) { System.out.print(limitRight.get(j) + " "); } //true limit if (((String) choice.getSelectedItem()).equals("Integer")) { for (int j = 0; j < limitLeft.size(); j++) { trueLimitLeft.add(limitLeft.get(j) - 0.5); } System.out.println(); for (int j = 0; j < trueLimitLeft.size(); j++) { System.out.print(trueLimitLeft.get(j) + " "); } for (int j = 0; j < limitRight.size(); j++) { trueLimitRight.add(limitRight.get(j) + 0.5); } System.out.println(); for (int j = 0; j < trueLimitRight.size(); j++) { System.out.print(trueLimitRight.get(j) + " "); } } else if (((String) choice.getSelectedItem()).equals("Floating")) { int count1 = 0; float diff = 0; boolean flag = false; for (int j = 0; j < frame2.size(); j++) { double value = Math.floor(frame2.get(j)); System.out.println(frame.get(j)); diff = (float) (frame2.get(j) - value); System.out.println("diff: " + diff); String counts = String.valueOf(diff); if (diff > 0.0) { if (counts.length() - 1 > count1) { count1 = counts.length() - 1; System.out.println(count1); } } } System.out.println(count1); for (int j = 0; j < count1 - 1; j++) { subtrahend /= 10; System.out.println(subtrahend); } System.out.println("sub: " + subtrahend); for (int j = 0; j < limitLeft.size(); j++) { trueLimitLeft.add(limitLeft.get(j) - subtrahend); } for (int j = 0; j < limitRight.size(); j++) { trueLimitRight.add(limitRight.get(j) + subtrahend); } } //midpoint for (int j = 0; j < limitLeft.size(); j++) { midpoint.add((limitLeft.get(j) + limitRight.get(j)) / 2); } System.out.println(); for (int j = 0; j < midpoint.size(); j++) { System.out.print(midpoint.get(j) + " "); } //frequency for (int j = 0; j < limitLeft.size(); j++) { int count = 0; for (int m = 0; m < frame2.size(); m++) { if (frame2.get(m) >= limitLeft.get(j) && frame2.get(m) <= limitRight.get(j)) { count++; } } frequency.add(count); } System.out.println(); for (int j = 0; j < frequency.size(); j++) { System.out.print(frequency.get(j) + " "); } //percent for (int j = 0; j < frequency.size(); j++) { double pp = (((double) frequency.get(j) / frame2.size()) * 100); percent.add(pp); } System.out.println(); for (int j = 0; j < percent.size(); j++) { System.out.print(percent.get(j) + " "); } int cff = 0; for (int j = 0; j < frequency.size(); j++) { cff += frequency.get(j); cf.add(cff); } System.out.println(); for (int j = 0; j < cf.size(); j++) { System.out.print(cf.get(j) + " "); } double cpp = 0; for (int j = 0; j < percent.size(); j++) { cpp += percent.get(j); cp.add(cpp); } System.out.println(); for (int j = 0; j < cp.size(); j++) { System.out.print(cp.get(j) + " "); } DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel(); dtm.setRowCount(limitLeft.size()); int ct = 0; if (collapse.isSelected() == true) { for (int j = 0; j < limitLeft.size(); j++) { if (ct == 0) { jTable1.getModel().setValueAt("< " + limitRight.get(j), ct, 1); jTable1.getModel().setValueAt("-", ct, 3); name.add("<"); } else if (ct == limitLeft.size() - 1) { jTable1.getModel().setValueAt("> " + limitLeft.get(j), ct, 1); jTable1.getModel().setValueAt("-", ct, 3); name.add(">"); } else { jTable1.getModel().setValueAt(limitLeft.get(j) + "-" + limitRight.get(j), ct, 1); jTable1.getModel().setValueAt(midpoint.get(j), ct, 3); name.add(midpoint.get(j) + ""); } jTable1.getModel().setValueAt(trueLimitLeft.get(j) + "-" + trueLimitRight.get(j), ct, 2); jTable1.getModel().setValueAt(frequency.get(j), ct, 4); jTable1.getModel().setValueAt(percent.get(j), ct, 5); jTable1.getModel().setValueAt(cf.get(j), ct, 6); jTable1.getModel().setValueAt(cp.get(j), ct, 7); ct++; } } else { for (int j = 0; j < limitLeft.size(); j++) { jTable1.getModel().setValueAt(limitLeft.get(j) + "-" + limitRight.get(j), ct, 1); jTable1.getModel().setValueAt(trueLimitLeft.get(j) + "-" + trueLimitRight.get(j), ct, 2); jTable1.getModel().setValueAt(midpoint.get(j), ct, 3); name.add(midpoint.get(j) + ""); jTable1.getModel().setValueAt(frequency.get(j), ct, 4); jTable1.getModel().setValueAt(percent.get(j), ct, 5); jTable1.getModel().setValueAt(cf.get(j), ct, 6); jTable1.getModel().setValueAt(cp.get(j), ct, 7); ct++; } } } if (Chart.isSelected() == true) { DefaultCategoryDataset chart = new DefaultCategoryDataset(); int h = 0; for (Integer z : frequency) { chart.setValue(z, "Frequency", name.get(h)); h++; } JFreeChart mychart = ChartFactory.createBarChart(Desc.getText() + "", "Midpoint", "Frequency", chart, PlotOrientation.VERTICAL, true, false, false); CategoryPlot p = (CategoryPlot) mychart.getPlot(); p.setDomainGridlinesVisible(true); p.getDomainAxis().setCategoryMargin(0.0); ChartFrame charteuFrame = new ChartFrame(Desc.getText(), mychart); charteuFrame.setVisible(true); charteuFrame.setSize(450, 500); } }
From source file:statisticsintegration.StatisticsLabr.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed List<String> Temp = new ArrayList<String>(); List<String> check = new ArrayList<String>(); List<Double> fnl = new ArrayList<>(); List<String> frame = new ArrayList<String>(); List<String> name = new ArrayList<String>(); List<String> name2 = new ArrayList<String>(); List<Double> frame2 = new ArrayList<Double>(); List<Double> limitLeft = new ArrayList<>(); List<Double> limitRight = new ArrayList<>(); List<Double> trueLimitLeft = new ArrayList<>(); List<Double> trueLimitRight = new ArrayList<>(); List<Double> midpoint = new ArrayList<>(); List<Integer> frequency = new ArrayList<>(); List<Double> percent = new ArrayList<>(); List<Integer> cf = new ArrayList<>(); List<Double> cp = new ArrayList<>(); Integer freq = 0;//from w w w .j av a 2s. c om Double freqtot = 0.0; if (Categorical.isSelected() == true && Numerical.isSelected() == false) { for (int i = 0; i < jTable1.getRowCount(); i++) { frame.add((String) jTable1.getModel().getValueAt(i, 0)); } Collections.sort(frame); Integer size = frame.size(); System.out.println(size); for (Object b : frame) { String c = b + ""; Temp.add(c); } for (int i = 0; i < jTable1.getRowCount(); i++) { for (int j = 0; j < jTable1.getColumnCount(); j++) { jTable1.setValueAt("", i, j); } } int ct = 0; for (Object z : frame) { String a = z + ""; System.out.print(check.contains(a)); if (!(check.contains(a))) { for (int i = 0; i < Temp.size(); i++) { if (a.equals(Temp.get(i))) { freq++; } } Double freque = (((freq + .0) / size) * 100); fnl.add(freque); name.add(a); freqtot += freque; jTable1.getModel().setValueAt(a, ct, 0); jTable1.getModel().setValueAt(String.format("%1.1f", freque) + "%", ct, 1); ct++; freq = 0; check.add(a); } total.setText("Total :" + String.format("%1.1f", freqtot)); } if (Chart.isSelected() == true) { DefaultPieDataset chart = new DefaultPieDataset(); int h = 0; for (Double z : fnl) { chart.setValue(name.get(h) + "", new Double(z)); h++; } JFreeChart mychart = ChartFactory.createPieChart3D(Desc.getText() + "", chart, true, true, true); PiePlot3D p = (PiePlot3D) mychart.getPlot(); ChartFrame charteuFrame = new ChartFrame(Desc.getText(), mychart); charteuFrame.setVisible(true); charteuFrame.setSize(450, 500); } } else if (Numerical.isSelected() == true && Categorical.isSelected() == false) { double subtrahend = 0.5; for (int i = 0; i < jTable1.getRowCount();) { double d = Double.parseDouble((String) jTable1.getModel().getValueAt(i, 0)); frame2.add(d); i++; } double max = 0; double min = frame2.get(0); for (int j = 0; j < frame2.size(); j++) { System.out.print("Sulod"); if (max < frame2.get(j)) { max = frame2.get(j); } if (min > frame2.get(j)) { min = frame2.get(j); } } System.out.print(frame2); double range = max - min; double k = Math.ceil(1 + 3.322 * Math.log10(frame2.size())); int width = (int) Math.ceil(range / k); System.out.println("char: " + max + " " + min + " " + range + " " + k + " width: " + width); double limit = min; while (limit < max) { limitLeft.add(limit); limit += width; } for (int j = 0; j < limitLeft.size(); j++) { System.out.print(limitLeft.get(j) + " "); } double limit2 = min + width - 1; while (limit2 <= max) { limitRight.add(limit2); limit2 += width; } if (limitRight.get(limitRight.size() - 1) != max) { limitRight.add(max); } System.out.println(); for (int j = 0; j < limitRight.size(); j++) { System.out.print(limitRight.get(j) + " "); } //true limit if (((String) choice.getSelectedItem()).equals("Integer")) { for (int j = 0; j < limitLeft.size(); j++) { trueLimitLeft.add(limitLeft.get(j) - 0.5); } System.out.println(); for (int j = 0; j < trueLimitLeft.size(); j++) { System.out.print(trueLimitLeft.get(j) + " "); } for (int j = 0; j < limitRight.size(); j++) { trueLimitRight.add(limitRight.get(j) + 0.5); } System.out.println(); for (int j = 0; j < trueLimitRight.size(); j++) { System.out.print(trueLimitRight.get(j) + " "); } } else if (((String) choice.getSelectedItem()).equals("Floating")) { int count1 = 0; float diff = 0; boolean flag = false; for (int j = 0; j < frame2.size(); j++) { double value = Math.floor(frame2.get(j)); // System.out.println(frame.get(j)); diff = (float) (frame2.get(j) - value); System.out.println("diff: " + diff); String counts = String.valueOf(diff); if (diff > 0.0) { if (counts.length() - 1 > count1) { count1 = counts.length() - 1; System.out.println(count1); } } } System.out.println(count1); for (int j = 0; j < count1 - 1; j++) { subtrahend /= 10; System.out.println(subtrahend); } System.out.println("sub: " + subtrahend); for (int j = 0; j < limitLeft.size(); j++) { trueLimitLeft.add(limitLeft.get(j) - subtrahend); } for (int j = 0; j < limitRight.size(); j++) { trueLimitRight.add(limitRight.get(j) + subtrahend); } } //midpoint for (int j = 0; j < limitLeft.size(); j++) { midpoint.add((limitLeft.get(j) + limitRight.get(j)) / 2); } System.out.println(); for (int j = 0; j < midpoint.size(); j++) { System.out.print(midpoint.get(j) + " "); } //frequency for (int j = 0; j < limitLeft.size(); j++) { int count = 0; for (int m = 0; m < frame2.size(); m++) { if (frame2.get(m) >= limitLeft.get(j) && frame2.get(m) <= limitRight.get(j)) { count++; } } frequency.add(count); } System.out.println(); for (int j = 0; j < frequency.size(); j++) { System.out.print(frequency.get(j) + " "); } //percent for (int j = 0; j < frequency.size(); j++) { double pp = (((double) frequency.get(j) / frame2.size()) * 100); percent.add(pp); } System.out.println(); for (int j = 0; j < percent.size(); j++) { System.out.print(percent.get(j) + " "); } int cff = 0; for (int j = 0; j < frequency.size(); j++) { cff += frequency.get(j); cf.add(cff); } System.out.println(); for (int j = 0; j < cf.size(); j++) { System.out.print(cf.get(j) + " "); } double cpp = 0; for (int j = 0; j < percent.size(); j++) { cpp += percent.get(j); cp.add(cpp); } System.out.println(); for (int j = 0; j < cp.size(); j++) { System.out.print(cp.get(j) + " "); } DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel(); dtm.setRowCount(limitLeft.size()); int ct = 0; if (collapse.isSelected() == true) { for (int j = 0; j < limitLeft.size(); j++) { if (ct == 0) { jTable1.getModel().setValueAt("< " + limitRight.get(j), ct, 1); jTable1.getModel().setValueAt("-", ct, 3); name.add("<"); } else if (ct == limitLeft.size() - 1) { jTable1.getModel().setValueAt("> " + limitLeft.get(j), ct, 1); jTable1.getModel().setValueAt("-", ct, 3); name.add(">"); } else { jTable1.getModel().setValueAt(limitLeft.get(j) + "-" + limitRight.get(j), ct, 1); jTable1.getModel().setValueAt(midpoint.get(j), ct, 3); name.add(midpoint.get(j) + ""); } jTable1.getModel().setValueAt(trueLimitLeft.get(j) + "-" + trueLimitRight.get(j), ct, 2); jTable1.getModel().setValueAt(frequency.get(j), ct, 4); jTable1.getModel().setValueAt(percent.get(j), ct, 5); jTable1.getModel().setValueAt(cf.get(j), ct, 6); jTable1.getModel().setValueAt(cp.get(j), ct, 7); ct++; } } else { for (int j = 0; j < limitLeft.size(); j++) { jTable1.getModel().setValueAt(limitLeft.get(j) + "-" + limitRight.get(j), ct, 1); jTable1.getModel().setValueAt(trueLimitLeft.get(j) + "-" + trueLimitRight.get(j), ct, 2); jTable1.getModel().setValueAt(midpoint.get(j), ct, 3); name.add(midpoint.get(j) + ""); jTable1.getModel().setValueAt(frequency.get(j), ct, 4); jTable1.getModel().setValueAt(percent.get(j), ct, 5); jTable1.getModel().setValueAt(cf.get(j), ct, 6); jTable1.getModel().setValueAt(cp.get(j), ct, 7); ct++; } } if (Chart.isSelected() == true) { DefaultCategoryDataset chart = new DefaultCategoryDataset(); int h = 0; for (Integer z : frequency) { chart.setValue(z, "Frequency", name.get(h)); h++; } JFreeChart mychart = ChartFactory.createBarChart(Desc.getText() + "", "Midpoint", "Frequency", chart, PlotOrientation.VERTICAL, true, false, false); CategoryPlot p = (CategoryPlot) mychart.getPlot(); p.setDomainGridlinesVisible(true); p.getDomainAxis().setCategoryMargin(0.0); ChartFrame charteuFrame = new ChartFrame(Desc.getText(), mychart); charteuFrame.setVisible(true); charteuFrame.setSize(450, 500); } } }
From source file:userInterface.EnergySourceBoardSupervisor.ManageEnergyConsumptionsJPanel.java
public void populateTable(Person person) { DefaultTableModel model = (DefaultTableModel) applianceTable.getModel(); TableColumnModel tcm = applianceTable.getColumnModel(); CustomTableCellRenderer customCellRenderer = new CustomTableCellRenderer(); model.setRowCount(0); if (person.getSensorsList().getSensorsList() != null) { for (Sensor sensor : person.getSensorsList().getSensorsList()) { Object[] row = new Object[5]; row[0] = sensor;/*from www.j a va2s .c o m*/ String appName = sensor.getSensorType().getValue(); row[1] = appName; int watts = sensor.getNumberWatt(); row[2] = watts; row[3] = sensor.getHours(); row[4] = sensor.getConsumptionLevel(); model.addRow(row); tcm.getColumn(4).setCellRenderer(customCellRenderer); } populateCalculations(); } }
From source file:vinci.project2.pkg1.View.java
private void calcButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_calcButtonActionPerformed try {//from w ww. j a va2 s .co m Integer.parseInt(ageField.getText()); Integer.parseInt(retAgeField.getText()); Double.parseDouble(capRateGainsField.getText()); Double.parseDouble(iTaxField.getText()); Double.parseDouble(rorField.getText()); Double.parseDouble(preBalField.getText()); Double.parseDouble(postBalField.getText()); Double.parseDouble(preContField.getText()); Double.parseDouble(postContField.getText()); Retirement r = new Retirement(); clearXY(); getVars(); loopVar = retAge - age; ror = 1 + ror; DefaultTableModel model = (DefaultTableModel) outputTable.getModel(); model.setRowCount(0); for (int q = 0; q < loopVar + 1; q++) { String preTaxS = r.preTaxM(q, loopVar, ror, year, preBal, preCont, iTax); String postTaxS = r.postTaxM(q, loopVar, year, ror, postBal, capRateGains, preCont, postTax); year = Double.parseDouble(preTaxS); post = Double.parseDouble(postTaxS); String totalS = r.total(total, year, post); totalD = Double.parseDouble(totalS); yearArray.add(new Year(age, year, post, totalD)); Object[] row = { age, "$" + preTaxS, "$" + postTaxS, "$" + String.format("%.2f", totalD) }; model.addRow(row); addXY(); age++; } outputTable.setModel(model); setChart(); } catch (NumberFormatException e) { calcButton.setEnabled(false); } }
From source file:temp1.JFrame1.java
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed if (RealTimeChart.getpd() == false) { jProgressBar1.setValue(0);// w ww . j a v a2 s. com jTextPane3.setText(null); DefaultTableModel tableMode2 = (DefaultTableModel) jTable1.getModel(); tableMode2.setRowCount(0); k = 1; q1 = true; q2 = false; q3 = false; q4 = false; w1 = true; w2 = false; w3 = false; w4 = false; e1 = true; e2 = false; e3 = false; e4 = false; e5 = false; p1 = false; p2 = false; p3 = false; } }