Java Code Examples for org.jfree.chart.StandardChartTheme#setLargeFont()

The following examples show how to use org.jfree.chart.StandardChartTheme#setLargeFont() . 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: GraphData.java    From iBioSim with Apache License 2.0 6 votes vote down vote up
public void applyChartTheme() {
	final StandardChartTheme chartTheme = (StandardChartTheme) org.jfree.chart.StandardChartTheme
			.createJFreeTheme();

	final Font oldExtraLargeFont = chartTheme.getExtraLargeFont();
	final Font oldLargeFont = chartTheme.getLargeFont();
	final Font oldRegularFont = chartTheme.getRegularFont();
	final Font oldSmallFont = chartTheme.getSmallFont();

	final Font extraLargeFont = new Font("Sans-serif", oldExtraLargeFont.getStyle(), oldExtraLargeFont.getSize());
	final Font largeFont = new Font("Sans-serif", oldLargeFont.getStyle(), oldLargeFont.getSize());
	final Font regularFont = new Font("Sans-serif", oldRegularFont.getStyle(), oldRegularFont.getSize());
	final Font smallFont = new Font("Sans-serif", oldSmallFont.getStyle(), oldSmallFont.getSize());

	chartTheme.setExtraLargeFont(extraLargeFont);
	chartTheme.setLargeFont(largeFont);
	chartTheme.setRegularFont(regularFont);
	chartTheme.setSmallFont(smallFont);

	chartTheme.apply(chart);
}
 
Example 2
Source File: AbstractBeltColumnStatisticsModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Changes the font of {@link JFreeChart}s to Sans Serif. This method uses a
 * {@link StandardChartTheme} to do so, so any changes to the look of the chart must be done
 * after calling this method.
 *
 * @param chart
 *            the chart to change fonts for
 */
static void setDefaultChartFonts(JFreeChart chart) {
	final ChartTheme chartTheme = StandardChartTheme.createJFreeTheme();

	if (StandardChartTheme.class.isAssignableFrom(chartTheme.getClass())) {
		StandardChartTheme standardTheme = (StandardChartTheme) chartTheme;
		// The default font used by JFreeChart cannot render japanese etc symbols
		final Font oldExtraLargeFont = standardTheme.getExtraLargeFont();
		final Font oldLargeFont = standardTheme.getLargeFont();
		final Font oldRegularFont = standardTheme.getRegularFont();
		final Font oldSmallFont = standardTheme.getSmallFont();

		final Font extraLargeFont = FontTools.getFont(Font.SANS_SERIF, oldExtraLargeFont.getStyle(),
				oldExtraLargeFont.getSize());
		final Font largeFont = FontTools.getFont(Font.SANS_SERIF, oldLargeFont.getStyle(), oldLargeFont.getSize());
		final Font regularFont = FontTools.getFont(Font.SANS_SERIF, oldRegularFont.getStyle(), oldRegularFont.getSize());
		final Font smallFont = FontTools.getFont(Font.SANS_SERIF, oldSmallFont.getStyle(), oldSmallFont.getSize());

		standardTheme.setExtraLargeFont(extraLargeFont);
		standardTheme.setLargeFont(largeFont);
		standardTheme.setRegularFont(regularFont);
		standardTheme.setSmallFont(smallFont);

		standardTheme.apply(chart);
	}
}
 
Example 3
Source File: AbstractAttributeStatisticsModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Changes the font of {@link JFreeChart}s to Sans Serif. This method uses a
 * {@link StandardChartTheme} to do so, so any changes to the look of the chart must be done
 * after calling this method.
 *
 * @param chart
 *            the chart to change fonts for
 */
