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:Gui.admin.NouveauStatistique.java

private void StatistiquesBouttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StatistiquesBouttonActionPerformed

    int size = tablemesEvaluation.getRowCount();

    List<Double> notes = new ArrayList<Double>();
    List<Integer> ids = new ArrayList<Integer>();
    List<String> noms = new ArrayList<String>();
    EvaluationDAO evaluationDAO = new EvaluationDAO();
    System.out.println("ouh ouh  " + size);
    //System.out.println(evaluationDAO.getMoyenneByAdherent(8));
    int idadh;/* w  ww  .j  a va  2s. c  om*/
    float ess;
    for (int i = 0; i < size; i++) {

        System.out.println(tablemesEvaluation.getValueAt(i, 4).toString());
        idadh = Integer.parseInt(tablemesEvaluation.getValueAt(i, 1).toString());
        String nom = (tablemesEvaluation.getValueAt(i, 2).toString());
        // notes.add((new Double (tablemesEvaluation.getValueAt(i,2).toString())));
        System.out.println(" id adherent " + idadh);
        // System.out.println("moyenne "+);
        ess = evaluationDAO.getMoyenneByAdherent(idadh);
        System.out.println(ess);
        // notes.add((new Double (evaluationDAO.getMoyenneByAdherent((int) tablemesEvaluation.getValueAt(i,1)))));
        notes.add((new Double(ess)));
        ids.add((int) tablemesEvaluation.getValueAt(i, 1));
        noms.add(nom);

    }

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int i = 0; i < size; i++) {

        dataset.setValue(new Double(notes.get(i)), "notes", new String(noms.get(i)));

    }

    //dataset.setValue(evaluationTable);

    JFreeChart chart = ChartFactory.createBarChart3D("Notes Adhrents", "Noms des adhrents", "Notes",
            dataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.black);
    ChartFrame frame = new ChartFrame(" les notes des adhrents", chart);
    frame.setVisible(true);
    frame.setSize(700, 800);
    ValueMarker marker = new ValueMarker(15);
    marker.setLabel(" seuil de l'valuation ");
    marker.setLabelAnchor(RectangleAnchor.CENTER);
    marker.setPaint(Color.YELLOW);
    p.addRangeMarker(marker);
    p.setRangeGridlinePaint(Color.RED);

    try {

    }

    catch (Exception e) {
    }

    /*
    String note =noteTxt.getText();
    String idAdherent=idAdherentEvaluText.getText();
            
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(new Double(note), "notes", new Double(idAdherent));
    //dataset.setValue(evaluationTable);
            
    JFreeChart chart = ChartFactory.createBarChart3D("Notes Adhrents", "Id Adhrents", "Notes", dataset, PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot p= chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.black);
    ChartFrame frame = new ChartFrame(" les notes des adhrents", chart);
    frame.setVisible(true);
    frame.setSize(450,350);
    */
    try {

        final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
        final File file1 = new File("statistiques.png");
        ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);

    }

    catch (Exception e) {
    }
}

From source file:info.financialecology.finance.utilities.datastruct.VersatileChart.java

public void drawSimpleHistogramExploded(VersatileTimeSeries... atsList) {
    ArrayList<JFreeChart> charts = new ArrayList<JFreeChart>();

    for (VersatileTimeSeries ats : atsList) {
        ArrayList<VersatileTimeSeries> atsArray = new ArrayList<VersatileTimeSeries>();
        atsArray.add(ats);// ww w.jav  a2 s .c om
        JFreeChart chart = drawSimpleHistogram((String) ats.getKey(), atsArray);
        charts.add(chart);
    }

    ChartFrame frame;

    for (JFreeChart chart : charts) {
        frame = new ChartFrame("UNKNOWN", chart);
        frame.pack();
        frame.setVisible(true);
    }
}

From source file:virgil.meanback.HistoryInfo.java

