Java Code Examples for org.jfree.chart.title.TextTitle#setPadding()

The following examples show how to use org.jfree.chart.title.TextTitle#setPadding() . 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: EyeCandySixtiesChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void configureChart(JFreeChart jfreeChart, JRChartPlot jrPlot) throws JRException
{
	super.configureChart(jfreeChart, jrPlot);

	TextTitle title = jfreeChart.getTitle();
	if (title != null)
	{
		RectangleInsets padding = title.getPadding();
		double bottomPadding = Math.max(padding.getBottom(), 15d);
		title.setPadding(padding.getTop(), padding.getLeft(), bottomPadding, padding.getRight());
	}

	GradientPaint gp = (GradientPaint)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BACKGROUND_PAINT);

	jfreeChart.setBackgroundPaint(new GradientPaint(0f, 0f, gp.getColor1(), 0f, getChart().getHeight() * 0.7f, gp.getColor2(), false));
}
 
Example 2
Source File: AegeanChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void configureChart(JFreeChart jfreeChart, JRChartPlot jrPlot) throws JRException
{

	super.configureChart(jfreeChart, jrPlot);
	TextTitle title = jfreeChart.getTitle();

	if(title != null)
	{
		
		RectangleInsets padding = title.getPadding();
		double bottomPadding = Math.max(padding.getBottom(), 15d);
		title.setPadding(padding.getTop(), padding.getLeft(), bottomPadding, padding.getRight());
	}
}
 
Example 3
Source File: SimpleChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void handleTitleSettings(
		TextTitle title, 
		TitleSettings titleSettings, 
		JRFont titleFont,
		Paint titleForegroundPaint,
		RectangleEdge titleEdge)
{
	JRBaseFont font = new JRBaseFont();
	FontUtil.copyNonNullOwnProperties(titleSettings.getFont(), font);
	FontUtil.copyNonNullOwnProperties(titleFont, font);
	font = new JRBaseFont(getChart(), font);
	title.setFont(getFontUtil().getAwtFont(font, getLocale()));
	
	HorizontalAlignment hAlign = titleSettings.getHorizontalAlignment();
	if (hAlign != null)
		title.setHorizontalAlignment(hAlign);
	
	VerticalAlignment vAlign = titleSettings.getVerticalAlignment();
	if (vAlign != null)
		title.setVerticalAlignment(vAlign);
	
	RectangleInsets padding = titleSettings.getPadding();
	if (padding != null)
		title.setPadding(padding);
	
	if (titleForegroundPaint != null)
		title.setPaint(titleForegroundPaint);

	Paint backPaint = titleSettings.getBackgroundPaint() != null ? titleSettings.getBackgroundPaint().getPaint() : null;
	if (backPaint != null)
		title.setBackgroundPaint(backPaint);
	if (titleEdge != null)
		title.setPosition(titleEdge);
}
 
Example 4
Source File: GenericChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void setChartSubtitles(JFreeChart jfreeChart, Integer baseFontSize) throws JRException
{			
	Boolean subtitleVisibility = (Boolean)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SUBTITLE_VISIBLE);

	if (subtitleVisibility != null && subtitleVisibility)
	{
		String subtitleText = evaluateTextExpression(getChart().getSubtitleExpression());
		if (subtitleText != null)
		{
			TextTitle subtitle = new TextTitle(subtitleText);
			
			Font themeSubtitleFont = getFont((JRFont)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SUBTITLE_FONT), getChart().getSubtitleFont(), baseFontSize);
			subtitle.setFont(themeSubtitleFont);
			
			HorizontalAlignment defaultSubtitleHAlignment = (HorizontalAlignment)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SUBTITLE_HORIZONTAL_ALIGNMENT);
			if (defaultSubtitleHAlignment != null)
				subtitle.setHorizontalAlignment(defaultSubtitleHAlignment);

			VerticalAlignment defaultSubtitleVAlignment = (VerticalAlignment)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SUBTITLE_VERTICAL_ALIGNMENT);
			if (defaultSubtitleVAlignment != null)
				subtitle.setVerticalAlignment(defaultSubtitleVAlignment);
			
			RectangleInsets defaultSubtitlePadding = (RectangleInsets)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SUBTITLE_PADDING);
			RectangleInsets subtitlePadding = subtitle.getPadding() != null ? subtitle.getPadding() : defaultSubtitlePadding;
			if (subtitlePadding != null)
				subtitle.setPadding(subtitlePadding);

			Color subtitleForecolor = getChart().getOwnSubtitleColor() != null ? 
					getChart().getOwnSubtitleColor() :
					(getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SUBTITLE_FORECOLOR) != null ? 
							(Color)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SUBTITLE_FORECOLOR) :
							getChart().getSubtitleColor());
			if (subtitleForecolor != null)
				subtitle.setPaint(subtitleForecolor);

			Color subtitleBackcolor = getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SUBTITLE_BACKCOLOR) != null ? 
					(Color)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SUBTITLE_BACKCOLOR) :
					null;
			if (subtitleBackcolor != null)
				subtitle.setBackgroundPaint(subtitleBackcolor);

			RectangleEdge defaultSubtitlePosition = (RectangleEdge)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SUBTITLE_POSITION);
			//Subtitle has not its own position set, and by default this will be set the same as title position
			RectangleEdge subtitleEdge = null;
			if (defaultSubtitlePosition == null)
			{	
				subtitleEdge = jfreeChart.getTitle().getPosition();
			}
			else
			{
				subtitleEdge = defaultSubtitlePosition;
			}
			if (subtitleEdge != null)
				subtitle.setPosition(subtitleEdge);
			
			jfreeChart.addSubtitle(subtitle);
		}
	}
}