Example usage for org.jfree.chart ChartTheme getClass

List of usage examples for org.jfree.chart ChartTheme getClass

Introduction

In this page you can find the example usage for org.jfree.chart ChartTheme getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.rapidminer.gui.viewer.metadata.model.AbstractAttributeStatisticsModel.java

/**
 * 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.//  ww w.  j a v a  2 s  . com
 * 
 * @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 = new Font(Font.SANS_SERIF, oldExtraLargeFont.getStyle(),
                oldExtraLargeFont.getSize());
        final Font largeFont = new Font(Font.SANS_SERIF, oldLargeFont.getStyle(), oldLargeFont.getSize());
        final Font regularFont = new Font(Font.SANS_SERIF, oldRegularFont.getStyle(), oldRegularFont.getSize());
        final Font smallFont = new Font(Font.SANS_SERIF, oldSmallFont.getStyle(), oldSmallFont.getSize());

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

        standardTheme.apply(chart);
    }
}