Example usage for org.jfree.chart ChartFrame pack

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

Introduction

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

Prototype

@SuppressWarnings("deprecation")
public void pack() 

Source Link

Document

Causes this Window to be sized to fit the preferred size and layouts of its subcomponents.

Usage

From source file:jfreechart.ViewGirlsBoysAvgChart.java

public static void viweGirlsAvgChart(List<String> testId, ArrayList<Double> totAvg, ArrayList<Double> girlsAvg,
        ArrayList<Double> boysAvg) throws SQLException, ClassNotFoundException {
    try {/* w  ww .j a  va2 s.  com*/
        UIManager.setLookAndFeel(new McWinLookAndFeel());
    } catch (UnsupportedLookAndFeelException ex) {
        Logger.getLogger(ViewEachStudentChart.class.getName()).log(Level.SEVERE, null, ex);
    }
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();

    for (Double marks : totAvg) {
        //Double mark = tstId;
        //String tetId = tstId.split(",")[3];
        objDataset.addValue(marks, "Line1", marks);

    }
    for (Double marks : girlsAvg) {
        //Double mark = tstId;
        //String tetId = tstId.split(",")[3];
        objDataset.addValue(marks, "Line2", marks);

    }
    //        for (Double testMark : bAvgList) {
    //            Double mark = testMark;
    //            //String tstId = testId.split(",")[3];
    //            objDataset.setValue(mark, "", mark);
    //            
    //            
    //        }
    JFreeChart objChart = ChartFactory.createLineChart("Marks Chart", //Chart title
            "Test", //Domain axis label
            "Marks", //Range axis label
            objDataset, //Chart Data 
            PlotOrientation.VERTICAL, // orientation
            true, // include legend?
            true, // include tooltips?
            false // include URLs?
    );

    ChartFrame frame = new ChartFrame("Dakma Higher Education Center", objChart);
    frame.setLocationRelativeTo(frame);
    frame.pack();
    frame.setVisible(true);
}

From source file:com.imaging100x.tracker.TrackerUtils.java

