Example usage for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT

List of usage examples for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT.

Prototype

Font DEFAULT_TITLE_FONT

To view the source code for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT.

Click Source Link

Document

The default font for titles.

Usage

From source file:jgnash.ui.budget.BudgetSparkline.java

public static Icon getSparklineImage(final List<BigDecimal> amounts) {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    final boolean[] negate = new boolean[amounts.size()];

    for (int i = 0; i < amounts.size(); i++) {
        dataset.addValue(amounts.get(i), CATEGORY, i);
        negate[i] = amounts.get(i).signum() == -1;
    }//from   w w  w  .  ja  va2s .c o m

    CategoryAxis xAxis = new CategoryAxis();
    xAxis.setTickLabelsVisible(false);
    xAxis.setTickMarksVisible(false);
    xAxis.setAxisLineVisible(false);
    xAxis.setVisible(false);

    NumberAxis yAxis = new NumberAxis();
    yAxis.setTickLabelsVisible(false);
    yAxis.setTickMarksVisible(false);
    yAxis.setAxisLineVisible(false);
    yAxis.setNegativeArrowVisible(false);
    yAxis.setPositiveArrowVisible(false);
    yAxis.setAutoRangeIncludesZero(true);
    yAxis.setAutoRange(true);
    yAxis.setVisible(false);

    BarRenderer renderer = new BarRenderer() {

        @Override
        public Paint getItemPaint(final int row, final int column) {
            return negate[column] ? Color.RED : Color.BLACK;
        }
    };

    renderer.setShadowVisible(false);
    renderer.setBarPainter(new StandardBarPainter());

    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    plot.setInsets(INSETS);
    plot.setDomainGridlinesVisible(false);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setBackgroundPaint(CLEAR);

    JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    chart.setBorderVisible(false);
    chart.setBackgroundPaint(CLEAR);

    Icon icon = EMPTY_ICON;

    try {
        byte[] image = ENCODER
                .encode(chart.createBufferedImage(DEFAULT_WIDTH, DEFAULT_HEIGHT, BufferedImage.BITMASK, null));
        icon = new ImageIcon(image);
    } catch (IOException ex) {
        Logger.getLogger(BudgetSparkline.class.getName()).log(Level.SEVERE, null, ex);
    }

    return icon;
}

From source file:net.sf.mzmine.chartbasics.gui.javafx.demo.FXCombinedChartGestureDemo.java

private JFreeChart createCombinedChart() {
    // create subplot 1...
    final XYDataset data1 = createDataset();
    final XYItemRenderer renderer1 = new StandardXYItemRenderer();
    final NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);

    // create subplot 2...
    final XYDataset data2 = createDataset();
    final XYItemRenderer renderer2 = new StandardXYItemRenderer();
    final NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);

    // parent plot...
    final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain"));
    plot.setGap(10.0);/*from   w  w w.  j ava 2 s  .c  o  m*/

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);

    // return a new chart containing the overlaid plot...
    return new JFreeChart("CombinedDomainXYPlot Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}

From source file:edu.ucla.stat.SOCR.motionchart.MotionChart.java

/**
 * Creates a new chart based on the supplied dataset.  The chart will have
 * a default title of "Motion Chart"./*from w ww . ja  va 2  s. c  o  m*/
 * A default font is used for the title, and the chart will
 * not have a legend.
 *
 * @param dataset the dataset (<code>null</code> not permitted).
 */
public MotionChart(MotionDataSet dataset) {
    this("SOCR Motion Charts", JFreeChart.DEFAULT_TITLE_FONT, dataset, false);
}

From source file:it.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.Meter.java

/**
 * Creates the MeterChart ./*from  www. j a  v  a 2  s  .c  om*/
 * 
 * @return A MeterChart .
 */
public JFreeChart createChart() {
    logger.debug("IN");
    if (dataset == null) {
        logger.debug("The dataset to be represented is null");
        return null;
    }
    MeterPlot plot = new MeterPlot((ValueDataset) dataset);
    logger.debug("Created new plot");
    plot.setRange(new Range(lower, upper));
    logger.debug("Setted plot range");

    for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
        KpiInterval interval = (KpiInterval) iterator.next();
        plot.addInterval(new MeterInterval(interval.getLabel(), new Range(interval.getMin(), interval.getMax()),
                Color.lightGray, new BasicStroke(2.0f), interval.getColor()));
        logger.debug("Added new interval to the plot");
    }

    plot.setNeedlePaint(Color.darkGray);
    plot.setDialBackgroundPaint(Color.white);
    plot.setDialOutlinePaint(Color.gray);
    plot.setDialShape(DialShape.CHORD);
    plot.setMeterAngle(260);
    plot.setTickLabelsVisible(true);
    Font f = new Font("Arial", Font.PLAIN, 11);
    plot.setTickLabelFont(f);
    plot.setTickLabelPaint(Color.darkGray);
    plot.setTickSize(5.0);
    plot.setTickPaint(Color.lightGray);
    plot.setValuePaint(Color.black);
    plot.setValueFont(new Font("Arial", Font.PLAIN, 14));
    logger.debug("Setted all properties of the plot");

    JFreeChart chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    logger.debug("Created the chart");
    chart.setBackgroundPaint(color);
    logger.debug("Setted background color of the chart");

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    logger.debug("Setted the title of the chart");
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
        logger.debug("Setted the subtitle of the chart");
    }
    logger.debug("OUT");
    return chart;
}

