Example usage for org.jfree.chart.axis Axis setLabel

List of usage examples for org.jfree.chart.axis Axis setLabel

Introduction

In this page you can find the example usage for org.jfree.chart.axis Axis setLabel.

Prototype

public void setLabel(String label) 

Source Link

Document

Sets the label for the axis and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java

protected void setAxisLabel(Axis axis, JRFont labelFont, Paint labelColor, Integer baseFontSize) {
    Boolean defaultAxisLabelVisible = (Boolean) getDefaultValue(defaultAxisPropertiesMap,
            ChartThemesConstants.AXIS_LABEL_VISIBLE);
    if (defaultAxisLabelVisible != null && defaultAxisLabelVisible.booleanValue()) {
        if (axis.getLabel() == null)
            axis.setLabel((String) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_LABEL));

        Double defaultLabelAngle = (Double) getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_LABEL_ANGLE);
        if (defaultLabelAngle != null)
            axis.setLabelAngle(defaultLabelAngle.doubleValue());
        Font themeLabelFont = getFont(
                (JRFont) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_LABEL_FONT),
                labelFont, baseFontSize);
        axis.setLabelFont(themeLabelFont);

        RectangleInsets defaultLabelInsets = (RectangleInsets) getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_LABEL_INSETS);
        if (defaultLabelInsets != null) {
            axis.setLabelInsets(defaultLabelInsets);
        }/*  www.  java  2 s . co  m*/
        Paint labelPaint = labelColor != null ? labelColor
                : (Paint) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_LABEL_PAINT);
        if (labelPaint != null) {
            axis.setLabelPaint(labelPaint);
        }
    }
}

From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java

protected void setAxisLabel(Axis axis, JRFont labelFont, Paint labelColor, Integer baseFontSize) {
    Boolean defaultAxisLabelVisible = (Boolean) getDefaultValue(defaultAxisPropertiesMap,
            ChartThemesConstants.AXIS_LABEL_VISIBLE);
    if (defaultAxisLabelVisible != null && defaultAxisLabelVisible) {
        if (axis.getLabel() == null)
            axis.setLabel((String) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_LABEL));

        Double defaultLabelAngle = (Double) getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_LABEL_ANGLE);
        if (defaultLabelAngle != null)
            axis.setLabelAngle(defaultLabelAngle);
        Font themeLabelFont = getFont(
                (JRFont) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_LABEL_FONT),
                labelFont, baseFontSize);
        axis.setLabelFont(themeLabelFont);

        RectangleInsets defaultLabelInsets = (RectangleInsets) getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_LABEL_INSETS);
        if (defaultLabelInsets != null) {
            axis.setLabelInsets(defaultLabelInsets);
        }// www .  j a v  a 2s. c o m
        Paint labelPaint = labelColor != null ? labelColor
                : (Paint) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_LABEL_PAINT);
        if (labelPaint != null) {
            axis.setLabelPaint(labelPaint);
        }
    }
}

From source file:org.operamasks.faces.render.graph.ChartRenderer.java

protected void setChartAxes(JFreeChart chart, UIChart comp) {
    UIAxis xAxis = comp.getxAxis();/*from   www .  j av a2 s  .  c o  m*/
    UIAxis yAxis = comp.getyAxis();
    String xAxisLabel = comp.getxAxisLabel();
    String yAxisLabel = comp.getyAxisLabel();

    Plot plot = chart.getPlot();
    Axis domainAxis = null;
    Axis rangeAxis = null;

    if (plot instanceof CategoryPlot) {
        CategoryPlot categoryPlot = (CategoryPlot) plot;
        if (yAxis != null && yAxis.isLogarithmic())
            categoryPlot.setRangeAxis(new LogarithmicAxis(null));

        domainAxis = categoryPlot.getDomainAxis();
        rangeAxis = categoryPlot.getRangeAxis();

        if (xAxis != null) {
            Boolean drawGridLine = xAxis.getDrawGridLine();
            if (drawGridLine != null) {
                categoryPlot.setDomainGridlinesVisible(drawGridLine);
            }
            Paint gridLineColor = xAxis.getGridLineColor();
            if (gridLineColor != null) {
                categoryPlot.setDomainGridlinePaint(gridLineColor);
            }
        }

        if (yAxis != null) {
            Boolean drawGridLine = yAxis.getDrawGridLine();
            if (drawGridLine != null) {
                categoryPlot.setRangeGridlinesVisible(drawGridLine);
            }
            Paint gridLineColor = yAxis.getGridLineColor();
            if (gridLineColor != null) {
                categoryPlot.setRangeGridlinePaint(gridLineColor);
            }
        }
    } else if (plot instanceof XYPlot) {
        XYPlot xyPlot = (XYPlot) plot;
        if (xAxis != null && xAxis.isLogarithmic())
            xyPlot.setDomainAxis(new LogarithmicAxis(null));
        if (yAxis != null && yAxis.isLogarithmic())
            xyPlot.setRangeAxis(new LogarithmicAxis(null));

        domainAxis = xyPlot.getDomainAxis();
        rangeAxis = xyPlot.getRangeAxis();

        if (xAxis != null) {
            Boolean drawGridLine = xAxis.getDrawGridLine();
            if (drawGridLine != null) {
                xyPlot.setDomainGridlinesVisible(drawGridLine);
            }
            Paint gridLineColor = xAxis.getGridLineColor();
            if (gridLineColor != null) {
                xyPlot.setDomainGridlinePaint(gridLineColor);
            }
            Boolean drawBaseLine = xAxis.getDrawBaseLine();
            if (drawBaseLine != null) {
                xyPlot.setDomainZeroBaselineVisible(drawBaseLine);
            }
            Paint baseLineColor = xAxis.getBaseLineColor();
            if (baseLineColor != null) {
                xyPlot.setDomainZeroBaselinePaint(baseLineColor);
            }
        }

        if (yAxis != null) {
            Boolean drawGridLine = yAxis.getDrawGridLine();
            if (drawGridLine != null) {
                xyPlot.setRangeGridlinesVisible(drawGridLine);
            }
            Paint gridLineColor = yAxis.getGridLineColor();
            if (gridLineColor != null) {
                xyPlot.setRangeGridlinePaint(gridLineColor);
            }
            Boolean drawBaseLine = yAxis.getDrawBaseLine();
            if (drawBaseLine != null) {
                xyPlot.setRangeZeroBaselineVisible(drawBaseLine);
            }
            Paint baseLineColor = yAxis.getBaseLineColor();
            if (baseLineColor != null) {
                xyPlot.setRangeZeroBaselinePaint(baseLineColor);
            }
        }
    }

    if (domainAxis != null) {
        if (xAxisLabel != null)
            domainAxis.setLabel(xAxisLabel);
        if (xAxis != null)
            setAxisStyles(domainAxis, xAxis);
    }
    if (rangeAxis != null) {
        if (yAxisLabel != null)
            rangeAxis.setLabel(yAxisLabel);
        if (yAxis != null)
            setAxisStyles(rangeAxis, yAxis);
    }
}