Example usage for org.jfree.chart ChartFrame setSize

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

Introduction

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

Prototype

public void setSize(int width, int height) 

Source Link

Document

The width and height values are automatically enlarged if either is less than the minimum size as specified by previous call to setMinimumSize .

Usage

From source file:br.unesp.rc.desafio.utils.Utils.java

public static void createPie(DefaultPieDataset pieDataset) {

    JFreeChart chart = ChartFactory.createPieChart("Grafico Torta", pieDataset, true, true, true);
    PiePlot p = (PiePlot) chart.getPlot();
    ChartFrame frame = new ChartFrame("Grafico Torta", chart);

    frame.setVisible(true);/*from   w w w .  j a va 2  s.co m*/
    frame.setSize(450, 500);
    ManagerGUI.centralizar(frame);

}

From source file:br.unesp.rc.desafio.utils.Utils.java

public static void createLine(DefaultCategoryDataset dataset) {
    JFreeChart chart = ChartFactory.createLineChart("Grafico", " ", " ", dataset);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.black);
    ChartFrame frame = new ChartFrame("Grafico de BArras", chart);
    frame.setVisible(true);/*from w w w. jav  a  2  s.com*/
    frame.setSize(400, 350);
    ManagerGUI.centralizar(frame);

}

From source file:view.visualization.TXTVisualization.java

public static void drawChart(String a, String b, String txt) {
    String[] boje = null;//from w w w  . java 2 s .c om
    LinkedList<String> atributi = new LinkedList<String>();
    LinkedList<String> sviAtributi = new LinkedList<String>();
    String[] vrAtribut = null;
    XYSeries[] xy = null;
    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
    int brojac = 0;
    boolean kraj = false;
    LinkedList<Integer> numeric = new LinkedList<Integer>();

    try {
        BufferedReader in = new BufferedReader(new FileReader(txt));
        int br = Integer.parseInt(in.readLine().split(" ")[1]);
        for (int j = 0; j < br + 1; j++) {

            String pom = in.readLine();
            if (pom.contains("@attribute")) {
                if (pom.contains("numeric")) {
                    sviAtributi.add(pom.substring(11, pom.lastIndexOf("n") - 1));
                } else {
                    sviAtributi.add(pom.split(" ")[1]);
                }
            }
            if (pom.contains("@attribute") && pom.contains("numeric")) {
                atributi.add(pom.substring(11, pom.lastIndexOf("n") - 1));
            }
            if (!pom.contains("numeric")) {
                brojac++;
                numeric.add(j - 2);
            }

        }
        String s = in.readLine();
        boje = s.substring(s.indexOf("{") + 1, s.lastIndexOf("}")).split(",");
        xy = new XYSeries[boje.length];
        for (int i = 0; i < boje.length; i++) {

            xy[i] = new XYSeries(boje[i]);

        }
        while (!kraj) {
            String pom2 = in.readLine();

            if (!(pom2.contains("@data"))) {
                vrAtribut = pom2.split(",");
                for (int i = 0; i < xy.length; i++) {
                    if (xy[i].getKey().equals(vrAtribut[vrAtribut.length - 1])) {

                        xy[i].add(Double.parseDouble(vrAtribut[sviAtributi.indexOf(a)]),
                                Double.parseDouble(vrAtribut[sviAtributi.indexOf(b)]));

                    }
                }
            }
        }
        in.close();
    } catch (Exception e) {
        e.getMessage();
    }
    for (int i = 0; i < xy.length; i++) {
        xySeriesCollection.addSeries(xy[i]);
    }

    JFreeChart grafik = ChartFactory.createScatterPlot("Vizuelizacija", a, b, xySeriesCollection,
            PlotOrientation.VERTICAL, true, true, false);
    ChartFrame proba = new ChartFrame("DataMiner", grafik);

    proba.setVisible(true);
    proba.setSize(500, 600);

}

From source file:PerformanceGraph.java

/**
 * Plots the performance graph of the best fitness value so far versus the
 * number of function calls (NFC)./*from w  ww .ja  v a 2 s .co m*/
 * 
 * @param bestFitness A linked hashmap mapping the NFC to the best fitness value
 * found so far.
 * @param fitnessFunction The name of the fitness function, used for the title and the
 * name of the file that is saved, e.g. "De Jong".
 */