public void printChart(Stock stock, List<String[]> list, int days) throws Exception {
    //?//from   ww  w  . j  a v a2  s . c  om
    StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
    //
    standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20));
    //
    standardChartTheme.setRegularFont(new Font("", Font.BOLD, 12));
    //?
    standardChartTheme.setLargeFont(new Font("", Font.BOLD, 18));
    //?
    ChartFactory.setChartTheme(standardChartTheme);
    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
    for (int i = list.size() - 1; i >= 0; i--) {
        String[] s = (String[]) list.get(i);
        dataSet.addValue(Double.parseDouble(s[1]), days + "", s[0]);
        dataSet.addValue(Double.parseDouble(stock.getList().get(i).getClose()), "", s[0]);
        float sub = Float.parseFloat(s[2]);
        float error = Float.parseFloat(s[3]);
        if (sub > error * 2) {
            dataSet.addValue(Double.parseDouble(stock.getList().get(i).getClose()), "??", s[0]);
        }
    }

    //?????Legend
    //????
    //??URL
    JFreeChart chart = ChartFactory.createLineChart(
            stock.getName() + "(" + stock.getCode() + ") ", "", "", dataSet,
            PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot cp = chart.getCategoryPlot();
    cp.setBackgroundPaint(ChartColor.WHITE); // 
    CategoryAxis categoryAxis = cp.getDomainAxis();
    //  Lable 90 
    Font labelFont = new Font("SansSerif", Font.TRUETYPE_FONT, 10);
    categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    categoryAxis.setTickLabelFont(labelFont);//X?? 
    ValueAxis yAxis = cp.getRangeAxis();
    yAxis.setAutoRange(true);
    double[] d = getAxiasThresold(stock, list);
    yAxis.setLowerBound(d[0] - 0.15);
    yAxis.setUpperBound(d[1] + 0.15);
    LineAndShapeRenderer lasp = (LineAndShapeRenderer) cp.getRenderer();
    lasp.setBaseFillPaint(ChartColor.RED);
    lasp.setDrawOutlines(true);
    lasp.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D));
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) cp.getRenderer(1);//?
    DecimalFormat decimalformat1 = new DecimalFormat("##.##");//???
    renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", decimalformat1));
    //????
    renderer.setItemLabelsVisible(true);//
    renderer.setBaseItemLabelsVisible(true);//
    //?????
    renderer.setShapesFilled(Boolean.TRUE);//??
    renderer.setShapesVisible(true);//?
    ChartFrame chartFrame = new ChartFrame("??", chart, true);
    //chart?JavaChartFramejavaJframe????
    chartFrame.pack(); //??
    chartFrame.setVisible(true);//???
}

From source file:userinterface.InventoryRole.InventoryWorkAreaJPanel.java

private void chartButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chartButtonActionPerformed
    // TODO add your handling code here:
    int a = enterprise.getHash().get("A+");
    int b = enterprise.getHash().get("A-");
    int c = enterprise.getHash().get("B+");
    int d = enterprise.getHash().get("B-");
    int e = enterprise.getHash().get("AB+");
    int f = enterprise.getHash().get("AB-");
    int g = enterprise.getHash().get("O+");
    int h = enterprise.getHash().get("O-");

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(a, "Quantity", "A+");
    dataset.setValue(b, "Quantity", "A-");
    dataset.setValue(c, "Quantity", "B+");
    dataset.setValue(d, "Quantity", "B-");
    dataset.setValue(e, "Quantity", "AB+");
    dataset.setValue(f, "Quantity", "AB-");
    dataset.setValue(g, "Quantity", "O+");
    dataset.setValue(h, "Quantity", "O-");

    JFreeChart chart = ChartFactory.createBarChart("BloodAvailability", "Blood Group", "Quantity", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.black);
    ChartFrame frame = new ChartFrame("Availability Bar Chart", chart);
    frame.setVisible(true);
    frame.setSize(450, 500);//www . ja va2s . com

}

