Example usage for org.jfree.chart JFreeChart getTitle

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

Introduction

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

Prototype

public TextTitle getTitle() 

Source Link

Document

Returns the main chart title.

Usage

From source file:Gui.Graficos.java

private void init(String titulo, String tituloX, String tituloY) {

    panel = new JPanel();
    panel.setBackground(Color.WHITE);

    getContentPane().add(panel);//from  w w w  .  ja  v  a 2s  .co m

    // Creando el Grafico

    JFreeChart chart = ChartFactory.createBarChart3D(titulo, tituloX, tituloY, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    chart.setBackgroundPaint(new Color(225, 255, 228));
    chart.getTitle().setPaint(Color.black);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.red);

    // Mostrar Grafico

    ChartPanel chartPanel = new ChartPanel(chart);
    panel.add(chartPanel);

    // panel.setLayout(new VerticalLayout());

    panel.add(btAceptar);

    //panel.
    panel.setLayout(null);

    chartPanel.setBounds(100, 10, 1100, 600);
    btAceptar.setBounds(1065, 620, 130, 30);

}

From source file:info.novatec.testit.livingdoc.confluence.macros.historic.LinearExecutionChartBuilder.java

@SuppressWarnings("deprecation")
private void customizeChart(JFreeChart chart) {
    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(settings.isBorder());

    TextTitle chartTitle = chart.getTitle();
    customizeTitle(chartTitle, DEFAULT_TITLE_FONT);

    addSubTitle(chart, settings.getSubTitle(), DEFAULT_SUBTITLE_FONT);
    addSubTitle(chart, settings.getSubTitle2(), DEFAULT_SUBTITLE2_FONT);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setNoDataMessage(ldUtil.getText("livingdoc.historic.nodata"));

    CategoryItemRenderer renderer = plot.getRenderer();

    int index = 0;
    renderer.setSeriesPaint(index++, GREEN_COLOR);
    if (settings.isShowIgnored()) {
        renderer.setSeriesPaint(index++, Color.yellow);
    }//from  w ww.j a  va  2 s.co  m
    renderer.setSeriesPaint(index, Color.red);

    renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
    renderer.setItemURLGenerator(new CategoryURLGenerator() {

        @Override
        public String generateURL(CategoryDataset data, int series, int category) {
            Comparable<?> valueKey = data.getColumnKey(category);
            ChartLongValue value = (ChartLongValue) valueKey;
            return "javascript:" + settings.getExecutionUID() + "_showExecutionResult('" + value.getId()
                    + "');";
        }
    });

    CategoryAxis domainAxis = plot.getDomainAxis();
    customizeAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);

    ValueAxis rangeAxis = plot.getRangeAxis();
    customizeAxis(rangeAxis);
    rangeAxis.setLowerBound(0);

    if (rangeAxis instanceof NumberAxis) {
        ((NumberAxis) rangeAxis).setTickUnit(new NumberTickUnit(1));
    }

    plot.setForegroundAlpha(0.8f);
}

From source file:edu.ucla.stat.SOCR.chart.demo.PieChartDemo1.java

