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:mil.tatrc.physiology.biogears.verification.ScenarioPlotTool.java

public void formatXYPlot(JFreeChart chart, Paint bgColor) {
    XYPlot plot = (XYPlot) chart.getPlot();

    //For Scientific notation
    NumberFormat formatter = new DecimalFormat("0.######E0");
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setNumberFormatOverride(formatter);

    //White background outside of plottable area
    chart.setBackgroundPaint(bgColor);/*from  w  ww  . j  a va2 s . c o m*/

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);

    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    //Changing font sizes so they are readable. 
    plot.getDomainAxis().setLabelFont(largeFont);
    plot.getRangeAxis().setLabelFont(largeFont);
    plot.getDomainAxis().setTickLabelFont(smallFont);
    plot.getRangeAxis().setTickLabelFont(smallFont);

    plot.getDomainAxis().setLabelPaint(bgColor == Color.red ? Color.white : Color.black);
    plot.getRangeAxis().setLabelPaint(bgColor == Color.red ? Color.white : Color.black);
    plot.getDomainAxis().setTickLabelPaint(bgColor == Color.red ? Color.white : Color.black);
    plot.getRangeAxis().setTickLabelPaint(bgColor == Color.red ? Color.white : Color.black);

    chart.getLegend().setItemFont(smallFont);
    chart.getTitle().setFont(largeFont);
    chart.getTitle().setPaint(bgColor == Color.red ? Color.white : Color.black);
}

From source file:it.unifi.rcl.chess.traceanalysis.gui.TracePanel.java

private void plotCompare() {
    XYSeriesCollection dataset = new XYSeriesCollection();

    XYSeries xyBoundsPositive = null;/*from w w  w. j av  a 2s.  c o  m*/
    XYSeries xyBoundsNegative = null;
    Trace[] posNeg = null;

    Component[] siblings = this.getParent().getComponents();
    Trace[] allTraces = new Trace[siblings.length];

    int rows = tableWindowSize.getRowCount();
    double coverage = 0.99;
    int wsize = 100;
    for (int i = 0; i < rows; i++) {
        try {
            wsize = (Integer) tableWindowSize.getValueAt(i, 0);
            coverage = (Double) tableWindowSize.getValueAt(i, 1);
        } catch (NullPointerException e) {
            //Ignore: cell value is null
            ;
        }
    }

    for (int i = 0; i < siblings.length; i++) {
        allTraces[i] = ((TracePanel) siblings[i]).getTrace();

        if (allTraces[i].hasNegativeValues()) {
            posNeg = allTraces[i].splitPositiveNegative();
            xyBoundsPositive = Plotter.arrayToSeries(posNeg[0].getDynamicBound(coverage, wsize),
                    allTraces[i].getName(), wsize - 1);
            xyBoundsNegative = Plotter.arrayToSeriesInvert(posNeg[1].getDynamicBound(coverage, wsize),
                    allTraces[i].getName() + "(neg)", wsize - 1);
            dataset.addSeries(xyBoundsPositive);
            dataset.addSeries(xyBoundsNegative);
        } else {
            dataset.addSeries(Plotter.arrayToSeries(allTraces[i].getDynamicBound(coverage, wsize),
                    allTraces[i].getName(), wsize - 1));
        }
    }

    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart("Comparative Plot (c=" + coverage + ",w=" + wsize + ")",
            // Title
            "Time Point",
            // x-axis Labels
            "Value",
            // y-axis Label
            dataset,
            // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            true,
            // Show Legend
            true,
            // Use tooltips
            false
    // Configure chart to generate URLs?
    );

    chart.setBackgroundPaint(Color.WHITE);
    chart.getXYPlot().setBackgroundPaint(ChartColor.VERY_LIGHT_YELLOW);
    chart.getXYPlot().setBackgroundAlpha(0.05f);
    chart.getXYPlot().setRangeGridlinePaint(Color.LIGHT_GRAY);
    chart.getXYPlot().setDomainGridlinePaint(Color.LIGHT_GRAY);

    chart.getTitle().setFont(new Font("Dialog", Font.BOLD, 14));

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setDrawSeriesLineAsPath(true);
    chart.getXYPlot().setRenderer(renderer);

    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesPaint(1, ChartColor.DARK_GREEN);
    renderer.setSeriesPaint(2, ChartColor.DARK_BLUE);
    renderer.setSeriesPaint(3, ChartColor.RED);

    int nSeries = chart.getXYPlot().getSeriesCount();
    for (int i = 0; i < nSeries; i++) {
        renderer.setSeriesShapesVisible(i, false);
    }
    if (posNeg != null) {
        renderer.setSeriesVisibleInLegend(5, false);
        renderer.setSeriesPaint(5, renderer.getSeriesPaint(4));
    }

    //      Stroke plainStroke = new BasicStroke(
    //                    1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f
    //                );
    //      
    //      renderer.setSeriesStroke(0, plainStroke);
    //      renderer.setSeriesStroke(1, 
    //            new BasicStroke(
    //                 1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 3.0f }, 0.0f
    //             ));
    //      renderer.setSeriesStroke(2, 
    //            new BasicStroke(
    //                 1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 3.0f, 0.5f, 3.0f }, 0.0f
    //             ));
    //      renderer.setSeriesStroke(3, 
    //            new BasicStroke(
    //                 1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 3.0f }, 0.0f
    //             ));

    JPanel plotPanel = new ChartPanel(chart);
    JFrame plotFrame = new JFrame();
    plotFrame.add(plotPanel);
    plotFrame.setVisible(true);
    plotFrame.pack();
    plotFrame.setTitle(TracePanel.this.trace.getName());
    plotFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}