From source file:Forms.SalesChart.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    String sql = "SELECT * FROM soldtime WHERE cast(datetime as date)";
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    try {//from  w ww.j av  a  2  s . co m
        Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/nafis", "root",
                "");

        Statement s = (Statement) con.prepareStatement(sql);

        ResultSet rs = s.executeQuery(sql);

        Map<String, Integer> m = new TreeMap<String, Integer>();

        int quantity = 0;
        //float sp=0;
        //float bp=0;
        String qua = "", sprice = "", bprice = "", date = "";
        while (rs.next()) {

            qua = rs.getString(3);
            /*sprice = rs.getString(4);
            bprice = rs.getString(5);*/
            date = rs.getString(6);
            date = date.substring(0, 10);

            //quantity=quantity+Integer.parseInt(qua);

            /*sp = sp + Float.parseFloat(sprice);
            bp = bp + Float.parseFloat(bprice);*/

            Integer oldVal = m.get(date);

            if (oldVal == null) {
                m.put(date, Integer.parseInt(qua));
            } else {
                m.put(date, oldVal + Integer.parseInt(qua));
            }

        }

        for (HashMap.Entry ma : m.entrySet()) {
            //System.out.println(m.getKey()+" "+m.getValue());

            dataset.setValue(Float.parseFloat(ma.getValue() + ""), "Items Sold", ma.getKey() + "");
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    /*dataset.setValue(50, "Date","Amount1");
    dataset.setValue(25, "Date","Amount2");
    dataset.setValue(30, "Date","Amount3");
    dataset.setValue(45, "Date","Amount4");*/
    JFreeChart chart = ChartFactory.createBarChart3D("SOLD BARCHART", "DATE", "PROFIT", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setForegroundAlpha(0.5f);
    ChartFrame frame = new ChartFrame("Bar Chart", chart);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    frame.setSize(750, 600);
}

From source file:Forms.SalesChart.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    String sql = "SELECT * FROM soldtime WHERE cast(datetime as date)";
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    try {/* ww  w  .j  a v  a 2 s . c o  m*/
        Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/nafis", "root",
                "");

        Statement s = (Statement) con.prepareStatement(sql);

        ResultSet rs = s.executeQuery(sql);

        Map<String, Float> m = new TreeMap<String, Float>();

        //int quantity=0;
        //float sp=0;
        //float bp=0;
        String qua = "", sprice = "", bprice = "", date = "";
        while (rs.next()) {

            //qua = rs.getString(3);
            sprice = rs.getString(4);
            bprice = rs.getString(5);
            date = rs.getString(6);
            date = date.substring(0, 10);

            //quantity=quantity+Integer.parseInt(qua);

            /*sp = sp + Float.parseFloat(sprice);
            bp = bp + Float.parseFloat(bprice);*/

            Float oldVal = m.get(date);

            if (oldVal == null) {
                m.put(date, Float.parseFloat(sprice) - Float.parseFloat(bprice));
            } else {
                m.put(date, oldVal + Float.parseFloat(sprice) - Float.parseFloat(bprice));
            }

        }

        for (HashMap.Entry ma : m.entrySet()) {
            //System.out.println(m.getKey()+" "+m.getValue());

            dataset.setValue(Float.parseFloat(ma.getValue() + ""), "Profit", ma.getKey() + "");
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    /*dataset.setValue(50, "Date","Amount1");
    dataset.setValue(25, "Date","Amount2");
    dataset.setValue(30, "Date","Amount3");
    dataset.setValue(45, "Date","Amount4");*/
    JFreeChart chart = ChartFactory.createBarChart3D("PROFIT BARCHART", "DATE", "PROFIT", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setForegroundAlpha(0.5f);
    ChartFrame frame = new ChartFrame("Bar Chart", chart);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    frame.setSize(750, 600);

}

From source file:UserInterface.AdministrativeRole.ReportsJPanel.java

private void resultSatisfactionBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resultSatisfactionBtnActionPerformed
    // TODO add your handling code here:
    int notSatisfied = 0;
    int somewhatSatisfied = 0;
    int verySatisfied = 0;
    int notApplicable = 0;
    for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) {
        if (organization instanceof AdminOrganization) {
            for (FarmerFeedbackWorkRequest request : organization.getFeedbackWorkQueue()
                    .getFarmerFeedbackList()) {

                if (request.getResearchSolutionHelped().equalsIgnoreCase("Not Satisfied")) {
                    notSatisfied++;//from ww w  .  j  av a  2s .co m
                } else if (request.getResearchSolutionHelped().equalsIgnoreCase("Somewhat Satisfied")) {
                    somewhatSatisfied++;
                } else if (request.getResearchSolutionHelped().equalsIgnoreCase("Very Satisfied")) {
                    verySatisfied++;
                } else {
                    notApplicable++;
                }
            }

            break;
        }
    }

    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
    dataSet.setValue(notSatisfied, "", "Not Satisfied");
    dataSet.setValue(somewhatSatisfied, "", "Somewhat Satisfied");
    dataSet.setValue(verySatisfied, "", "Very Satisfied");
    dataSet.setValue(notApplicable, "", "Not Applicable");

    JFreeChart chart = ChartFactory.createBarChart("Research Result Satisfaction", "Satisfaction Level",
            "Number of Farmers", dataSet, PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setRangeGridlinePaint(Color.black);
    ChartFrame frame = new ChartFrame("Result Satisfaction", chart);
    frame.setVisible(true);
    frame.setSize(700, 500);
}

From source file:AirplaneSettings.java

public void planeGraph(List<Double> gp, List<Double> pp) {
    // Create XY series for the ground
    XYSeries ground = new XYSeries("Ground Height");
    for (int i = 0; i < gp.size(); i++)
        ground.add(i, gp.get(i));//from ww  w. ja  va  2 s .  c o  m

    // Create XY series for the plane
    XYSeries plane = new XYSeries("Plane Height");
    for (int i = 0; i < pp.size(); i++)
        plane.add(i, pp.get(i));

    // Add the series to the data set
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(ground);
    dataset.addSeries(plane);

    // Generate the graph
    JFreeChart memFunction = ChartFactory.createXYLineChart("Plane Flight", // Title
            "Time", // x-axis Label
            "Height", // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            true, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );

    ChartFrame frame = new ChartFrame("Plane Flight", memFunction);
    frame.pack();
    frame.setVisible(true);
}

From source file:UserInterface.AdministrativeRole.ReportsJPanel.java

private void appEasyReportBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_appEasyReportBtnActionPerformed
    // TODO add your handling code here:
    int countEasy = 0;
    int countSomewhat = 0;
    int countVery = 0;
    for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) {
        if (organization instanceof AdminOrganization) {
            for (FarmerFeedbackWorkRequest request : organization.getFeedbackWorkQueue()
                    .getFarmerFeedbackList()) {

                if (request.getSiteUserFriendly().equalsIgnoreCase("Easy To Use")) {
                    countEasy++;//from w w w. j a v  a  2s  .  co m
                } else if (request.getSiteUserFriendly().equalsIgnoreCase("Somewhat Difficult")) {
                    countSomewhat++;
                } else if (request.getSiteUserFriendly().equalsIgnoreCase("Very Difficult")) {
                    countVery++;
                }
            }

            break;
        }
    }
    float total = countEasy + countSomewhat + countVery;
    float pEasy = (countEasy / total) * 100;
    float pSomewhat = (countSomewhat / total) * 100;
    float pVery = (countVery / total) * 100;

    DefaultPieDataset pieDataSet = new DefaultPieDataset();
    pieDataSet.setValue("Easy To Use%: " + pEasy, pEasy);
    pieDataSet.setValue("Somewhat Difficult%: " + pSomewhat, pSomewhat);
    pieDataSet.setValue("Very Difficult%: " + pVery, pVery);
    JFreeChart chart = ChartFactory.createPieChart("Application Easiness Level", pieDataSet, true, true, true);
    PiePlot plot = (PiePlot) chart.getPlot();
    ChartFrame frame = new ChartFrame("Application Easiness Level", chart);
    frame.setVisible(true);
    frame.setSize(500, 500);
}

