Example usage for org.jfree.chart.renderer.category LineAndShapeRenderer setFillPaint

List of usage examples for org.jfree.chart.renderer.category LineAndShapeRenderer setFillPaint

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.category LineAndShapeRenderer setFillPaint.

Prototype

public void setFillPaint(Paint paint) 

Source Link

Document

Sets the fill paint for ALL series (optional).

Usage

From source file:com.etest.view.tq.charts.SubjectTestLineChart.java

public static JFreeChart discriminationIndex(int tqCoverageId) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    for (CellItem ci : CellItemDAO.getItemAnalysisResult(tqCoverageId)) {
        dataset.setValue((int) (ci.getDiscriminationIndex() * 100), "Discrimination Index",
                String.valueOf(ci.getItemNo()));
    }/*from w  w  w. jav a  2  s  . c o  m*/

    JFreeChart chart = ChartFactory.createLineChart("Item Analysis Report", "Item No.",
            "Discrimination Index (%)", dataset, PlotOrientation.VERTICAL, true, true, false);

    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);

    // customise the range axis...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // customise the renderer...
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setFillPaint(Color.white);

    return chart;
}

From source file:com.etest.view.tq.charts.SubjectTestLineChart.java

public static JFreeChart difficultIndex(int tqCoverageId) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    for (CellItem ci : CellItemDAO.getItemAnalysisResult(tqCoverageId)) {
        dataset.setValue((int) (ci.getDifficultIndex() * 100), "Difficulty Index",
                String.valueOf(ci.getItemNo()));
    }//  w w  w.j av  a  2 s  .  c  o m

    JFreeChart chart = ChartFactory.createLineChart("Item Analysis Report", "Item No.", "Difficulty Index (%)",
            dataset, PlotOrientation.VERTICAL, true, true, false);

    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);

    // customise the range axis...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // customise the renderer...
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setFillPaint(Color.white);

    return chart;
}

From source file:spec.reporter.Utils.java

public static void createBmResultGraph(BenchmarkRecord record) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    String iterName = "";
    double max = 0;
    double min = Long.MAX_VALUE;
    for (int i = 0; i < record.iterRecords.size(); i++) {
        BenchmarkRecord.IterationRecord iterRecord = (BenchmarkRecord.IterationRecord) record.iterRecords
                .get(i);// w  ww. jav  a 2s.  c  o m
        String shortName = iterRecord.iterName.replaceFirst("ation", "");
        if (iterRecord.score > max) {
            max = iterRecord.score;
            iterName = shortName;
        }

        if (iterRecord.score < min) {
            min = iterRecord.score;
        }

        dataset.addValue(iterRecord.score, " ", shortName);
    }

    JFreeChart chart = ChartFactory.createLineChart("  ", "iterations", Constants.WORKLOAD_METRIC, dataset,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(new Color(201, 222, 254));
    plot.setRangeGridlinePaint(Color.WHITE);
    if (record.isValidRun() && min != Long.MAX_VALUE) {
        plot.getRangeAxis().setRange(min - 10, max + 10);
    } else {
        plot.getRangeAxis().setRange(0, max + 10);
    }
    ValueMarker vm = new ValueMarker(record.maxScore);
    vm.setLabel(Utils.df.format(record.maxScore));
    vm.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    vm.setLabelTextAnchor(TextAnchor.HALF_ASCENT_LEFT);

    plot.addRangeMarker(vm);
    CategoryMarker marker = new CategoryMarker(iterName);
    marker.setDrawAsLine(true);
    marker.setPaint(vm.getPaint());
    plot.addDomainMarker(marker);
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setFillPaint(Color.WHITE);
    renderer.setSeriesPaint(0, Color.BLUE.darker());

    try {
        ChartUtilities.saveChartAsJPEG(new File(Utils.getFullImageName(record.name + "_results")), chart, 300,
                200);
    } catch (Exception e) {
        System.out.println("Problems...");
    }
}

From source file:charts.Chart.java

public static void LineChart(double[][] data, String title_validation, String title, String x_axis_label,
        String y_axis_label) {// ww  w .  j  a v a2 s . co  m

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int i = 0; i < data.length; i++) {
        dataset.addValue(data[i][1], title_validation, String.valueOf(data[i][2]));
    }
    JFrame chartwindow = new JFrame(title);
    JFreeChart jfreechart = ChartFactory.createLineChart(title, x_axis_label, y_axis_label, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.black);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());

    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setShapesVisible(true);
    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setFillPaint(Color.white);

    JPanel jpanel = new ChartPanel(jfreechart);
    jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight));
    chartwindow.setContentPane(jpanel);
    chartwindow.pack();
    RefineryUtilities.centerFrameOnScreen(chartwindow);
    chartwindow.setVisible(true);
}

From source file:charts.Chart.java

public static void LineChart(DefaultCategoryDataset dataset, String title, String x_axis_label,
        String y_axis_label, boolean showlegend, float maxvalue, float minvalue) {

    JFrame chartwindow = new JFrame(title);

    JFreeChart jfreechart = ChartFactory.createLineChart(title, x_axis_label, y_axis_label, dataset,
            PlotOrientation.VERTICAL, showlegend, // include legend
            true, // tooltips
            true // urls
    );/*from www.java 2  s  . c o m*/

    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.black);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());

    CategoryPlot plot = (CategoryPlot) jfreechart.getPlot();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    if (minvalue == 0 && maxvalue == 0) {
        rangeAxis.setAutoRangeIncludesZero(true);
    } else {
        rangeAxis.setRange(minvalue, maxvalue);
    }
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setBaseStroke(new BasicStroke(2.0f));
    lineandshaperenderer.setShapesVisible(true);
    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setFillPaint(Color.white);

    //GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.MAGENTA, 0.0f, 0.0f, Color.MAGENTA);
    //lineandshaperenderer.setSeriesPaint(0, gp1);
    //ou
    lineandshaperenderer.setSeriesPaint(0, Color.RED);

    JPanel jpanel = new ChartPanel(jfreechart);
    jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight));
    chartwindow.setContentPane(jpanel);
    chartwindow.pack();
    RefineryUtilities.centerFrameOnScreen(chartwindow);
    chartwindow.setVisible(true);
}