From source file:org.jfree.chart.demo.MeterChartDemo.java

/**
 * Displays a meter chart./*from ww  w.ja v a2s .c o  m*/
 *
 * @param value  the value.
 * @param shape  the dial shape.
 */
void displayMeterChart(final double value, final DialShape shape) {

    final DefaultValueDataset data = new DefaultValueDataset(75.0);
    final MeterPlot plot = new MeterPlot(data);
    plot.setUnits("Degrees");
    plot.setRange(new Range(20.0, 140.0));
    //        plot.setNormalRange(new Range(70.0, 100.0));
    //      plot.setWarningRange(new Range(100.0, 120.0));
    //    plot.setCriticalRange(new Range(120.0, 140.0));

    plot.setDialShape(shape);
    plot.setNeedlePaint(Color.white);
    plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 9));

    //  plot.setInsets(new Insets(5, 5, 5, 5));
    final JFreeChart chart = new JFreeChart("Meter Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    //        final MeterLegend legend = new MeterLegend("Sample Meter");
    //      chart.setLegend(legend);

    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));

    final JFrame chartFrame = new ChartFrame("Meter Chart", chart);
    chartFrame.addWindowListener(new WindowAdapter() {
        /**
         * Invoked when a window is in the process of being closed.
         * The close operation can be overridden at this point.
         */
        public void windowClosing(final WindowEvent e) {
            System.exit(0);
        }
    });
    chartFrame.pack();
    RefineryUtilities.positionFrameRandomly(chartFrame);
    chartFrame.setSize(250, 250);
    chartFrame.setVisible(true);

}

From source file:org.jfree.chart.demo.LayeredBarChartDemo2.java

/**
 * Creates a new demo instance.//from   w  w w . j  a  v  a 2 s. c om
 *
 * @param title  the frame title.
 */
public LayeredBarChartDemo2(final String title) {

    super(title);

    // create a dataset...
    final double[][] data = new double[][] { { 41.0, 33.0, 22.0, 64.0, 42.0, 62.0, 22.0, 14.0 },
            { 55.0, 63.0, 55.0, 48.0, 54.0, 37.0, 41.0, 39.0 },
            { 57.0, 75.0, 43.0, 33.0, 63.0, 46.0, 57.0, 33.0 } };

    final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Series ", "Factor ", data);

    // create the chart...
    final CategoryAxis categoryAxis = new CategoryAxis("Category");
    final ValueAxis valueAxis = new NumberAxis("Score (%)");

    final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, new LayeredBarRenderer());

    plot.setOrientation(PlotOrientation.VERTICAL);
    final JFreeChart chart = new JFreeChart("Layered Bar Chart Demo 2", JFreeChart.DEFAULT_TITLE_FONT, plot,
            true);

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.lightGray);

    final LayeredBarRenderer renderer = (LayeredBarRenderer) plot.getRenderer();

    // we can set each series bar width individually or let the renderer manage a standard view.
    // the width is set in percentage, where 1.0 is the maximum (100%).
    renderer.setSeriesBarWidth(0, 1.0);
    renderer.setSeriesBarWidth(1, 0.7);
    renderer.setSeriesBarWidth(2, 0.5);

    renderer.setItemMargin(0.01);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryMargin(0.25);
    domainAxis.setUpperMargin(0.05);
    domainAxis.setLowerMargin(0.05);

    // add the chart to a panel...
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}