From source file:com.haskins.cloudtrailviewer.feature.MetricsFeature.java

private void showChart(String service) {

    final TimeSeriesCollection chartData = generateTimeSeriesData(service);

    JFreeChart chart = ChartFactory.createTimeSeriesChart(service, "Time", "Calls", chartData, false, true,
            false);//from  w  ww . j a va 2 s  .c  o m

    // draw outter line
    XYLineAndShapeRenderer lineAndShapeRenderer = new XYLineAndShapeRenderer();
    lineAndShapeRenderer.setPaint(new Color(64, 168, 228, 75));
    lineAndShapeRenderer.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 6, 6));
    lineAndShapeRenderer.setSeriesShapesFilled(0, true);
    lineAndShapeRenderer.setSeriesShapesVisible(0, true);
    lineAndShapeRenderer.setUseOutlinePaint(true);
    lineAndShapeRenderer.setUseFillPaint(true);

    // draw filled area
    XYAreaRenderer renderer = new XYAreaRenderer();
    renderer.setPaint(new Color(64, 168, 228, 50));

    // configure Plot
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlineVisible(false);

    plot.setDataset(0, chartData);
    plot.setDataset(1, chartData);

    plot.setRenderer(0, lineAndShapeRenderer);
    plot.setRenderer(1, renderer);

    plot.getDomainAxis().setLowerMargin(0);
    plot.getDomainAxis().setUpperMargin(0);

    // format chart title
    TextTitle t = chart.getTitle();
    t.setFont(new Font("Arial", Font.BOLD, 14));

    // Cross Hairs
    xCrosshair = new Crosshair(Double.NaN, Color.GRAY, new BasicStroke(0f));
    xCrosshair.setLabelVisible(true);
    xCrosshair.setLabelGenerator(new DateTimeCrosshairLabelGenerator());

    CrosshairOverlay crosshairOverlay = new CrosshairOverlay();
    crosshairOverlay.addDomainCrosshair(xCrosshair);

    // Create the panel
    chartPanel = new ChartPanel(chart);
    chartPanel.setMinimumDrawWidth(0);
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    chartPanel.setMinimumDrawHeight(0);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    chartPanel.setMouseZoomable(true, false);
    chartPanel.setDomainZoomable(true);
    chartPanel.setRangeZoomable(false);
    chartPanel.addChartMouseListener(this);
    chartPanel.addOverlay(crosshairOverlay);

    // update the display
    chartCards.removeAll();
    chartCards.add(chartPanel, "");
    chartCards.revalidate();
}

From source file:org.operamasks.faces.render.graph.ChartRenderer.java

protected void setChartTitles(JFreeChart chart, UIChart comp) {
    String titleText = comp.getTitle();
    if (titleText != null) {
        chart.setTitle(titleText);//from www  . jav a 2s. c om
    }

    for (UIComponent kid : comp.getChildren()) {
        if (kid.isRendered() && (kid instanceof UITitle)) {
            TextTitle title = createTitle((UITitle) kid);
            if (chart.getTitle() == null) {
                chart.setTitle(title);
            } else {
                chart.addSubtitle(title);
            }
        }
    }
}

