Example usage for org.jfree.chart.title TextTitle setFont

List of usage examples for org.jfree.chart.title TextTitle setFont

Introduction

In this page you can find the example usage for org.jfree.chart.title TextTitle setFont.

Prototype

public void setFont(Font font) 

Source Link

Document

Sets the font used to display the title string.

Usage

From source file:com.rcp.wbw.demo.editor.SWTTitleEditor.java

/**
 * Sets the properties of the specified title to match the properties
 * defined on this panel.//from  w w  w  .  j a  v a  2s. co m
 * 
 * @param chart
 *            the chart whose title is to be modified.
 */
public void setTitleProperties(JFreeChart chart) {
    if (this.showTitle) {
        TextTitle title = chart.getTitle();
        if (title == null) {
            title = new TextTitle();
            chart.setTitle(title);
        }
        title.setText(getTitleText());
        title.setFont(SWTUtils.toAwtFont(getDisplay(), getTitleFont(), true));
        title.setPaint(SWTUtils.toAwtColor(getTitleColor()));
    } else {
        chart.setTitle((TextTitle) null);
    }
}

From source file:ch.zhaw.simulation.diagram.charteditor.DefaultTitleEditor.java

/**
 * Sets the properties of the specified title to match the properties
 * defined on this panel./*from  w w  w. jav a2 s. c o m*/
 * 
 * @param chart
 *            the chart whose title is to be modified.
 */
public void setTitleProperties(JFreeChart chart) {
    TextTitle title = chart.getTitle();
    if (title == null) {
        title = new TextTitle();
        chart.setTitle(title);
    }
    title.setText(getTitleText());
    title.setFont(getTitleFont());
    title.setPaint(getTitlePaint());
    title.setVisible(this.showTitle);
}

From source file:playground.thibautd.analysis.joinabletripsidentifier.DataPloter.java

private void formatChart(final JFreeChart chart) {
    TextTitle title = chart.getTitle();
    Font font = title.getFont();/*from ww  w .j  a  va  2  s .  com*/
    title.setFont(font.deriveFont(TITLE_FONT_SIZE));
    chart.getPlot().setBackgroundPaint(new Color(1.0f, 1.0f, 1.0f, 1.0f));
}

From source file:adapters.HistogramChartAdapter.java

/**
 * Modified method//from w w  w.j a v  a  2s  . com
 *
 * Displays chart on the screen using Swing.
 *    This method creates an application containing a chart panel displaying
 *    the chart. The created frame is positioned on-screen, and displayed before
 *    it is returned. The <TT>width</TT> and the <TT>height</TT>
 *    of the chart are measured in pixels.
 *
 * @param width frame width in pixels.
 *
 *    @param height frame height in pixels.
 *
 *    @return frame containing the chart.
 *
 */
public JFrame view(int width, int height) {
    JFrame myFrame;
    if (chart.getTitle() != null)
        myFrame = new JFrame("Histogram Chart: " + chart.getTitle().getText());
    else
        myFrame = new JFrame("Histogram Chart");
    TextTitle tt = chart.getTitle();
    tt.setFont(new FontUIResource("DensityChartSmallFont", Font.ITALIC, 12));
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(width, height));
    myFrame.setContentPane(chartPanel);
    myFrame.pack();
    myFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    return myFrame;
}

From source file:org.n52.io.measurement.img.ChartIoHandler.java

private void addNotice(JFreeChart chart) {
    TextTitle notice = new TextTitle();
    String msg = i18n.get("msg.io.chart.notice");
    if (msg != null && !msg.isEmpty()) {
        notice.setText(msg);//w  w  w. ja v a 2s .  c  om
        notice.setPaint(BLACK);
        notice.setFont(FONT_LABEL_SMALL);
        notice.setPosition(RectangleEdge.BOTTOM);
        notice.setHorizontalAlignment(HorizontalAlignment.RIGHT);
        notice.setVerticalAlignment(VerticalAlignment.BOTTOM);
        notice.setPadding(new RectangleInsets(0, 0, 20, 20));
        chart.addSubtitle(notice);
    }
}

From source file:unalcol.termites.boxplots.ECALinfoCollected.java

/**
 * Creates a new demo.// www .  java  2s  .c o  m
 *
 * @param title the frame title.
 * @param pf
 */
