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

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

Introduction

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

Prototype

public void setSeriesPaint(int series, Paint paint);

Source Link

Document

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

Usage

From source file:org.interpss.chart.dstab.SimpleOneStateChart.java

/**
 * create the chart based on the data attributes
 * /* w ww.j  av a  2  s.  c o m*/
 */
public void createChart() {
    final JFreeChart chart = ChartFactory.createXYLineChart(plotTitle, xLabel, yLabel,
            createXYDataSet(xDataAry, yDataAry, yDataLabel), PlotOrientation.VERTICAL, true, false, false);

    final XYPlot plot = (XYPlot) chart.getPlot();
    final StandardXYItemRenderer renderer = new StandardXYItemRenderer();
    renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    plot.setRenderer(renderer);

    //NumberAxis axis_x = (NumberAxis) plot.getDomainAxis();
    //axis_x.setRangeAboutValue(12.0, 24.0);

    final NumberAxis axisLeft = (NumberAxis) plot.getRangeAxis();
    axisLeft.setAutoRangeIncludesZero(false);
    axisLeft.setAutoRangeMinimumSize(autoRangeMinimumSize);

    final XYItemRenderer v_renderer = plot.getRenderer(0);
    v_renderer.setSeriesPaint(0, yColor);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(Chart_Width, Chart_Height));
    setContentPane(chartPanel);
}

From source file:edu.ucla.stat.SOCR.chart.SuperBubbleChart.java

/**
 * Creates a chart.//from w  w  w.j  ava2  s  .c o m
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(XYZDataset dataset) {
    // create the chart...
    JFreeChart chart = ChartFactory.createBubbleChart(chartTitle, // chart titl                          
            rangeLabel, // y axis label
            domainLabel, // x axis label
            dataset, // data
            PlotOrientation.VERTICAL, !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setForegroundAlpha(0.65f);

    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setLegendItemLabelGenerator(new SOCRXYZSeriesLabelGenerator());

    // increase the margins to account for the fact that the auto-range 
    // doesn't take into account the bubble size...
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setLowerMargin(0.15);
    domainAxis.setUpperMargin(0.15);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLowerMargin(0.15);
    rangeAxis.setUpperMargin(0.15);

    return chart;
}

From source file:org.interpss.chart.dist.LoadScheduleChart.java

public void createChart() {
    final JFreeChart chart = ChartFactory.createXYLineChart(plotTitle, xLabel, voltYLabel,
            createDataSet(voltDataAry, voltDataLabel), PlotOrientation.VERTICAL, true, false, false);

    final XYPlot plot = (XYPlot) chart.getPlot();
    final XYStepRenderer renderer = new XYStepRenderer();
    renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    plot.setRenderer(renderer);/*from  w w w  .  j  a v  a2s  . co  m*/

    //NumberAxis axis_x = (NumberAxis) plot.getDomainAxis();
    //axis_x.setRangeAboutValue(12.0, 24.0);

    final NumberAxis axisLeft = (NumberAxis) plot.getRangeAxis();
    axisLeft.setAutoRangeIncludesZero(false);
    axisLeft.setAutoRangeMinimumSize(1.0);

    final NumberAxis axisRight = new NumberAxis(pqYLabel);
    axisRight.setAutoRangeIncludesZero(false);
    axisRight.setAutoRangeMinimumSize(1.0);
    plot.setRangeAxis(1, axisRight);

    final XYItemRenderer v_renderer = plot.getRenderer(0);
    v_renderer.setSeriesPaint(0, vColor);

    plot.setDataset(1, createDataSet(pDataAry, pDataLabel));
    plot.mapDatasetToRangeAxis(1, 1);
    final XYStepRenderer p_renderer = new XYStepRenderer();
    p_renderer.setSeriesPaint(0, pColor);
    p_renderer.setBaseShapesVisible(false);
    plot.setRenderer(1, p_renderer);

    plot.setDataset(2, createDataSet(qDataAry, qDataLabel));
    plot.mapDatasetToRangeAxis(2, 1);
    final XYStepRenderer q_renderer = new XYStepRenderer();
    q_renderer.setSeriesPaint(0, qColor);
    q_renderer.setBaseShapesVisible(false);
    plot.setRenderer(2, q_renderer);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(Chart_Width, Chart_Height));
    setContentPane(chartPanel);
}