From source file:br.prof.salesfilho.oci.image.GraphicBuilder.java

public void createCombinedChart(Map<String, double[]> mapSeries, String legendTitle) {
    XYSeriesCollection xds;/*from  w  ww .jav a 2  s  .c om*/
    final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis(legendTitle));
    plot.setGap(10.0);
    for (Map.Entry<String, double[]> entrySet : mapSeries.entrySet()) {
        String serieName = entrySet.getKey();
        double[] values = entrySet.getValue();

        final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

        final XYSeries series = new XYSeries(serieName);
        for (int i = 0; i < values.length; i++) {
            series.add(i, Precision.round(values[i], 2));
            renderer.setSeriesVisible(i, true, true);
            renderer.setSeriesShapesVisible(i, true);
        }
        xds = new XYSeriesCollection();
        xds.addSeries(series);

        final NumberAxis rangeAxis = new NumberAxis(serieName);

        final XYPlot subplot = new XYPlot(xds, null, rangeAxis, renderer);
        subplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
        plot.add(subplot);

    }
    this.chart = new JFreeChart(this.title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    chartPanel.setChart(chart);
}

From source file:playground.yu.utils.charts.XYScatterLineChart.java

private JFreeChart createChart(final String title, final String categoryAxisLabel, final String valueAxisLabel,
        final XYSeriesCollection dataset) {
    // return ChartFactory.createScatterPlot(title, categoryAxisLabel,
    // valueAxisLabel, dataset, PlotOrientation.VERTICAL, true, // legend?
    // false, // tooltips?
    // false // URLs?
    // );//from  ww  w .  jav  a  2 s  . c  om
    NumberAxis xAxis = new NumberAxis(categoryAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setRange(0, 24);
    NumberAxis yAxis = new NumberAxis(valueAxisLabel);
    yAxis.setAutoRangeIncludesZero(true);
    yAxis.setRange(0, 100);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);

    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, true);
    renderer.setBaseToolTipGenerator(null/* XYToolTipGenerator */);
    renderer.setURLGenerator(null/* urlGenerator */);
    plot.setRenderer(renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true/* legend */);
    return chart;
}

From source file:org.jtotus.gui.graph.GraphPrinter.java

private JFreeChart createChart(String title) {

    // valueAxis.setAutoRangeMinimumSize(1);
    DateAxis domain = new DateAxis("Date");
    domain.setDateFormatOverride(new SimpleDateFormat("dd-MM-yyyy"));

    mainPlot = new CombinedDomainXYPlot(domain);
    mainPlot.setGap(4.0);//from w  w  w .ja  v  a  2 s  .  c  o m
    //mainPlot.setOrientation(PlotOrientation.HORIZONTAL);
    mainPlot.setBackgroundPaint(Color.lightGray);
    mainPlot.setRangePannable(true);
    mainPlot.setDomainGridlinesVisible(true);
    mainPlot.setOutlineVisible(true);
    mainPlot.setDomainCrosshairVisible(true);
    mainPlot.setRangeMinorGridlinesVisible(true);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true);

    chart.setBackgroundPaint(Color.white);

    return chart;

}

From source file:de.iteratec.visualizationmodel.jfreechart.ChartFactory.java

public JFreeChart createXYStepChart(XYDataset dataset) {
    XYToolTipGenerator toolTipGenerator = !showTooltips ? null : new StandardXYToolTipGenerator();
    XYURLGenerator urlGenerator = !showUrls ? null : new StandardXYURLGenerator();
    XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, urlGenerator);

    XYPlot plot = new XYPlot(dataset, (ValueAxis) xAxis, (ValueAxis) yAxis, null);
    plot.setRenderer(renderer);/*from  w  w w  .j  a v a  2  s .  c  o m*/
    plot.setOrientation(orientation);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(5.0f));
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend);
    THEME.apply(chart);
    return chart;
}