Example usage for org.jfree.text TextUtilities createTextBlock

List of usage examples for org.jfree.text TextUtilities createTextBlock

Introduction

In this page you can find the example usage for org.jfree.text TextUtilities createTextBlock.

Prototype

public static TextBlock createTextBlock(final String text, final Font font, final Paint paint,
        final float maxWidth, final int maxLines, final TextMeasurer measurer) 

Source Link

Document

Creates a new text block from the given string, breaking the text into lines so that the maxWidth value is respected.

Usage

From source file:org.pentaho.plugin.jfreereport.reportcharts.backport.FormattedCategoryAxis.java

protected TextBlock createLabel(final Comparable category, final float width, final RectangleEdge edge,
        final Graphics2D g2) {
    return TextUtilities.createTextBlock(format.format(new Object[] { category }), getTickLabelFont(category),
            getTickLabelPaint(category), width, getMaximumCategoryLabelLines(), new G2TextMeasurer(g2));
}

From source file:com.bdaum.zoom.report.internal.jfree.custom.SparseCategoryAxis.java

@Override
protected TextBlock createLabel(@SuppressWarnings("rawtypes") Comparable category, float width,
        RectangleEdge edge, Graphics2D g2) {
    return TextUtilities.createTextBlock(category.toString(), getTickLabelFont(category),
            getTickLabelPaint(category), width * nth, 1, new G2TextMeasurer(g2));
}

From source file:org.jboss.weld.benchmark.charts.Chart.java

/**
 * Saving a chart to hard disk as png image
 *
 * @param path absolute path/* w  w w  . j av  a2  s  .  c o m*/
 * @return true if no errors occurred
 */
public Boolean saveImageTo(String path) {
    try {
        JFreeChart lineChartObject = ChartFactory.createBarChart(NAME, X_AXIS_NAME, Y_AXIS_NAME,
                lineChartDataset, PlotOrientation.VERTICAL, true, true, false);

        CategoryPlot plot = (CategoryPlot) lineChartObject.getPlot();

        plot.setDomainAxis(new CategoryAxis() {
            private static final long serialVersionUID = 1L;

            @Override
            protected TextBlock createLabel(@SuppressWarnings("rawtypes") Comparable category, float width,
                    RectangleEdge edge, Graphics2D g2) {
                TextBlock label = TextUtilities.createTextBlock(category.toString(), getTickLabelFont(category),
                        getTickLabelPaint(category), ONE_PART_WIDTH - 30, 2, new G2TextMeasurer(g2));

                label.setLineAlignment(HorizontalAlignment.LEFT);
                return label;
            }
        });

        File lineChart = new File(path, NAME + ".png");
        ChartUtilities.saveChartAsPNG(lineChart, lineChartObject,
                ONE_PART_WIDTH * lineChartDataset.getColumnCount(), GRAPH_HEIGHT);
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
    return true;
}