Example usage for org.jfree.chart ChartFrame setVisible

List of usage examples for org.jfree.chart ChartFrame setVisible

Introduction

In this page you can find the example usage for org.jfree.chart ChartFrame setVisible.

Prototype

public void setVisible(boolean b) 

Source Link

Document

Shows or hides this Window depending on the value of parameter b .

Usage

From source file:gskproject.Analyze.java

private void btnPersonGraphActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPersonGraphActionPerformed
    //System.out.println();
    if (tblPersonVise.getSelectedRow() != -1) {
        String username = tablePersonWise.get(tblPersonVise.getSelectedRow()).get(0).toString();
        int userID = dbOps.getUserID(username);
        java.sql.Date from;//from   w w  w.  j a v a2s. c  o  m
        java.sql.Date to;
        if (dtPFrom.getDate() == null && dtPTo.getDate() == null) {
            from = null;
            to = null;

        } else if (dtPFrom.getDate() == null) {
            from = null;
            to = new java.sql.Date(dtPTo.getDate().getTime());

        } else if (dtPTo.getDate() == null) {
            from = new java.sql.Date(dtPFrom.getDate().getTime());
            to = null;

        } else {
            from = new java.sql.Date(dtPFrom.getDate().getTime());
            to = new java.sql.Date(dtPTo.getDate().getTime());

        }
        Vector<Vector> eachPersonDates = new Vector<Vector>();

        eachPersonDates = dbOps.getEachPersonObservation(from, to, userID);

        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        JFreeChart chart = null;
        Calendar start = Calendar.getInstance();
        Calendar end = Calendar.getInstance();
        for (Vector<Object> row : eachPersonDates) {
            start.setTime((Date) row.get(1));
            end.setTime((Date) row.get(2));
            dataset.addValue(end.get(Calendar.DAY_OF_YEAR) - start.get(Calendar.DAY_OF_YEAR), "First Aid",
                    row.get(0).toString());
        }
        chart = ChartFactory.createLineChart("All Departments VS All Accident Types", "Observation ID", "Days",
                dataset, PlotOrientation.VERTICAL, false, true, false);
        CategoryPlot p = chart.getCategoryPlot();
        p.setRangeGridlinePaint(Color.BLACK);
        ChartFrame frame = new ChartFrame(username + " Chart", chart);
        frame.setSize(700, 500);
        frame.setVisible(true);
    } else {
        JOptionPane.showMessageDialog(this, "Please select a person using table!");
    }
}

From source file:gskproject.Analyze.java

