Example usage for org.jfree.chart ChartFrame setLocationRelativeTo

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

Introduction

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

Prototype

public void setLocationRelativeTo(Component c) 

Source Link

Document

Sets the location of the window relative to the specified component according to the following scenarios.

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 {/*from   www.ja  va2 s  .c  o  m*/
        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:dumbara.view.Chart1.java

public static void ViewLineChart(String[] agencyID, String[] sslesDate, ArrayList<String[]> arrayList)
        throws SQLException, ClassNotFoundException {
    XYSeries series1 = new XYSeries("Agency 1");
    XYSeries series2 = new XYSeries("Agency 2");
    XYSeries series3 = new XYSeries("Agency 3");
    XYSeries series4 = new XYSeries("Agency 4");

    for (String[] strings : arrayList) {

        for (int i = 0; i < sslesDate.length; i++) {
            System.out.println(sslesDate[i].split("-")[1] + "");
            series1.add(Double.parseDouble(sslesDate[i].split("-")[1] + ""),
                    Double.parseDouble(arrayList.get(0)[i]));
        }/*from   w  w  w .j a  v  a 2s .  co m*/

        for (int i = 0; i < sslesDate.length; i++) {
            series2.add(Double.parseDouble(sslesDate[i].split("-")[1] + ""),
                    Double.parseDouble(arrayList.get(1)[i]));
        }

        for (int i = 0; i < sslesDate.length; i++) {
            series3.add(Double.parseDouble(sslesDate[i].split("-")[1] + ""),
                    Double.parseDouble(arrayList.get(2)[i]));
        }

        for (int i = 0; i < sslesDate.length; i++) {
            series4.add(Double.parseDouble(sslesDate[i].split("-")[1] + ""),
                    Double.parseDouble(arrayList.get(3)[i]));

        }

    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series1);
    dataset.addSeries(series2);
    dataset.addSeries(series3);
    dataset.addSeries(series4);
    XYDataset dataset1 = dataset;
    JFreeChart chart = ChartFactory.createXYLineChart("", "Test Id", "Average Marks", dataset1,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(1, true);
    renderer.setSeriesLinesVisible(2, true);
    renderer.setSeriesShapesVisible(2, true);
    renderer.setSeriesFillPaint(2, Color.MAGENTA);
    plot.setRenderer(renderer);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
    //(chartPanel);
    ChartFrame frame = new ChartFrame("Dumbara Water Management System", chart);
    frame.setLocationRelativeTo(null);
    frame.pack();
    frame.setVisible(true);

}

From source file:dumbara.view.Chart1.java

public static void loanInfo() {
    DefaultPieDataset objDataset = new DefaultPieDataset();
    try {/*w  w w. j  ava2 s . c  o m*/
        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 byAgent() {
    DefaultPieDataset objDataset = new DefaultPieDataset();
    try {/*  ww  w.j  a va 2 s  .c  om*/
        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 byEmployee() {
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();
    try {// w  w w. ja  v  a  2s  .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 {//  w ww. j  a va 2  s.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 {/*from w w w  .  java2 s . c om*/
        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  a v  a2s. co 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 getBottleIncome() {
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();
    try {//from  w w w.  j  a  v  a2 s . 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 {/*from  ww  w.  jav 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);
}