Example usage for org.jfree.chart.renderer.xy StackedXYAreaRenderer3 setSeriesPaint

List of usage examples for org.jfree.chart.renderer.xy StackedXYAreaRenderer3 setSeriesPaint

Introduction

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

Prototype

public void setSeriesPaint(int series, Paint paint, boolean notify) 

Source Link

Document

Sets the paint used for a series and, if requested, sends a RendererChangeEvent to all registered listeners.

Usage

From source file:org.ash.gui.StackedChart.java

/**
 * Creates the chart.//w w  w  . j  ava 2s .c  om
 * 
 * @return the j free chart
 */
private JFreeChart createChart() {

    xAxis = new DateAxis("time");
    xAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));

    currentDate = new Date();
    updatexAxisLabel(new Long(currentDate.getTime()).doubleValue());

    chart = ChartFactory.createStackedXYAreaChart("Top activity", // chart title
            "X Value", // domain axis label
            "Active Sessions", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // the plot orientation
            xAxis, false, // legend
            true, // tooltips
            false // urls
    );

    plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer3 renderer = new StackedXYAreaRenderer3();
    renderer.setRoundXCoordinates(true);
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} ({1}, {2})",
            new SimpleDateFormat("HH:mm"), new DecimalFormat("0.0")));
    plot.setRenderer(0, renderer);
    plot.getRangeAxis().setLowerBound(0.0);
    plot.getRangeAxis().setAutoRange(true);

    // add a labelled marker for the cpu_count
    thresholdMaxCpu = new ValueMarker(this.maxCpu);
    thresholdMaxCpu.setLabelOffsetType(LengthAdjustmentType.EXPAND);
    thresholdMaxCpu.setPaint(Color.red);
    thresholdMaxCpu.setStroke(new BasicStroke(1.0f));
    thresholdMaxCpu.setLabel("Maximum CPU");
    thresholdMaxCpu.setLabelFont(new Font("SansSerif", Font.PLAIN, 11));
    thresholdMaxCpu.setLabelPaint(Color.red);
    thresholdMaxCpu.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    thresholdMaxCpu.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
    plot.addRangeMarker(thresholdMaxCpu);

    renderer.setSeriesPaint(0,
            Options.getInstance().getColor(Options.getInstance().getResource("cpuLabel.text")), true);
    renderer.setSeriesPaint(1,
            Options.getInstance().getColor(Options.getInstance().getResource("schedulerLabel.text")), true);
    renderer.setSeriesPaint(2,
            Options.getInstance().getColor(Options.getInstance().getResource("userIOLabel.text")), true);
    renderer.setSeriesPaint(3,
            Options.getInstance().getColor(Options.getInstance().getResource("systemIOLabel.text")), true);
    renderer.setSeriesPaint(4,
            Options.getInstance().getColor(Options.getInstance().getResource("concurrencyLabel.text")), true);
    renderer.setSeriesPaint(5,
            Options.getInstance().getColor(Options.getInstance().getResource("applicationsLabel.text")), true);
    renderer.setSeriesPaint(6,
            Options.getInstance().getColor(Options.getInstance().getResource("commitLabel.text")), true);
    renderer.setSeriesPaint(7,
            Options.getInstance().getColor(Options.getInstance().getResource("configurationLabel.text")), true);
    renderer.setSeriesPaint(8,
            Options.getInstance().getColor(Options.getInstance().getResource("administrativeLabel.text")),
            true);
    renderer.setSeriesPaint(9,
            Options.getInstance().getColor(Options.getInstance().getResource("networkLabel.text")), true);
    renderer.setSeriesPaint(11,
            Options.getInstance().getColor(Options.getInstance().getResource("queueningLabel.text")), true);//que
    renderer.setSeriesPaint(10,
            Options.getInstance().getColor(Options.getInstance().getResource("clusterLabel.text")), true);//cluster
    renderer.setSeriesPaint(12,
            Options.getInstance().getColor(Options.getInstance().getResource("otherLabel.text")), true);

    // Set format for x axis
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));
    // Add legend to right
    LegendTitle legend = new LegendTitle(chart.getPlot());

    BlockContainer wrapper = new BlockContainer(new BorderArrangement());
    wrapper.setFrame(new BlockBorder(1.0, 1.0, 1.0, 1.0));

    BlockContainer itemss = legend.getItemContainer();
    itemss.setPadding(2, 10, 5, 2);
    wrapper.add(itemss);
    legend.setWrapper(wrapper);

    legend.setPosition(RectangleEdge.RIGHT);
    legend.setHorizontalAlignment(HorizontalAlignment.LEFT);

    chart.addSubtitle(legend);

    return chart;
}