public ECALinfoCollected(final String title, ArrayList<Double> pf) {
    super(title);
    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf);
    final CategoryAxis xAxis = new CategoryAxis("");
    final NumberAxis yAxis = new NumberAxis("");
    //final NumberAxis yAxis = new NumberAxis("Information Collected");
    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    Font font = new Font("Dialog", Font.PLAIN, 16);
    xAxis.setTickLabelFont(font);
    yAxis.setTickLabelFont(font);
    yAxis.setLabelFont(font);

    final JFreeChart chart = new JFreeChart("Information Collected " + getTitle(pf),
            new Font("SansSerif", Font.BOLD, 18), plot, true);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 370));
    setContentPane(chartPanel);
    TextTitle legendText = null;
    if (pf.size() == 1) {
        legendText = new TextTitle("Population Size");
    } else {
        legendText = new TextTitle("Population Size - Probability of Failure");
    }

    legendText.setFont(font);
    legendText.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendText);
    chart.getLegend().setItemFont(font);
    FileOutputStream output;
    try {
        output = new FileOutputStream("ECALinfoColl" + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 400, 400, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(ECALinfoCollected.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(ECALinfoCollected.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:unalcol.termites.boxplots.RoundNumberGlobal.java

/**
 * Creates a new demo.//from w w w .j a  v a2s . c  om
 *
 * @param title the frame title.
 * @param pf
 */
public RoundNumberGlobal(final String title, ArrayList<Double> pf) {

    super(title);

    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf);

    final CategoryAxis xAxis = new CategoryAxis("");
    //final NumberAxis yAxis = new NumberAxis("Round number");
    final NumberAxis yAxis = new NumberAxis("");
    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    Font font = new Font("Dialog", Font.PLAIN, 16);
    xAxis.setTickLabelFont(font);
    yAxis.setTickLabelFont(font);
    yAxis.setLabelFont(font);

    final JFreeChart chart = new JFreeChart("Round Number" + getTitle(pf), new Font("SansSerif", Font.BOLD, 18),
            plot, true);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 370));
    setContentPane(chartPanel);

    TextTitle legendText = null;
    if (pf.size() == 1) {
        legendText = new TextTitle("Population Size");
    } else {
        legendText = new TextTitle("Population Size - Probability of Failure");
    }

    legendText.setFont(font);
    legendText.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendText);
    chart.getLegend().setItemFont(font);

    FileOutputStream output;
    try {
        output = new FileOutputStream("roundGlobalNumber" + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 400, 400, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(RoundNumberGlobal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(RoundNumberGlobal.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:org.n52.io.type.quantity.handler.img.ChartIoHandler.java

private void addNotice(JFreeChart chart) {
    TextTitle notice = new TextTitle();
    String msg = i18n.get("msg.io.chart.notice");
    if (msg != null && !msg.isEmpty()) {
        notice.setText(msg);/*  w  w w . j  a v  a  2  s  . c o  m*/
        notice.setPaint(Color.BLACK);
        notice.setFont(LabelConstants.FONT_LABEL_SMALL);
        notice.setPosition(RectangleEdge.BOTTOM);
        notice.setHorizontalAlignment(HorizontalAlignment.RIGHT);
        notice.setVerticalAlignment(VerticalAlignment.BOTTOM);
        notice.setPadding(new RectangleInsets(0, 0, 20, 20));
        chart.addSubtitle(notice);
    }
}

From source file:unalcol.termites.boxplots.ECALAgentsRight.java

/**
 * Creates a new demo./*from   ww w . j  a v a 2  s.c  o m*/
 *
 * @param title the frame title.
 * @param pf
 */
public ECALAgentsRight(final String title, ArrayList<Double> pf) {

    super(title);

    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf);

    final CategoryAxis xAxis = new CategoryAxis("");
    //        final NumberAxis yAxis = new NumberAxis("Round number");
    final NumberAxis yAxis = new NumberAxis("");

    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    Font font = new Font("Dialog", Font.PLAIN, 13);
    xAxis.setTickLabelFont(font);
    yAxis.setTickLabelFont(font);
    yAxis.setLabelFont(font);

    final JFreeChart chart = new JFreeChart("Agents Right " + getTitle(pf),
            new Font("SansSerif", Font.BOLD, 18), plot, true);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 370));
    setContentPane(chartPanel);
    TextTitle legendText = null;
    if (pf.size() == 1) {
        legendText = new TextTitle("Population Size");
    } else {
        legendText = new TextTitle("Population Size - Probability of Failure");
    }

    legendText.setFont(font);
    legendText.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendText);
    chart.getLegend().setItemFont(font);

    FileOutputStream output;
    try {
        output = new FileOutputStream("ECALright" + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 400, 400, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(ECALAgentsRight.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(ECALAgentsRight.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:unalcol.termites.boxplots.ECALRoundNumber.java

/**
 * Creates a new demo./* w  w  w. j  a v  a 2  s  .  co m*/
 *
 * @param title the frame title.
 * @param pf
 */
public ECALRoundNumber(final String title, ArrayList<Double> pf) {

    super(title);

    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf);

    final CategoryAxis xAxis = new CategoryAxis("");
    //        final NumberAxis yAxis = new NumberAxis("Round number");
    final NumberAxis yAxis = new NumberAxis("");

    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    Font font = new Font("Dialog", Font.PLAIN, 13);
    xAxis.setTickLabelFont(font);
    yAxis.setTickLabelFont(font);
    yAxis.setLabelFont(font);

    final JFreeChart chart = new JFreeChart("Round Number " + getTitle(pf),
            new Font("SansSerif", Font.BOLD, 18), plot, true);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 370));
    setContentPane(chartPanel);
    TextTitle legendText = null;
    if (pf.size() == 1) {
        legendText = new TextTitle("Population Size");
    } else {
        legendText = new TextTitle("Population Size - Probability of Failure");
    }

    legendText.setFont(font);
    legendText.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendText);
    chart.getLegend().setItemFont(font);

    FileOutputStream output;
    try {
        output = new FileOutputStream("ECALround" + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 400, 400, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(ECALRoundNumber.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(ECALRoundNumber.class.getName()).log(Level.SEVERE, null, ex);
    }

}