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

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

Introduction

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

Prototype

public void setPosition(RectangleEdge position) 

Source Link

Document

Sets the position for the title and sends a TitleChangeEvent to all registered listeners.

Usage

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

/**
 * Creates a new demo.//  w w  w . j a v a2s .  co  m
 *
 * @param title the frame title.
 * @param pf
 */
public HybridRoundNumberReport(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, 14);
    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("roundnumber1" + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 1350, 400, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(HybridRoundNumberReport.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(HybridRoundNumberReport.class.getName()).log(Level.SEVERE, null, ex);
    }

}

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

/**
 * Creates a new demo./*  w  w w  .ja va 2 s  .  c o m*/
 *
 * @param title the frame title.
 * @param pf
 */
public HybridInformationCollected(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, 12);
    xAxis.setTickLabelFont(font);
    yAxis.setTickLabelFont(font);
    yAxis.setLabelFont(font);

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

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(1300, 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("totalInformationCollected" + pf + mazeMode + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 1300, 400, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(HybridInformationCollected.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(HybridInformationCollected.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);//from   ww w  . j  av  a2 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:edu.ucla.stat.SOCR.chart.demo.AreaChartDemo1.java

/**
 * Creates a Area chart./*from  ww w  . j  av  a 2s  .com*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createAreaChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    if (isDemo) {
        TextTitle subtitle = new TextTitle("An area chart demonstration.  We use this subtitle as an "
                + "example of what happens when you get a really long title or " + "subtitle.");
        subtitle.setFont(new Font("SansSerif", Font.PLAIN, 12));
        subtitle.setPosition(RectangleEdge.TOP);
        subtitle.setPadding(new RectangleInsets(UnitType.RELATIVE, 0.05, 0.05, 0.05, 0.05));
        subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM);
        chart.addSubtitle(subtitle);
    }

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setForegroundAlpha(0.5f);

    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    AreaRenderer renderer = (AreaRenderer) plot.getRenderer();
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    if (isDemo) {
        domainAxis.addCategoryLabelToolTip("Type 1", "The first type.");
        domainAxis.addCategoryLabelToolTip("Type 2", "The second type.");
        domainAxis.addCategoryLabelToolTip("Type 3", "The third type.");
    }
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelAngle(0 * Math.PI / 2.0);
    // OPTIONAL CUSTOMISATION COMPLETED.

    setCategorySummary(dataset);
    return chart;

}

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

/**
 * Creates a new demo./*from ww w.java2  s. co m*/
 *
 * @param title the frame title.
 * @param pf
 */
public MessagesSent1(final String title, ArrayList<Double> pf) {

    super(title);

    final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf);

    final CategoryAxis xAxis = new CategoryAxis("");
    //final NumberAxis yAxis = new NumberAxis("Messages Sent");
    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("Messages Sent " + 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("messagesnumber1" + pf + mazeMode + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 400, 400, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex);
    }
}

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

/**
 * Creates a new demo.//from  w  w  w  .ja  va2 s . c  o m
 *
 * @param title the frame title.
 * @param pf
 */
public InformationCollected1(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, 14);
    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("informationcollected1" + mazeMode + pf + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 450, 400, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(InformationCollected1.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(InformationCollected1.class.getName()).log(Level.SEVERE, null, ex);
    }
}

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

/**
 * Creates a new demo.//from   w ww.  ja v  a 2s  . co  m
 *
 * @param title the frame title.
 * @param pf
 */
public RoundNumber1(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("roundnumber1" + pf + mazeMode + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 450, 400, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(RoundNumber1.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(RoundNumber1.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:org.squale.squaleweb.util.graph.BubbleMaker.java

/**
 * Affichage sous la forme de sous-titres de la rpartition des mthodes - Maintenable et structur, - Maintenable
 * mais mal structur - Difficilement maintenable mais structur - Difficilement maintenable et mal structur
 * /*from w  w  w  .  j  a  v  a 2s  . c om*/
 * @param pChart graphe de type Bubble
 */
private void displayRepartitionSubtitles(JFreeChart pChart) {
    double percentTopLeft = 0;
    double percentTopRight = 0;
    double percentBottomLeft = 0;
    double percentBottomRight = 0;
    int totalMethods = (int) (totalTopLeft + totalTopRight + totalBottomLeft + totalBottomRight);
    if (totalMethods > 0) {
        final int oneHundred = 100;
        // haut gauche : difficilement maintenable mais structur
        percentTopLeft = totalTopLeft * oneHundred / totalMethods;
        // haut droit : difficilement maintenable et mal structur
        percentTopRight = totalTopRight * oneHundred / totalMethods;
        // Bas gauche : maintenable et structur
        percentBottomLeft = totalBottomLeft * oneHundred / totalMethods;
        // Bas droit : maintenable mais mal structur
        percentBottomRight = totalBottomRight * oneHundred / totalMethods;
    }
    // Formatage des zones d'affichage
    NumberFormat numberFormat = NumberFormat.getInstance();
    numberFormat.setMaximumFractionDigits(1);
    numberFormat.setMinimumFractionDigits(1);
    // Ajout du sous-titre de rpartition des mthodes avec le pourcentage correspondant : partie suprieure, coin
    // gauche et droit
    StringBuffer stringBufferTop = new StringBuffer();
    stringBufferTop.append(WebMessages.getString(locale, "bubble.project.subtitle.topLeft") + " "
            + numberFormat.format(percentTopLeft) + "%     ");
    stringBufferTop.append(WebMessages.getString(locale, "bubble.project.subtitle.topRight") + " "
            + numberFormat.format(percentTopRight) + "%");
    TextTitle subtitleTop = new TextTitle(stringBufferTop.toString());

    // Ajout du sous-titre de rpartition des mthodes avec le pourcentage correspondant : partie infrieure, coin
    // gauche et droit
    StringBuffer stringBufferBottom = new StringBuffer();
    stringBufferBottom.append(WebMessages.getString(locale, "bubble.project.subtitle.bottomLeft") + " "
            + numberFormat.format(percentBottomLeft) + "%     ");
    stringBufferBottom.append(WebMessages.getString(locale, "bubble.project.subtitle.bottomRight") + " "
            + numberFormat.format(percentBottomRight) + "%");
    TextTitle subtitleBottom = new TextTitle(stringBufferBottom.toString());

    // Les rpartitions sont ajoutes sous la forme de sous-menus
    subtitleBottom.setPosition(RectangleEdge.BOTTOM);
    pChart.addSubtitle(subtitleBottom);
    subtitleTop.setPosition(RectangleEdge.BOTTOM);
    pChart.addSubtitle(subtitleTop);
}

From source file:org.toobsframework.pres.chart.ChartBuilder.java

private JFreeChart finishChart(IRequest componentRequest, ChartDefinition chartDef, Plot plot, Map params) {

    JFreeChart chart = new JFreeChart(
            ChartUtil.evaluateTextLabel(componentRequest, chartDef.getTitle(), params),
            ChartUtil.getFont(chartDef.getTitle(), JFreeChart.DEFAULT_TITLE_FONT), plot,
            chartDef.isShowLegend());//from   w  ww .  j  a  v  a2 s  .  c  o  m

    if (chartDef.getSubtitle() != null) {
        TextTitle subtitle = new TextTitle(
                ChartUtil.evaluateTextLabel(componentRequest, chartDef.getSubtitle(), params));
        if (chartDef.getSubtitle().getFont() != null) {
            subtitle.setFont(ChartUtil.getFont(chartDef.getSubtitle(), null));
        }
        subtitle.setPosition(ChartUtil.getPosition(chartDef.getSubtitle().getPosition()));
        subtitle.setPadding(
                ChartUtil.getRectangle(componentRequest, chartDef.getSubtitle().getPadding(), params));
        subtitle.setVerticalAlignment(
                ChartUtil.getVerticalAlignment(chartDef.getSubtitle().getVerticalAlignment()));
        subtitle.setPaint(ChartUtil.getColor(chartDef.getSubtitle().getColor()));
        chart.addSubtitle(subtitle);
    }

    chart.setBackgroundPaint(ChartUtil.getColor(chartDef.getBackgroundColor()));
    if (chartDef.getTitle() != null && chartDef.getTitle().getColor() != null) {
        chart.getTitle().setPaint(ChartUtil.getColor(chartDef.getTitle().getColor()));
    }

    if (chartDef.isShowLegend()) {
        ChartUtil.configureLegend(componentRequest, chart, chartDef.getLegend(), params);
    }

    return chart;
}

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

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

    super(title);
    String sDirectorio = experimentsDir;

    Hashtable<String, List> info = new Hashtable();

    //String[] aMode = {"levywalk", "lwphevap", "hybrid", "hybrid3", "hybrid4"};
    /*for (String mode : aMode) {
     info.put(mode, new ArrayList());
     }*/
    createSampleDataset(pf, info);
    AddDataFailingExperiments(sDirectorio, pf, info);
    final BoxAndWhiskerCategoryDataset dataset = addDataSet(info);

    final CategoryAxis xAxis = new CategoryAxis("");
    //final NumberAxis yAxis = new NumberAxis("Information Collected");
    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("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("BestAgentsPercentageInfoCollected" + pf + mazeMode + ".jpg");
        ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 350, 350, null);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(BestAgentsPercentageInfoCollected.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(BestAgentsPercentageInfoCollected.class.getName()).log(Level.SEVERE, null, ex);
    }
}