Example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer XYLineAndShapeRenderer

List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer XYLineAndShapeRenderer

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer XYLineAndShapeRenderer.

Prototype

public XYLineAndShapeRenderer(boolean lines, boolean shapes) 

Source Link

Document

Creates a new renderer.

Usage

From source file:ta4jexamples.indicators.CandlestickChart.java

public static void main(String[] args) {
    /**//w w w.java  2  s  . c om
     * Getting time series
     */
    TimeSeries series = CsvTradesLoader.loadBitstampSeries();

    /**
     * Creating the OHLC dataset
     */
    OHLCDataset ohlcDataset = createOHLCDataset(series);

    /**
     * Creating the additional dataset
     */
    TimeSeriesCollection xyDataset = createAdditionalDataset(series);

    /**
     * Creating the chart
     */
    JFreeChart chart = ChartFactory.createCandlestickChart("Bitstamp BTC price", "Time", "USD", ohlcDataset,
            true);
    // Candlestick rendering
    CandlestickRenderer renderer = new CandlestickRenderer();
    renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
    XYPlot plot = chart.getXYPlot();
    plot.setRenderer(renderer);
    // Additional dataset
    int index = 1;
    plot.setDataset(index, xyDataset);
    plot.mapDatasetToRangeAxis(index, 0);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
    renderer2.setSeriesPaint(index, Color.blue);
    plot.setRenderer(index, renderer2);
    // Misc
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setBackgroundPaint(Color.white);
    NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
    numberAxis.setAutoRangeIncludesZero(false);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    /**
     * Displaying the chart
     */
    displayChart(chart);
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    SymbolAxis symbolaxis = new SymbolAxis("Domain", new String[] { "A", "B", "C", "D" });
    SymbolAxis symbolaxis1 = new SymbolAxis("Range", new String[] { "V", "X", "Y", "Z" });
    symbolaxis1.setUpperMargin(0.0D);/*w w  w .  jav  a2 s  .  c  o m*/
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(false, true);
    XYPlot xyplot = new XYPlot(xydataset, symbolaxis, symbolaxis1, xylineandshaperenderer);
    JFreeChart jfreechart = new JFreeChart("SymbolicAxis Demo 1", xyplot);
    return jfreechart;
}

From source file:org.jax.maanova.plot.PlotUtil.java

/**
 * Create a simple XY renderer which can be used for scatter plots
 * @return  the renderer/* ww w.j a va  2  s .  co  m*/
 */
public static XYLineAndShapeRenderer createSimpleScatterPlotRenderer() {
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);

    renderer.setAutoPopulateSeriesShape(false);
    renderer.setAutoPopulateSeriesOutlinePaint(false);
    renderer.setAutoPopulateSeriesOutlineStroke(false);
    renderer.setAutoPopulateSeriesPaint(false);

    renderer.setBaseShape(new Ellipse2D.Float(-PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F,
            -PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F, PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS,
            PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS));

    renderer.setUseOutlinePaint(true);
    renderer.setBaseOutlinePaint(Color.BLACK);
    renderer.setBaseOutlineStroke(new BasicStroke(0.25F));

    renderer.setSeriesPaint(0, new Color(0x55, 0x55, 0xFF)); // blue
    renderer.setSeriesPaint(1, new Color(0xFF, 0x55, 0x55)); // red

    return renderer;
}

From source file:jamel.gui.charts.AbstractScatterChart.java

/**
 * Returns a new plot./*from  w w w  .  j  a v  a2  s.c o  m*/
 * 
 * @param xySeries  the series.
 * @param xAxisLabel  the label of the horizontal axis.
 * @param yAxisLabel  the label of the vertical axis.
 * @return a new plot.
 */
static private Plot newPlot(XYSeries xySeries, String xAxisLabel, String yAxisLabel) {
    final XYSeriesCollection dataset = new XYSeriesCollection();
    if (xySeries != null)
        dataset.addSeries(xySeries);
    final XYPlot plot = new XYPlot(dataset, new NumberAxis(xAxisLabel), new NumberAxis(yAxisLabel),
            new XYLineAndShapeRenderer(false, true));
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}

