Example usage for org.jfree.chart JFreeChart setTextAntiAlias

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

Introduction

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

Prototype

public void setTextAntiAlias(Object val) 

Source Link

Document

Sets the value in the rendering hints table for RenderingHints#KEY_TEXT_ANTIALIASING and sends a ChartChangeEvent to all registered listeners.

Usage

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

private static JFreeChart createChart(TableXYDataset tablexydataset) {
    DateAxis dateaxis = new DateAxis("Date");
    dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    dateaxis.setLowerMargin(0.01D);//from w w  w. ja  v  a2s . c o m
    dateaxis.setUpperMargin(0.01D);
    NumberAxis numberaxis = new NumberAxis("Count");
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setUpperMargin(0.10000000000000001D);
    StackedXYBarRenderer stackedxybarrenderer = new StackedXYBarRenderer(0.14999999999999999D);
    stackedxybarrenderer.setDrawBarOutline(false);
    stackedxybarrenderer.setBaseItemLabelsVisible(true);
    stackedxybarrenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    stackedxybarrenderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER));
    stackedxybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} : {1} = {2}",
            new SimpleDateFormat("yyyy"), new DecimalFormat("0")));
    XYPlot xyplot = new XYPlot(tablexydataset, dateaxis, numberaxis, stackedxybarrenderer);
    JFreeChart jfreechart = new JFreeChart("Holes-In-One / Double Eagles", xyplot);
    jfreechart.removeLegend();
    jfreechart.addSubtitle(new TextTitle("PGA Tour, 1983 to 2003"));
    TextTitle texttitle = new TextTitle(
            "http://www.golfdigest.com/majors/masters/index.ssf?/majors/masters/gw20040402albatross.html",
            new Font("Dialog", 0, 8));
    jfreechart.addSubtitle(texttitle);
    jfreechart.setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
    LegendTitle legendtitle = new LegendTitle(xyplot);
    legendtitle.setBackgroundPaint(Color.white);
    legendtitle.setFrame(new BlockBorder());
    legendtitle.setPosition(RectangleEdge.BOTTOM);
    jfreechart.addSubtitle(legendtitle);
    return jfreechart;
}

From source file:com.controlj.addon.gwttree.server.GraphServlet.java

/**<!====== getChart ======================================================>
   Generates the chart.  Note that most of these options are not required
   for a simple chart, but we wanted to try to get a particular look that
   matched another charting package, so we went to some trouble to set
   a lot of non-standard options.  In particular, the OpaqueBarRenderer3D
   is a non-standard renderer that gives much better looking 3D bars.
<!=======================================================================>*/
private static JFreeChart getChart(DefaultCategoryDataset dataset) {
    JFreeChart chart = ChartFactory.createBarChart3D("Integration Over Time", "24 Hour Period", "", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.black);
    chart.getTitle().setPaint(Color.white);
    chart.getTitle().setFont(new Font("Verdana", Font.BOLD, 20));
    chart.setAntiAlias(true);//from  w w  w.j  a v a  2  s .c om
    chart.setTextAntiAlias(true);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setForegroundAlpha(1);
    OpaqueBarRenderer3D renderer = new OpaqueBarRenderer3D();
    renderer.setItemMargin(0.1);
    plot.setRenderer(renderer);

    renderer.setSeriesPaint(0, new Color(116, 225, 118));
    renderer.setSeriesPaint(1, new Color(245, 107, 107));
    renderer.setSeriesPaint(2, new Color(250, 187, 107));
    renderer.setSeriesPaint(3, new Color(72, 72, 238));
    renderer.setSeriesPaint(4, new Color(184, 32, 157));
    renderer.setDrawBarOutline(false);

    Font small = new Font("Verdana", Font.PLAIN, 12);
    Font big = new Font("Verdana", Font.BOLD, 14);

    renderer.setItemLabelPaint(Color.white);
    plot.getDomainAxis().setTickLabelPaint(Color.white);
    plot.getDomainAxis().setTickLabelFont(small);
    plot.getDomainAxis().setLabelPaint(Color.white);
    plot.getDomainAxis().setLabelFont(big);
    plot.getDomainAxis().setCategoryMargin(0.2);

    plot.getRangeAxis().setTickLabelPaint(Color.white);
    plot.getRangeAxis().setTickLabelFont(small);
    plot.getRangeAxis().setLabelPaint(Color.white);
    plot.getRangeAxis().setLabelFont(big);
    plot.setBackgroundPaint(Color.black);

    chart.getLegend().setBackgroundPaint(Color.black);
    chart.getLegend().setItemPaint(Color.white);
    chart.getLegend().setItemFont(big);

    return chart;
}

