Example usage for org.jfree.chart ChartFactory setChartTheme

List of usage examples for org.jfree.chart ChartFactory setChartTheme

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory setChartTheme.

Prototype

public static void setChartTheme(ChartTheme theme) 

Source Link

Document

Sets the current chart theme.

Usage

From source file:cl.apr.pdf.chart.BarChartAviso.java

public static BufferedImage crearBarchart(List<BarChartItem> barChartItems) {
    BufferedImage bi = null;/*from  www.j  a va 2s.  co  m*/
    try {

        ChartFactory.setChartTheme(StandardChartTheme.createJFreeTheme());
        //ChartFactory.setChartTheme(StandardChartTheme.createDarknessTheme());

        /* Step - 1: Define the data for the bar chart  */
        DefaultCategoryDataset my_bar_chart_dataset = new DefaultCategoryDataset();
        int i = 0;
        for (BarChartItem barChartItem : barChartItems) {
            if (barChartItem.getNombre().equals("-")) {
                my_bar_chart_dataset.addValue(barChartItem.getValor(), "serie", (++i) + "");
            } else
                my_bar_chart_dataset.addValue(barChartItem.getValor(), "serie", barChartItem.getNombre());
        }
        //                my_bar_chart_dataset.addValue(34, "mes", "Ene");
        //                my_bar_chart_dataset.addValue(25, "mes", "Feb");
        //                my_bar_chart_dataset.addValue(22, "mes", "Mar");
        //                my_bar_chart_dataset.addValue(12, "mes", "Abr");
        //                my_bar_chart_dataset.addValue(40, "mes", "May");
        //                my_bar_chart_dataset.addValue(30, "mes", "jun");
        //                my_bar_chart_dataset.addValue(2, "mes", "Jul");
        //                my_bar_chart_dataset.addValue(15, "mes", "Ago");

        /* Step -2:Define the JFreeChart object to create bar chart */
        //JFreeChart chart=ChartFactory.createBarChart("Detalle de sus consumos","","MT3",my_bar_chart_dataset,PlotOrientation.VERTICAL,true,true,false);    
        JFreeChart chart = ChartFactory.createBarChart("", "", "MT3", my_bar_chart_dataset,
                PlotOrientation.VERTICAL, true, true, false);

        //chart.setBackgroundPaint(Color.lightGray);
        // get a reference to the plot for further customisation... 
        final CategoryPlot plot = chart.getCategoryPlot();
        CategoryItemRenderer renderer = new CustomRenderer();

        renderer.setSeriesPaint(0, Color.DARK_GRAY);

        plot.setRenderer(renderer);
        plot.setBackgroundPaint(Color.white);

        chart.setBorderVisible(false);
        chart.setBackgroundPaint(Color.white);
        chart.setBorderStroke(null);
        chart.getLegend().visible = false;
        /* Step -3: Write the output as PNG file with bar chart information */
        int width = 480; /* Width of the image */
        int height = 250; /* Height of the image */
        bi = chart.createBufferedImage(width, height);

        /*
                
        File BarChart=new File("output_chart.png");              
        ChartUtilities.saveChartAsPNG(BarChart,BarChartObject,width,height); 
                */
    } catch (Exception i) {
        System.out.println(i);
    }

    return bi;
}

From source file:net.sourceforge.processdash.ui.web.reports.DashboardChartDefaults.java

public static void initialize() {
    // install the legacy theme for chart colors
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    // turn off shadows on bar charts by default
    BarRenderer.setDefaultShadowsVisible(false);
    XYBarRenderer.setDefaultShadowsVisible(false);
    // the standard set of colors includes yellow, which is nearly
    // impossible to see on a white background. Replace those yellows with
    // variations on orange.
    DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[3] = Color.orange;
    DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[18] = new Color(215, 170, 0);
    DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[31] = new Color(255, 200, 128);
}

From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreeSetup.java