From source file:com.igalia.java.zk.components.JFreeChartEngine.java

public byte[] drawChart(Object data) {
    Chart chart = (Chart) data;//from  ww  w .j ava  2  s. c o  m
    ChartImpl impl = getChartImpl(chart);
    JFreeChart jfchart = impl.createChart(chart);

    Plot plot = (Plot) jfchart.getPlot();
    float alpha = (float) (((float) chart.getFgAlpha()) / 255);
    plot.setForegroundAlpha(alpha);

    alpha = (float) (((float) chart.getBgAlpha()) / 255);
    plot.setBackgroundAlpha(alpha);

    int[] bgRGB = chart.getBgRGB();
    if (bgRGB != null) {
        plot.setBackgroundPaint(new Color(bgRGB[0], bgRGB[1], bgRGB[2], chart.getBgAlpha()));
    }

    int[] paneRGB = chart.getPaneRGB();
    if (paneRGB != null) {
        jfchart.setBackgroundPaint(new Color(paneRGB[0], paneRGB[1], paneRGB[2], chart.getPaneAlpha()));
    }

    //since 3.6.3, JFreeChart 1.0.13 change default fonts which does not support Chinese, allow
    //developer to set font.

    //title font
    final Font tfont = chart.getTitleFont();
    if (tfont != null) {
        jfchart.getTitle().setFont(tfont);
    }

    //legend font
    final Font lfont = chart.getLegendFont();
    if (lfont != null) {
        jfchart.getLegend().setItemFont(lfont);
    }

    if (plot instanceof CategoryPlot) {
        final CategoryPlot cplot = (CategoryPlot) plot;
        cplot.setRangeGridlinePaint(new Color(0xc0, 0xc0, 0xc0));

        //Domain axis(x axis)
        final Font xlbfont = chart.getXAxisFont();
        final Font xtkfont = chart.getXAxisTickFont();
        if (xlbfont != null) {
            cplot.getDomainAxis().setLabelFont(xlbfont);
        }
        if (xtkfont != null) {
            cplot.getDomainAxis().setTickLabelFont(xtkfont);
        }

        Color[] colorMappings = (Color[]) chart.getAttribute("series-color-mappings");
        if (colorMappings != null) {
            for (int ii = 0; ii < colorMappings.length; ii++) {
                cplot.getRenderer().setSeriesPaint(ii, colorMappings[ii]);
            }
        }

        Double lowerBound = (Double) chart.getAttribute("range-axis-lower-bound");
        if (lowerBound != null) {
            cplot.getRangeAxis().setAutoRange(false);
            cplot.getRangeAxis().setLowerBound(lowerBound);
        }

        Double upperBound = (Double) chart.getAttribute("range-axis-upper-bound");
        if (upperBound != null) {
            cplot.getRangeAxis().setAutoRange(false);
            cplot.getRangeAxis().setUpperBound(upperBound);
        }

        //Range axis(y axis)
        final Font ylbfont = chart.getYAxisFont();
        final Font ytkfont = chart.getYAxisTickFont();
        if (ylbfont != null) {
            cplot.getRangeAxis().setLabelFont(ylbfont);
        }
        if (ytkfont != null) {
            cplot.getRangeAxis().setTickLabelFont(ytkfont);
        }
    } else if (plot instanceof XYPlot) {
        final XYPlot xyplot = (XYPlot) plot;
        xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);

        //Domain axis(x axis)
        final Font xlbfont = chart.getXAxisFont();
        final Font xtkfont = chart.getXAxisTickFont();
        if (xlbfont != null) {
            xyplot.getDomainAxis().setLabelFont(xlbfont);
        }
        if (xtkfont != null) {
            xyplot.getDomainAxis().setTickLabelFont(xtkfont);
        }

        //Range axis(y axis)
        final Font ylbfont = chart.getYAxisFont();
        final Font ytkfont = chart.getYAxisTickFont();
        if (ylbfont != null) {
            xyplot.getRangeAxis().setLabelFont(ylbfont);
        }
        if (ytkfont != null) {
            xyplot.getRangeAxis().setTickLabelFont(ytkfont);
        }
    } else if (plot instanceof PiePlot) {
        plot.setOutlineStroke(null);
    }

    //callbacks for each area
    ChartRenderingInfo jfinfo = new ChartRenderingInfo();
    BufferedImage bi = jfchart.createBufferedImage(chart.getIntWidth(), chart.getIntHeight(),
            Transparency.TRANSLUCENT, jfinfo);

    //remove old areas
    if (chart.getChildren().size() > 20)
        chart.invalidate(); //improve performance if too many chart
    chart.getChildren().clear();

    if (Events.isListened(chart, Events.ON_CLICK, false) || chart.isShowTooltiptext()) {
        int j = 0;
        String preUrl = null;
        for (Iterator it = jfinfo.getEntityCollection().iterator(); it.hasNext();) {
            ChartEntity ce = (ChartEntity) it.next();
            final String url = ce.getURLText();

            //workaround JFreeChart's bug (skip replicate areas)
            if (url != null) {
                if (preUrl == null) {
                    preUrl = url;
                } else if (url.equals(preUrl)) { //start replicate, skip
                    break;
                }
            }

            //1. JFreeChartEntity area cover the whole chart, will "mask" other areas
            //2. LegendTitle area cover the whole legend, will "mask" each legend
            //3. PlotEntity cover the whole chart plotting araa, will "mask" each bar/line/area
            if (!(ce instanceof JFreeChartEntity)
                    && !(ce instanceof TitleEntity && ((TitleEntity) ce).getTitle() instanceof LegendTitle)
                    && !(ce instanceof PlotEntity)) {
                Area area = new Area();
                area.setParent(chart);
                area.setCoords(ce.getShapeCoords());
                area.setShape(ce.getShapeType());
                area.setId("area_" + chart.getId() + '_' + (j++));
                if (chart.isShowTooltiptext() && ce.getToolTipText() != null) {
                    area.setTooltiptext(ce.getToolTipText());
                }
                area.setAttribute("url", ce.getURLText());
                impl.render(chart, area, ce);
                if (chart.getAreaListener() != null) {
                    try {
                        chart.getAreaListener().onRender(area, ce);
                    } catch (Exception ex) {
                        throw UiException.Aide.wrap(ex);
                    }
                }
            }
        }
    }
    //clean up the "LEGEND_SEQ"
    //used for workaround LegendItemEntity.getSeries() always return 0
    //used for workaround TickLabelEntity no information
    chart.removeAttribute("LEGEND_SEQ");
    chart.removeAttribute("TICK_SEQ");

    try {
        //encode into png image format byte array
        return EncoderUtil.encode(bi, ImageFormat.PNG, true);
    } catch (java.io.IOException ex) {
        throw UiException.Aide.wrap(ex);
    }
}

