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

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

Introduction

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

Prototype

public void setLabelAngle(double angle) 

Source Link

Document

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

Usage

From source file:com.appnativa.rare.ui.chart.jfreechart.ChartHandler.java

protected void setLabelAngel(iPlatformComponent chartPanel, ChartDefinition cd, boolean range) {
    Axis a = getAxis(cd, range);
    int angle = range ? cd.getRangeAxis().getAngle() : cd.getDomainAxis().getAngle();

    if (a != null) {
        float ang = (float) Math.toRadians(angle);

        if (!SNumber.isEqual(ang, a.getLabelAngle())) {
            a.setLabelAngle(ang);

            LabelData[] labels = null;/*from   w w  w  .  java  2s. c o  m*/

            if (a instanceof NumberAxisEx) {
                labels = ((NumberAxisEx) a).categoryLabels;
            } else if (a instanceof NumberAxis3DEx) {
                labels = ((NumberAxis3DEx) a).categoryLabels;
            }

            if (labels != null) {
                UIFont f = getAxisLabelFont(cd.getRangeAxis());

                remeasureLabels(labels, UIFontMetrics.getMetrics(f), angle);
            }
        }
    }
}

From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java

protected void setAxisLabel(Axis axis, JRFont labelFont, Paint labelColor, AxisSettings axisSettings) {
    Boolean axisLabelVisible = axisSettings.getLabelVisible();

    if (axisLabelVisible == null || axisLabelVisible.booleanValue()) {
        //         if(axis.getLabel() == null)
        //            axis.setLabel(axisSettings.getLabel());

        Double labelAngle = axisSettings.getLabelAngle();
        if (labelAngle != null)
            axis.setLabelAngle(labelAngle.doubleValue());

        JRBaseFont font = new JRBaseFont();
        JRFontUtil.copyNonNullOwnProperties(axisSettings.getLabelFont(), font);
        JRFontUtil.copyNonNullOwnProperties(labelFont, font);
        font = new JRBaseFont(getChart(), font);
        axis.setLabelFont(JRFontUtil.getAwtFont(font, getLocale()));

        RectangleInsets labelInsets = axisSettings.getLabelInsets();
        if (labelInsets != null) {
            axis.setLabelInsets(labelInsets);
        }//www.  jav  a  2 s .co m
        Paint labelPaint = labelColor != null ? labelColor
                : axisSettings.getLabelPaint() != null ? axisSettings.getLabelPaint().getPaint() : null;
        if (labelPaint != null) {
            axis.setLabelPaint(labelPaint);
        }
    }
}

From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java

protected void setAxisLabel(Axis axis, JRFont labelFont, Paint labelColor, AxisSettings axisSettings) {
    Boolean axisLabelVisible = axisSettings.getLabelVisible();

    if (axisLabelVisible == null || axisLabelVisible) {
        //         if (axis.getLabel() == null)
        //            axis.setLabel(axisSettings.getLabel());

        Double labelAngle = axisSettings.getLabelAngle();
        if (labelAngle != null)
            axis.setLabelAngle(labelAngle);

        JRBaseFont font = new JRBaseFont();
        FontUtil.copyNonNullOwnProperties(axisSettings.getLabelFont(), font);
        FontUtil.copyNonNullOwnProperties(labelFont, font);
        font = new JRBaseFont(getChart(), font);
        axis.setLabelFont(getFontUtil().getAwtFont(font, getLocale()));

        RectangleInsets labelInsets = axisSettings.getLabelInsets();
        if (labelInsets != null) {
            axis.setLabelInsets(labelInsets);
        }//w  w  w  . j  ava  2 s.c om
        Paint labelPaint = labelColor != null ? labelColor
                : axisSettings.getLabelPaint() != null ? axisSettings.getLabelPaint().getPaint() : null;
        if (labelPaint != null) {
            axis.setLabelPaint(labelPaint);
        }
    }
}

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);
        }//from  w  ww  . ja v a  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);
        }/* w ww .  jav  a2 s .  c  o m*/
        Paint labelPaint = labelColor != null ? labelColor
                : (Paint) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_LABEL_PAINT);
        if (labelPaint != null) {
            axis.setLabelPaint(labelPaint);
        }
    }
}