protected static void setDefaultChartFonts(JFreeChart chart) {
	final ChartTheme chartTheme = StandardChartTheme.createJFreeTheme();

	if (StandardChartTheme.class.isAssignableFrom(chartTheme.getClass())) {
		StandardChartTheme standardTheme = (StandardChartTheme) chartTheme;
		// The default font used by JFreeChart cannot render japanese etc symbols
		final Font oldExtraLargeFont = standardTheme.getExtraLargeFont();
		final Font oldLargeFont = standardTheme.getLargeFont();
		final Font oldRegularFont = standardTheme.getRegularFont();
		final Font oldSmallFont = standardTheme.getSmallFont();

		final Font extraLargeFont = FontTools.getFont(Font.SANS_SERIF, oldExtraLargeFont.getStyle(),
				oldExtraLargeFont.getSize());
		final Font largeFont = FontTools.getFont(Font.SANS_SERIF, oldLargeFont.getStyle(), oldLargeFont.getSize());
		final Font regularFont = FontTools.getFont(Font.SANS_SERIF, oldRegularFont.getStyle(), oldRegularFont.getSize());
		final Font smallFont = FontTools.getFont(Font.SANS_SERIF, oldSmallFont.getStyle(), oldSmallFont.getSize());

		standardTheme.setExtraLargeFont(extraLargeFont);
		standardTheme.setLargeFont(largeFont);
		standardTheme.setRegularFont(regularFont);
		standardTheme.setSmallFont(smallFont);

		standardTheme.apply(chart);
	}
}
 
Example 4
Source File: ScatterPlot.java    From Benchmark with GNU General Public License v2.0 6 votes vote down vote up
public static StandardChartTheme initializeTheme() {
    String fontName = "Arial";
    StandardChartTheme theme = (StandardChartTheme) org.jfree.chart.StandardChartTheme.createJFreeTheme();
    theme.setExtraLargeFont(new Font(fontName, Font.PLAIN, 24)); // title
    theme.setLargeFont(new Font(fontName, Font.PLAIN, 20)); // axis-title
    theme.setRegularFont(new Font(fontName, Font.PLAIN, 16));
    theme.setSmallFont(new Font(fontName, Font.PLAIN, 12));
    theme.setRangeGridlinePaint(Color.decode("#C0C0C0"));
    theme.setPlotBackgroundPaint(Color.white);
    theme.setChartBackgroundPaint(Color.white);
    theme.setGridBandPaint(Color.red);
    theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
    theme.setBarPainter(new StandardBarPainter());
    theme.setAxisLabelPaint(Color.decode("#666666"));
    return theme;
}
 
Example 5
Source File: ChartTheme.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
private static StandardChartTheme getChartTheme(StandardChartTheme standardChartTheme, boolean shadow) {
    standardChartTheme.setExtraLargeFont(new Font(Font.DIALOG, Font.BOLD, 24));
    standardChartTheme.setLargeFont(new Font(Font.DIALOG, Font.PLAIN, 18));
    standardChartTheme.setRegularFont(new Font(Font.DIALOG, Font.PLAIN, 14));
    standardChartTheme.setSmallFont(new Font(Font.DIALOG, Font.PLAIN, 10));
    standardChartTheme.setTitlePaint(Color.BLACK);
    standardChartTheme.setSubtitlePaint(Color.BLACK);
    standardChartTheme.setLegendBackgroundPaint(Color.WHITE);
    standardChartTheme.setLegendItemPaint(Color.BLACK);
    standardChartTheme.setChartBackgroundPaint(Color.WHITE);
    standardChartTheme.setDrawingSupplier(new DefaultDrawingSupplier());
    standardChartTheme.setPlotBackgroundPaint(Color.WHITE);
    standardChartTheme.setPlotOutlinePaint(Color.BLACK);
    standardChartTheme.setLabelLinkStyle(PieLabelLinkStyle.STANDARD);
    standardChartTheme.setAxisOffset(new RectangleInsets(4, 4, 4, 4));
    standardChartTheme.setDomainGridlinePaint(Color.LIGHT_GRAY);
    standardChartTheme.setRangeGridlinePaint(Color.LIGHT_GRAY);
    standardChartTheme.setBaselinePaint(Color.BLACK);
    standardChartTheme.setCrosshairPaint(Color.BLACK);
    standardChartTheme.setAxisLabelPaint(Color.DARK_GRAY);
    standardChartTheme.setTickLabelPaint(Color.DARK_GRAY);
    standardChartTheme.setBarPainter(new StandardBarPainter());
    standardChartTheme.setXYBarPainter(new StandardXYBarPainter());
    standardChartTheme.setShadowVisible(shadow);
    standardChartTheme.setItemLabelPaint(Color.BLACK);
    standardChartTheme.setThermometerPaint(Color.WHITE);
    standardChartTheme.setErrorIndicatorPaint(Color.RED);
    return standardChartTheme;
}
 