From source file:org.pentaho.chart.plugin.jfreechart.chart.JFreeChartGenerator.java

public JFreeChart createChart(ChartDocumentContext chartDocContext, ChartTableModel data) {
    JFreeChart chart = doCreateChart(chartDocContext, data);

    chart.setBackgroundPaint(getChartBackgroundColor(chartDocContext.getChartDocument()));

    Color chartBackgroundPaint = ColorFactory.getInstance()
            .getColor(chartDocContext.getChartDocument().getPlotElement(), BorderStyleKeys.BACKGROUND_COLOR);
    if (chartBackgroundPaint != null) {
        chart.getPlot().setBackgroundPaint(chartBackgroundPaint);
    }// w w w. j  a v a  2 s.com

    CSSNumericValue opacity = (CSSNumericValue) chartDocContext.getChartDocument().getPlotElement()
            .getLayoutStyle().getValue(ColorStyleKeys.OPACITY);
    if (opacity != null) {
        chart.getPlot().setForegroundAlpha((float) opacity.getValue());
    }

    ChartElement rootElement = chartDocContext.getChartDocument().getRootElement();
    ChartElement[] children = rootElement.findChildrenByName(ChartElement.TAG_NAME_TITLE); //$NON-NLS-1$
    if (children != null && children.length > 0) {
        Font font = ChartUtils.getFont(children[0]);
        if (font != null) {
            chart.getTitle().setFont(font);
        }
    }

    if (getShowLegend(chartDocContext.getChartDocument())) {
        children = chartDocContext.getChartDocument().getRootElement()
                .findChildrenByName(ChartElement.TAG_NAME_LEGEND); //$NON-NLS-1$
        if ((children != null) && (children.length > 0)) {
            ChartElement legendElement = children[0];
            Font font = JFreeChartUtils.getFont(legendElement);
            if (font != null) {
                chart.getLegend().setItemFont(font);
            }

            CSSNumericValue value = (CSSNumericValue) legendElement.getLayoutStyle()
                    .getValue(BorderStyleKeys.BORDER_TOP_WIDTH);
            if ((value == null) || (value.getValue() <= 0)) {
                chart.getLegend().setBorder(BlockBorder.NONE);
            }
        }
    }

    CSSValue borderWidth = rootElement.getLayoutStyle().getValue(BorderStyleKeys.BORDER_TOP_WIDTH);
    if ((borderWidth != null) && (borderWidth instanceof CSSNumericValue)
            && (((CSSNumericValue) borderWidth).getValue() > 0)) {
        chart.setBorderVisible(true);
    } else if ((borderWidth != null) && (borderWidth instanceof CSSStringValue)) {
        chart.setBorderVisible(true);
    }

    Color borderColor = ColorFactory.getInstance().getColor(rootElement, BorderStyleKeys.BORDER_TOP_COLOR);
    if (borderColor != null) {
        chart.setBorderPaint(borderColor);
    }

    Plot plot = chart.getPlot();
    if (plot instanceof CategoryPlot) {
        CategoryPlot categoryPlot = (CategoryPlot) plot;

        children = chartDocContext.getChartDocument().getRootElement()
                .findChildrenByName(ChartElement.TAG_NAME_RANGE_LABEL); //$NON-NLS-1$
        if (children != null && children.length > 0) {
            Font font = ChartUtils.getFont(children[0]);
            if (font != null) {
                categoryPlot.getRangeAxis().setLabelFont(font);
            }
        }

        children = chartDocContext.getChartDocument().getRootElement()
                .findChildrenByName(ChartElement.TAG_NAME_DOMAIN_LABEL); //$NON-NLS-1$
        if (children != null && children.length > 0) {
            Font font = ChartUtils.getFont(children[0]);
            if (font != null) {
                categoryPlot.getDomainAxis().setLabelFont(font);
            }
        }
    }
    return chart;
}

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   ww  w  . j  a  va  2s.co  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:mil.tatrc.physiology.utilities.csv.plots.CSVPlotTool.java

