Example usage for org.jfree.chart.plot XYPlot getRenderer

List of usage examples for org.jfree.chart.plot XYPlot getRenderer

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot getRenderer.

Prototype

public XYItemRenderer getRenderer() 

Source Link

Document

Returns the renderer for the primary dataset.

Usage

From source file:se.six.jmeter.visualizer.statagg.StatAggVisualizer.java

private JFreeChart createChart() {
    setupDatasets();/*  w ww  .j a  v a 2  s . c  o m*/

    final JFreeChart chart = ChartFactory.createTimeSeriesChart(null, "Time", "ThroughPut", _dataSet1, true,
            true, false);
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));

    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    //axis.setFixedAutoRange(12 * 3600 * 1000);  // 12 Hours

    XYItemRenderer renderer1 = plot.getRenderer();
    renderer1.setSeriesPaint(0, Color.BLACK);

    final NumberAxis axis2 = new NumberAxis("Response Time");
    axis2.setAutoRangeIncludesZero(false);
    plot.setRangeAxis(1, axis2);
    plot.setDataset(1, _dataSet2);
    plot.mapDatasetToRangeAxis(1, 1);

    StandardXYItemRenderer renderer2 = new StandardXYItemRenderer();
    renderer2.setSeriesPaint(0, new Color(0, 153, 255));
    plot.setRenderer(1, renderer2);

    chart.setBackgroundPaint(Color.white);

    return chart;
}

From source file:org.openscience.cdk.applications.taverna.basicutilities.ChartTool.java

/**
 * Creates a XY bar chart.//  w  ww.  j  a  va2s .  c om
 * 
 * @param title
 * @param categoryAxisLabel
 * @param valueAxisLabel
 * @param dataset
 * @param includeZero
 * @param shadow
 * @return
 */
public JFreeChart createXYBarChart(String title, String categoryAxisLabel, String valueAxisLabel,
        IntervalXYDataset dataset, boolean includeZero, boolean shadow) {
    JFreeChart chart = ChartFactory.createXYBarChart(title, categoryAxisLabel, false, valueAxisLabel, dataset,
            this.orientation, this.drawLegend, false, false);
    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);
    chart.setAntiAlias(true);
    XYPlot plot = chart.getXYPlot();
    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLowerMargin(0.025);
    domainAxis.setUpperMargin(0.025);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(includeZero);
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setShadowVisible(shadow);
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    renderer.setSeriesPaint(2, Color.green);
    renderer.setSeriesPaint(3, Color.darkGray);
    renderer.setSeriesPaint(4, Color.yellow);
    return chart;
}

From source file:net.sf.fspdfs.chartthemes.spring.AegeanChartTheme.java

/**
 *
 *//*from  ww  w.  j  a v  a 2 s  . c o  m*/
protected void configurePlot(Plot plot, JRChartPlot jrPlot) {

    super.configurePlot(plot, jrPlot);

    if (plot instanceof CategoryPlot) {
        CategoryPlot categoryPlot = (CategoryPlot) plot;
        CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
        CategoryDataset categoryDataset = categoryPlot.getDataset();
        if (categoryDataset != null) {
            for (int i = 0; i < categoryDataset.getRowCount(); i++) {
                categoryRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
            }
        }
        categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
        categoryPlot.setRangeGridlineStroke(new BasicStroke(0.5f));
        categoryPlot.setDomainGridlinesVisible(false);
        categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    } else if (plot instanceof XYPlot) {
        XYPlot xyPlot = (XYPlot) plot;
        XYItemRenderer xyItemRenderer = xyPlot.getRenderer();
        XYDataset xyDataset = xyPlot.getDataset();
        if (xyDataset != null) {
            for (int i = 0; i < xyDataset.getSeriesCount(); i++) {
                xyItemRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
            }
        }
        xyPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
        xyPlot.setRangeGridlineStroke(new BasicStroke(0.5f));
        xyPlot.setDomainGridlinesVisible(false);
        xyPlot.setRangeZeroBaselineVisible(true);
    }
}

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

private JFreeChart createLineChart(String title, String constraint, XYDataset dataset) {
    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(title, "Date/Time", // x axis label
            null, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );/* w  w  w.ja  v a 2  s  . c  om*/
    XYPlot plot = chart.getXYPlot();
    // X axis shows dates
    plot.setDomainAxis(new DateAxis());
    // if data has a constraint, hide every thing else
    if (constraint != null) {
        chart.removeLegend();
        XYDataset data = plot.getDataset();
        Paint bg = plot.getBackgroundPaint();
        for (int i = 0; i < data.getSeriesCount(); i++) {
            if (!constraint.equals(data.getSeriesKey(i)))
                plot.getRenderer().setSeriesPaint(i, bg);
            else {
                // get a color match...
                plot.getRenderer().setSeriesPaint(i, DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[i]);
                // reset plot range for this maximum
                double d = 0;
                for (int j = 0; j < data.getItemCount(i); j++) {
                    if (d < data.getYValue(i, j))
                        d = data.getYValue(i, j);
                }
                // add a bit for top margin
                d += d * 0.04;
                plot.getRangeAxis().setUpperBound(d);
            }
        }
    }
    return chart;
}