public static void setup() {
    StandardChartTheme theme = new StandardChartTheme("webapp");
    theme.setSmallFont(new Font("Arial", Font.PLAIN, 10));
    theme.setRegularFont(new Font("Arial", Font.PLAIN, 12));
    theme.setLargeFont(new Font("Arial", Font.PLAIN, 14));
    theme.setExtraLargeFont(new Font("Arial", Font.PLAIN, 20));

    ChartFactory.setChartTheme(theme);
}

From source file:com.ouc.cpss.view.EmpSaleChartBuilder.java

private static JFreeChart createJFreeChart(CategoryDataset dataset) {
    /**//from  ww  w .j  a v a  2  s . c  o  m
     * JFreeChart
     */
    //?     
    StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
    //     
    standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20));
    //    
    standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15));
    //?     
    standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15));
    //?   
    ChartFactory.setChartTheme(standardChartTheme);
    //?
    JFreeChart jfreeChart = ChartFactory.createBarChart3D("", "", "?", dataset,
            PlotOrientation.VERTICAL, true, false, false);
    /**
     * JFreeChart
     */
    jfreeChart.setTitle(new TextTitle("", new Font("", Font.BOLD + Font.ITALIC, 20)));
    CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot();
    CategoryAxis categoryAxis = plot.getDomainAxis();
    categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12));

    return jfreeChart;
}

From source file:com.ouc.cpss.view.SupTradeChartBuilder.java

private static JFreeChart createJFreeChart(PieDataset dataset) {
    /**//ww w .  j  av  a  2s  . c o m
     * JFreeChart
     */
    //?     
    StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
    //     
    standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20));
    //    
    standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15));
    //?     
    standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15));
    //?   
    ChartFactory.setChartTheme(standardChartTheme);
    //??  
    //createPieChart 2D; createPieChart3D  3D
    JFreeChart chart = ChartFactory.createPieChart("", dataset, true, true, false);

    //,?
    chart.setTitle(new TextTitle("", new Font("", Font.ITALIC, 22)));

    //?
    LegendTitle legend = chart.getLegend(0);
    //,ture,?
    legend.setItemFont(new Font("", Font.BOLD, 20));

    //?(??)
    PiePlot plot = (PiePlot) chart.getPlot();
    //?==?
    plot.setLabelFont(new Font("", Font.BOLD, 22));
    //
    plot.setBaseSectionOutlinePaint(Color.BLUE);
    //
    plot.setBaseSectionOutlineStroke(new BasicStroke(0.5f));
    //?,??,??
    plot.setDirection(Rotation.CLOCKWISE);//,Rotation.CLOCKWISE
    //()
    plot.setStartAngle(70);
    //???
    //plot.setExplodePercent(1, 0.5D);
    //plot.setExplodePercent("One", 0.5D);
    //,3D?
    plot.setExplodePercent(dataset.getKey(0), 0.1d);
    //
    plot.setLabelLinkPaint(Color.BLUE);
    //
    plot.setLabelOutlinePaint(Color.black);
    //
    plot.setLabelShadowPaint(Color.RED);
    //
    plot.setSectionPaint(1, Color.BLACK);
    // :,{0},{1},{2}?,???
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{1}\r\n{2}",
            NumberFormat.getNumberInstance(), new DecimalFormat("0.00%")));

    //
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={2}"));
    //:(true),(false)
    plot.setCircular(true);
    //?
    plot.setNoDataMessage("??...");

    //???
    plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    //
    //plot.setURLGenerator(new StandardPieURLGenerator("detail.jsp"));

    return chart;
}

From source file:com.ouc.cpss.view.ChartProBuilder.java

