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

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

Introduction

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

Prototype

public void setFixedDimension(double dimension) 

Source Link

Document

Sets the fixed dimension for the axis.

Usage

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

/**
 * Sets all the axis formatting options.  This includes the colors and fonts to use on
 * the axis as well as the color to use when drawing the axis line.
 *
 * @param axis the axis to format//from  ww  w.  ja  v a 2  s.co m
 * @param labelFont the font to use for the axis label
 * @param labelColor the color of the axis label
 * @param tickLabelFont the font to use for each tick mark value label
 * @param tickLabelColor the color of each tick mark value label
 * @param tickLabelMask formatting mask for the label.  If the axis is a NumberAxis then
 *                    the mask should be <code>java.text.DecimalFormat</code> mask, and
 *                   if it is a DateAxis then the mask should be a
 *                   <code>java.text.SimpleDateFormat</code> mask.
 * @param verticalTickLabels flag to draw tick labels at 90 degrees
 * @param lineColor color to use when drawing the axis line and any tick marks
 * @param isRangeAxis used to distinguish between range and domain axis type
 * @param timeUnit time unit used to create a DateAxis
 */
protected void configureAxis(Axis axis, JRFont labelFont, Color labelColor, JRFont tickLabelFont,
        Color tickLabelColor, String tickLabelMask, Boolean verticalTickLabels, Paint lineColor,
        boolean isRangeAxis, Comparable axisMinValue, Comparable axisMaxValue) throws JRException {
    Boolean axisVisible = (Boolean) getDefaultValue(defaultAxisPropertiesMap,
            ChartThemesConstants.AXIS_VISIBLE);

    if (axisVisible != null && axisVisible.booleanValue()) {
        setAxisLine(axis, lineColor);

        Double defaultFixedDimension = (Double) getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_FIXED_DIMENSION);
        if (defaultFixedDimension != null) {
            axis.setFixedDimension(defaultFixedDimension.doubleValue());
        }

        Integer baseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap,
                ChartThemesConstants.BASEFONT_SIZE);
        setAxisLabel(axis, labelFont, labelColor, baseFontSize);
        setAxisTickLabels(axis, tickLabelFont, tickLabelColor, tickLabelMask, baseFontSize);
        setAxisTickMarks(axis, lineColor);
        String timePeriodUnit = isRangeAxis
                ? (String) getDefaultValue(defaultAxisPropertiesMap,
                        ChartThemesConstants.RANGE_AXIS_TIME_PERIOD_UNIT)
                : (String) getDefaultValue(defaultAxisPropertiesMap,
                        ChartThemesConstants.DOMAIN_AXIS_TIME_PERIOD_UNIT);
        setAxisBounds(axis, isRangeAxis, timePeriodUnit, axisMinValue, axisMaxValue);

        if (verticalTickLabels != null && axis instanceof ValueAxis) {
            ((ValueAxis) axis).setVerticalTickLabels(verticalTickLabels.booleanValue());
        }
    } else {
        axis.setVisible(false);
    }
}

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

/**
 * Sets all the axis formatting options.  This includes the colors and fonts to use on
 * the axis as well as the color to use when drawing the axis line.
 *
 * @param axis the axis to format/*w  w w .  j  a v a  2s  . c  o m*/
 * @param labelFont the font to use for the axis label
 * @param labelColor the color of the axis label
 * @param tickLabelFont the font to use for each tick mark value label
 * @param tickLabelColor the color of each tick mark value label
 * @param tickLabelMask formatting mask for the label.  If the axis is a NumberAxis then
 *                   the mask should be <code>java.text.DecimalFormat</code> mask, and
 *                   if it is a DateAxis then the mask should be a
 *                   <code>java.text.SimpleDateFormat</code> mask.
 * @param verticalTickLabels flag to draw tick labels at 90 degrees
 * @param lineColor color to use when drawing the axis line and any tick marks
 * @param isRangeAxis used to distinguish between range and domain axis type
 */
protected void configureAxis(Axis axis, JRFont labelFont, Color labelColor, JRFont tickLabelFont,
        Color tickLabelColor, String tickLabelMask, Boolean verticalTickLabels, Paint lineColor,
        boolean isRangeAxis, Comparable<?> axisMinValue, Comparable<?> axisMaxValue) throws JRException {
    Boolean axisVisible = (Boolean) getDefaultValue(defaultAxisPropertiesMap,
            ChartThemesConstants.AXIS_VISIBLE);

    if (axisVisible != null && axisVisible) {
        setAxisLine(axis, lineColor);

        Double defaultFixedDimension = (Double) getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_FIXED_DIMENSION);
        if (defaultFixedDimension != null) {
            axis.setFixedDimension(defaultFixedDimension);
        }

        Integer baseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap,
                ChartThemesConstants.BASEFONT_SIZE);
        setAxisLabel(axis, labelFont, labelColor, baseFontSize);
        setAxisTickLabels(axis, tickLabelFont, tickLabelColor, tickLabelMask, baseFontSize);
        setAxisTickMarks(axis, lineColor);
        String timePeriodUnit = isRangeAxis
                ? (String) getDefaultValue(defaultAxisPropertiesMap,
                        ChartThemesConstants.RANGE_AXIS_TIME_PERIOD_UNIT)
                : (String) getDefaultValue(defaultAxisPropertiesMap,
                        ChartThemesConstants.DOMAIN_AXIS_TIME_PERIOD_UNIT);
        setAxisBounds(axis, isRangeAxis, timePeriodUnit, axisMinValue, axisMaxValue);

        if (verticalTickLabels != null && axis instanceof ValueAxis) {
            ((ValueAxis) axis).setVerticalTickLabels(verticalTickLabels);
        }
    } else {
        axis.setVisible(false);
    }
}