Example usage for org.jfree.chart.title ImageTitle ImageTitle

List of usage examples for org.jfree.chart.title ImageTitle ImageTitle

Introduction

In this page you can find the example usage for org.jfree.chart.title ImageTitle ImageTitle.

Prototype

public ImageTitle(Image image, RectangleEdge position, HorizontalAlignment horizontalAlignment,
        VerticalAlignment verticalAlignment) 

Source Link

Document

Creates a new image title.

Usage

From source file:playground.yu.utils.charts.DoubleBarChart.java

public void saveAsPng(final String filename, final String title, final int width, final int height) {
    for (int i = 0; i < subCharts.length; i++)
        plot.add((CategoryPlot) subCharts[i].getChart().getPlot(), 1);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    // add MATSim logo
    Image image = MatsimResource.getAsImage("matsim_logo_transparent_small.png");
    Title subtitle = new ImageTitle(image, RectangleEdge.BOTTOM, HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM);//from   w  w  w.  j a  va2  s  .com
    chart.addSubtitle(subtitle);
    // add default Formatting
    chart.setBackgroundPaint(new Color(1.0f, 1.0f, 1.0f, 1.0f));
    chart.getLegend().setBorder(0.0, 0.0, 0.0, 0.0);

    try {
        ChartUtilities.saveChartAsPNG(new File(filename), chart, width, height, null, true, 9);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:org.matsim.core.utils.charts.ChartUtil.java

/**
 * Adds the MATSim Logo in the lower right corner of the chart.
 *//*from   ww w  .  java  2  s .c  o m*/
public void addMatsimLogo() {
    try {
        Image image = MatsimResource.getAsImage("matsim_logo_transparent_small.png");
        Title subtitle = new ImageTitle(image, RectangleEdge.BOTTOM, HorizontalAlignment.RIGHT,
                VerticalAlignment.BOTTOM);
        this.chart.addSubtitle(subtitle);
    } catch (Exception e) {
        e.printStackTrace();
        // I just had a resource-not-found error inside the method; don't know what that means but does not feel like a reason 
        // to not continue.  kai, apr'30
    }
}