From source file:org.esa.beam.visat.toolviews.stat.HistogramPanel.java

private void createUI() {
    dataset = new XIntervalSeriesCollection();
    chart = ChartFactory.createHistogram(CHART_TITLE, "Values", "Frequency in #pixels", dataset,
            PlotOrientation.VERTICAL, false, // Legend?
            true, // tooltips
            false // url
    );//  ww w  . j  a v a2s  .co m
    final XYPlot xyPlot = chart.getXYPlot();
    xyPlot.setDomainZeroBaselineStroke(new BasicStroke(0.2f));

    final XYBarRenderer renderer = (XYBarRenderer) xyPlot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setShadowVisible(false);
    renderer.setShadowYOffset(-4.0);
    renderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator());
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setSeriesPaint(0, new Color(0, 0, 200));

    createUI(createChartPanel(chart), createOptionsPanel(), bindingContext);

    isInitialized = true;

    final Binding minBinding = xAxisRangeControl.getBindingContext().getBinding("min");
    final double min = (Double) minBinding.getPropertyValue();
    final Binding maxBinding = xAxisRangeControl.getBindingContext().getBinding("max");
    final double max = (Double) maxBinding.getPropertyValue();
    if (!histogramComputing && min > max) {
        minBinding.setPropertyValue(max);
        maxBinding.setPropertyValue(min);
    }
    updateXAxis();
}

From source file:com.intel.stl.ui.main.view.PacketRateChartRangeUpdater.java

@Override
public void updateChartRange(JFreeChart chart, long lower, long upper) {
    if (lower > upper) {
        return;/*from   w  ww.  j av a 2 s.co  m*/
    }

    XYPlot xyplot = (XYPlot) chart.getPlot();
    NumberAxis range = (NumberAxis) xyplot.getRangeAxis();
    range.setRangeWithMargins(lower, upper);
    range.setLowerBound(0);

    // If upper is less than 1000, don't do anything to convert the y-axis
    // label and
    // convert the unit tick.
    TickUnitSource unitSrc = createTickUnits(upper);
    if (unitSrc != null) {
        // Change tick values only if upper is above 1000.
        range.setStandardTickUnits(unitSrc);
        xyplot.getRenderer().setBaseToolTipGenerator(
                new PktsRateToolTipGenerator("<html><b>{0}</b><br> Time: {1}<br> Data: {2}</html>",
                        Util.getHHMMSS(), new DecimalFormat("#,##0.00" + " " + unitDes)));
    } else {
        range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }

    // y-axis label
    setChartRangeLabel(range);
}

From source file:sanger.team16.gui.genevar.eqtl.gene.RegionalPlot.java

private JFreeChart createChart(String geneChromosome, int geneStart, int distanceToTSS, double threshold,
        XYDataset dataset) {/*from ww  w . j a  v  a2s . c om*/
    JFreeChart chart = ChartFactory.createScatterPlot(null,
            "Position on chromosome " + geneChromosome + " (bp)", "-log10(P)", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.lightGray);
    //plot.setRangeGridlinePaint(Color.lightGray);
    //plot.setRangeCrosshairVisible(true);

    //NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    //domainAxis.setRange(geneStart - distance, geneStart + distance);       
    //domainAxis.setUpperMargin(1000);
    //domainAxis.setLowerMargin(1000);

    //ValueAxis rangeAxis = plot.getRangeAxis();
    //rangeAxis.setUpperMargin(dataset.getYValue(0, 0)/5);
    //rangeAxis.setLowerBound(0);

    XYItemRenderer renderer = plot.getRenderer();
    int size = dataset.getSeriesCount();
    for (int i = 0; i < size; i++) {
        //int scale = (int) Math.round((255 - (255 * dataset.getYValue(i, 0)) / top) / 1.4);
        //renderer.setSeriesPaint(i, new Color(255, scale, scale));

        renderer.setSeriesPaint(i, new Color(255, 0, 0));
        renderer.setSeriesShape(i, ShapeUtilities.createDiamond((float) 3));
        renderer.setBaseSeriesVisibleInLegend(false);
    }

    ValueMarker upperMarker = new ValueMarker(-Math.log10(threshold));
    upperMarker.setPaint(Color.gray);
    //upperMarker.setLabelOffsetType(LengthAdjustmentType.EXPAND);        
    //upperMarker.setLabel("-log10(10E-4)");
    //upperMarker.setLabelPaint(Color.red);
    //upperMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    //upperMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    float[] f = { 4, 3, 4, 3 };
    upperMarker.setStroke(new BasicStroke(1.0f, 1, 1, 0, f, 1.0f));
    plot.addRangeMarker(upperMarker);

    ValueMarker marker = new ValueMarker(0.0);
    marker.setPaint(Color.lightGray);
    plot.addRangeMarker(marker);

    XYSeries series = new XYSeries("Range");
    series.add(geneStart - distanceToTSS, -0.05);
    series.add(geneStart + distanceToTSS, -0.05);
    ((XYSeriesCollection) dataset).addSeries(series);
    renderer.setSeriesVisible(dataset.getSeriesCount() - 1, false, false);

    return chart;
}