/**
* Create a frame with a plot of the data given in XYSeries
*///from  w  w w .j a v a  2  s .com
public static void plotData(String title, final XYSeries data, String xTitle, String yTitle, int xLocation,
        int yLocation) {
    // JFreeChart code
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(data);
    JFreeChart chart = ChartFactory.createScatterPlot(title, // Title
            xTitle, // x-axis Label
            yTitle, // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            false, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );
    final XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setSeriesPaint(0, Color.black);
    renderer.setSeriesFillPaint(0, Color.white);
    renderer.setSeriesLinesVisible(0, true);
    Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
    renderer.setSeriesShape(0, circle, false);
    renderer.setUseFillPaint(true);

    ChartFrame graphFrame = new ChartFrame(title, chart);
    graphFrame.getChartPanel().setMouseWheelEnabled(true);
    graphFrame.setPreferredSize(new Dimension(SIZE, SIZE));
    graphFrame.setResizable(true);
    graphFrame.pack();
    graphFrame.setLocation(xLocation, yLocation);
    graphFrame.setVisible(true);

    dataset.addChangeListener(new DatasetChangeListener() {

        public void datasetChanged(DatasetChangeEvent dce) {
            double xRange = data.getMaxX() - data.getMinX();
            double yRange = data.getMaxY() - data.getMinY();
            double xAvg = (data.getMaxX() + data.getMinX()) / 2;
            double yAvg = (data.getMaxY() + data.getMinY()) / 2;
            double range = xRange;
            if (yRange > range) {
                range = yRange;
            }
            double offset = 0.55 * range;
            plot.getDomainAxis().setRange(xAvg - offset, xAvg + offset);
            plot.getRangeAxis().setRange(yAvg - offset, yAvg + offset);
        }

    });

}

From source file:dumbara.view.Chart1.java

public static void loanInfo() {
    DefaultPieDataset objDataset = new DefaultPieDataset();
    try {//w w w.  jav a  2s. c  om
        Loan[] loan = LoanController.viewLoan();
        for (Loan loan1 : loan) {
            objDataset.setValue(loan1.getLoanID(), Double.parseDouble(loan1.getLongAmount()));
        }
    } catch (ClassNotFoundException | SQLException ex) {
        Logger.getLogger(Chart1.class.getName()).log(Level.SEVERE, null, ex);
    }

    JFreeChart objChart = ChartFactory.createPieChart("Variation of Loan Amounts", objDataset, true, true,
            false);
    ChartFrame frame = new ChartFrame("Data Analysis Wizard - v2.1.4", objChart);
    frame.pack();
    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
}

From source file:dumbara.view.Chart1.java

public static void byEmployee() {
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();
    try {// w ww .ja va2 s.co  m
        dumbara.model.Chart1[] chart1 = LoanController.getLoanAmounts();
        for (dumbara.model.Chart1 chart11 : chart1) {
            objDataset.setValue(chart11.getLoanamount(), "Loan amounts", chart11.getEmpID());
        }
    } catch (ClassNotFoundException | SQLException ex) {
        Logger.getLogger(Chart1.class.getName()).log(Level.SEVERE, null, ex);
    }
    //
    JFreeChart objChart = ChartFactory.createBarChart("Total Loan Amounts of Employees", "Employee ID",
            "Loan Amount (Rs.)", objDataset, PlotOrientation.VERTICAL, true, true, false);
    ChartFrame frame = new ChartFrame("Data Analysis Wizard - v2.1.4", objChart);
    frame.pack();
    frame.setSize(1000, 600);
    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
}

From source file:dumbara.view.Chart1.java

public static void getIncomebyDate() {
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();
    try {/*from  w w  w . j a v a2s . c o m*/
        Chart4[] chart4s = SalesController.getIncomeByDate();
        for (Chart4 chart4 : chart4s) {
            objDataset.setValue(chart4.getSumIncme(), "Days Income", chart4.getSalesDate());
        }
    } catch (ClassNotFoundException | SQLException ex) {
        Logger.getLogger(Chart1.class.getName()).log(Level.SEVERE, null, ex);
    }
    //
    JFreeChart objChart = ChartFactory.createBarChart("Total Sales Comparisson by Date", "Sales Date",
            "Sales Income", objDataset, PlotOrientation.VERTICAL, true, true, false);
    ChartFrame frame = new ChartFrame("Data Analysis Wizard - v2.1.4", objChart);
    frame.pack();
    frame.setSize(1100, 600);
    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
}

From source file:dumbara.view.Chart1.java

public static void paymentHistory() {
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();
    try {// ww w . j  a va2s  .  co  m
        LoanSettle[] loanSettles = LoanSettleController.viewLoanSettle();
        for (LoanSettle loanSettle : loanSettles) {
            objDataset.setValue(Double.parseDouble(loanSettle.getPayment()), "Loan Payments",
                    loanSettle.getLoanSettleID());
        }
    } catch (ClassNotFoundException | SQLException ex) {
        Logger.getLogger(Chart1.class.getName()).log(Level.SEVERE, null, ex);
    }
    //
    JFreeChart objChart = ChartFactory.createBarChart("Sales Comparisson", "Sales ID", "Sales Income",
            objDataset, PlotOrientation.VERTICAL, true, true, false);
    ChartFrame frame = new ChartFrame("Data Analysis Wizard - v2.1.4", objChart);
    frame.pack();
    frame.setSize(1000, 600);
    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
}

From source file:dumbara.view.Chart1.java

public static void paymentHistorybyEmp(String empID) {
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();
    try {/*from   w ww  .j  av  a  2  s.c  o  m*/
        LoanSettle[] loanSettles = LoanSettleController.viewLoanSettlebyEmp(empID);
        for (LoanSettle loanSettle : loanSettles) {
            objDataset.setValue(Double.parseDouble(loanSettle.getPayment()), "Loan Payments",
                    loanSettle.getLoanSettleID());
        }
    } catch (ClassNotFoundException | SQLException ex) {
        Logger.getLogger(Chart1.class.getName()).log(Level.SEVERE, null, ex);
    }
    //
    JFreeChart objChart = ChartFactory.createBarChart("Loan Settlements of Employee No " + empID,
            "Loan Settle ID", "Amount (Rs.)", objDataset, PlotOrientation.VERTICAL, true, true, false);
    ChartFrame frame = new ChartFrame("Data Analysis Wizard - v2.1.4", objChart);
    frame.pack();
    frame.setSize(1000, 600);
    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
}

From source file:dumbara.view.Chart1.java

public static void byAgent() {
    DefaultPieDataset objDataset = new DefaultPieDataset();
    try {/*from   w  w w . j  a  v  a2s  .c o  m*/
        Chart[] charts = SalesController.getAgencyAmounts();
        for (Chart chart : charts) {
            objDataset.setValue(chart.getAgencyID(), chart.getIncomeSum());
        }
    } catch (ClassNotFoundException | SQLException ex) {
        Logger.getLogger(Chart1.class.getName()).log(Level.SEVERE, null, ex);
    }
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.MONTH, -1);
    Date result = cal.getTime();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("E yyyy.MM.dd");
    String format = simpleDateFormat.format(result);
    Date date = new Date();
    String format1 = simpleDateFormat.format(date);

    JFreeChart objChart = ChartFactory.createPieChart(
            "Sales Range of Agencies from " + format + " to " + format1, objDataset, true, true, false);
    ChartFrame frame = new ChartFrame("Data Analysis Wizard - v2.1.4", objChart);
    frame.pack();
    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
}