/**
 * Creates a chart//from   w w  w  .  j  a va  2s . co  m
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(PieDataset dataset) {
    JFreeChart chart = ChartFactory.createPieChart(chartTitle, // chart title
            dataset, // data
            !legendPanelOn, // include legend
            true, false);
    TextTitle title = chart.getTitle();
    title.setToolTipText("A title tooltip!");

    PiePlot plot = (PiePlot) chart.getPlot();
    for (int i = 0; i < pulloutFlag.length; i++) {
        //System.out.println("\""+pulloutFlag[i]+"\"");
        if (isPullout(i)) {
            Comparable key = dataset.getKey(i);
            plot.setExplodePercent(key, 0.30);
        }
    }
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);

    setCategorySummary(dataset);

    if (rotateOn) {
        Rotator rotator = new Rotator(plot);
        rotator.start();
    }
    return chart;
}

From source file:com.greenpepper.confluence.macros.historic.LinearExecutionChartBuilder.java

private void customizeChart(JFreeChart chart) throws IOException {
    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(settings.isBorder());

    TextTitle chartTitle = chart.getTitle();
    customizeTitle(chartTitle, DEFAULT_TITLE_FONT);

    addSubTitle(chart, settings.getSubTitle(), DEFAULT_SUBTITLE_FONT);
    addSubTitle(chart, settings.getSubTitle2(), DEFAULT_SUBTITLE2_FONT);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setNoDataMessage(gpUtil.getText("greenpepper.historic.nodata"));

    CategoryItemRenderer renderer = plot.getRenderer();

    int index = 0;
    renderer.setSeriesPaint(index++, GREEN_COLOR);
    if (settings.isShowIgnored())
        renderer.setSeriesPaint(index++, Color.yellow);
    renderer.setSeriesPaint(index, Color.red);

    renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
    renderer.setItemURLGenerator(new CategoryURLGenerator() {

        public String generateURL(CategoryDataset data, int series, int category) {
            Comparable valueKey = data.getColumnKey(category);
            ChartLongValue value = (ChartLongValue) valueKey;
            return "javascript:" + settings.getExecutionUID() + "_showExecutionResult('" + value.getId()
                    + "');";
        }//w w  w .j  av  a 2s  .  c o m
    });

    CategoryAxis domainAxis = plot.getDomainAxis();
    customizeAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);

    ValueAxis rangeAxis = plot.getRangeAxis();
    customizeAxis(rangeAxis);
    rangeAxis.setLowerBound(0);

    if (rangeAxis instanceof NumberAxis) {
        ((NumberAxis) rangeAxis).setTickUnit(new NumberTickUnit(1));
    }

    plot.setForegroundAlpha(0.8f);
}

From source file:fr.crnan.videso3d.ihm.PLNSPanel.java

private void addChart(JFreeChart chart) {
    ChartPanel panel = new ChartPanel(chart);
    chartPanels.add(panel);/*w w  w  . j  av  a2s . com*/
    JInternalFrame frame = new JInternalFrame(chart.getTitle().getText(), true, false, true, true);
    frame.add(panel);
    frame.pack();
    frame.setVisible(true);
    desktop.add(frame);
    desktop.tile(true);
    if (chartMouseListener != null) {
        panel.addChartMouseListener(chartMouseListener);
    }
}

From source file:org.ala.spatial.web.services.GDMWSController.java