public static void plot(LinkedHashMap<Integer, Double> bestFitness, String fitnessFunction) {
    /* Create an XYSeries plot */
    XYSeries series = new XYSeries("Best Fitness Value Vs. Number of Function Calls");

    /* Add the NFC and best fitness value data to the series */
    for (Integer NFC : bestFitness.keySet()) {
        /* Jfreechart crashes if double values are too large! */
        if (bestFitness.get(NFC) <= 10E12) {
            series.add(NFC.doubleValue(), bestFitness.get(NFC).doubleValue());
        }
    }

    /* Add the x,y series data to the dataset */
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);

    /* Plot the data as an X,Y line chart */
    JFreeChart chart = ChartFactory.createXYLineChart("Best Fitness Value Vs. Number of Function Calls",
            "Number of Function Calls (NFC)", "Best Fitness Value", dataset, PlotOrientation.VERTICAL, false,
            true, false);

    /* Configure the chart settings such as anti-aliasing, background colour */
    chart.setAntiAlias(true);

    XYPlot plot = chart.getXYPlot();

    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);
    plot.setDomainGridlinePaint(Color.black);

    /* Set the domain range from 0 to NFC */
    NumberAxis domain = (NumberAxis) plot.getDomainAxis();
    domain.setRange(0.0, ControlVariables.MAX_FUNCTION_CALLS.doubleValue());

    /* Logarithmic range axis */
    plot.setRangeAxis(new LogAxis());

    /* Set the thickness and colour of the lines */
    XYItemRenderer renderer = plot.getRenderer();
    BasicStroke thickLine = new BasicStroke(3.0f);
    renderer.setSeriesStroke(0, thickLine);
    renderer.setPaint(Color.BLACK);

    /* Display the plot in a JFrame */
    ChartFrame frame = new ChartFrame(fitnessFunction + " Best Fitness Value", chart);
    frame.setVisible(true);
    frame.setSize(1000, 600);

    /* Save the plot as an image named after fitness function
    try
    {
       ChartUtilities.saveChartAsJPEG(new File("plots/" + fitnessFunction + ".jpg"), chart, 1600, 900);
    }
    catch (IOException e)
    {
       e.printStackTrace();
    }*/
}

From source file:jsdp.app.inventory.univariate.CapacitatedStochasticLotSizing.java

static void plotOptimalPolicyAction(int targetPeriod, BackwardRecursionImpl recursion) {
    XYSeries series = new XYSeries("Optimal policy");
    for (double i = StateImpl.getMinState(); i <= StateImpl.getMaxState(); i += StateImpl.getStepSize()) {
        StateDescriptorImpl stateDescriptor = new StateDescriptorImpl(targetPeriod, i);
        series.add(i, recursion.getOptimalAction(stateDescriptor).getAction());
    }/*w w  w .  j  av  a2 s .co  m*/

    XYDataset xyDataset = new XYSeriesCollection(series);
    JFreeChart chart = ChartFactory.createXYLineChart(
            "Optimal policy - period " + targetPeriod + " order quantity", "Opening inventory level",
            "Order quantity", xyDataset, PlotOrientation.VERTICAL, false, true, false);
    ChartFrame frame = new ChartFrame("Optimal policy", chart);
    frame.setVisible(true);
    frame.setSize(500, 400);
}

From source file:jsdp.app.inventory.univariate.CapacitatedStochasticLotSizing.java

static void plotOptimalPolicyCost(int targetPeriod, BackwardRecursionImpl recursion) {
    recursion.runBackwardRecursion(targetPeriod);
    XYSeries series = new XYSeries("Optimal policy");
    for (double i = StateImpl.getMinState(); i <= StateImpl.getMaxState(); i += StateImpl.getStepSize()) {
        StateDescriptorImpl stateDescriptor = new StateDescriptorImpl(targetPeriod, i);
        series.add(i, recursion.getExpectedCost(stateDescriptor));
    }/*w w w. j av  a 2  s  .  co m*/
    XYDataset xyDataset = new XYSeriesCollection(series);
    JFreeChart chart = ChartFactory.createXYLineChart(
            "Optimal policy policy - period " + targetPeriod + " expected total cost",
            "Opening inventory level", "Expected total cost", xyDataset, PlotOrientation.VERTICAL, false, true,
            false);
    ChartFrame frame = new ChartFrame("Optimal policy", chart);
    frame.setVisible(true);
    frame.setSize(500, 400);
}

From source file:jsdp.app.inventory.univariate.StochasticLotSizing.java

static void plotOptimalPolicyCost(int targetPeriod, BackwardRecursionImpl recursion) {
    recursion.runBackwardRecursionMonitoring(targetPeriod);
    XYSeries series = new XYSeries("Optimal policy");
    for (double i = StateImpl.getMinState(); i <= StateImpl.getMaxState(); i += StateImpl.getStepSize()) {
        StateDescriptorImpl stateDescriptor = new StateDescriptorImpl(targetPeriod, i);
        series.add(i, recursion.getExpectedCost(stateDescriptor));
    }/*from  ww w. j a va2  s .com*/
    XYDataset xyDataset = new XYSeriesCollection(series);
    JFreeChart chart = ChartFactory.createXYLineChart(
            "Optimal policy policy - period " + targetPeriod + " expected total cost",
            "Opening inventory level", "Expected total cost", xyDataset, PlotOrientation.VERTICAL, false, true,
            false);
    ChartFrame frame = new ChartFrame("Optimal policy", chart);
    frame.setVisible(true);
    frame.setSize(500, 400);
}

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   ww w .  ja v a  2 s . c  o m
    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:dumbara.view.Chart1.java

public static void byEmployee() {
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();
    try {//from ww w. j av a2s. 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  ww  w . j  a  v a2 s  . c  om*/
        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);
}