List of usage examples for org.jfree.chart ChartFrame pack
@SuppressWarnings("deprecation") public void pack()
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 www. j ava 2 s.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(); frame.setVisible(true);// w w w.j a v a2s . c o m }
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(); frame.setVisible(true);//from ww w . ja v a 2 s. co m }
From source file:UserInterface.GarbageCollectorRole.GarbageCollectorWorkAreaJPanel.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed DefaultCategoryDataset dataset = new DefaultCategoryDataset(); int mCollected = getSumMCollected(); int pCollected = getSumpCollected(); int bcollected = getSumbCollected(); dataset.setValue(mCollected, "Metal collected", "" + "Metal collected"); dataset.setValue(pCollected, "Plastic collected", "" + "Plastic collected"); dataset.setValue(bcollected, "BioDegradable Collected", "" + "BioDegradable Collected"); JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo", "Category", "Value", dataset, PlotOrientation.VERTICAL.VERTICAL, true, true, false); ChartPanel chartPanel = new ChartPanel(chart, false); chartPanel.setPreferredSize(new Dimension(500, 270)); ChartFrame cFrame = new ChartFrame("Name", chart); cFrame.pack(); cFrame.setVisible(true);//w ww . java 2 s.co m }
From source file:UserInterface.GarbageCollectorRole.GarbageCollectorWorkAreaJPanel.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed DefaultCategoryDataset dataset = new DefaultCategoryDataset(); int mCollected = getSumMSegregated(); int pCollected = getSumpSegregated(); int bcollected = getSumbSegregated(); dataset.setValue(mCollected, "Metal Segregated", "" + "Metal Segregated"); dataset.setValue(pCollected, "Plastic Segregated", "" + "Plastic Segregated"); dataset.setValue(bcollected, "BioDegradable Segregated", "" + "BioDegradable Segregated"); JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo", "Category", "Value", dataset, PlotOrientation.VERTICAL.VERTICAL, true, true, false); ChartPanel chartPanel = new ChartPanel(chart, false); chartPanel.setPreferredSize(new Dimension(500, 270)); ChartFrame cFrame = new ChartFrame("Name", chart); cFrame.pack(); cFrame.setVisible(true);/*from www .j a v a2 s .c o m*/ }
From source file:whitebox.stats.Kriging.java
/** * It gets the semivariogram type and bins list and draw a graph for them * TheoryVariogram should be called first * * @param bins/*from ww w . ja va 2 s . c o m*/ * @param variogram */ public void DrawSemivariogram(bin[][] bins, Variogram variogram) { XYSeriesCollection sampleCollct = new XYSeriesCollection(); XYSeries series = new XYSeries("Sample Variogram"); // for (Iterator<bin> i = bins.iterator(); i.hasNext(); ) // { // series.add(bins.get(j).Distance,bins.get(j).Value); // i.next(); // j++; // } XYLineAndShapeRenderer xylineshapRend = new XYLineAndShapeRenderer(false, true); CombinedRangeXYPlot combinedrangexyplot = new CombinedRangeXYPlot(); for (int i = 0; i < bins[0].length; i++) { for (int k = 0; k < bins.length; k++) { if (!Double.isNaN(bins[k][i].Value)) { series.add(bins[k][i].Distance, bins[k][i].Value); } } sampleCollct.addSeries(series); double[][] res = CalcTheoreticalSVValues(variogram, series.getMaxX()); XYSeries seriesTSV = new XYSeries("Theoretical Variogram"); for (int l = 0; l < res.length; l++) { seriesTSV.add(res[l][0], res[l][1]); } XYSeriesCollection theorCollct = new XYSeriesCollection(); theorCollct.addSeries(seriesTSV); XYDataset xydataset = sampleCollct; XYPlot xyplot1 = new XYPlot(xydataset, new NumberAxis(), null, xylineshapRend); xyplot1.setDataset(1, theorCollct); XYLineAndShapeRenderer lineshapRend = new XYLineAndShapeRenderer(true, false); xyplot1.setRenderer(1, lineshapRend); xyplot1.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); combinedrangexyplot.add(xyplot1); } DecimalFormat df = new DecimalFormat("###,##0.000"); String title = "Semivariogram (RMSE = " + df.format(Math.sqrt(variogram.mse)) + ")"; JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, combinedrangexyplot, true); // JFreeChart chart = ChartFactory.createScatterPlot( // "Semivariogram", // chart title // "Distance", // x axis label // "Moment of Inertia", // y axis label // result, // data // PlotOrientation.VERTICAL, // true, // include legend // true, // tooltips // false // urls // ); // create and display a frame... ChartFrame frame = new ChartFrame("Semivariogram", chart); frame.pack(); frame.setVisible(true); }
From source file:whitebox.stats.Kriging.java
/** * Draw Semivariogram surface map and also draw the search are if * Anisotropic// w w w. j ava 2 s . co m * * @param Radius * @param AnIsotropic */ public void DrawSemivariogramSurface(double Radius, boolean AnIsotropic) { double[][] data = new double[3][BinSurface.length * BinSurface[0].length]; int n = 0; double max = Double.MIN_VALUE; for (int i = 0; i < BinSurface.length; i++) { for (int j = 0; j < BinSurface[i].length; j++) { data[0][n] = BinSurface[i][j].GridHorDistance; data[1][n] = BinSurface[i][j].GridVerDistance; if ((Math.pow(data[0][n], 2) + Math.pow(data[1][n], 2)) <= Radius * Radius && !Double.isNaN(BinSurface[i][j].Value)) { data[2][n] = BinSurface[i][j].Value; if (max < data[2][n]) { max = data[2][n]; } } else { data[2][n] = -1; } n++; } } DefaultXYZDataset dataset = new DefaultXYZDataset(); dataset.addSeries("Value", data); NumberAxis xAxis = new NumberAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setLowerMargin(0.0); yAxis.setUpperMargin(0.0); XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setBlockWidth(LagSize); renderer.setBlockHeight(LagSize); renderer.setBlockAnchor(RectangleAnchor.CENTER); LookupPaintScale paintScale = new LookupPaintScale(0, max, Color.white); double colorRange = max / 6; //double colorRange = 23013; paintScale.add(0.0, Color.blue); paintScale.add(1 * colorRange, Color.green); paintScale.add(2 * colorRange, Color.cyan); paintScale.add(3 * colorRange, Color.yellow); paintScale.add(4 * colorRange, Color.ORANGE); paintScale.add(5 * colorRange, Color.red); renderer.setPaintScale(paintScale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.white); if (AnIsotropic) { CombinedRangeXYPlot combinedrangexyplot = new CombinedRangeXYPlot(); XYSeries seriesT1 = new XYSeries("1"); XYSeriesCollection AngleCollct = new XYSeriesCollection(); double bw = BandWidth; double r = bw / Math.sin(Tolerance); if (r > Radius) { bw = Radius * Math.sin(Tolerance); r = Radius; } seriesT1.add(r * Math.cos(Angle + Tolerance), r * Math.sin(Angle + Tolerance)); if ((double) Math.round(Math.sin(Angle) * 10000) / 10000 != 0) { if ((double) Math.round(Math.cos(Angle) * 10000) / 10000 != 0) { double a = (1 + Math.pow(Math.tan(Angle), 2)); double b = 2 * bw / Math.sin(Angle) * Math.pow(Math.tan(Angle), 2); double c = Math.pow(Math.tan(Angle), 2) * Math.pow(bw / Math.sin(Angle), 2) - Math.pow(Radius, 2); double x1 = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y1 = Math.tan(Angle) * (x1 + bw / Math.sin(Angle)); double x2 = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y2 = Math.tan(Angle) * (x2 + bw / Math.sin(Angle)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT1.add(x1, y1); } else { seriesT1.add(x2, y2); } } else { double x1 = -bw * Math.sin(Angle); double y1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double y2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT1.add(x1, y1); } else { seriesT1.add(x1, y2); } } } else { double y1 = bw * Math.cos(Angle); double x1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double x2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); if (d1 < d2) { seriesT1.add(x1, y1); } else { seriesT1.add(x2, y1); } } AngleCollct.addSeries(seriesT1); XYSeries seriesT2 = new XYSeries("2"); seriesT2.add(r * Math.cos(Angle + Tolerance), r * Math.sin(Angle + Tolerance)); seriesT2.add(0.0, 0.0); AngleCollct.addSeries(seriesT2); XYSeries seriesT3 = new XYSeries("3"); seriesT3.add(Radius * Math.cos(Angle), Radius * Math.sin(Angle)); seriesT3.add(0, 0); AngleCollct.addSeries(seriesT3); XYSeries seriesT4 = new XYSeries("4"); seriesT4.add(r * Math.cos(Angle - Tolerance), r * Math.sin(Angle - Tolerance)); seriesT4.add(0, 0); AngleCollct.addSeries(seriesT4); XYSeries seriesT5 = new XYSeries("5"); seriesT5.add(r * Math.cos(Angle - Tolerance), r * Math.sin(Angle - Tolerance)); if ((double) Math.round(Math.sin(Angle) * 10000) / 10000 != 0) { if ((double) Math.round(Math.cos(Angle) * 10000) / 10000 != 0) { double a = (1 + Math.pow(Math.tan(Angle), 2)); double b = -2 * bw / Math.sin(Angle) * Math.pow(Math.tan(Angle), 2); double c = Math.pow(Math.tan(Angle), 2) * Math.pow(bw / Math.sin(Angle), 2) - Math.pow(Radius, 2); double x1 = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y1 = Math.tan(Angle) * (x1 - bw / Math.sin(Angle)); double x2 = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y2 = Math.tan(Angle) * (x2 - bw / Math.sin(Angle)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT5.add(x1, y1); } else { seriesT5.add(x2, y2); } } else { double x1 = bw * Math.sin(Angle); double y1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double y2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT5.add(x1, y1); } else { seriesT5.add(x1, y2); } } } else { double y1 = -bw * Math.cos(Angle); double x1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double x2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); if (d1 < d2) { seriesT5.add(x1, y1); } else { seriesT5.add(x2, y1); } } AngleCollct.addSeries(seriesT5); plot.setDataset(1, AngleCollct); XYLineAndShapeRenderer lineshapRend = new XYLineAndShapeRenderer(true, false); for (int i = 0; i < AngleCollct.getSeriesCount(); i++) { //plot.getRenderer().setSeriesPaint(i , Color.BLUE); lineshapRend.setSeriesPaint(i, Color.BLACK); } plot.setRenderer(1, lineshapRend); combinedrangexyplot.add(plot); } plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); JFreeChart chart = new JFreeChart("Semivariogram Surface", plot); chart.removeLegend(); chart.setBackgroundPaint(Color.white); // create and display a frame... ChartFrame frame = new ChartFrame("", chart); frame.pack(); //frame.setSize(100, 50); frame.setVisible(true); }