Example 6
Source File: ChartWriterFactory.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
private static void notSoUglyPlease(JFreeChart chart) {
	String fontName = "Lucida Sans";

	StandardChartTheme theme = (StandardChartTheme)org.jfree.chart.StandardChartTheme.createJFreeTheme();

	theme.setTitlePaint( Color.decode("#4572a7") );
	theme.setExtraLargeFont(new Font(fontName, Font.BOLD, 14)); //title
	theme.setLargeFont(new Font(fontName, Font.BOLD, 15)); //axis-title
	theme.setRegularFont(new Font(fontName, Font.PLAIN, 11));
	theme.setRangeGridlinePaint(Color.decode("#C0C0C0"));
	theme.setPlotBackgroundPaint(Color.white);
	theme.setChartBackgroundPaint(Color.white);
	theme.setGridBandPaint(Color.red);
	theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
	theme.setBarPainter(new StandardBarPainter());
	theme.setAxisLabelPaint(Color.decode("#666666"));
	theme.apply(chart);
	chart.getCategoryPlot().setOutlineVisible(false);
	chart.getCategoryPlot().getRangeAxis().setAxisLineVisible(false);
	chart.getCategoryPlot().getRangeAxis().setTickMarksVisible(false);
	chart.getCategoryPlot().setRangeGridlineStroke(new BasicStroke());
	chart.getCategoryPlot().getRangeAxis().setTickLabelPaint(Color.decode("#666666"));
	chart.getCategoryPlot().getDomainAxis().setTickLabelPaint(Color.decode("#666666"));
	chart.setTextAntiAlias(true);
	chart.setAntiAlias(true);
	BarRenderer rend = (BarRenderer) chart.getCategoryPlot().getRenderer();
	rend.setShadowVisible(true);
	rend.setShadowXOffset(2);
	rend.setShadowYOffset(0);
	rend.setShadowPaint(Color.decode("#C0C0C0"));
	rend.setMaximumBarWidth(0.1);
}
 
Example 7
Source File: ChartUtils.java    From PDV with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Set theme
 */
private static void setChartTheme() {
    StandardChartTheme chartTheme = new StandardChartTheme("US");
    chartTheme.setExtraLargeFont(new Font("Arial", Font.BOLD, 14));
    chartTheme.setRegularFont(new Font("Arial", Font.PLAIN, 13));
    chartTheme.setLargeFont(new Font("Arial", Font.PLAIN, 14));
    chartTheme.setSmallFont(new Font("Arial", Font.PLAIN, 12));
    chartTheme.setTitlePaint(new Color(51, 51, 51));
    chartTheme.setSubtitlePaint(new Color(85, 85, 85));

    chartTheme.setLegendBackgroundPaint(Color.WHITE);
    chartTheme.setLegendItemPaint(Color.BLACK);
    chartTheme.setChartBackgroundPaint(Color.WHITE);

    Paint[] OUTLINE_PAINT_SEQUENCE = new Paint[] { Color.WHITE };
    DefaultDrawingSupplier drawingSupplier = new DefaultDrawingSupplier(CHART_COLORS, CHART_COLORS, OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE);
    chartTheme.setDrawingSupplier(drawingSupplier);

    chartTheme.setPlotBackgroundPaint(Color.WHITE);
    chartTheme.setPlotOutlinePaint(Color.WHITE);
    chartTheme.setLabelLinkPaint(new Color(8, 55, 114));
    chartTheme.setLabelLinkStyle(PieLabelLinkStyle.CUBIC_CURVE);

    chartTheme.setAxisOffset(new RectangleInsets(5, 12, 5, 12));
    chartTheme.setDomainGridlinePaint(new Color(192, 208, 224));
    chartTheme.setRangeGridlinePaint(new Color(192, 192, 192));

    chartTheme.setBaselinePaint(Color.WHITE);
    chartTheme.setCrosshairPaint(Color.BLUE);
    chartTheme.setAxisLabelPaint(new Color(51, 51, 51));
    chartTheme.setTickLabelPaint(new Color(67, 67, 72));
    chartTheme.setBarPainter(new StandardBarPainter());
    chartTheme.setXYBarPainter(new StandardXYBarPainter());

    chartTheme.setItemLabelPaint(Color.black);
    chartTheme.setThermometerPaint(Color.white);

    ChartFactory.setChartTheme(chartTheme);
}