List of usage examples for org.jfree.chart ChartFrame setVisible
public void setVisible(boolean b)
From source file:omr.sheet.LinesBuilder.java
private void writePlot(int[] histo, int maxHisto, double ratio) { XYSeriesCollection dataset = new XYSeriesCollection(); // Threshold line XYSeries thresholdSeries = new XYSeries("Staff ratio used" + " [" + ratio + "]"); thresholdSeries.add(0, ratio);//from w ww. j a va2s .c o m thresholdSeries.add(-histo.length + 1, ratio); dataset.addSeries(thresholdSeries); // Projection data XYSeries dataSeries = new XYSeries("Projections"); for (int i = 0; i < histo.length; i++) { dataSeries.add(-i, histo[i] / (double) maxHisto); } dataset.addSeries(dataSeries); // Chart JFreeChart chart = ChartFactory.createXYLineChart(sheet.getRadix() + " (Horizontal Projections)", // Title "Ordinate", "Ratios of horizontal counts", dataset, // Dataset PlotOrientation.HORIZONTAL, // orientation, true, // Show legend false, // Show tool tips false // urls ); // Hosting frame ChartFrame frame = new ChartFrame(sheet.getRadix() + " - Staff Lines", chart, true); frame.pack(); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); RefineryUtilities.centerFrameOnScreen(frame); frame.setVisible(true); }
From source file:UserInterfaces.HAdministration.FallReportJPanel.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: int timeofem = 0; int timeofpha = 0; int timeofward = 0; int timeofor = 0; int timeoflab = 0; int timeofoutpatient = 0; int i;/* w w w . java 2s . c o m*/ int max = 0; for (WorkRequest workRequest : enterprise.getWorkQueue().getWorkRequestList()) { if (workRequest.getLevel2().equals(ErrorUtil.FALL)) { if (workRequest.getLocation().equals(Location.EMERGENCY)) { timeofem = timeofem + 1; } if (workRequest.getLocation().equals(Location.LABORATORY)) { timeoflab = timeoflab + 1; } if (workRequest.getLocation().equals(Location.OR)) { timeofor = timeofor + 1; } if (workRequest.getLocation().equals(Location.OUTPATIEN)) { timeofoutpatient = timeofoutpatient + 1; } if (workRequest.getLocation().equals(Location.PHARMACY)) { timeofpha = timeofpha + 1; } if (workRequest.getLocation().equals(Location.WARD)) { timeofward = timeofward + 1; } } } int[] numbs; numbs = new int[6]; numbs[0] = timeofem; numbs[1] = timeoflab; numbs[2] = timeofor; numbs[3] = timeofoutpatient; numbs[4] = timeofpha; numbs[5] = timeofward; DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue(Location.EMERGENCY, timeofem); dataset.setValue(Location.LABORATORY, timeoflab); dataset.setValue(Location.OR, timeofor); dataset.setValue(Location.OUTPATIEN, timeofoutpatient); dataset.setValue(Location.PHARMACY, timeofpha); dataset.setValue(Location.WARD, timeofward); JFreeChart chart = ChartFactory.createPieChart(" Chart", dataset, true, true, true); PiePlot p = (PiePlot) chart.getPlot(); ChartFrame chartFrame = new ChartFrame("Location of events", chart); chartFrame.setSize(450, 550); chartFrame.setVisible(true); }
From source file:e3fraud.gui.MainWindow.java
public void actionPerformed(ActionEvent e) { //Handle open button action. if (e.getSource() == openButton) { int returnVal = fc.showOpenDialog(MainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); //parse file this.baseModel = FileParser.parseFile(file); log.append(currentTime.currentTime() + " Opened: " + file.getName() + "." + newline); } else {//from w w w.java 2s .c o m log.append(currentTime.currentTime() + " Open command cancelled by user." + newline); } log.setCaretPosition(log.getDocument().getLength()); //handle Generate button } else if (e.getSource() == generateButton) { if (this.baseModel != null) { //have the user indicate the ToA via pop-up JFrame frame1 = new JFrame("Select Target of Assessment"); Map<String, Resource> actorsMap = this.baseModel.getActorsMap(); String selectedActorString = (String) JOptionPane.showInputDialog(frame1, "Which actor's perspective are you taking?", "Choose main actor", JOptionPane.QUESTION_MESSAGE, null, actorsMap.keySet().toArray(), actorsMap.keySet().toArray()[0]); if (selectedActorString == null) { log.append(currentTime.currentTime() + " Attack generation cancelled!" + newline); } else { lastSelectedActorString = selectedActorString; //have the user select a need via pop-up JFrame frame2 = new JFrame("Select graph parameter"); Map<String, Resource> needsMap = this.baseModel.getNeedsMap(); String selectedNeedString = (String) JOptionPane.showInputDialog(frame2, "What do you want to use as parameter?", "Choose need to parametrize", JOptionPane.QUESTION_MESSAGE, null, needsMap.keySet().toArray(), needsMap.keySet().toArray()[0]); if (selectedNeedString == null) { log.append("Attack generation cancelled!" + newline); } else { lastSelectedNeedString = selectedNeedString; //have the user select occurence interval via pop-up JTextField xField = new JTextField("1", 4); JTextField yField = new JTextField("500", 4); JPanel myPanel = new JPanel(); myPanel.add(new JLabel("Mininum occurences:")); myPanel.add(xField); myPanel.add(Box.createHorizontalStrut(15)); // a spacer myPanel.add(new JLabel("Maximum occurences:")); myPanel.add(yField); int result = JOptionPane.showConfirmDialog(null, myPanel, "Please Enter occurence rate interval", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.CANCEL_OPTION) { log.append("Attack generation cancelled!" + newline); } else if (result == JOptionPane.OK_OPTION) { startValue = Integer.parseInt(xField.getText()); endValue = Integer.parseInt(yField.getText()); selectedNeed = needsMap.get(selectedNeedString); selectedActor = actorsMap.get(selectedActorString); //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI) GenerationWorker generationWorker = new GenerationWorker(baseModel, selectedActorString, selectedActor, selectedNeed, selectedNeedString, startValue, endValue, log, lossButton, gainButton, lossGainButton, gainLossButton, groupingButton, collusionsButton) { //make it so that when Worker is done @Override protected void done() { try { progressBar.setVisible(false); System.err.println("I made it invisible"); //the Worker's result is retrieved treeModel.setRoot(get()); tree.setModel(treeModel); tree.updateUI(); tree.collapseRow(1); //tree.expandRow(0); tree.setRootVisible(false); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } catch (InterruptedException | ExecutionException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); log.append("Out of memory; please increase heap size of JVM"); PopUps.infoBox( "Encountered an error. Most likely out of memory; try increasing the heap size of JVM", "Error"); } } }; this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); progressBar.setVisible(true); progressBar.setIndeterminate(true); progressBar.setString("generating..."); generationWorker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("phase".equals(evt.getPropertyName())) { progressBar.setMaximum(100); progressBar.setIndeterminate(false); progressBar.setString("ranking..."); } else if ("progress".equals(evt.getPropertyName())) { progressBar.setValue((Integer) evt.getNewValue()); } } }); generationWorker.execute(); } } } } else { log.append("Load a model file first!" + newline); } } //handle the refresh button else if (e.getSource() == refreshButton) { if (lastSelectedNeedString != null && lastSelectedActorString != null) { Map<String, Resource> actorsMap = this.baseModel.getActorsMap(); Map<String, Resource> needsMap = this.baseModel.getNeedsMap(); selectedNeed = needsMap.get(lastSelectedNeedString); selectedActor = actorsMap.get(lastSelectedActorString); //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI) GenerationWorker generationWorker = new GenerationWorker(baseModel, lastSelectedActorString, selectedActor, selectedNeed, lastSelectedNeedString, startValue, endValue, log, lossButton, gainButton, lossGainButton, gainLossButton, groupingButton, collusionsButton) { //make it so that when Worker is done @Override protected void done() { try { progressBar.setVisible(false); //the Worker's result is retrieved treeModel.setRoot(get()); tree.setModel(treeModel); tree.updateUI(); tree.collapseRow(1); //tree.expandRow(0); tree.setRootVisible(false); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } catch (InterruptedException | ExecutionException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); log.append("Most likely out of memory; please increase heap size of JVM"); PopUps.infoBox( "Encountered an error. Most likely out of memory; try increasing the heap size of JVM", "Error"); } } }; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); progressBar.setVisible(true); progressBar.setIndeterminate(true); progressBar.setString("generating..."); generationWorker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("phase".equals(evt.getPropertyName())) { progressBar.setMaximum(100); progressBar.setIndeterminate(false); progressBar.setString("ranking..."); } else if ("progress".equals(evt.getPropertyName())) { progressBar.setValue((Integer) evt.getNewValue()); } } }); generationWorker.execute(); } else { log.append(currentTime.currentTime() + " Nothing to refresh. Generate models first" + newline); } } //handle show ideal graph button else if (e.getSource() == idealGraphButton) { if (this.baseModel != null) { graph1 = GraphingTool.generateGraph(baseModel, selectedNeed, startValue, endValue, true);//expected graph ChartFrame chartframe1 = new ChartFrame("Ideal results", graph1); chartframe1.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT)); chartframe1.pack(); chartframe1.setLocationByPlatform(true); chartframe1.setVisible(true); } else { log.append(currentTime.currentTime() + " Load a model file first!" + newline); } } //Handle the graph extend button//Handle the graph extend button else if (e.getSource() == expandButton) { //make sure there is a graph to show if (graph2 == null) { log.append(currentTime.currentTime() + " No graph to display. Select one first." + newline); } else { //this makes sure both graphs have the same y axis: // double lowerBound = min(graph1.getXYPlot().getRangeAxis().getRange().getLowerBound(), graph2.getXYPlot().getRangeAxis().getRange().getLowerBound()); // double upperBound = max(graph1.getXYPlot().getRangeAxis().getRange().getUpperBound(), graph2.getXYPlot().getRangeAxis().getRange().getUpperBound()); // graph1.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound); // graph2.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound); chartPane.removeAll(); chartPanel = new ChartPanel(graph2); chartPanel.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT)); chartPane.add(chartPanel); chartPane.add(collapseButton); extended = true; this.setPreferredSize(new Dimension(this.getWidth() + CHART_WIDTH, this.getHeight())); JFrame frame = (JFrame) getRootPane().getParent(); frame.pack(); } } //Handle the graph collapse button//Handle the graph collapse button else if (e.getSource() == collapseButton) { System.out.println("resizing by -" + CHART_WIDTH); chartPane.removeAll(); chartPane.add(expandButton); this.setPreferredSize(new Dimension(this.getWidth() - CHART_WIDTH, this.getHeight())); chartPane.repaint(); chartPane.revalidate(); extended = false; JFrame frame = (JFrame) getRootPane().getParent(); frame.pack(); } }
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 av a 2 s . c o m*/ 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;// w ww . j av a 2s . com 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:net.bioclipse.chembl.moss.ui.wizard.ChemblMossWizardPage2.java
@Override public void createControl(Composite parent) { final Composite container = new Composite(parent, SWT.NONE); final GridLayout layout = new GridLayout(4, false); layout.marginRight = 2;//w ww . j a v a 2s . c o m layout.marginLeft = 2; layout.marginBottom = -2; layout.marginTop = 10; layout.marginWidth = 2; layout.marginHeight = 2; layout.verticalSpacing = 5; layout.horizontalSpacing = 5; container.setLayout(layout); PlatformUI.getWorkbench().getHelpSystem().setHelp(container, "net.bioclipse.moss.business.helpmessage"); setControl(container); setMessage("Select the first protein family to compare with substructure mining."); setPageComplete(true); label = new Label(container, SWT.NONE); gridData = new GridData(GridData.FILL); gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 2; label.setLayoutData(gridData); label.setText("Choose Kinase Protein Familes"); cbox = new Combo(container, SWT.READ_ONLY); cbox.setToolTipText("Kinase family"); gridData = new GridData(); gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 2; gridData.widthHint = 100; cbox.setLayoutData(gridData); String[] items = { "TK", "TKL", "STE", "CK1", "CMGC", "AGC", "CAMK" }; cbox.setItems(items); cbox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { final String selected = cbox.getItem(cbox.getSelectionIndex()); try { table.clearAll(); table.removeAll(); setErrorMessage(null); List<String> list = chembl.mossAvailableActivities(selected); if (list.size() > 0) { String[] item = new String[list.size()]; for (int i = 0; i < list.size(); i++) { item[i] = list.get(i); } if (cboxAct.isEnabled()) { if (cboxAct.getSelection().x == cboxAct.getSelection().y) { cboxAct.setItems(item); } else { //Solves the problem involving changing the protein family... //Brings the current activities to an array String oldItems[] = cboxAct.getItems(); // Takes that array and makes it a list for (int i = 0; i < list.size(); i++) { cboxAct.add(item[i]); } //Remove the old items in the combobox int oldlistsize = cboxAct.getItemCount() - list.size(); index = cboxAct.getText();//cboxAct.getItem(cboxAct.getSelectionIndex()); cboxAct.remove(0, oldlistsize - 1); //Adds new items to the comboboxlist List<String> oldItemsList = new ArrayList<String>(); for (int i = 0; i < oldItems.length; i++) { oldItemsList.add(oldItems[i]); } //New query with the given settings //if(oldItemsList.contains((index))==true){ if (list.contains((index)) == true) { spinn.setSelection(50); IStringMatrix matrix, matrix2; try { matrix = chembl.mossGetCompoundsFromProteinFamilyWithActivity(selected, index, spinn.getSelection()); matrix2 = chembl.mossGetCompoundsFromProteinFamily(selected, index); cboxAct.setText(index); info.setText("Distinct compunds: " + matrix2.getRowCount()); addToTable(matrix); } catch (BioclipseException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else { setErrorMessage("The activity " + index + " does not exist for the protein family " + selected + "."); info.setText("Total compund hit:"); setPageComplete(false); } } } else { cboxAct.setItems(item); cboxAct.setEnabled(true); } } } catch (BioclipseException e1) { e1.printStackTrace(); } } }); /*Returns the available compunds for the family*/ label = new Label(container, SWT.NONE); gridData = new GridData(GridData.FILL); gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 2; label.setLayoutData(gridData); label.setText("Choose one available activity"); cboxAct = new Combo(container, SWT.READ_ONLY); gridData = new GridData(GridData.FILL); gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 2; gridData.widthHint = 100; String[] item = { "No available activity" }; cboxAct.setItems(item); cboxAct.setLayoutData(gridData); cboxAct.setEnabled(false); cboxAct.setToolTipText("These activities are only accurate for chosen protein"); //Listener for available activities(IC50, Ki etc) cboxAct.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { String selected = cboxAct.getItem(cboxAct.getSelectionIndex()); try { setErrorMessage(null); table.clearAll(); table.removeAll(); spinn.setSelection(50); check.setSelection(false); spinnLow.setEnabled(false); spinnHigh.setEnabled(false); spinnLow.setSelection(0); spinnHigh.setSelection(1000); //SPARQL queries for fetching compounds and activities IStringMatrix matrix = chembl.mossGetCompoundsFromProteinFamilyWithActivity( cbox.getItem(cbox.getSelectionIndex()), selected, spinn.getSelection()); addToTable(matrix); //Count the amount of compounds there is for one hit, i.e. same query without limit. IStringMatrix matrix2 = chembl.mossGetCompoundsFromProteinFamily( cbox.getItem(cbox.getSelectionIndex()), cboxAct.getItem(cboxAct.getSelectionIndex())); info.setText("Distinct compounds: " + matrix2.getRowCount()); //Query for activities. Adds them to the plot series. matrixAct = chembl.mossGetCompoundsFromProteinFamilyWithActivity( cbox.getItem(cbox.getSelectionIndex()), selected); //IStringMatrix matrix = chembl.MossProtFamilyCompounds(cbox.getItem(cbox.getSelectionIndex()), selected,50); //IStringMatrix matrix = chembl.MossProtFamilyCompounds(cbox.getItem(cbox.getSelectionIndex()), selected, spinn.getSelection()); //Adds activity to histogram series series = new XYSeries("Activity for compounds"); histogramSeries = new HistogramDataset(); histogramSeries.setType(HistogramType.FREQUENCY); ArrayList<Double> activites = new ArrayList<Double>(); double value; int cnt = 1; double[] histact = new double[matrixAct.getRowCount() + 1]; for (int i = 1; i < matrixAct.getRowCount() + 1; i++) { if (matrixAct.get(i, "actval").equals("")) { value = 0; } else { value = Double.parseDouble(matrixAct.get(i, "actval")); } activites.add(value); } //Sort list to increasing order of activities and adds them to histogram Collections.sort(activites); for (int i = 0; i < activites.size(); i++) { double d = activites.get(i); histact[i] = d; int t = activites.size() - 1; if (i == t) { series.add(d, cnt); } else { double dd = activites.get(i + 1); if (d == dd) { cnt++; } else { histact[i] = d; series.add(d, cnt); cnt = 1; } } } histogramSeries.addSeries("Histogram", histact, matrixAct.getRowCount()); button.setEnabled(true); spinn.setEnabled(true); check.setEnabled(true); //cboxAct.setEnabled(true); //buttonH.setEnabled(true); } catch (BioclipseException e1) { e1.printStackTrace(); } setPageComplete(true); } }); label = new Label(container, SWT.NONE); gridData = new GridData(); gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 2; label.setLayoutData(gridData); label.setText("Limit"); spinn = new Spinner(container, SWT.BORDER); gridData = new GridData(); spinn.setLayoutData(gridData); spinn.setSelection(50); spinn.setMaximum(10000000); spinn.setIncrement(50); spinn.setEnabled(false); gridData.widthHint = 100; gridData.horizontalSpan = 1; spinn.setToolTipText("Limits the search, increases by 50"); spinn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selected = spinn.getSelection(); try { table.clearAll(); table.removeAll(); IStringMatrix matrix = chembl.mossGetCompounds(cbox.getItem(cbox.getSelectionIndex()), cboxAct.getItem(cboxAct.getSelectionIndex()), selected); table.setVisible(true); addToTable(matrix); } catch (BioclipseException e1) { e1.printStackTrace(); } } }); //Button that adds all hits to the limit button = new Button(container, SWT.PUSH); button.setToolTipText("Add all compounds to the table"); button.setText("Display all"); button.setEnabled(false); button.setLayoutData(gridData); gridData = new GridData(); gridData.horizontalSpan = 1; button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { //try { table.removeAll(); // ProgressMonitorDialog dialog = new ProgressMonitorDialog(container.getShell()); // // try { // dialog.run(true, true, new IRunnableWithProgress(){ // public void run(IProgressMonitor monitor) { // monitor.beginTask("Searching for compounds", IProgressMonitor.UNKNOWN); try { IStringMatrix matrix = chembl.mossGetCompoundsFromProteinFamilyWithActivity( cbox.getItem(cbox.getSelectionIndex()), cboxAct.getItem(cboxAct.getSelectionIndex())); // final IStringMatrix matrix = chembl.MossProtFamilyCompoundsAct("TK", "Ki"); addToTable(matrix); info.setText("Total hit(not always distinct compounds): " + matrix.getRowCount()); spinn.setSelection(matrix.getRowCount()); } catch (BioclipseException eb) { // TODO Auto-generated catch block eb.printStackTrace(); } // // monitor.done(); // } // }); // } catch (InvocationTargetException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // } catch (InterruptedException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // } // } catch (BioclipseException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // } } }); label = new Label(container, SWT.NONE); label.setText("Optional: Modify activity values."); Font font1 = new Font(container.getDisplay(), "Helvetica", 13, SWT.NONE); label.setFont(font1); gridData = new GridData(); gridData.horizontalSpan = 4; gridData.verticalSpan = 5; label.setLayoutData(gridData); check = new Button(container, SWT.CHECK); check.setText("Modify activities"); check.setToolTipText("Modify data by specifying upper and lower activity limit"); check.setEnabled(false); gridData = new GridData(GridData.BEGINNING); gridData.horizontalSpan = 2; check.setLayoutData(gridData); check.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean selected = check.getSelection(); if (selected == true) { spinnLow.setEnabled(true); spinnHigh.setEnabled(true); buttonUpdate.setEnabled(true); labelHigh.setEnabled(true); labelLow.setEnabled(true); buttonH.setEnabled(true); } else if (selected == false) { spinnLow.setEnabled(false); spinnHigh.setEnabled(false); buttonUpdate.setEnabled(false); labelHigh.setEnabled(false); labelLow.setEnabled(false); buttonH.setEnabled(false); } } }); label = new Label(container, SWT.NONE); label.setText("Look at activity span: "); gridData = new GridData(); gridData.horizontalSpan = 1; label.setLayoutData(gridData); buttonH = new Button(container, SWT.PUSH); buttonH.setText("Graph"); buttonH.setToolTipText("Shows activity in a graph(for all compounds)"); buttonH.setEnabled(false); gridData = new GridData(); gridData.horizontalSpan = 1; buttonH.setLayoutData(gridData); buttonH.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { JFreeChart jfreechart = ChartFactory.createXYLineChart("Histogram Demo", "Activity values", "Number of compounds", histogramSeries, PlotOrientation.VERTICAL, true, false, false); // final XYSeriesCollection dataset = new XYSeriesCollection(series); // JFreeChart chart = ChartFactory.createXYBarChart( // "Activity chart", // "Activity value", // false, // "Number of Compounds", // dataset, // PlotOrientation.VERTICAL, // true, // true, // false // ); ChartFrame frame = new ChartFrame("Activities", jfreechart); frame.pack(); frame.setVisible(true); } }); // Lower activity bound for updating table labelLow = new Label(container, SWT.NONE); labelLow.setText("Lower activity limit"); labelLow.setEnabled(false); gridData = new GridData(); gridData.horizontalSpan = 1; labelLow.setLayoutData(gridData); spinnLow = new Spinner(container, SWT.NONE); spinnLow.setSelection(0); spinnLow.setMaximum(10000000); spinnLow.setIncrement(50); spinnLow.setEnabled(false); spinnLow.setToolTipText("Specify lower activity limit"); gridData = new GridData(); gridData.widthHint = 100; gridData.horizontalSpan = 1; spinnLow.setLayoutData(gridData); buttonUpdate = new Button(container, SWT.PUSH); buttonUpdate.setText("Update table"); buttonUpdate.setToolTipText("Update the table with the specified activity limits"); buttonUpdate.setEnabled(false); gridData = new GridData(); gridData.horizontalSpan = 2; buttonUpdate.setLayoutData(gridData); buttonUpdate.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { table.clearAll(); table.removeAll(); try { IStringMatrix matrix = chembl.mossSetActivityBound(matrixAct, spinnLow.getSelection(), spinnHigh.getSelection()); addToTable(matrix); spinn.setSelection(matrix.getRowCount()); info.setText("Total compound hit: " + matrix.getRowCount()); } catch (BioclipseException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); //Upper activity bound for updating table labelHigh = new Label(container, SWT.NONE); labelHigh.setText("Upper activity limit"); labelHigh.setEnabled(false); gridData = new GridData(); gridData.horizontalSpan = 1; labelHigh.setLayoutData(gridData); spinnHigh = new Spinner(container, SWT.BORDER); spinnHigh.setSelection(1000); spinnHigh.setMaximum(1000000000); spinnHigh.setIncrement(50); spinnHigh.setEnabled(false); spinnHigh.setToolTipText("Specify upper activity limit"); gridData = new GridData(); gridData.widthHint = 100; gridData.horizontalSpan = 3; spinnHigh.setLayoutData(gridData); //Label for displaying compound hits info = new Label(container, SWT.NONE); gridData = new GridData(); info.setLayoutData(gridData); gridData.horizontalSpan = 4; gridData.verticalSpan = 6; gridData.widthHint = 350; info.setText("Total compound hit:"); //Table displaying contents table = new Table(container, SWT.BORDER); table.setHeaderVisible(true); table.setLinesVisible(true); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.widthHint = 300; gridData.heightHint = 300; gridData.horizontalSpan = 4; table.setLayoutData(gridData); column1 = new TableColumn(table, SWT.NONE); column1.setText("Index"); column2 = new TableColumn(table, SWT.NONE); column2.setText("Activity value"); column3 = new TableColumn(table, SWT.NONE); column3.setText("Compounds (SMILES)"); }
From source file:net.bioclipse.chembl.business.ChEMBLManager.java
public void moSSViewHistogram(IStringMatrix matrix) throws BioclipseException { XYSeries series = new XYSeries("Activity for compounds"); HistogramDataset histogramSeries = new HistogramDataset(); histogramSeries.setType(HistogramType.FREQUENCY); ArrayList<Double> activites = new ArrayList<Double>(); double value; int cnt = 1;// www . j a v a 2s . c o m double[] histact = new double[matrix.getRowCount() + 1]; for (int i = 1; i < matrix.getRowCount() + 1; i++) { if (matrix.get(i, "actval").equals("")) { value = 0; } else { value = Double.parseDouble(matrix.get(i, "actval")); } activites.add(value); } //Sort list to increasing order of activities and adds them to histogram Collections.sort(activites); for (int i = 0; i < activites.size(); i++) { double d = activites.get(i); histact[i] = d; int t = activites.size() - 1; if (i == t) { series.add(d, cnt); } else { double dd = activites.get(i + 1); if (d == dd) { cnt++; } else { histact[i] = d; series.add(d, cnt); cnt = 1; } } } histogramSeries.addSeries("Histogram", histact, matrix.getRowCount()); JFreeChart jfreechart = ChartFactory.createXYLineChart("Histogram", "Activity values", "Number of compounds", histogramSeries, PlotOrientation.VERTICAL, true, false, false); ChartFrame frame = new ChartFrame("Activities", jfreechart); frame.pack(); frame.setVisible(true); }
From source file:ui.Interface.java
private void butChartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butChartActionPerformed try {/*from w ww .j av a 2s.c o m*/ if (txtNumbersAll.getText().equals("")) { JOptionPane.showMessageDialog(this, "Please fill out the Empty fields!", "Sorting Algo Simulator v2.0", javax.swing.JOptionPane.ERROR_MESSAGE); return; } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(InsertInstructionCount, "InsertionSort", "InsertionSort"); dataset.setValue(SelectInstructionCount, "SelectionSort", "SelectionSort"); JFreeChart chart = ChartFactory.createBarChart("Instruction Count", "Instruction Count", "Unique Counts", dataset, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.white); chart.getTitle().setPaint(Color.blue); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.red); ChartFrame frame1 = new ChartFrame("Insertion Sort Vs Selection Sort - Performance Analyze", chart); Dimension screenSize = new Dimension(Toolkit.getDefaultToolkit().getScreenSize()); Dimension windowSize = new Dimension(getPreferredSize()); int wdwLeft2 = screenSize.width / 2 - windowSize.width / 2 - 200; int wdwTop2 = screenSize.height / 2 - windowSize.height / 2; frame1.setLocation(wdwLeft2, wdwTop2); frame1.pack(); frame1.setSize(400, 350); frame1.setVisible(true); DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(InsertTimeDiff, "InsertionSort", "InsertionSort"); dataset2.setValue(SelectTimeDiff, "SelectionSort", "SelectionSort"); JFreeChart chart2 = ChartFactory.createBarChart("Time Complexity* (can be vary)", "Time Complexity", "Nano Seconds", dataset2, PlotOrientation.VERTICAL, false, true, false); chart2.setBackgroundPaint(Color.white); chart2.getTitle().setPaint(Color.blue); CategoryPlot p2 = chart2.getCategoryPlot(); p2.setRangeGridlinePaint(Color.red); ChartFrame frame2 = new ChartFrame("Insertion Sort Vs Selection Sort - Performance Analyze", chart2); int wdwLeft = 50 + screenSize.width / 2 - windowSize.width / 2 + 200; int wdwTop = screenSize.height / 2 - windowSize.height / 2; frame2.setLocation(wdwLeft, wdwTop); frame2.pack(); frame2.setVisible(true); frame2.setSize(400, 350); } catch (Exception e) { e.printStackTrace(); } }
From source file:vinci.project2.pkg1.View.java
/** * Initializes the chart// ww w . j a v a 2s . c om */ private void setChart() { final JFreeChart chart = createChart(gd.createDataset(xySeries1, xySeries2, xySeries3)); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setSize(400, 300); ChartFrame chartFrame = new ChartFrame("Taxes", chart); chartFrame.setSize(400, 300); chartFrame.add(chartPanel); chartFrame.pack(); chartFrame.setVisible(false); chartFrame1.add(chartPanel); chartFrame1.setSize(400, 300); chartFrame1.repaint(); chartFrame1.revalidate(); }
From source file:userInterface.HospitalAdminRole.ManagePatientsJPanel.java
private void createChart() { DefaultCategoryDataset vitalSignDataset = new DefaultCategoryDataset(); int selectedRow = vitalSignjTable.getSelectedRow(); Member member = (Member) vitalSignjTable.getValueAt(selectedRow, 0); ArrayList<VitalSign> vitalSignList = member.getVitalSignList().getVitalSignList(); /*At least 2 vital sign records needed to show chart */ if (vitalSignList.isEmpty() || vitalSignList.size() == 1) { JOptionPane.showMessageDialog(this, "No vital signs or only one vital sign found. At least 2 vital sign records needed to show chart!", "Warning", JOptionPane.INFORMATION_MESSAGE); return;/*w ww . j ava2 s.c o m*/ } for (VitalSign vitalSign : vitalSignList) { vitalSignDataset.addValue(vitalSign.getRespiratoryRate(), "RR", vitalSign.getTimestamp()); vitalSignDataset.addValue(vitalSign.getHeartRate(), "HR", vitalSign.getTimestamp()); vitalSignDataset.addValue(vitalSign.getBloodPressure(), "BP", vitalSign.getTimestamp()); vitalSignDataset.addValue(vitalSign.getTemperature(), "Temp", vitalSign.getTimestamp()); } JFreeChart vitalSignChart = ChartFactory.createBarChart3D("Vital Sign Chart", "Time Stamp", "Rate", vitalSignDataset, PlotOrientation.VERTICAL, true, false, false); vitalSignChart.setBackgroundPaint(Color.white); CategoryPlot vitalSignChartPlot = vitalSignChart.getCategoryPlot(); vitalSignChartPlot.setBackgroundPaint(Color.lightGray); CategoryAxis vitalSignDomainAxis = vitalSignChartPlot.getDomainAxis(); vitalSignDomainAxis .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); NumberAxis vitalSignRangeAxis = (NumberAxis) vitalSignChartPlot.getRangeAxis(); vitalSignRangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartFrame chartFrame = new ChartFrame("Chart", vitalSignChart); chartFrame.setVisible(true); chartFrame.setSize(500, 500); }