Example usage for org.jfree.chart.renderer.xy XYAreaRenderer setSeriesFillPaint

List of usage examples for org.jfree.chart.renderer.xy XYAreaRenderer setSeriesFillPaint

Introduction

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

Prototype

public void setSeriesFillPaint(int series, Paint paint) 

Source Link

Document

Sets the paint used for a series fill and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:edu.fullerton.ldvservlet.SrcList.java

private PageItem makePlots(ArrayList<ChanSourceData> csdList, String name, Database db, Page vpage,
        ViewUser vuser, String contextPath) throws WebUtilException, LdvTableException {
    PageItemList ret = new PageItemList();
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Date/Time (UTC)"));
    plot.setGap(10.0);//w w  w  . j ava2s. c  o  m

    String baseName = "";
    StringBuilder errors = new StringBuilder();
    int plotNum = 0;
    Color[] colors = { Color.RED, Color.BLUE, Color.MAGENTA, Color.ORANGE, Color.DARK_GRAY, Color.GREEN };
    boolean gotData = false;
    TimeInterval timeRange = null;
    for (ChanSourceData csd : csdList) {
        TimeInterval ti = csd.getTimeRange();
        if (ti != null) {
            if (timeRange == null) {
                timeRange = ti;
            } else if (timeRange.overlaps(ti)) {
                timeRange = timeRange.mergeIntervals(ti);
            } else if (ti.getStartGps() < timeRange.getStartGps()) {
                timeRange.setStartGps(ti.getStartGps());
            } else if (ti.getStopGps() > timeRange.getStopGps()) {
                timeRange.setStopGps(ti.getStopGps());
            }
        }
    }
    if (timeRange != null) {
        for (ChanSourceData csd : csdList) {
            baseName = csd.getChanInfo().getBaseName();
            TimeSeriesCollection mtds = new TimeSeriesCollection();
            String server = csd.getChanInfo().getServer().replace(".caltech.edu", "");
            String legend = String.format("Type: %1$s at %2$s", csd.getChanInfo().getcType(), server);
            TimeSeries ts;
            double[][] data = csd.getGraphData();
            if (data == null) {
                data = new double[2][2];
                data[0][0] = timeRange.getStartGps();
                data[1][0] = timeRange.getStopGps();
                data[0][1] = data[1][1] = 0;
                errors.append("Error getting data for: ").append(legend).append("<br>");
            } else {
                gotData = true;
            }
            for (double[] d : data) {
                d[1] = d[1] <= 1 ? 1 : d[1];
            }
            ts = getTimeSeries(data, legend);

            mtds.addSeries(ts);
            XYAreaRenderer renderer = new XYAreaRenderer(XYAreaRenderer.AREA);

            BasicStroke str = new BasicStroke(2);
            int colorIdx = plotNum % colors.length;
            Color color = colors[colorIdx];
            NumberAxis yAxis = new NumberAxis("% Avail");
            yAxis.setRange(0, 100);
            renderer.setBaseFillPaint(color);
            renderer.setSeriesFillPaint(0, Color.WHITE);
            renderer.setBaseStroke(str);
            renderer.setUseFillPaint(true);
            XYPlot subplot = new XYPlot(mtds, null, yAxis, renderer);
            plot.add(subplot);

            plotNum++;
        }

        ChartPanel cpnl;
        JFreeChart chart;
        String gtitle = String.format("Available data for %1$s ", baseName);
        String subTitleTxt = String.format("From %1$s to %2$s",
                TimeAndDate.gpsAsUtcString(timeRange.getStartGps()),
                TimeAndDate.gpsAsUtcString(timeRange.getStopGps()));

        plot.setOrientation(PlotOrientation.VERTICAL);

        chart = new JFreeChart(gtitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true);

        chart.addSubtitle(new TextTitle(subTitleTxt));
        cpnl = new ChartPanel(chart, false, false, false, false, false);

        PluginSupport psupport = new PluginSupport();
        psupport.setup(db, vpage, vuser);
        int imgId;
        PageItemImage img = null;
        try {
            psupport.setSize(800, 600);
            imgId = psupport.saveImageAsPNG(cpnl);
            String url = String.format("%1$s/view?act=getImg&amp;imgId=%2$d", contextPath, imgId);

            img = new PageItemImage(url, "availability", baseName);

        } catch (SQLException | IOException | NoSuchAlgorithmException ex) {
            String ermsg = String.format("Error creating or saving image: %1$s - $2$s",
                    ex.getClass().getSimpleName(), ex.getLocalizedMessage());
            errors.append(ermsg);

        }
        if (errors.length() > 0) {
            ret.add(errors.toString());
        }
        if (img != null) {
            ret.add(img);
        }
    } else {
        ret.add("No data to plot.");
    }
    return ret;
}

From source file:com.afunms.system.manage.equipManager.java

/**
 * Creates a sample chart./*from w  w  w  . ja  va 2  s .  c  o m*/
 * 
 * @return a sample chart.
 */
private JFreeChart createChart() {
    final XYDataset direction = createDirectionDataset(600);
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", direction,
            true, true, false);

    final XYPlot plot = chart.getXYPlot();
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setUpperMargin(0.0);
    plot.setRangeCrosshairVisible(true);
    plot.setDomainCrosshairVisible(true);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setForegroundAlpha(0.8f);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.darkGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(new Color(139, 69, 19));
    XYLineAndShapeRenderer render0 = (XYLineAndShapeRenderer) plot.getRenderer(0);
    render0.setSeriesPaint(0, Color.BLUE);

    XYAreaRenderer xyarearenderer = new XYAreaRenderer();
    xyarearenderer.setSeriesPaint(1, Color.GREEN); // 
    xyarearenderer.setSeriesFillPaint(1, Color.GREEN);
    xyarearenderer.setPaint(Color.GREEN);

    // configure the range axis to display directions...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    final TickUnits units = new TickUnits();
    units.add(new NumberTickUnit(180.0, new CompassFormat()));
    units.add(new NumberTickUnit(90.0, new CompassFormat()));
    units.add(new NumberTickUnit(45.0, new CompassFormat()));
    units.add(new NumberTickUnit(22.5, new CompassFormat()));
    rangeAxis.setStandardTickUnits(units);

    // add the wind force with a secondary dataset/renderer/axis
    plot.setRangeAxis(rangeAxis);
    final XYItemRenderer renderer2 = new XYAreaRenderer();
    final ValueAxis axis2 = new NumberAxis("");
    axis2.setRange(0.0, 12.0);
    xyarearenderer.setSeriesPaint(1, new Color(0, 204, 0)); // 
    xyarearenderer.setSeriesFillPaint(1, Color.GREEN);
    xyarearenderer.setPaint(Color.GREEN);
    plot.setDataset(1, createForceDataset(600));
    plot.setRenderer(1, xyarearenderer);
    plot.setRangeAxis(1, axis2);
    plot.mapDatasetToRangeAxis(1, 1);

    return chart;
}