public static void generateCharts123(String outputdir) {
    try {/* w  w w.ja v  a  2  s.c o m*/
        IniReader ir = new IniReader(outputdir + "/gdm_params.txt");
        double intercept = ir.getDoubleValue("GDMODEL", "Intercept");

        // 1. read the ObservedVsPredicted.csv file
        System.out.println("Loading csv data");
        CSVReader csv = new CSVReader(new FileReader(outputdir + "ObservedVsPredicted.csv"));
        List<String[]> rawdata = csv.readAll();
        double[][] dataCht1 = new double[2][rawdata.size() - 1];
        double[][] dataCht2 = new double[2][rawdata.size() - 1];

        // for Chart 1: obs count
        int[] obscount = new int[11];
        for (int i = 0; i < obscount.length; i++) {
            obscount[i] = 0;
        }

        System.out.println("populating data");
        for (int i = 1; i < rawdata.size(); i++) {
            String[] row = rawdata.get(i);
            double obs = Double.parseDouble(row[4]);
            dataCht1[0][i - 1] = Double.parseDouble(row[6]);
            dataCht1[1][i - 1] = obs;

            dataCht2[0][i - 1] = Double.parseDouble(row[5]) - intercept;
            dataCht2[1][i - 1] = obs;

            int obc = (int) Math.round(obs * 10);
            obscount[obc]++;
        }

        DefaultXYDataset dataset1 = new DefaultXYDataset();
        dataset1.addSeries("", dataCht1);

        DefaultXYDataset dataset2 = new DefaultXYDataset();
        dataset2.addSeries("", dataCht2);

        DefaultCategoryDataset dataset3 = new DefaultCategoryDataset();
        for (int i = 0; i < obscount.length; i++) {
            String col = "0." + i + "-0." + (i + 1);
            if (i == 10) {
                col = "0.9-1.0";
            }
            dataset3.addValue(obscount[i] + 100, "col", col);
        }
        generateChartByType("Response Histogram", "Observed Dissimilarity Class", "Number of Site Pairs",
                dataset3, outputdir, "bar", "resphist");

        XYDotRenderer renderer = new XYDotRenderer();
        //Shape cross = ShapeUtilities.createDiagonalCross(3, 1);
        //renderer.setSeriesShape(0, cross);
        renderer.setDotWidth(3);
        renderer.setDotHeight(3);
        renderer.setSeriesPaint(0, Color.BLACK);

        JFreeChart jChart1 = ChartFactory.createScatterPlot(
                "Observed versus predicted compositional dissimilarity",
                "Predicted Compositional Dissimilarity", "Observed Compositional Dissimilarity", dataset1,
                PlotOrientation.VERTICAL, false, false, false);
        jChart1.getTitle().setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14));

        XYPlot plot = (XYPlot) jChart1.getPlot();
        plot.setBackgroundPaint(Color.WHITE);
        plot.setDomainZeroBaselineVisible(true);
        plot.setRangeZeroBaselineVisible(true);
        plot.setDomainGridlinesVisible(true);
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        plot.setDomainGridlineStroke(new BasicStroke(0.5F, 0, 1));
        plot.setRangeGridlinesVisible(true);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        plot.setRangeGridlineStroke(new BasicStroke(0.5F, 0, 1));
        plot.setRenderer(0, renderer);

        NumberAxis domain = (NumberAxis) plot.getDomainAxis();
        domain.setAutoRangeIncludesZero(false);
        domain.setAxisLineVisible(false);
        domain.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));

        NumberAxis range = (NumberAxis) plot.getRangeAxis();
        range.setAutoRangeIncludesZero(false);
        range.setAxisLineVisible(false);
        range.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));

        double dMinPred = domain.getRange().getLowerBound();
        double dMaxPred = domain.getRange().getUpperBound();

        double dMinObs = range.getRange().getLowerBound();
        double dMaxObs = range.getRange().getUpperBound();

        System.out.println("1..pred.min.max: " + dMinPred + ", " + dMaxPred);

        int regressionLineSegs = 10;
        double dInc = (dMaxPred - dMinPred) / regressionLineSegs;
        double[][] dataReg1 = new double[2][regressionLineSegs + 1];
        DefaultXYDataset dsReg1 = new DefaultXYDataset();
        int i = 0;
        for (double d = dMinPred; d <= dMaxPred; d += dInc, i++) {
            dataReg1[0][i] = d;
            dataReg1[1][i] = d;
        }
        dsReg1.addSeries("", dataReg1);
        XYSplineRenderer regressionRenderer = new XYSplineRenderer();
        regressionRenderer.setBaseSeriesVisibleInLegend(true);
        regressionRenderer.setSeriesPaint(0, Color.RED);
        regressionRenderer.setSeriesStroke(0, new BasicStroke(1.5f));
        regressionRenderer.setBaseShapesVisible(false);
        plot.setDataset(1, dsReg1);
        plot.setRenderer(1, regressionRenderer);

        System.out.println("Writing image....");
        ChartUtilities.saveChartAsPNG(new File(outputdir + "plots/obspredissim.png"), jChart1, 600, 400);

        // For chart 3
        JFreeChart jChart2 = ChartFactory.createScatterPlot(
                "Observed compositional dissimilarity vs predicted ecological distance",
                "Predicted ecological distance", "Observed Compositional Dissimilarity", dataset2,
                PlotOrientation.VERTICAL, false, false, false);
        jChart2.getTitle().setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14));

        plot = (XYPlot) jChart2.getPlot();
        plot.setBackgroundPaint(Color.WHITE);
        plot.setDomainZeroBaselineVisible(true);
        plot.setRangeZeroBaselineVisible(true);
        plot.setDomainGridlinesVisible(true);
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        plot.setDomainGridlineStroke(new BasicStroke(0.5F, 0, 1));
        plot.setRangeGridlinesVisible(true);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        plot.setRangeGridlineStroke(new BasicStroke(0.5F, 0, 1));
        plot.setRenderer(0, renderer);

        domain = (NumberAxis) plot.getDomainAxis();
        domain.setAutoRangeIncludesZero(false);
        domain.setAxisLineVisible(false);
        domain.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));

        range = (NumberAxis) plot.getRangeAxis();
        range.setAutoRangeIncludesZero(false);
        range.setAxisLineVisible(false);
        range.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));

        dMinPred = domain.getRange().getLowerBound();
        dMaxPred = domain.getRange().getUpperBound();

        dMinObs = range.getRange().getLowerBound();
        dMaxObs = range.getRange().getUpperBound();

        System.out.println("2.pred.min.max: " + dMinPred + ", " + dMaxPred);

        regressionLineSegs = 10;
        dInc = (dMaxPred - dMinPred) / regressionLineSegs;
        dataReg1 = new double[2][regressionLineSegs + 1];
        dsReg1 = new DefaultXYDataset();
        i = 0;
        for (double d = dMinPred; d <= dMaxPred; d += dInc, i++) {
            dataReg1[0][i] = d;
            dataReg1[1][i] = (1.0 - Math.exp(-d));
        }
        dsReg1.addSeries("", dataReg1);
        regressionRenderer.setBaseSeriesVisibleInLegend(true);
        regressionRenderer.setSeriesPaint(0, Color.RED);
        regressionRenderer.setSeriesStroke(0, new BasicStroke(1.5f));
        regressionRenderer.setBaseShapesVisible(false);
        plot.setDataset(1, dsReg1);
        plot.setRenderer(1, regressionRenderer);

        System.out.println("Writing image....");
        ChartUtilities.saveChartAsPNG(new File(outputdir + "plots/dissimdist.png"), jChart2, 600, 400);

    } catch (Exception e) {
        System.out.println("Unable to generate charts 2 and 3:");
        e.printStackTrace(System.out);
    }
}