private void ddGraphPersonWiseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ddGraphPersonWiseActionPerformed
    Object obj = evt.getSource();
    if (obj == ddGraphPersonWise) {

        if (ddGraphPersonWise.getSelectedItem().toString().equals("Spread of all Cases among Persons")) {
            DefaultPieDataset pieDataSet = new DefaultPieDataset();

            for (Vector row : tablePersonWise) {
                pieDataSet.setValue(row.get(0).toString(), Double.parseDouble(row.get(1).toString()));
            }/*from  w  ww.  j av a2s. c  o  m*/
            JFreeChart chart = ChartFactory.createPieChart("Spread of all Cases among Persons", pieDataSet,
                    true, true, true);

            PiePlot p = (PiePlot) chart.getPlot();
            //p.setForegroundAlpha(TOP_ALIGNMENT);
            ChartFrame frame = new ChartFrame("Pie Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
            //System.out.println("aaa");
        } else if (ddGraphPersonWise.getSelectedItem().toString()
                .equals("Percentage of Cases(As Resposible Parties)")) {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {//select the personwise for analysing
                barDataSet.setValue((Double.parseDouble(row.get(2).toString()) / (int) row.get(1)) * 100,
                        "Percentage of Cases(As Resposible Parties)", row.get(0).toString());
            }

            JFreeChart chart = ChartFactory.createBarChart("Percentage of Cases(As Resposible Parties)",
                    "Person", "Percentage of Cases(As Resposible Parties)", barDataSet,
                    PlotOrientation.VERTICAL, false, true, false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);

        } else if (ddGraphPersonWise.getSelectedItem().toString()
                .equals("Percentage of opened cases out of No: of Cases(As Responsible Parties)")) {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {
                barDataSet.setValue((Double.parseDouble(row.get(3).toString()) / (int) row.get(2)) * 100,
                        "Percentage of opened cases out of No: of Cases(As Responsible Parties)",
                        row.get(0).toString());
            }
            JFreeChart chart = ChartFactory.createBarChart(
                    "Percentage of opened cases out of No: of Cases(As Responsible Parties)", "Person",
                    "Percentage of opened cases out of No: of Cases(As Responsible Parties)", barDataSet,
                    PlotOrientation.VERTICAL, false, true, false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
        } else if (ddGraphPersonWise.getSelectedItem().toString()
                .equals("Percentage of closed cases out of No: of Cases(As Responsible Parties)")) {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {
                barDataSet.setValue(
                        (Double.parseDouble(row.get(2).toString())
                                - (Double.parseDouble(row.get(3).toString())) / (int) row.get(2)) * 100,
                        "Percentage of closed cases out of No: of Cases(As Responsible Parties)",
                        row.get(0).toString());
            }
            JFreeChart chart = ChartFactory.createBarChart(
                    "Percentage of closed cases out of No: of Cases(As Responsible Parties)", "Person",
                    "Percentage of closed cases out of No: of Cases(As Responsible Parties)", barDataSet,
                    PlotOrientation.VERTICAL, false, true, false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
        } else if (ddGraphPersonWise.getSelectedItem().toString().equals("Percentage of Cases(As Observer)")) {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {
                barDataSet.setValue((Double.parseDouble(row.get(5).toString()) / (int) row.get(1)) * 100,
                        "Percentage of Cases(As Observer)", row.get(0).toString());
            }
            JFreeChart chart = ChartFactory.createBarChart("Percentage of Cases(As Observer)", "Person",
                    "Percentage of Cases(As Observer)", barDataSet, PlotOrientation.VERTICAL, false, true,
                    false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
        } else if (ddGraphPersonWise.getSelectedItem().toString()
                .equals("Percentage of opened cases out of No: of Cases(As Observer)")) {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {
                barDataSet.setValue((Double.parseDouble(row.get(6).toString()) / (int) row.get(5)) * 100,
                        "Percentage of Closed cases", row.get(0).toString());
            }
            JFreeChart chart = ChartFactory.createBarChart(
                    "Percentage of opened cases out of No: of Cases(As Observer)", "Person",
                    "Percentage of opened cases out of No: of Cases(As Observer)", barDataSet,
                    PlotOrientation.VERTICAL, false, true, false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
        } else {
            DefaultCategoryDataset barDataSet = new DefaultCategoryDataset();
            for (Vector row : tablePersonWise) {
                barDataSet.setValue(
                        ((Double.parseDouble(row.get(5).toString())
                                - (Double.parseDouble(row.get(6).toString()))) / (int) row.get(5)) * 100,
                        "Percentage of closed cases out of No: of Cases(As Observer)", row.get(0).toString());
            }
            JFreeChart chart = ChartFactory.createBarChart(
                    "Percentage of closed cases out of No: of Cases(As Observer)", "Person",
                    "Percentage of closed cases out of No: of Cases(As Observer)", barDataSet,
                    PlotOrientation.VERTICAL, false, true, false);

            CategoryPlot p = chart.getCategoryPlot();
            p.setRangeGridlinePaint(Color.BLACK);
            ChartFrame frame = new ChartFrame("Bar Chart", chart);
            frame.setVisible(true);
            frame.setSize(700, 500);
        }
    }
}

From source file:recyclingsimulationUI.MainFrame.java

private void seeMaxCapacityChartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_seeMaxCapacityChartActionPerformed
    // TODO add your handling code here:
    DbConnect conn = new DbConnect();
    ArrayList<String> capacity_array = new ArrayList<String>();
    ArrayList<String> name_array = new ArrayList<String>();
    try {/* www. j a  va2  s  .  c o m*/
        Object[] obj = new Object[2];
        obj = conn.getCapacityOfRcms();
        name_array = (ArrayList<String>) obj[0];
        capacity_array = (ArrayList<String>) obj[1];
    } catch (SQLException ex) {
        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
    }

    for (int i = 0; i < name_array.size(); i++) {
        System.out.print(name_array.get(i));
    }
    DefaultPieDataset dp = new DefaultPieDataset();
    for (int i = 0; i < name_array.size(); i++) {
        dp.setValue(name_array.get(i), Integer.parseInt(capacity_array.get(i)));
    }

    JFreeChart pieChart = ChartFactory.createPieChart("Pie chart representing capacity of each RCM", dp, true,
            true, false);
    PiePlot p = (PiePlot) pieChart.getPlot();

    ChartFrame cf = new ChartFrame("Pie Chart", pieChart);
    cf.setVisible(true);
    cf.setSize(750, 500);
}

From source file:recyclingsimulationUI.MainFrame.java

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
    // TODO add your handling code here:
    DbConnect conn = new DbConnect();
    ArrayList<String> name_array = new ArrayList<String>();
    ArrayList<String> count_array = new ArrayList<String>();
    try {/*from   w ww.  j a v  a  2  s  .  c  om*/
        String totalCount = conn.getTotalCountOfTransacations();
        Object[] name_and_count_array = new Object[10];
        name_and_count_array = conn.getTransactionDetailsCount();
        name_array = (ArrayList<String>) name_and_count_array[0];
        count_array = (ArrayList<String>) name_and_count_array[1];
    } catch (SQLException ex) {
        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
    }

    for (int i = 0; i < name_array.size(); i++) {
        System.out.print(name_array.get(i));
    }
    DefaultPieDataset dp = new DefaultPieDataset();
    for (int i = 0; i < name_array.size(); i++) {
        dp.setValue(name_array.get(i), Integer.parseInt(count_array.get(i)));
    }

    JFreeChart pieChart = ChartFactory.createPieChart("Pie chart representing usage of each RCM", dp, true,
            true, false);
    PiePlot p = (PiePlot) pieChart.getPlot();

    ChartFrame cf = new ChartFrame("Pie Chart", pieChart);
    cf.setVisible(true);
    cf.setSize(750, 500);
}

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();//from  w ww .  j a  v  a2s. co m
    cFrame.setVisible(true);
}

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();/*  ww w.j a v  a  2 s .c  o m*/
    cFrame.setVisible(true);
}

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 w  ww .j  a  va  2 s.co  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//ww  w  .  j a  v  a2 s.  c o  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);
}