From source file:UserInterface.AdministrativeRole.ReportsJPanel.java

private void ReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReportActionPerformed
    // TODO add your handling code here:
    int countBad = 0;
    int countGood = 0;
    int countExcellent = 0;
    for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) {
        if (organization instanceof AdminOrganization) {
            for (FarmerFeedbackWorkRequest request : organization.getFeedbackWorkQueue()
                    .getFarmerFeedbackList()) {

                if (request.getOverallRating().equalsIgnoreCase("Bad")) {
                    countBad++;/*www  . java 2  s  .co m*/
                } else if (request.getOverallRating().equalsIgnoreCase("Good")) {
                    countGood++;
                } else if (request.getOverallRating().equalsIgnoreCase("Excellent")) {
                    countExcellent++;
                }
            }

            break;
        }
    }
    float total = countBad + countGood + countExcellent;
    float pGood = (countGood / total) * 100;
    float pBad = (countBad / total) * 100;
    float pExcellent = (countExcellent / total) * 100;

    DefaultPieDataset pieDataSet = new DefaultPieDataset();
    pieDataSet.setValue("Bad%: " + pBad, pGood);
    pieDataSet.setValue("Good%: " + pGood, pBad);
    pieDataSet.setValue("Excellent%: " + pExcellent, pExcellent);
    JFreeChart chart = ChartFactory.createPieChart("Overall Application Rating", pieDataSet, true, true, true);
    PiePlot plot = (PiePlot) chart.getPlot();
    ChartFrame frame = new ChartFrame("Overall Application Rating", chart);
    frame.setVisible(true);
    frame.setSize(500, 500);

}