From source file:mediamatrix.gui.JVMMemoryProfilerPanel.java

public JVMMemoryProfilerPanel() {
    initComponents();//from   ww w.j  a  v  a  2 s. c om
    profiler = new JVMMemoryProfiler(frequency);
    profiler.addListener(new JVMMemoryProfilerListener() {

        @Override
        public void addScore(long t, long f) {
            total.add(new Millisecond(), t);
            free.add(new Millisecond(), f);
        }
    });

    total = new TimeSeries("Total Memory");
    total.setMaximumItemCount(historyCount);
    free = new TimeSeries("Free Memory");
    free.setMaximumItemCount(historyCount);

    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(total);
    dataset.addSeries(free);

    final DateAxis domain = new DateAxis("Time");
    final NumberAxis range = new NumberAxis("Memory");
    domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    final XYItemRenderer renderer = new DefaultXYItemRenderer();
    renderer.setSeriesPaint(0, Color.red);
    renderer.setSeriesPaint(1, Color.green);
    renderer.setBaseStroke(new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));

    final XYPlot plot = new XYPlot(dataset, domain, range, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    domain.setAutoRange(true);
    domain.setLowerMargin(0.0);
    domain.setUpperMargin(0.0);
    domain.setTickLabelsVisible(true);

    final JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot,
            true);
    chart.setBackgroundPaint(Color.white);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 12));

    add(chartPanel, BorderLayout.CENTER);
}

From source file:org.encog.workbench.dialogs.training.ChartPane.java

/**
 * Create the initial chart./*from  www  . j  av  a 2s  . com*/
 * @return The chart.
 */
private JFreeChart createChart() {

    this.chart = ChartFactory.createXYLineChart(null, "Iteration", "Current Error", this.dataset1,
            PlotOrientation.VERTICAL, true, true, false);

    final XYPlot plot = (XYPlot) this.chart.getPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);

    plot.getRangeAxis().setFixedDimension(15.0);

    // AXIS 2
    final NumberAxis axis2 = new NumberAxis("Error Improvement");
    axis2.setFixedDimension(10.0);
    axis2.setAutoRangeIncludesZero(false);
    axis2.setLabelPaint(Color.red);
    axis2.setTickLabelPaint(Color.red);
    plot.setRangeAxis(1, axis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);

    plot.setDataset(1, this.dataset2);
    plot.mapDatasetToRangeAxis(1, 1);
    final XYItemRenderer renderer2 = new StandardXYItemRenderer();
    renderer2.setSeriesPaint(0, Color.red);
    plot.setRenderer(1, renderer2);

    ChartUtilities.applyCurrentTheme(this.chart);

    return this.chart;
}

From source file:MSUmpire.DIA.RTMappingExtLib.java

private void GenerateRTMapPNG(XYSeriesCollection xySeriesCollection, XYSeries series, float R2)
        throws IOException {
    String pngfile = FilenameUtils.getFullPath(TargetLCMS.mzXMLFileName) + "/"
            + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName) + "_" + libManager.LibID + "_RTMap.png";
    FileWriter writer = new FileWriter(FilenameUtils.getFullPath(TargetLCMS.mzXMLFileName) + "/"
            + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName) + "_" + libManager.LibID + "_RTMap.txt");

    XYSeries smoothline = new XYSeries("RT fitting curve");
    for (XYZData data : regression.PredictYList) {
        smoothline.add(data.getX(), data.getY());
        writer.write(data.getX() + "\t" + data.getY() + "\n");
    }/*from  w w w  .  j a v a  2  s  . c om*/
    writer.close();
    xySeriesCollection.addSeries(smoothline);
    xySeriesCollection.addSeries(series);
    JFreeChart chart = ChartFactory.createScatterPlot("Retention time mapping: R2=" + R2,
            "Normalized RT (" + libManager.LibID + ")",
            "RT:" + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName), xySeriesCollection,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) chart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);

    XYItemRenderer renderer = xyPlot.getRenderer();
    renderer.setSeriesPaint(1, Color.blue);
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesShape(1, new Ellipse2D.Double(0, 0, 3, 3));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(0, new BasicStroke(3.0f));
    xyPlot.setBackgroundPaint(Color.white);
    ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
}

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

/**
 * Creates the demo chart.//from w w  w  .j  a v  a  2s .c  o m
 * 
 * @return The chart.
 */
