Example usage for org.jfree.chart.renderer.category AbstractCategoryItemRenderer getNegativeItemLabelPosition

List of usage examples for org.jfree.chart.renderer.category AbstractCategoryItemRenderer getNegativeItemLabelPosition

Introduction

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

Prototype

public ItemLabelPosition getNegativeItemLabelPosition() 

Source Link

Document

Returns the item label position for negative values in ALL series.

Usage

From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java

private void setCategoryItemLabelsData(AbstractCategoryItemRenderer renderer, cfCHARTSERIESData seriesData)
        throws cfmRunTimeException {
    // Set them as visible
    renderer.setItemLabelsVisible(true);

    // Set their color
    renderer.setItemLabelPaint(convertStringToColor(seriesData.getDataLabelColor()));

    // Set their font
    renderer.setItemLabelFont(getFont(seriesData.getDataLabelFont(), seriesData.getDataLabelFontBold(),
            seriesData.getDataLabelFontItalic(), seriesData.getDataLabelFontSize()));

    // Set the item label position for negative data values
    double degrees = seriesData.getDataLabelAngle();
    double radians = Math.toRadians(degrees);
    String negPosition = seriesData.getNegativeDataLabelPosition();
    if (negPosition.equals("top"))
        renderer.setNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                TextAnchor.BOTTOM_CENTER, TextAnchor.CENTER, radians));
    else if (negPosition.equals("top_inside"))
        renderer.setNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE12,
                TextAnchor.TOP_CENTER, TextAnchor.CENTER, radians));
    else if (negPosition.equals("left"))
        renderer.setNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9,
                TextAnchor.CENTER_RIGHT, TextAnchor.CENTER, radians));
    else if (negPosition.equals("left_inside"))
        renderer.setNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE9,
                TextAnchor.CENTER_LEFT, TextAnchor.CENTER, radians));
    else if (negPosition.equals("center"))
        renderer.setNegativeItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, radians));
    else if (negPosition.equals("right"))
        renderer.setNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
                TextAnchor.CENTER_LEFT, TextAnchor.CENTER, radians));
    else if (negPosition.equals("right_inside"))
        renderer.setNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE3,
                TextAnchor.CENTER_RIGHT, TextAnchor.CENTER, radians));
    else if (negPosition.equals("bottom_inside"))
        renderer.setNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE6,
                TextAnchor.BOTTOM_CENTER, TextAnchor.CENTER, radians));
    else if (negPosition.equals("bottom"))
        renderer.setNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6,
                TextAnchor.TOP_CENTER, TextAnchor.CENTER, radians));

    // Set the item label position for positive data values
    String posPosition = seriesData.getPositiveDataLabelPosition();
    if (posPosition.equals("top"))
        renderer.setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                TextAnchor.BOTTOM_CENTER, TextAnchor.CENTER, radians));
    else if (posPosition.equals("top_inside"))
        renderer.setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE12,
                TextAnchor.TOP_CENTER, TextAnchor.CENTER, radians));
    else if (posPosition.equals("left"))
        renderer.setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9,
                TextAnchor.CENTER_RIGHT, TextAnchor.CENTER, radians));
    else if (posPosition.equals("left_inside"))
        renderer.setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE9,
                TextAnchor.CENTER_LEFT, TextAnchor.CENTER, radians));
    else if (posPosition.equals("center"))
        renderer.setPositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, radians));
    else if (posPosition.equals("right"))
        renderer.setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
                TextAnchor.CENTER_LEFT, TextAnchor.CENTER, radians));
    else if (posPosition.equals("right_inside"))
        renderer.setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE3,
                TextAnchor.CENTER_RIGHT, TextAnchor.CENTER, radians));
    else if (posPosition.equals("bottom_inside"))
        renderer.setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE6,
                TextAnchor.BOTTOM_CENTER, TextAnchor.CENTER, radians));
    else if (posPosition.equals("bottom"))
        renderer.setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6,
                TextAnchor.TOP_CENTER, TextAnchor.CENTER, radians));

    // With Bar graphs and an inside position, we want to force the item labels
    // to be drawn even if they don't fit inside the bar graph.
    if (renderer instanceof BarRenderer) {
        ((BarRenderer) renderer).setNegativeItemLabelPositionFallback(renderer.getNegativeItemLabelPosition());
        ((BarRenderer) renderer).setPositiveItemLabelPositionFallback(renderer.getPositiveItemLabelPosition());
    }/*  w w  w .j  a  v  a 2 s. c  o m*/
}