From source file:sanger.team16.gui.genevar.mqtl.gene.RegionalPlot.java

private JFreeChart createChart(String geneChromosome, int geneStart, int distanceToTSS, double threshold,
        XYDataset dataset) {/* w  w w.ja v  a  2  s.  c o  m*/
    JFreeChart chart = ChartFactory.createScatterPlot(null,
            "Position on chromosome " + geneChromosome + " (bp)", "-log10(P)", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.lightGray);
    //plot.setRangeGridlinePaint(Color.lightGray);
    //plot.setRangeCrosshairVisible(true);

    //NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    //domainAxis.setRange(geneStart - distance, geneStart + distance);       
    //domainAxis.setUpperMargin(1000);
    //domainAxis.setLowerMargin(1000);

    //ValueAxis rangeAxis = plot.getRangeAxis();
    //rangeAxis.setUpperMargin(dataset.getYValue(0, 0)/5);
    //rangeAxis.setLowerBound(0);

    XYItemRenderer renderer = plot.getRenderer();
    int size = dataset.getSeriesCount();
    for (int i = 0; i < size; i++) {
        //int scale = (int) Math.round((255 - (255 * dataset.getYValue(i, 0)) / top) / 1.4);
        //renderer.setSeriesPaint(i, new Color(255, scale, scale));

        renderer.setSeriesPaint(i, new Color(50, 205, 50));
        renderer.setSeriesShape(i, ShapeUtilities.createDiamond((float) 3));
        renderer.setBaseSeriesVisibleInLegend(false);
    }

    ValueMarker upperMarker = new ValueMarker(-Math.log10(threshold));
    upperMarker.setPaint(Color.gray);
    //upperMarker.setLabelOffsetType(LengthAdjustmentType.EXPAND);        
    //upperMarker.setLabel("-log10(10E-4)");
    //upperMarker.setLabelPaint(Color.red);
    //upperMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    //upperMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    float[] f = { 4, 3, 4, 3 };
    upperMarker.setStroke(new BasicStroke(1.0f, 1, 1, 0, f, 1.0f));
    plot.addRangeMarker(upperMarker);

    ValueMarker marker = new ValueMarker(0.0);
    marker.setPaint(Color.lightGray);
    plot.addRangeMarker(marker);

    XYSeries series = new XYSeries("Range");
    series.add(geneStart - distanceToTSS, -0.05);
    series.add(geneStart + distanceToTSS, -0.05);
    ((XYSeriesCollection) dataset).addSeries(series);
    renderer.setSeriesVisible(dataset.getSeriesCount() - 1, false, false);

    return chart;
}

From source file:net.sf.fspdfs.chartthemes.spring.AegeanChartTheme.java

/**
 *
 *//*from   w  w w  .ja v  a 2 s  .c  o  m*/
protected JFreeChart createBubbleChart() throws JRException {
    JFreeChart jfreeChart = super.createBubbleChart();

    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
    XYBubbleRenderer bubbleRenderer = (XYBubbleRenderer) xyPlot.getRenderer();
    XYDataset xyDataset = xyPlot.getDataset();
    if (xyDataset != null) {
        for (int i = 0; i < xyDataset.getSeriesCount(); i++) {
            bubbleRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
        }
    }
    return jfreeChart;
}

From source file:net.sf.fspdfs.chartthemes.spring.AegeanChartTheme.java

/**
 *
 *///  w  w  w  . j a  v a  2  s.c o m
protected JFreeChart createCandlestickChart() throws JRException {
    JFreeChart jfreeChart = super.createCandlestickChart();
    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
    CandlestickRenderer renderer = (CandlestickRenderer) xyPlot.getRenderer();
    DefaultHighLowDataset dataset = (DefaultHighLowDataset) xyPlot.getDataset();
    List seriesPaints = (List) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS);

    for (int i = 0; i < dataset.getSeriesCount(); i++) {

        renderer.setSeriesFillPaint(i, (Paint) seriesPaints.get(i));
        renderer.setSeriesPaint(i, Color.DARK_GRAY);
    }
    return jfreeChart;
}