From source file:FirstStatMain.java

private void stpiechartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stpiechartActionPerformed
    String sql = "select English,Science,Social,Math from Marks_info where Studentid=?";
    try {//from  ww w. j av  a 2 s  . co  m
        pst = connection.prepareStatement(sql);
        pst.setString(1, txtStudentId.getText());
        rst = pst.executeQuery();
        DefaultPieDataset dataset = new DefaultPieDataset();
        while (rst.next()) {
            dataset.setValue("English", Integer.parseInt(rst.getString("English")));
            dataset.setValue("Science", Integer.parseInt(rst.getString("Science")));
            dataset.setValue("Social", Integer.parseInt(rst.getString("Social")));
            dataset.setValue("Math", Integer.parseInt(rst.getString("Math")));

        }
        JFreeChart pchart = ChartFactory.createPieChart("Pie Chart", dataset, true, true, true);
        PiePlot P = (PiePlot) pchart.getPlot();
        ChartFrame cf = new ChartFrame("Pie Chart", pchart);
        cf.setSize(450, 450);
        cf.setVisible(true);

    } catch (SQLException ex) {
        JOptionPane.showMessageDialog(rootPane, ex);
    }
}

From source file:FirstStatMain.java

private void allstpiechartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allstpiechartActionPerformed
    String sql = "select Studentid,Total from Marks_info";
    try {//from   w  w w .j  av a2  s  .  co  m
        pst = connection.prepareStatement(sql);
        //pst.setString(1, txtStudentId.getText());
        rst = pst.executeQuery();
        DefaultPieDataset dataset = new DefaultPieDataset();
        while (rst.next()) {
            dataset.setValue(rst.getString("Studentid"), Integer.parseInt(rst.getString("Total")));
            //dataset.setValue(rst.getString("Studentid"),Integer.parseInt(rst.getString("Science")));
            //dataset.setValue(rst.getString("Studentid"),Integer.parseInt(rst.getString("Social")));
            //dataset.setValue(rst.getString("Studentid"),Integer.parseInt(rst.getString("Math")));

        }
        JFreeChart pchart = ChartFactory.createPieChart("Pie Chart", dataset, true, true, true);
        PiePlot P = (PiePlot) pchart.getPlot();
        ChartFrame cf = new ChartFrame("Pie Chart", pchart);
        cf.setSize(450, 450);
        cf.setVisible(true);

    } catch (SQLException ex) {
        JOptionPane.showMessageDialog(rootPane, ex);
    }

}