From source file:dumbara.view.Chart1.java

public static void getBottleIncome() {
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();
    try {// ww w  . j a  v a2s . c  o  m
        Chart3[] chart3s = SalesController.getBottleIncome();
        for (Chart3 chart3 : chart3s) {
            objDataset.setValue(chart3.getIncome(), "Bottle Income", chart3.getBottleID());
        }
    } catch (ClassNotFoundException | SQLException ex) {
        Logger.getLogger(Chart1.class.getName()).log(Level.SEVERE, null, ex);
    }
    //
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.MONTH, -1);
    Date result = cal.getTime();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("E yyyy.MM.dd");
    String format = simpleDateFormat.format(result);
    Date date = new Date();
    String format1 = simpleDateFormat.format(date);
    JFreeChart objChart = ChartFactory.createBarChart(
            "Sales Comparisson by Bottle ID from " + format + " to " + format1, "Bottle ID", "Sales Income",
            objDataset, PlotOrientation.VERTICAL, true, true, false);
    ChartFrame frame = new ChartFrame("Data Analysis Wizard - v2.1.4", objChart);
    frame.pack();
    frame.setSize(1000, 600);
    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
}

From source file:dumbara.view.Chart1.java

public static void byIncome() {
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();
    try {// w ww  .  j a v a  2 s . c  o  m
        Sale[] sale = SalesController.viewAllSales();
        for (Sale sale1 : sale) {
            objDataset.setValue(sale1.getIncome(), "Sales Progress", sale1.getSalesID());
        }
    } catch (ClassNotFoundException | SQLException ex) {
        Logger.getLogger(Chart1.class.getName()).log(Level.SEVERE, null, ex);
    }
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.MONTH, -1);
    Date result = cal.getTime();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("E yyyy.MM.dd");
    String format = simpleDateFormat.format(result);
    Date date = new Date();
    String format1 = simpleDateFormat.format(date);

    JFreeChart objChart = ChartFactory.createBarChart(
            "Sales Comparisson by Sales ID from " + format + " to " + format1, "Sales ID", "Sales Income",
            objDataset, PlotOrientation.VERTICAL, true, true, false

    );
    ChartFrame frame = new ChartFrame("Data Analysis Wizard - v2.1.4", objChart);
    frame.pack();
    frame.setSize(1300, 600);
    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
}