From source file:com.uttesh.pdfngreport.util.chart.ChartStyle.java

/**
 * this method will set the style theme for pie chart.
 *
 * @see org.jfree.chart.StandardChartTheme
 * @param chart/*from ww w.  j a  v  a2 s .  c  o m*/
 */
public static void theme(JFreeChart chart) {
    String fontName = "Lucida Sans";

    StandardChartTheme theme = (StandardChartTheme) org.jfree.chart.StandardChartTheme.createJFreeTheme();

    theme.setTitlePaint(Color.decode("#4572a7"));
    theme.setExtraLargeFont(new Font(fontName, Font.PLAIN, 16)); //title
    theme.setLargeFont(new Font(fontName, Font.BOLD, 15)); //axis-title
    theme.setRegularFont(new Font(fontName, Font.PLAIN, 11));
    theme.setRangeGridlinePaint(Color.decode("#C0C0C0"));
    theme.setPlotBackgroundPaint(Color.white);
    theme.setChartBackgroundPaint(Color.white);
    theme.setGridBandPaint(Color.red);
    theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
    theme.setBarPainter(new StandardBarPainter());
    theme.setAxisLabelPaint(Color.decode("#666666"));
    theme.apply(chart);
    chart.setTextAntiAlias(true);
    chart.setAntiAlias(true);
}

From source file:playground.benjamin.scenarios.zurich.analysis.charts.BkChartTemplate.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    plot.setDataset(0, this.getDataset());
    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.setTextAntiAlias(true);
    //    chart.removeLegend();
    return chart;
}

From source file:org.shredzone.bullshitcharts.servlet.ChartServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    String pathInfo = req.getPathInfo();
    PlotGenerator generator = null;// w ww.  ja v  a2s  . co  m
    if ("/pie.png".equals(pathInfo)) {
        generator = new ChoicePieGenerator();
    } else if ("/agree.png".equals(pathInfo)) {
        generator = new AgreementPieGenerator();
    } else if ("/line.png".equals(pathInfo)) {
        generator = new LineChartGenerator();
    } else if ("/bar.png".equals(pathInfo)) {
        generator = new BarChartGenerator();
    } else {
        resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
        return;
    }

    generator.configure(req);

    Plot plot = generator.generate();

    // Generate the chart
    JFreeChart chart = new JFreeChart(plot);
    chart.setAntiAlias(true);
    chart.setTextAntiAlias(true);
    chart.setBorderVisible(false);
    chart.removeLegend();

    String title = req.getParameter("title");
    if (title != null) {
        chart.setTitle(title);
    }

    // Write the chart to a byte array. It is small enough so it won't load the
    // server's memory too much.
    try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
        ChartUtilities.writeChartAsPNG(baos, chart, IMAGE_WIDTH, IMAGE_HEIGHT);
        byte[] data = baos.toByteArray();

        // Stream the chart
        resp.setContentType("image/png");
        resp.setContentLength(data.length);
        resp.setHeader("Cache-Control", "no-cache, must-revalidate");
        resp.setHeader("Expires", "Sat, 01 Jan 2000 00:00:00 GMT");
        resp.getOutputStream().write(data);
    }
}

From source file:gsn.charts.GsnChartJfreechart.java

public JFreeChart createChart(Collection<Data> datas) {
    TimeSeries t1 = new TimeSeries("S1");
    Iterator<Data> iter = datas.iterator();
    Data data;//from w  ww. j  a v a  2  s  .  c  om
    while (iter.hasNext()) {
        data = iter.next();
        t1.addOrUpdate(RegularTimePeriod.createInstance(Millisecond.class, new Date((Long) data.getP2()),
                TimeZone.getDefault()), data.getValue());
    }
    XYDataset dataset = new TimeSeriesCollection(t1);
    JFreeChart chart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, false, false, false);
    chart.setAntiAlias(true);
    chart.setTextAntiAlias(true);
    chart.setBackgroundPaint(Color.WHITE);
    //
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setNoDataMessage("No Data to Display");
    plot.setDomainGridlinesVisible(true);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setInsets(new RectangleInsets(5, 14, 0, 5));
    //
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(ssdf);
    axis.setTickLabelFont(TICK_FONT);
    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setTickLabelFont(TICK_FONT);
    //
    return chart;
}