From source file:com.spotify.heroic.http.render.RenderUtils.java

public static JFreeChart createChart(final List<ShardedResultGroup> groups, final String title,
        Map<String, String> highlight, Double threshold, int height) {
    final XYLineAndShapeRenderer lineAndShapeRenderer = new XYLineAndShapeRenderer(true, true);
    final DeviationRenderer intervalRenderer = new DeviationRenderer();

    final XYSeriesCollection regularData = new XYSeriesCollection();
    final YIntervalSeriesCollection intervalData = new YIntervalSeriesCollection();

    int lineAndShapeCount = 0;
    int intervalCount = 0;

    for (final ShardedResultGroup resultGroup : groups) {
        final MetricCollection group = resultGroup.getMetrics();

        if (group.getType() == MetricType.POINT) {
            final XYSeries series = new XYSeries(resultGroup.getMetrics().toString());

            final List<Point> data = group.getDataAs(Point.class);

            for (final Point d : data) {
                series.add(d.getTimestamp(), d.getValue());
            }//from  w  ww.j  a va2s .  c  o m

            lineAndShapeRenderer.setSeriesPaint(lineAndShapeCount, Color.BLUE);
            lineAndShapeRenderer.setSeriesShapesVisible(lineAndShapeCount, false);
            lineAndShapeRenderer.setSeriesStroke(lineAndShapeCount, new BasicStroke(2.0f));
            regularData.addSeries(series);
            ++lineAndShapeCount;
        }

        if (group.getType() == MetricType.SPREAD) {
            final YIntervalSeries series = new YIntervalSeries(resultGroup.getMetrics().toString());

            final List<Spread> data = group.getDataAs(Spread.class);

            for (final Spread d : data) {
                series.add(d.getTimestamp(), d.getSum() / d.getCount(), d.getMin(), d.getMax());
            }

            intervalRenderer.setSeriesPaint(intervalCount, Color.GREEN);
            intervalRenderer.setSeriesStroke(intervalCount, new BasicStroke(2.0f));
            intervalRenderer.setSeriesFillPaint(intervalCount, new Color(200, 255, 200));
            intervalRenderer.setSeriesShapesVisible(intervalCount, false);
            intervalData.addSeries(series);
            ++intervalCount;
        }
    }

    final JFreeChart chart = buildChart(title, regularData, intervalData, lineAndShapeRenderer,
            intervalRenderer);

    chart.setAntiAlias(true);
    chart.setBackgroundPaint(Color.WHITE);

    final XYPlot plot = chart.getXYPlot();

    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.BLACK);
    plot.setRangeGridlinePaint(Color.BLACK);

    if (threshold != null) {
        final ValueMarker marker = new ValueMarker(threshold, Color.RED,
                new BasicStroke(Math.max(Math.min(height / 20, 6), 1)), Color.RED, null, 0.5f);
        plot.addRangeMarker(marker);
    }

    plot.setRenderer(lineAndShapeRenderer);

    // final DateAxis rangeAxis = (DateAxis) plot.getRangeAxis();
    // rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits());

    return chart;
}

From source file:edu.gmu.cs.sim.util.media.chart.ScatterPlotGenerator.java

protected void buildChart() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    chart = ChartFactory.createScatterPlot("Untitled Chart", "Untitled X Axis", "Untitled Y Axis", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    chart.setAntiAlias(true);/*from  w w w .  jav  a2s . co  m*/
    //chartPanel = new ScrollableChartPanel(chart, true); 
    chartPanel = buildChartPanel(chart);
    //chartHolder.getViewport().setView(chartPanel);
    setChartPanel(chartPanel);
    chart.getXYPlot().setRenderer(new XYLineAndShapeRenderer(false, true));
    //              ((StandardLegend) chart.getLegend()).setDisplaySeriesShapes(true);

    // this must come last because the chart must exist for us to set its dataset
    setSeriesDataset(dataset);
}

From source file:jesse.GA_ANN.DataVis.java