private static JFreeChart createJFreeChart(CategoryDataset dataset) {
    /**//from   w w  w  .  j av  a 2  s .c  o m
     * JFreeChart
     */
    //?     
    StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
    //     
    standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20));
    //    
    standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15));
    //?     
    standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15));
    //?   
    ChartFactory.setChartTheme(standardChartTheme);
    //?
    // ?
    JFreeChart jfreeChart = null;
    if (choice == 1) {
        jfreeChart = ChartFactory.createBarChart3D("? -- ?TOP10", "",
                "?", dataset, PlotOrientation.VERTICAL, true, false, false);
        /**
          * JFreeChart
          */
        jfreeChart.setTitle(new TextTitle("? -- ?TOP10",
                new Font("", Font.BOLD + Font.ITALIC, 20)));
        CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot();
        CategoryAxis categoryAxis = plot.getDomainAxis();
        categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12));
    } else {
        jfreeChart = ChartFactory.createBarChart3D("? -- ?TOP10", "",
                "?", dataset, PlotOrientation.VERTICAL, true, false, false);
        jfreeChart.setTitle(new TextTitle("? -- ?TOP10",
                new Font("", Font.BOLD + Font.ITALIC, 20)));
        CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot();
        CategoryAxis categoryAxis = plot.getDomainAxis();
        categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12));
    }
    return jfreeChart;
}

From source file:uom.research.thalassemia.util.PieChartCreator.java

/**
 * Creates a panel for the demo (used by SuperDemo.java).
 *
 * @param pPieDataset dataset/*from w w w.j  av  a  2  s  . c o  m*/
 * @param pTitle title
 * @return A panel.
 */
public JPanel createPanel(final PieDataset pPieDataset, final String pTitle) {
    title = pTitle;
    pieDataset = pPieDataset;

    // set a theme using the new shadow generator feature available in
    // 1.0.14 - for backwards compatibility it is not enabled by default
    ChartFactory.setChartTheme(new StandardChartTheme("JFree/Shadow", true));
    JFreeChart chart = createChart(pieDataset);
    chart.setPadding(new RectangleInsets(4, 8, 2, 2));
    ChartPanel panel = new ChartPanel(chart);
    panel.setMouseWheelEnabled(true);
    panel.setPreferredSize(new Dimension(600, 300));
    return panel;
}

From source file:storybook.ui.chart.AbstractChartPanel.java

public AbstractChartPanel(MainFrame paramMainFrame, String paramString) {
    super(paramMainFrame);
    this.chartTitle = I18N.getMsg(paramString);

    // ChartFactory??
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.LegacyChartModule.java

/**
 * Initializes the module. Use this method to perform all initial setup operations. This method is called only once in
 * a modules lifetime. If the initializing cannot be completed, throw a ModuleInitializeException to indicate the
 * error,. The module will not be available to the system.
 *
 * @param subSystem the subSystem.//from ww w.j a v  a  2  s. com
 * @throws ModuleInitializeException if an error occurred while initializing the module.
 */
public void initialize(final SubSystem subSystem) throws ModuleInitializeException {
    ElementMetaDataParser.initializeOptionalExpressionsMetaData(
            "org/pentaho/plugin/jfreereport/reportcharts/meta-xy-chart-expressions.xml");
    ElementMetaDataParser.initializeOptionalExpressionsMetaData(
            "org/pentaho/plugin/jfreereport/reportcharts/meta-other-chart-expressions.xml");
    ElementMetaDataParser.initializeOptionalExpressionsMetaData(
            "org/pentaho/plugin/jfreereport/reportcharts/meta-categorical-chart-expressions.xml");
    ElementMetaDataParser.initializeOptionalExpressionsMetaData(
            "org/pentaho/plugin/jfreereport/reportcharts/meta-collector-expressions.xml");

    // Set the ChartFactory to the Legacy Theme
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());

}

From source file:fi.smaa.jsmaa.gui.JSMAAMainFrame.java

public JSMAAMainFrame(SMAAModel model) {
    super(AppInfo.getAppName());

    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    ToolTipManager.sharedInstance().setInitialDelay(0);
    setPreferredSize(new Dimension(950, 700));
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    modelManager = new ModelFileManager();
    modelManager.addPropertyChangeListener(ModelFileManager.PROPERTY_TITLE, new PropertyChangeListener() {
        @Override//from  w  ww.jav a2  s . c  om
        public void propertyChange(PropertyChangeEvent ev) {
            setTitle((String) ev.getNewValue());
        }
    });
    modelManager.addPropertyChangeListener(ModelFileManager.PROPERTY_MODEL, new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            initWithModel((SMAAModel) evt.getNewValue());
        }
    });
    modelManager.setModel(model);
}