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

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

Introduction

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

Prototype

public void setAxisLinePaint(Paint paint) 

Source Link

Document

Sets the paint used to draw the axis line and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.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 va  2 s.  com*/
 * @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
 */
protected void configureAxis(Axis axis, JRFont labelFont, Color labelColor, JRFont tickLabelFont,
        Color tickLabelColor, String tickLabelMask, Boolean verticalTickLabels, Color lineColor,
        boolean isRangeAxis, Comparable<?> axisMinValue, Comparable<?> axisMaxValue) {
    axis.setLabelFont(fontUtil.getAwtFont(getFont(labelFont), getLocale()));
    axis.setTickLabelFont(fontUtil.getAwtFont(getFont(tickLabelFont), getLocale()));
    if (labelColor != null) {
        axis.setLabelPaint(labelColor);
    }

    if (tickLabelColor != null) {
        axis.setTickLabelPaint(tickLabelColor);
    }

    if (lineColor != null) {
        axis.setAxisLinePaint(lineColor);
        axis.setTickMarkPaint(lineColor);
    }

    TimeZone timeZone = chartContext.getTimeZone();
    if (axis instanceof DateAxis && timeZone != null) {
        // used when no mask is set
        ((DateAxis) axis).setTimeZone(timeZone);
    }

    // FIXME use locale for formats
    if (tickLabelMask != null) {
        if (axis instanceof NumberAxis) {
            NumberFormat fmt = NumberFormat.getInstance(getLocale());
            if (fmt instanceof DecimalFormat) {
                ((DecimalFormat) fmt).applyPattern(tickLabelMask);
            }
            ((NumberAxis) axis).setNumberFormatOverride(fmt);
        } else if (axis instanceof DateAxis) {
            DateFormat fmt;
            if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) {
                fmt = DateFormat.getDateInstance(DateFormat.SHORT, getLocale());
            } else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) {
                fmt = DateFormat.getDateInstance(DateFormat.MEDIUM, getLocale());
            } else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) {
                fmt = DateFormat.getDateInstance(DateFormat.LONG, getLocale());
            } else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) {
                fmt = DateFormat.getDateInstance(DateFormat.FULL, getLocale());
            } else {
                fmt = new SimpleDateFormat(tickLabelMask, getLocale());
            }

            if (timeZone != null) {
                fmt.setTimeZone(timeZone);
            }

            ((DateAxis) axis).setDateFormatOverride(fmt);
        }
        // ignore mask for other axis types.
    }

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

    setAxisBounds(axis, isRangeAxis, axisMinValue, axisMaxValue);
}

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

protected void setAxisLine(Axis axis, Paint lineColor, AxisSettings axisSettings) {
    Boolean axisLineVisible = axisSettings.getLineVisible();
    if (axisLineVisible == null || axisLineVisible.booleanValue()) {
        Paint linePaint = lineColor;
        if (linePaint == null && axisSettings.getLinePaint() != null) {
            linePaint = axisSettings.getLinePaint().getPaint();
        }/* w  ww. j  av a2s . co m*/
        if (linePaint != null) {
            axis.setAxisLinePaint(linePaint);
        }
        Stroke axisLineStroke = axisSettings.getLineStroke();
        if (axisLineStroke != null)
            axis.setAxisLineStroke(axisLineStroke);
    } else {
        axis.setAxisLineVisible(false);
    }
}

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

protected void setAxisLine(Axis axis, Paint lineColor) {
    Boolean defaultAxisLineVisible = (Boolean) getDefaultValue(defaultAxisPropertiesMap,
            ChartThemesConstants.AXIS_LINE_VISIBLE);
    if (defaultAxisLineVisible != null && defaultAxisLineVisible.booleanValue()) {
        Paint linePaint = lineColor != null ? lineColor
                : (Paint) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_LINE_PAINT);

        if (linePaint != null) {
            axis.setAxisLinePaint(linePaint);
        }//w ww .  j  a v  a 2 s  . co m
        Stroke defaultAxisLineStroke = (Stroke) getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_LINE_STROKE);
        if (defaultAxisLineStroke != null)
            axis.setAxisLineStroke(defaultAxisLineStroke);
    }
}

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

protected void setAxisLine(Axis axis, Paint lineColor, AxisSettings axisSettings) {
    Boolean axisLineVisible = axisSettings.getLineVisible();
    if (axisLineVisible == null || axisLineVisible) {
        Paint linePaint = lineColor;
        if (linePaint == null && axisSettings.getLinePaint() != null) {
            linePaint = axisSettings.getLinePaint().getPaint();
        }/*  w  w  w.j a  v  a  2s . c  o m*/
        if (linePaint != null) {
            axis.setAxisLinePaint(linePaint);
        }
        Stroke axisLineStroke = axisSettings.getLineStroke();
        if (axisLineStroke != null)
            axis.setAxisLineStroke(axisLineStroke);
    } else {
        axis.setAxisLineVisible(false);
    }
}

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

protected void setAxisLine(Axis axis, Paint lineColor) {
    Boolean defaultAxisLineVisible = (Boolean) getDefaultValue(defaultAxisPropertiesMap,
            ChartThemesConstants.AXIS_LINE_VISIBLE);
    if (defaultAxisLineVisible != null && defaultAxisLineVisible) {
        Paint linePaint = lineColor != null ? lineColor
                : (Paint) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_LINE_PAINT);

        if (linePaint != null) {
            axis.setAxisLinePaint(linePaint);
        }/*from   w  w  w .  j  av a  2  s. c om*/
        Stroke defaultAxisLineStroke = (Stroke) getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_LINE_STROKE);
        if (defaultAxisLineStroke != null)
            axis.setAxisLineStroke(defaultAxisLineStroke);
    }
}