JFreeChart createChart()//Here Input MillSecond
{
    total = new XYSeries[10];
    XYSeriescollection = new XYSeriesCollection();
    for (int i = 0; i < 10; i++) {
        total[i] = new XYSeries(i);
        XYSeriescollection.addSeries(total[i]);
    }/*  ww  w  .  j  av a  2 s .  com*/

    dateaxis = new NumberAxis("Time");
    NumberAxis Conaxis = new NumberAxis("z??");
    dateaxis.setAutoRange(true);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setTickLabelsVisible(true);
    xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    xylineandshaperenderer.setSeriesPaint(0, Color.green);
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(1F, 0, 2));
    xylineandshaperenderer.setFillPaint(new Color(30, 30, 220), true);

    Conaxis.setRange(-1, 1);
    Conaxis.setAutoRange(true);
    Conaxis.setAutoRangeIncludesZero(false);

    XYPlot xyplot = new XYPlot(XYSeriescollection, dateaxis, Conaxis, xylineandshaperenderer);
    JFreeChart jfreechart = new JFreeChart("time-z", new Font("Arial", 1, 24), xyplot, true);
    ChartUtilities.applyCurrentTheme(jfreechart);
    ChartPanel chartpanel = new ChartPanel(jfreechart, true);
    chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    return jfreechart;
}

From source file:controller.DrawCurve.java

private JPanel createChart() {
    String chartTitle = "Camera Response Curve";
    String xAxisLabel = "log Exposure G(Z)";
    String yAxisLabel = "Intensity pixel Z";

    XYDataset dataset = createDataset();

    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, xAxisLabel, yAxisLabel, dataset);

    //Set custom color and thickness for line curve
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);

    // sets paint color for each series
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.BLUE);

    // sets thickness for series (using strokes)
    renderer.setSeriesStroke(0, new BasicStroke(1.5f));
    renderer.setSeriesStroke(1, new BasicStroke(1.5f));
    renderer.setSeriesStroke(2, new BasicStroke(1.5f));

    XYPlot plot = chart.getXYPlot();/* ww w . j  a  va  2 s. co  m*/
    plot.setRenderer(renderer);

    return new ChartPanel(chart);
}

From source file:net.sf.maltcms.chromaui.charts.renderer.XYPlotRendererModel.java

/**
 *
 *//*from   w ww . ja  v  a 2s  .  com*/
public XYPlotRendererModel() {
    XYLineAndShapeRenderer l = new XYLineAndShapeRenderer(true, false);
    l.setDrawSeriesLineAsPath(false);
    addElement(l);
    XYAreaRenderer xya = new XYAreaRenderer(XYAreaRenderer.AREA);
    addElement(xya);
    addElement(new EntityAwareSamplingXYLineRenderer());
    XYBarRenderer xyb = new XYBarRenderer(0.0d);
    xyb.setBarAlignmentFactor(0.5);
    xyb.setDrawBarOutline(false);
    xyb.setShadowVisible(false);
    StandardXYBarPainter barPainter = new StandardXYBarPainter();
    xyb.setBarPainter(barPainter);
    addElement(xyb);
}

From source file:jamel.gui.charts.TimeChart.java

/**
 * Returns a new time plot./*from   w  w w .  j a  v a  2 s . c om*/
 * @param timeSeries  the time series.
 * @param valueAxisLabel the value axis label.
 * @return a new time plot.
 */
private static Plot newTimePlot(TimeSeries[] timeSeries, String valueAxisLabel) {
    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.setXPosition(TimePeriodAnchor.MIDDLE);
    for (int i = 0; i < timeSeries.length; i++) {
        TimeSeries series = timeSeries[i];
        if (series == null)
            throw new RuntimeException();
        dataset.addSeries(series);
    }
    final XYPlot plot = new XYPlot(dataset, new DateAxis(), new NumberAxis(valueAxisLabel),
            new XYLineAndShapeRenderer(true, false));
    ((DateAxis) plot.getDomainAxis()).setAutoRange(false);
    ((DateAxis) plot.getDomainAxis()).setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    plot.setDomainGridlinesVisible(false);
    return plot;
}