private JFreeChart createChart() {

    final XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200);

    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 1", "Time of Day",
            "Primary Range Axis", dataset1, true, true, false);

    chart.setBackgroundPaint(Color.white);
    chart.addSubtitle(new TextTitle("Four datasets and four range axes."));
    final XYPlot plot = chart.getXYPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    //        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));

    final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer();
    renderer.setPaint(Color.black);

    // AXIS 2
    final NumberAxis axis2 = new NumberAxis("Range Axis 2");
    axis2.setAutoRangeIncludesZero(false);
    axis2.setLabelPaint(Color.red);
    axis2.setTickLabelPaint(Color.red);
    plot.setRangeAxis(1, axis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT);

    final XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170);
    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    renderer2.setSeriesPaint(0, Color.red);
    plot.setRenderer(1, renderer2);

    // AXIS 3
    final NumberAxis axis3 = new NumberAxis("Range Axis 3");
    axis3.setLabelPaint(Color.blue);
    axis3.setTickLabelPaint(Color.blue);
    plot.setRangeAxis(2, axis3);

    final XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170);
    plot.setDataset(2, dataset3);
    plot.mapDatasetToRangeAxis(2, 2);
    XYItemRenderer renderer3 = new StandardXYItemRenderer();
    renderer3.setSeriesPaint(0, Color.blue);
    plot.setRenderer(2, renderer3);

    // AXIS 4        
    final NumberAxis axis4 = new NumberAxis("Range Axis 4");
    axis4.setLabelPaint(Color.green);
    axis4.setTickLabelPaint(Color.green);
    plot.setRangeAxis(3, axis4);

    final XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200);
    plot.setDataset(3, dataset4);
    plot.mapDatasetToRangeAxis(3, 3);

    XYItemRenderer renderer4 = new StandardXYItemRenderer();
    renderer4.setSeriesPaint(0, Color.green);
    plot.setRenderer(3, renderer4);

    return chart;
}

From source file:wattsup.jsdk.ui.LineChartPanelSupport.java

/**
 * Sets the color for a series.// w  w  w  . j  a v a2s .com
 * 
 * @param serie
 *            The index of a series. It's zero based.
 * @param color
 *            The color of a series. Might not be <code>null</code>.
 */
protected void setSeriesPaint(int serie, Color color) {
    XYItemRenderer localXYItemRenderer = getPlot().getRenderer();
    localXYItemRenderer.setSeriesPaint(serie, color);
    localXYItemRenderer.setSeriesStroke(serie, this.getDefaultLineStroke());
    getPlot().setRenderer(localXYItemRenderer);
}

From source file:com.att.aro.ui.view.diagnostictab.CreateBarPlot.java

public XYPlot drawXYItemPlot() {

    // Set up renderer
    XYItemRenderer throughputRenderer = new StandardXYItemRenderer();
    throughputRenderer.setSeriesPaint(0, Color.red);

    // Normalize the throughput axis so that it represents max value
    NumberAxis axis = new NumberAxis();
    axis.setVisible(false);//from  w  w w .j av a 2s .co m

    // Create plot
    XYPlot throughputPlot = new XYPlot(null, null, axis, throughputRenderer);
    throughputPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    throughputPlot.getRangeAxis().setVisible(false);

    return throughputPlot;
}

From source file:de.hs.mannheim.modUro.diagram.JCellCountDiagram.java

protected JFreeChart createChart(XYDataset dataset, String name) {
    String title = name;//w  w  w.ja v a2 s  .c  o  m

    JFreeChart xyLineChart = ChartFactory.createXYLineChart(title, // title
            "t", // x-axis label
            "n", // y-axis label
            dataset);

    String fontName = "Palatino";
    xyLineChart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));

    XYPlot plot = (XYPlot) xyLineChart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.getRangeAxis().setLowerMargin(0.0);
    // plot.getRangeAxis().setRange(0.0, 1.01);
    plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.gray);
    xyLineChart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
    xyLineChart.getLegend().setFrame(BlockBorder.NONE);
    xyLineChart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);
    XYItemRenderer r = plot.getRenderer();
    // set the default stroke for all series
    int i = 0;
    for (String celltype : getTimeSeries().getDataSeriesNames()) {
        r.setSeriesPaint(i, CellTypeColor.getColor(celltype));
        i++;
    }
    r.setSeriesPaint(i, Color.BLACK);
    return xyLineChart;
}