Example usage for org.jfree.chart JFreeChart setAntiAlias

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

Introduction

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

Prototype

public void setAntiAlias(boolean flag) 

Source Link

Document

Sets a flag that indicates whether or not anti-aliasing is used when the chart is drawn.

Usage

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

private void sexupLayout(JFreeChart chart) {
    chart.setAntiAlias(true);
    chart.setBackgroundPaint(VisorFrame.bgcolor);
    chart.setBorderVisible(false);//from w w w. j  av a  2 s .  c o m
    TextTitle title = chart.getTitle();
    title.setFont(VisorFrame.smallerfont);
    title.setPaint(VisorFrame.fgcolor);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(VisorFrame.bgcolor);
    plot.setDomainAxis(new DateAxis());
    sexupAxis(plot.getDomainAxis());
    sexupAxis(plot.getRangeAxis());
}

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

/**
 * Updates the chart./*from w ww.  j a v  a  2s  .c om*/
 * 
 * @param chart
 *            the chart.
 */
public void updateChartProperties(JFreeChart chart) {
    chart.setAntiAlias(this.antialias.getSelection());
    chart.setBackgroundPaint(SWTUtils.toAwtColor(this.backgroundPaintCanvas.getColor()));
}

From source file:org.geotools.renderer.chart.GeometryRendererTest.java

void showChart(XYPlot plot) throws Exception {
    JFreeChart chart = new JFreeChart(plot);
    chart.setAntiAlias(true);
    ChartPanel panel = new ChartPanel(chart, true);

    final String headless = System.getProperty("java.awt.headless", "false");
    if (!headless.equalsIgnoreCase("true") && TestData.isInteractiveTest()) {
        try {/* ww  w  .  j a v a  2 s. c om*/
            JFrame frame = new JFrame(getName());
            frame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    e.getWindow().dispose();
                }
            });
            frame.setContentPane(panel);
            frame.setSize(new Dimension(500, 500));
            frame.setVisible(true);

            Thread.sleep(5000);
            frame.dispose();
        } catch (HeadlessException exception) {
            // The test is running on a machine without X11 display. Ignore.
            return;
        }
    }
}

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;/*from  ww w.j a  v a2 s  .c  o 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   ww w . j a  va 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:net.relet.freimap.LinkInfo.java

private void sexupLayout(JFreeChart chart) {
    chart.setAntiAlias(true);
    chart.setBackgroundPaint(VisorFrame.bgcolor2);
    chart.setBorderVisible(false);/*from w  ww  .j ava2 s .com*/
    TextTitle title = chart.getTitle();
    title.setFont(VisorFrame.smallerfont);
    title.setPaint(VisorFrame.fgcolor2);
    Plot plot = chart.getPlot();
    sexupPlot(plot);
}

From source file:LowPassFilterTest.java

@Test
public void test() throws InterruptedException {
    CategoryTableXYDataset serie = new CategoryTableXYDataset();
    serie.setNotify(false);/* ww w. j  av a2 s .  co m*/
    double step = 1.0 / discretization;
    double startPosition = step * framePosition;
    //100 ? - 100 , 50 ? - 50 , 25 ?- 25 
    double[] data = math.convolve(
            math.HammingWindow(testData.get1DPolyharmSignal(4, 200, frameWidth, discretization), frameWidth),
            math.lpf(60, step, 1024));
    //        double[] data = math.convolve(testData.get1DSignal(100, 200, frameWidth, discretization), math.lpf(70, step, 128));

    //        double[] data = math.convolve(testData.get1DSignal(100, 200, 32768, 10000), math.lpf(70, 1./10000, 32));
    //        double[] data = testData.get1DSignal(100, 200, frameWidth, discretization);
    //        double[] data = math.lpf(70, step,128);
    for (int i = 0; i < data.length; i++) {
        serie.add(startPosition, data[i], "");
        startPosition += step;
    }
    JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "g, /c^2", serie);
    chart.removeLegend();
    chart.setAntiAlias(false);

    XYPlot plot = chart.getXYPlot();
    //plot.setRangeGridlinePaint(Color.BLACK);
    org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis();
    org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis();
    double start = framePosition * 1.0 / discretization;
    double max = start + frameWidth * 1.0 / discretization;
    xAxis.setRange(start, max);
    ChartPanel chartPanel = new ChartPanel(chart);

    JPanel p = new JPanel(new BorderLayout());

    p.removeAll();
    p.add(chartPanel);
    p.validate();
    //1. Create the frame.
    JFrame frame = new JFrame("FrameDemo");

    //2. Optional: What happens when the frame closes?
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //3. Create components and put them in the frame.
    //...create emptyLabel...
    frame.getContentPane().add(new Label("olol"), BorderLayout.CENTER);
    frame.getContentPane().add(p, BorderLayout.CENTER);

    //4. Size the frame.
    frame.pack();

    //5. Show it.
    frame.setVisible(true);
}

