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:jsdp.app.lotsizing.sS_jsdp.java

public static void plotCostFunction(int targetPeriod, double fixedOrderingCost, double proportionalOrderingCost,
        double holdingCost, double penaltyCost, Distribution[] distributions, double minDemand,
        double maxDemand, boolean printCostFunctionValues, boolean latexOutput,
        sS_StateSpaceSampleIterator.SamplingScheme samplingScheme, int maxSampleSize) {

    sS_BackwardRecursion recursion = new sS_BackwardRecursion(distributions, minDemand, maxDemand,
            fixedOrderingCost, proportionalOrderingCost, holdingCost, penaltyCost, samplingScheme,
            maxSampleSize);/*from  w w w  . j av  a2 s .c  om*/
    recursion.runBackwardRecursion(targetPeriod);
    XYSeries series = new XYSeries("(s,S) policy");
    for (double i = sS_State.getMinInventory(); i <= sS_State.getMaxInventory(); i += sS_State.getStepSize()) {
        sS_StateDescriptor stateDescriptor = new sS_StateDescriptor(targetPeriod, sS_State.inventoryToState(i));
        series.add(i, recursion.getExpectedCost(stateDescriptor));
        if (printCostFunctionValues)
            System.out.println(i + "\t" + recursion.getExpectedCost(stateDescriptor));
    }
    XYDataset xyDataset = new XYSeriesCollection(series);
    JFreeChart chart = ChartFactory.createXYLineChart(
            "(s,S) policy - period " + targetPeriod + " expected total cost", "Opening inventory level",
            "Expected total cost", xyDataset, PlotOrientation.VERTICAL, false, true, false);
    ChartFrame frame = new ChartFrame("(s,S) policy", chart);
    frame.setVisible(true);
    frame.setSize(500, 400);

    if (latexOutput) {
        try {
            XYLineChart lc = new XYLineChart("(s,S) policy", "Opening inventory level", "Expected total cost",
                    new XYSeriesCollection(series));
            File latexFolder = new File("./latex");
            if (!latexFolder.exists()) {
                latexFolder.mkdir();
            }
            Writer file = new FileWriter("./latex/graph.tex");
            file.write(lc.toLatex(8, 5));
            file.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

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

/**
* Create a frame with a plot of the data given in XYSeries
*///from  w w  w . ja va  2  s. c  om
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 {//from   w ww.j av a 2 s  .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 byAgent() {
    DefaultPieDataset objDataset = new DefaultPieDataset();
    try {/*ww  w . j  a v  a  2s .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 byEmployee() {
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();
    try {/* ww  w  .j  av a 2  s  .  c o  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  . jav  a 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 {//w w  w.  ja v a  2s.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 w w .ja v 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 getBottleIncome() {
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();
    try {/*  www .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 {//from w  w w. j a v a 2 s .c om
        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);
}