From source file:org.ash.history.TopActivityPreview.java

/**
 * Creates the chart.//w  ww . j ava 2  s  .  c  o  m
 * 
 * @return the j free chart
 */
private JFreeChart createChart() {

    xAxis = new DateAxis("time");
    xAxis.setLabel(null);

    chart = ChartFactory.createStackedXYAreaChart(this.title, // chart title
            "X Value", // domain axis label
            "Active Sessions", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // the plot orientation
            xAxis, false, // legend
            true, // tooltips
            false // urls
    );

    chart.getTitle()
            .setFont(new Font(TextTitle.DEFAULT_FONT.getFontName(), TextTitle.DEFAULT_FONT.getStyle(), 14));

    plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer3 renderer = new StackedXYAreaRenderer3();
    renderer.setRoundXCoordinates(true);
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} ({1}, {2})",
            new SimpleDateFormat("HH:mm"), new DecimalFormat("0.0")));
    plot.setRenderer(0, renderer);
    plot.getRangeAxis().setLowerBound(0.0);
    plot.getRangeAxis().setAutoRange(true);

    // add a labelled marker for the cpu_count
    thresholdMaxCpu = new ValueMarker(this.maxCpu);
    thresholdMaxCpu.setLabelOffsetType(LengthAdjustmentType.EXPAND);
    thresholdMaxCpu.setPaint(Color.red);
    thresholdMaxCpu.setStroke(new BasicStroke(1.0f));
    thresholdMaxCpu.setLabel("Maximum CPU");
    thresholdMaxCpu.setLabelFont(new Font("SansSerif", Font.PLAIN, 11));
    thresholdMaxCpu.setLabelPaint(Color.red);
    thresholdMaxCpu.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    thresholdMaxCpu.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
    plot.addRangeMarker(thresholdMaxCpu);

    renderer.setSeriesPaint(0,
            Options.getInstance().getColor(Options.getInstance().getResource("cpuLabel.text")), true);
    renderer.setSeriesPaint(1,
            Options.getInstance().getColor(Options.getInstance().getResource("schedulerLabel.text")), true);
    renderer.setSeriesPaint(2,
            Options.getInstance().getColor(Options.getInstance().getResource("userIOLabel.text")), true);
    renderer.setSeriesPaint(3,
            Options.getInstance().getColor(Options.getInstance().getResource("systemIOLabel.text")), true);
    renderer.setSeriesPaint(4,
            Options.getInstance().getColor(Options.getInstance().getResource("concurrencyLabel.text")), true);
    renderer.setSeriesPaint(5,
            Options.getInstance().getColor(Options.getInstance().getResource("applicationsLabel.text")), true);
    renderer.setSeriesPaint(6,
            Options.getInstance().getColor(Options.getInstance().getResource("commitLabel.text")), true);
    renderer.setSeriesPaint(7,
            Options.getInstance().getColor(Options.getInstance().getResource("configurationLabel.text")), true);
    renderer.setSeriesPaint(8,
            Options.getInstance().getColor(Options.getInstance().getResource("administrativeLabel.text")),
            true);
    renderer.setSeriesPaint(9,
            Options.getInstance().getColor(Options.getInstance().getResource("networkLabel.text")), true);
    renderer.setSeriesPaint(11,
            Options.getInstance().getColor(Options.getInstance().getResource("queueningLabel.text")), true);//que
    renderer.setSeriesPaint(10,
            Options.getInstance().getColor(Options.getInstance().getResource("clusterLabel.text")), true);//cluster
    renderer.setSeriesPaint(12,
            Options.getInstance().getColor(Options.getInstance().getResource("otherLabel.text")), true);

    return chart;
}