From source file:picocash.components.panel.statistic.IncomeByCategoryStatistic.java

private void init() {
    this.title = "Income";
    this.dataset = new DefaultPieDataset();
    this.chartPanel = new JXPanel(new MigLayout("fill, insets 0 0 0 0"));

    final JFreeChart piechart = ChartFactory.createPieChart(title, dataset, true, true, Locale.getDefault());
    piechart.setBorderVisible(false);//www  .  j  a v a2 s. c om
    piechart.setAntiAlias(true);
    ((PiePlot) piechart.getPlot()).setLabelGenerator(null);

    ChartPanel chart = new ChartPanel(piechart, 300, 300, 200, 200, 400, 400, false, false, false, false, false,
            true);

    chart.getChart().getPlot().setBackgroundAlpha(0);
    chart.getChart().getPlot().setOutlineVisible(false);

    this.chartPanel.setOpaque(false);
    this.chartPanel.add(chart, "aligny top");
}

From source file:org.yccheok.jstock.gui.charting.DynamicChart.java

/** Creates new form DynamicChart */
public DynamicChart() {
    this.price = new TimeSeries("Price");
    // Sets the maximumItemAge attribute, which specifies the maximum age of data items in the series
    // (in terms of the RegularTimePeriod type used by this series). Whenever a new data value is
    // added, any data items that are older than the limit specified by maximumItemAge are automatically
    // discarded/* w w  w  .j a v a2 s.  co  m*/
    // Maximum 2 hours.
    this.price.setMaximumItemAge(2 * 60 * 60);

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(this.price);

    JFreeChart freeChart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, false, true, false);

    freeChart.setAntiAlias(true);
    while (freeChart.getSubtitleCount() > 0) {
        freeChart.removeSubtitle(freeChart.getSubtitle(0));
    }

    // Due to limited spacing, we remove all information regarding x and y axis
    // as well.
    XYPlot plot = freeChart.getXYPlot();
    plot.getRangeAxis().setVisible(false);
    plot.getDomainAxis().setVisible(false);

    XYItemRenderer renderer1 = plot.getRenderer();
    renderer1.setBaseToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("h:mm:ss a"), new DecimalFormat("0.00#")));

    org.yccheok.jstock.charting.Utils.applyChartTheme(freeChart);

    // Disable zoom.
    chartPanel = new ChartPanel(freeChart, true, true, true, false, true);
    chartPanel.setMouseZoomable(false);
}

From source file:D1WaveletTransform.java

@Test
public void test() throws InterruptedException, JWaveException {
    CategoryTableXYDataset serie = new CategoryTableXYDataset();
    serie.setNotify(false);//from   w ww.  ja  va 2  s.  com
    double step = 1.0 / discretization;
    double startPosition = step * framePosition;
    //100 ? - 100 , 50 ? - 50 , 25 ?- 25 
    WaveletTransform t = new FastWaveletTransform((new Haar1()));
    double[] data = t.forward(testData.get1DSimpleSignal(1, 3, frameWidth, discretization), 128);
    //        double[] data = math.convolve(testData.get1DSignal(100, 200, frameWidth, discretization), math.lpf(70, step, 128));

    //        double[] data = math.convolve(testData.get1DSignal(100, 200, 32768, 10000), math.lpf(70, 1./10000, 32));
    //        double[] data = testData.get1DSignal(100, 200, frameWidth, discretization);
    //        double[] data = math.lpf(70, step,128);
    for (int i = 0; i < data.length; i++) {
        serie.add(startPosition, data[i], "");
        startPosition += step;
    }
    JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "wave", serie);
    chart.removeLegend();
    chart.setAntiAlias(false);

    XYPlot plot = chart.getXYPlot();
    //plot.setRangeGridlinePaint(Color.BLACK);
    org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis();
    org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis();
    double start = framePosition * 1.0 / discretization;
    double max = start + frameWidth * 1.0 / discretization;
    xAxis.setRange(start, max);
    ChartPanel chartPanel = new ChartPanel(chart);

    JPanel p = new JPanel(new BorderLayout());

    p.removeAll();
    p.add(chartPanel);
    p.validate();
    //1. Create the frame.
    JFrame frame = new JFrame("FrameDemo");

    //2. Optional: What happens when the frame closes?
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //3. Create components and put them in the frame.
    //...create emptyLabel...
    frame.getContentPane().add(new Label("olol"), BorderLayout.CENTER);
    frame.getContentPane().add(p, BorderLayout.CENTER);

    //4. Size the frame.
    frame.pack();

    //5. Show it.
    frame.setVisible(true);
}