From source file:net.relet.freimap.LinkInfo.java

private void sexupLayout(JFreeChart chart) {
    chart.setAntiAlias(true);/* w w  w .j  ava  2  s  .c o  m*/
    chart.setBackgroundPaint(VisorFrame.bgcolor2);
    chart.setBorderVisible(false);
    TextTitle title = chart.getTitle();
    title.setFont(VisorFrame.smallerfont);
    title.setPaint(VisorFrame.fgcolor2);
    Plot plot = chart.getPlot();
    sexupPlot(plot);
}

From source file:com.greenpepper.confluence.macros.historic.AggregationExecutionChartBuilder.java

private void customizeChart(JFreeChart chart) throws IOException {
    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(settings.isBorder());

    TextTitle chartTitle = chart.getTitle();
    customizeTitle(chartTitle, DEFAULT_TITLE_FONT);

    addSubTitle(chart, settings.getSubTitle(), DEFAULT_SUBTITLE_FONT);
    addSubTitle(chart, settings.getSubTitle2(), DEFAULT_SUBTITLE2_FONT);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setNoDataMessage(gpUtil.getText("greenpepper.historic.nodata"));

    StackedBarRenderer renderer = new StackedBarRenderer(true);
    plot.setRenderer(renderer);// w ww. ja  va  2s.  c  o  m

    int index = 0;
    renderer.setSeriesPaint(index++, GREEN_COLOR);
    if (settings.isShowIgnored())
        renderer.setSeriesPaint(index++, Color.yellow);
    renderer.setSeriesPaint(index, Color.red);

    renderer.setToolTipGenerator(new DefaultTooltipGenerator());
    renderer.setItemURLGenerator(new CategoryURLGenerator() {

        public String generateURL(CategoryDataset data, int series, int category) {
            Comparable valueKey = data.getColumnKey(category);
            ChartLongValue value = (ChartLongValue) valueKey;
            return "javascript:" + settings.getExecutionUID() + "_showHistoricChart('" + value.getId() + "');";
        }
    });

    CategoryAxis domainAxis = plot.getDomainAxis();
    customizeAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setCategoryMargin(0.01);

    ValueAxis rangeAxis = plot.getRangeAxis();
    customizeAxis(rangeAxis);
    rangeAxis.setLowerBound(0);
    rangeAxis.setUpperBound(1.0);

    if (rangeAxis instanceof NumberAxis) {
        NumberAxis numberAxis = (NumberAxis) rangeAxis;
        numberAxis.setTickUnit(new NumberTickUnit(.10));
        numberAxis.setNumberFormatOverride(PERCENT_FORMATTER);
    }

    plot.setForegroundAlpha(0.8f);
}

From source file:tdunnick.jphineas.console.queue.Charts.java

private BufferedImage getJFreeImage(JFreeChart image, int width, int height, ChartRenderingInfo info) {
    image.getTitle().setFont(new Font("Times New Roman", Font.BOLD, 16));
    image.setBackgroundPaint(new Color(255, 255, 255, 0));
    image.setBackgroundImageAlpha(0.0f);
    return (image.createBufferedImage(width, height, info));
}

From source file:playground.ivt.utils.WrapperChartUtil.java

public WrapperChartUtil(final JFreeChart chart) {
    super(TITLE, XLABEL, YLABEL);
    this.chart = chart;
    try {//w  ww . j  a  v a 2 s .c o m
        this.addDefaultFormatting();
        //this.addMatsimLogo();
    } catch (Exception e) {
        // no default formating: not a big deal.
        log.warn("Could not set the default formating for chart with title <<" + chart.getTitle().getText()
                + ">>: got a " + e + " with message " + e.getMessage()
                //+" and stack trace "+e.getStackTrace()
                + ". This is not fatal, but the plot may not look as expected.");
    }
}