public void formatXYPlot(JFreeChart chart, Paint bgColor) {
    XYPlot plot = (XYPlot) chart.getPlot();

    //For Scientific notation
    NumberFormat formatter = new DecimalFormat("0.######E0");

    for (int i = 0; i < plot.getDomainAxisCount(); i++) {
        plot.getDomainAxis(i).setLabelFont(largeFont);
        plot.getDomainAxis(i).setTickLabelFont(smallFont);
        plot.getDomainAxis(i).setLabelPaint(bgColor == Color.red ? Color.white : Color.black);
        plot.getDomainAxis(i).setTickLabelPaint(bgColor == Color.red ? Color.white : Color.black);
    }//  w w w  .  j  a v a  2 s. c  o  m
    for (int i = 0; i < plot.getRangeAxisCount(); i++) {
        plot.getRangeAxis(i).setLabelFont(largeFont);
        plot.getRangeAxis(i).setTickLabelFont(smallFont);
        plot.getRangeAxis(i).setLabelPaint(bgColor == Color.red ? Color.white : Color.black);
        plot.getRangeAxis(i).setTickLabelPaint(bgColor == Color.red ? Color.white : Color.black);
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(i);
        rangeAxis.setNumberFormatOverride(formatter);
    }

    //White background outside of plottable area
    chart.setBackgroundPaint(bgColor);

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);

    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    chart.getLegend().setItemFont(smallFont);
    chart.getTitle().setFont(largeFont);
    chart.getTitle().setPaint(bgColor == Color.red ? Color.white : Color.black);
}

From source file:edu.harvard.i2b2.analysis.ui.AnalysisComposite.java

private JFreeChart createWaitingChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createBarChart("Working .............", // chart
            // title
            "", // domain axis label
            "", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );/*from w w w  .j  a  va  2 s  .com*/

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    Font f = chart.getTitle().getFont();
    chart.getTitle().setFont(new java.awt.Font(f.getFamily(), 1, 12));
    return chart;

}

From source file:edu.harvard.i2b2.analysis.ui.AnalysisComposite.java

private JFreeChart createNoDataChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createBarChart("No results to display", // chart
            // title
            "", // domain axis label
            "", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );/*w ww .j a v  a2  s .co m*/

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    Font f = chart.getTitle().getFont();
    chart.getTitle().setFont(new java.awt.Font(f.getFamily(), 1, 12));

    return chart;

}