Java Code Examples for org.jfree.chart.axis.Axis#setVisible()

The following examples show how to use org.jfree.chart.axis.Axis#setVisible() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenericChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * 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
 * @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);
	}
}
 
Example 2
Source File: SimpleChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
	 * 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
	 * @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,
			Paint lineColor,
			AxisSettings axisSettings,
			DateTickUnitType timePeriod,
			Comparable<?> axisMinValue,
			Comparable<?> axisMaxValue
			) throws JRException
	{
		Boolean axisVisible = axisSettings.getVisible();
		
		if (axisVisible == null || axisVisible)
		{
			setAxisLine(axis, lineColor, axisSettings);

//			Double defaultFixedDimension = getAxisSettings(isRangeAxis);
//			if (defaultFixedDimension != null)
//			{
//				axis.setFixedDimension(defaultFixedDimension);
//			}
			
			setAxisLabel(axis, labelFont, labelColor, axisSettings);
			setAxisTickLabels(axis, tickLabelFont, tickLabelColor, tickLabelMask, axisSettings);
			setAxisTickMarks(axis, lineColor, axisSettings);
			setAxisBounds(axis, axisSettings, timePeriod, axisMinValue, axisMaxValue);
			if (verticalTickLabels != null && axis instanceof ValueAxis)
			{
				((ValueAxis)axis).setVerticalTickLabels(verticalTickLabels);
			}
			
		}
		else
		{
			axis.setVisible(false);
		}
	}