From source file:playground.dgrether.analysis.charts.DgMixedModeSwitcherOnlyDeltaScoreIncomeModeChoiceChart.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("Income [Chf / Year]");
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]");
    plot.setDomainAxis(xAxis);//w  w  w. j  a  v a2  s. co  m
    plot.setRangeAxis(yAxis);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(false, true);
    renderer1.setSeriesPaint(0, colorScheme.COLOR3B);
    renderer1.setSeriesPaint(1, colorScheme.COLOR4B);
    plot.setDataset(0, this.inomeModeChoiceDs);
    plot.setRenderer(0, renderer1);

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    plot.setDataset(1, this.avgDeltaScoreIncomeDs);
    for (int i = 2; i <= 3; i++) {
        renderer2.setSeriesStroke(i - 2, new BasicStroke(2.0f));
        renderer2.setSeriesOutlineStroke(i - 2, new BasicStroke(3.0f));
        renderer2.setSeriesPaint(i - 2, colorScheme.getColor(i + 1, "a"));
    }
    plot.setRenderer(1, renderer2);
    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    return chart;
}

From source file:playground.dgrether.analysis.charts.DgMixedDeltaUtilsModeGroupChart.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("% of Population Sorted by Income");
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]");
    plot.setDomainAxis(xAxis);//from  w  w  w .j a  va 2 s  .c  o  m
    plot.setRangeAxis(yAxis);
    //RANGE
    xAxis.setRange(0.0, 102.0);
    yAxis.setRange(-0.31, 0.61);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(false, true);
    renderer1.setSeriesPaint(0, colorScheme.COLOR1B);
    renderer1.setSeriesPaint(1, colorScheme.COLOR2B);
    renderer1.setSeriesPaint(2, colorScheme.COLOR3B);
    renderer1.setSeriesPaint(3, colorScheme.COLOR4B);
    plot.setDataset(0, this.inomeModeChoiceDs);
    plot.setRenderer(0, renderer1);

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    plot.setDataset(1, this.avgDeltaScoreIncomeDs);
    for (int i = 0; i <= 3; i++) {
        renderer2.setSeriesStroke(i, new BasicStroke(2.0f));
        renderer2.setSeriesOutlineStroke(i, new BasicStroke(3.0f));
        renderer2.setSeriesPaint(i, colorScheme.getColor(i + 1, "a"));
    }
    plot.setRenderer(1, renderer2);
    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    return chart;
}

From source file:playground.dgrether.analysis.charts.DgAvgDeltaUtilsModeGroupChart.java

@Override
public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("Income [Chf / Year]");
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]");
    plot.setDomainAxis(xAxis);/*from  w  ww  .  j av a2  s  . com*/
    plot.setRangeAxis(yAxis);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    plot.setDataset(0, this.dataset);
    for (int i = 0; i <= 3; i++) {
        renderer2.setSeriesStroke(i, new BasicStroke(2.0f));
        renderer2.setSeriesOutlineStroke(i, new BasicStroke(3.0f));
        renderer2.setSeriesPaint(i, colorScheme.getColor(i + 1, "a"));
    }
    plot.setRenderer(0, renderer2);

    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    return chart;
}

From source file:playground.dgrether.linkanalysis.DgCountPerIterationGraph.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("Iteration");
    xAxis.setRange(this.controllerConfig.getFirstIteration(), this.controllerConfig.getLastIteration() + 2);
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Trips");
    //      yAxis.setRange(-0.05, 0.3);
    //      xAxis.setVisible(false);
    //      xAxis.setFixedAutoRange(1.0);
    plot.setDomainAxis(xAxis);//from   w  ww  .  j av  a 2  s.c om
    plot.setRangeAxis(yAxis);

    plot.setDataset(0, this.dataset);

    DgColorScheme colorScheme = new DgColorScheme();
    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    for (int i = 0; i < this.dataset.getSeriesCount(); i++) {
        renderer2.setSeriesItemLabelsVisible(i, true);
        renderer2.setSeriesOutlineStroke(i, new BasicStroke(3.0f));
        renderer2.setSeriesStroke(i, new BasicStroke(2.0f));
        renderer2.setSeriesPaint(i, colorScheme.getColor(i + 1, "a"));
    }
    //      renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator);
    //      renderer2.setSeriesStroke(1, new BasicStroke(2.0f));
    //      renderer2.setSeriesOutlineStroke(1, new BasicStroke(3.0f));
    //      renderer2.setSeriesPaint(1, colorScheme.getColor(2, "a"));

    plot.setRenderer(0, renderer2);

    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    //      chart.removeLegend();
    return chart;
}