List of usage examples for org.jfree.chart ChartFrame setVisible
public void setVisible(boolean b)
From source file:gui_pack.MainGui.java
private void runTestsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runTestsButtonActionPerformed int rangeMin, rangeMax, spacing; int passing = 0; {// Beginning of input validation String errorTitle, errorMessage; //make sure at least one sort algorithm is selected if (!(insertionCheckBox.isSelected() || mergeCheckBox.isSelected() || quickCheckBox.isSelected() || selectionCheckBox.isSelected())) { errorTitle = "Selection Error"; errorMessage = "At least one sort algorithm (Insertion Sort, " + "Merge Sort, Quick Sort, or Selection Sort) must be selected."; JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE); return; }//from www.j av a 2 s .co m //make sure at least one order is selected if (!(ascendingCheckBox.isSelected() || descendingCheckBox.isSelected() || randomCheckBox.isSelected())) { errorTitle = "Selection Error"; errorMessage = "At least one order (Ascending Order, Descending Order, or Random Order) " + "must be selected."; JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE); return; } //make sure all the proper fields contain data try { rangeMin = Integer.parseInt(rangeMinField.getText()); rangeMax = Integer.parseInt(rangeMaxField.getText()); spacing = Integer.parseInt(spacingField.getText()); //for the multithreaded version of this program "iterations" cannot be a variable //this was left in to catch if the iteration field is left blank or has no value if (iterationField.isEnabled()) { Integer.parseInt(iterationField.getText()); } } catch (NumberFormatException arbitraryName) { errorTitle = "Input Error"; if (iterationField.isEnabled()) { errorMessage = "The size, intervals, and iterations fields must contain " + "integer values and only integer values."; } else { errorMessage = "The size and intervals fields must contain " + "integer values and only integer values."; } JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE); return; } //make sure field data is appropriate if (rangeMin > rangeMax) { errorTitle = "Range Error"; errorMessage = "Minimum Size must be less than or equal to Maximum Size."; JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE); return; } if (spacing < 1 || rangeMin < 1 || rangeMax < 1 || (iterationField.isEnabled() && Integer.parseInt(iterationField.getText()) < 1)) { errorTitle = "Value Error"; if (iterationField.isEnabled()) { errorMessage = "Intervals, sizes, and iterations must be in the positive domain. " + "Spacing, Range(min), Range(max), and Iterations must be greater than or" + " equal to one."; } else { errorMessage = "Intervals and sizes must be in the positive domain. " + "Spacing, Range(min) and Range(max) be greater than or" + " equal to one."; } JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE); return; } if (!iterationField.isEnabled()) { passing = 0; } } // End of input validation //here's where we set up a loading bar in case the tests take a while JProgressBar loadBar = new JProgressBar(); JFrame loadFrame = new JFrame(); JLabel displayLabel1 = new JLabel(); loadBar.setIndeterminate(true); loadBar.setVisible(true); displayLabel1.setText("Running large tests, or many tests, using inefficient algorithms \n" + "may take a while. Please be patient."); loadFrame.setLayout(new FlowLayout()); loadFrame.add(loadBar); loadFrame.add(displayLabel1); loadFrame.setSize(600, 100); loadFrame.setTitle("Loading"); loadFrame.setVisible(true); //now we will leave this open until the tests are completed //now we can conduct the actual tests SwingWorker worker = new SwingWorker<XYSeriesCollection, Void>() { XYSeriesCollection results = new XYSeriesCollection(); @Override protected XYSeriesCollection doInBackground() { XYSeries insertSeries = new XYSeries("Insertion Sort"); XYSeries mergeSeries = new XYSeries("Merge Sort"); XYSeries quickSeries = new XYSeries("Quick Sort"); XYSeries selectSeries = new XYSeries("Selection Sort"); final boolean ascending = ascendingCheckBox.isSelected(); final boolean descending = descendingCheckBox.isSelected(); final boolean insertion = insertionCheckBox.isSelected(); final boolean merge = mergeCheckBox.isSelected(); final boolean quick = quickCheckBox.isSelected(); final boolean selection = selectionCheckBox.isSelected(); final int iterations = Integer.parseInt(iterationField.getText()); ListGenerator generator = new ListGenerator(); int[] list; for (int count = rangeMin; count <= rangeMax; count = count + spacing) { if (ascending) { list = generator.ascending(count); if (insertion) { insertSeries.add(count, insertionSort.sort(list)); } if (merge) { mergeSeries.add(count, mergeSort.sort(list)); } if (quick) { quickSeries.add(count, quickSort.sort(list)); } if (selection) { selectSeries.add(count, selectionSort.sort(list)); } } if (descending) { list = generator.descending(count); if (insertion) { insertSeries.add(count, insertionSort.sort(list)); } if (merge) { mergeSeries.add(count, mergeSort.sort(list)); } if (quick) { quickSeries.add(count, quickSort.sort(list)); } if (selection) { selectSeries.add(count, selectionSort.sort(list)); } } for (int iteration = 0; iteration < iterations; iteration++) { list = generator.random(count); if (insertion) { insertSeries.add(count, insertionSort.sort(list)); } if (merge) { mergeSeries.add(count, mergeSort.sort(list)); } if (quick) { quickSeries.add(count, quickSort.sort(list)); } if (selection) { selectSeries.add(count, selectionSort.sort(list)); } } } //now we aggregate the results if (insertion) { results.addSeries(insertSeries); } if (merge) { results.addSeries(mergeSeries); } if (quick) { results.addSeries(quickSeries); } if (selection) { results.addSeries(selectSeries); } return results; } @Override protected void done() { //finally, we display the results JFreeChart chart = ChartFactory.createScatterPlot("SortExplorer", // chart title "List Size", // x axis label "Number of Comparisons", // y axis label results, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); ChartFrame frame = new ChartFrame("First", chart); frame.pack(); frame.setVisible(true); loadFrame.setVisible(false); } }; //having set up the multithreading 'worker' we can finally conduct the //test worker.execute(); }
From source file:UserInterface.SystemAdmin.ReportsJPanel.java
private void buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonActionPerformed if (c == null) { JOptionPane.showMessageDialog(null, "No Customer"); return;/*www .ja v a 2 s.c o m*/ } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (WaterUsage waterUsage : c.getWaterUsageHistory()) { dataset.setValue(waterUsage.getUsageVolume(), waterUsage.getDate(), "Usage Volume"); } JFreeChart chart = ChartFactory.createBarChart("Customer Water Usage Trends over a period of time", "Time of Usage", "Gallons", dataset, PlotOrientation.VERTICAL, true, true, true); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.cyan); ChartFrame frame = new ChartFrame("Bar Char for Weight", chart); frame.setVisible(true); frame.setSize(450, 350); }
From source file:UserInterface.SystemAdmin.ReportsJPanel.java
private void usageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_usageActionPerformed int selectedRow = customerTable.getSelectedRow(); if (selectedRow < 0) { JOptionPane.showMessageDialog(null, "Select a customer first"); return;//from w w w . j ava 2 s. c o m } Customer customer = (Customer) customerTable.getValueAt(selectedRow, 0); if (customer.getWaterUsageHistory().size() == 0) { JOptionPane.showMessageDialog(null, "No water usage yet"); return; } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (WaterUsage waterUsage : customer.getWaterUsageHistory()) { dataset.setValue(waterUsage.getUsageVolume(), waterUsage.getDate(), "Usage Volume"); } JFreeChart chart = ChartFactory.createBarChart("Customer Water Usage Trends over a period of time", "Time of Usage", "Gallons", dataset, PlotOrientation.VERTICAL, true, true, true); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.cyan); ChartFrame frame = new ChartFrame("Bar Char for Weight", chart); frame.setVisible(true); frame.setSize(450, 350); }
From source file:UserInterface.SystemAdmin.ReportsJPanel.java
private void flowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_flowActionPerformed int selectedRow = customerTable.getSelectedRow(); if (selectedRow < 0) { JOptionPane.showMessageDialog(null, "Select a customer first"); return;//from w ww. j ava 2s .c o m } Customer customer = (Customer) customerTable.getValueAt(selectedRow, 0); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (SensorValue sensorValue : customer.getTargetSensor().getSensorValueList()) { dataset.addValue(sensorValue.getFlowrate(), "Date", sensorValue.getDate()); } if (customer.getTargetSensor().getSensorValueList().size() == 1) { JFreeChart chart = ChartFactory.createBarChart( "Customer's water flowrate variation over a period of time", "Time of Usage", "FlowRate(gallons/sec)", dataset, PlotOrientation.VERTICAL, true, true, true); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.cyan); ChartFrame frame = new ChartFrame("Bar Char for Weight", chart); frame.setVisible(true); frame.setSize(450, 350); } else { JFreeChart chart = ChartFactory.createLineChart( "Customer's water flowrate variation over a period of time", "Time of Usage", "FlowRate(gallons/sec)", dataset, PlotOrientation.VERTICAL, true, true, true); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.cyan); ChartFrame frame = new ChartFrame("Bar Char for Weight", chart); RefineryUtilities.centerFrameOnScreen(frame); frame.setVisible(true); frame.setSize(450, 350); } }
From source file:net.bioclipse.chembl.moss.ui.wizard.ChemblMossWizardPage1.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;//from w w w .java 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(false); label = new Label(container, SWT.NONE); gridData = new GridData(GridData.FILL); gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 2; label.setLayoutData(gridData); label.setText("Choose a Kinase Protein Family"); 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); helpToHistogram(chembl .mossGetCompoundsFromProteinFamilyWithActivity(selected, index)); cboxAct.setText(index); info.setText("Distinct compunds: " + matrix2.getRowCount()); addToTable(matrix); //adds info about target, activities and compounds to a file ((ChemblMossWizard) getWizard()).data.matrix3 = chembl .mossGetCompoundsFromProteinFamilyWithActivityTarget( cbox.getItem(cbox.getSelectionIndex()), cboxAct.getItem(cboxAct.getSelectionIndex()), spinn.getSelection()); //adds the query to a file ((ChemblMossWizard) getWizard()).data.query = chembl .mossGetCompoundsFromProteinFamilyWithActivitySPARQL(selected, index); } 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()); ((ChemblMossWizard) getWizard()).data.matrix3 = chembl .mossGetCompoundsFromProteinFamilyWithActivityTarget( cbox.getItem(cbox.getSelectionIndex()), selected, spinn.getSelection()); ((ChemblMossWizard) getWizard()).data.query = chembl .mossGetCompoundsFromProteinFamilyWithActivitySPARQL( cbox.getItem(cbox.getSelectionIndex()), selected); //Adds activity to histogram series helpToHistogram(matrixAct); // 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."); // gridData = new GridData(); // gridData.horizontalSpan=4; // gridData.verticalSpan=5; // label.setLayoutData(gridData); check = new Button(container, SWT.CHECK); check.setText("Modify activities (optional)"); 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: "); label.setToolTipText("The graph don't consider limited search, will display for all available compounds"); 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(1); 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 mmatrixAct = chembl.mossGetCompoundsFromProteinFamilyWithActivity( cbox.getItem(cbox.getSelectionIndex()), cboxAct.getText()); IStringMatrix matrix = chembl.mossSetActivityBound(mmatrixAct, spinnLow.getSelection(), spinnHigh.getSelection()); // IStringMatrix m = chembl.mossSetActivityOutsideBound(matrixAct, spinnLow.getSelection(), spinnHigh.getSelection()); addToTable(matrix); int yes = 0, no = 0; for (int index = 1; index < matrix.getRowCount() + 1; index++) { if (matrix.get(index, "active").equals("yes")) { yes++; } else no++; } spinn.setSelection(matrix.getRowCount()); info.setText("Total compound hit: " + matrix.getRowCount() + ": active: " + yes + ", inactive: " + no); } 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("Active?"); column4 = new TableColumn(table, SWT.NONE); column4.setText("Compounds (SMILES)"); }
From source file:techtonic.Onview.java
private void maxBtnActionPerformed(java.awt.event.ActionEvent evt) { ChartFrame frame = new ChartFrame("XY graph using JFreeChart", chart); frame.pack();/*from w w w . java2s . c o m*/ frame.setVisible(true); }
From source file:techtonic.Techtonic.java
private void maxBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_maxBtnActionPerformed ChartFrame frame = new ChartFrame("XY graph using JFreeChart", chart); frame.pack();// w w w . j av a 2 s .c om frame.setVisible(true); }
From source file:UserInterface.SystemAdmin.ReportsJPanel.java
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed int total = 0; // for(Network network : system.getNetworkList()){ // for(Enterprise enterprise : network.getEnterpriseDirectory().getEnterpriseList()){ // for(Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()){ // if(organization instanceof CustomerOrganization){ // for(Employee employee : organization.getEmployeeDirectory().getEmployeeList()){ // Customer customer = (Customer) employee; // total += customer.getTotalUsageVolume(); // } // } // }/*from ww w .jav a 2 s . co m*/ // } // } for (Network network : system.getNetworkList()) { for (Enterprise enterprise : network.getEnterpriseDirectory().getEnterpriseList()) { if (enterprise instanceof WaterEnterprise) { for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) { if (organization instanceof CustomerOrganization) { for (Employee employee : organization.getEmployeeDirectory().getEmployeeList()) { Customer customer = (Customer) employee; total += customer.getTotalUsageVolume(); } } } } } } if (total == 0) { JOptionPane.showMessageDialog(null, "No Customer has used water yet"); return; } DefaultPieDataset dataset = new DefaultPieDataset(); for (Network network : system.getNetworkList()) { for (Enterprise enterprise : network.getEnterpriseDirectory().getEnterpriseList()) { for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) { if (organization instanceof CustomerOrganization) { for (Employee employee : organization.getEmployeeDirectory().getEmployeeList()) { Customer customer = (Customer) employee; dataset.setValue(customer.getName(), customer.getTotalUsageVolume()); } } } } } JFreeChart chart = ChartFactory.createPieChart3D("Customer Water Usage", dataset, true, true, true); ChartFrame frame = new ChartFrame("Pie Chart demonstrating customer water usage ", chart); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(200); plot.setForegroundAlpha(0.50f); RefineryUtilities.centerFrameOnScreen(frame); frame.setVisible(true); frame.setSize(650, 550); }
From source file:graph.plotter.PieMenu.java
/** * This is the main working button for this class... It creates pie chart analyZing whole data set * //from w ww . j ava 2 s . c o m * @param evt */ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed try { DefaultPieDataset pieDataset = new DefaultPieDataset(); /** Initializing pie dataset*/ int i; i = 0; String genre = "a"; if (Button == 1) { /** For User Input*/ while (i < cnt) { double aa = Double.parseDouble(Table.getModel().getValueAt(i, 1).toString()); String str = Table.getModel().getValueAt(i, 0).toString(); pieDataset.setValue(str, new Double(aa)); i++; genre += "a"; } } else { try { BufferedReader br = new BufferedReader(new FileReader(jTextField3.getText())); String Line; while ((Line = br.readLine()) != null) { String[] value = Line.split(","); double val = Double.parseDouble(value[1]); pieDataset.setValue(value[0], new Double(val)); // dataset.setValue(new Double(val),genre,value[0]); // genre+="a"; // (value[0]); } } catch (FileNotFoundException ex) { Logger.getLogger(PieMenu.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(PieMenu.class.getName()).log(Level.SEVERE, null, ex); } } JFreeChart chart = ChartFactory.createPieChart("Pie Chart", pieDataset, true, true, true); PiePlot P = (PiePlot) chart.getPlot(); P.setLabelLinkPaint(Color.BLACK); P.setBackgroundPaint(Color.white); ChartFrame frame = new ChartFrame("PieChart", chart); jButto1 = new JButton("Save"); frame.setLayout(new BorderLayout()); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints gc = new GridBagConstraints(); gc.gridx = 1; gc.gridy = 0; panel.add(jButto1, gc); frame.add(panel, BorderLayout.SOUTH); jButto1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("Pie_Chart.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); } catch (Exception ex) { } } }); frame.setVisible(true); frame.setSize(858, 512); try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("Pie_Chart.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); } catch (Exception e) { } } catch (Exception ex) { } }
From source file:userinterface.DoctorWorkArea.DiagnosePatientJPanel.java
private void barBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_barBtnActionPerformed // TODO add your handling code here: DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); int i = 1;/*from ww w .j a v a2s . co m*/ Employee patient = (Employee) patientCombo.getSelectedItem(); for (VitalSign vs : patient.getMedicalRecord().getVitalSignHistory().getVitalSignList()) { dataSet.setValue(vs.getBloodPressure(), "Blood Pressure", vs.getTimestamp()); i++; } JFreeChart chart = ChartFactory.createBarChart("Blood Pressure Graph", "Timestamp", "Blood Pressure", dataSet, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLACK); ChartFrame frame = new ChartFrame("Bar Chart for Patient", chart); frame.setVisible(true); frame.setSize(800, 550); }