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

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

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer 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:cv.mikusher.freechart.XYLineChart.java

public XYLineChart(String applicationTitle, String chartTitle) {
    super(applicationTitle);
    setDefaultCloseOperation(ApplicationFrame.EXIT_ON_CLOSE);
    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "Category", "Score", createDataset(),
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setRenderer(renderer);/*w  w  w  .  ja va2 s . com*/
    setContentPane(chartPanel);
}

From source file:com.mycompany.istudy.principalservices.GraphicalView.java

/**
 * Overwrites the method of createXYLineChart from ChartFactory interface
 * and creates a XYLine Chart./*from  w w  w  .j  av a  2  s  .c o  m*/
 * @param applicationTitle
 * @param chartTitle
 * @param investedHoursPerWeek
 * @param hoursToBeInvested 
 */
public GraphicalView(String applicationTitle, String chartTitle, Map<Double, Double> investedHoursPerWeek,
        Map<Double, Double> hoursToBeInvested) {
    super(applicationTitle);
    xylineChart = ChartFactory.createXYLineChart(chartTitle, "Calender Weeks", "Invested Study-hours",
            createDataset(investedHoursPerWeek, hoursToBeInvested), PlotOrientation.VERTICAL, true, true,
            false);
    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.BLUE);
    renderer.setSeriesPaint(1, Color.RED);
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    plot.setRenderer(renderer);
    setContentPane(chartPanel);
}

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

public MemoryUsageDemo(int i) {
    super(new BorderLayout());
    total = new TimeSeries("Total Memory");
    total.setMaximumItemAge(i);//from w w w.ja v  a 2s . c o  m
    free = new TimeSeries("Free Memory");
    free.setMaximumItemAge(i);
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    timeseriescollection.addSeries(total);
    timeseriescollection.addSeries(free);
    DateAxis dateaxis = new DateAxis("Time");
    NumberAxis numberaxis = new NumberAxis("Memory");
    dateaxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    numberaxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    dateaxis.setLabelFont(new Font("SansSerif", 0, 14));
    numberaxis.setLabelFont(new Font("SansSerif", 0, 14));
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    xylineandshaperenderer.setSeriesPaint(0, Color.red);
    xylineandshaperenderer.setSeriesPaint(1, Color.green);
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(3F, 0, 2));
    xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(3F, 0, 2));
    XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    dateaxis.setAutoRange(true);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setTickLabelsVisible(true);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    JFreeChart jfreechart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", 1, 24), xyplot, true);
    jfreechart.setBackgroundPaint(Color.white);
    ChartPanel chartpanel = new ChartPanel(jfreechart, true);
    chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    add(chartpanel);
}

From source file:unusedClasses.MemoryUsageDemo.java

public MemoryUsageDemo(int paramInt) {
    super(new BorderLayout());
    this.total.setMaximumItemAge(paramInt);
    this.free = new TimeSeries("Free Memory");
    this.free.setMaximumItemAge(paramInt);
    TimeSeriesCollection localTimeSeriesCollection = new TimeSeriesCollection();
    localTimeSeriesCollection.addSeries(this.total);
    localTimeSeriesCollection.addSeries(this.free);
    DateAxis localDateAxis = new DateAxis("Time");
    NumberAxis localNumberAxis = new NumberAxis("Memory");
    localDateAxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    localNumberAxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    localDateAxis.setLabelFont(new Font("SansSerif", 0, 14));
    localNumberAxis.setLabelFont(new Font("SansSerif", 0, 14));
    XYLineAndShapeRenderer localXYLineAndShapeRenderer = new XYLineAndShapeRenderer(true, false);
    localXYLineAndShapeRenderer.setSeriesPaint(0, Color.red);
    localXYLineAndShapeRenderer.setSeriesPaint(1, Color.green);
    localXYLineAndShapeRenderer.setSeriesStroke(0, new BasicStroke(3.0F, 0, 2));
    localXYLineAndShapeRenderer.setSeriesStroke(1, new BasicStroke(3.0F, 0, 2));
    XYPlot localXYPlot = new XYPlot(localTimeSeriesCollection, localDateAxis, localNumberAxis,
            localXYLineAndShapeRenderer);
    localDateAxis.setAutoRange(true);/*  www .j a  va 2 s.c  o  m*/
    localDateAxis.setLowerMargin(0.0D);
    localDateAxis.setUpperMargin(0.0D);
    localDateAxis.setTickLabelsVisible(true);
    localNumberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    JFreeChart localJFreeChart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", 1, 24), localXYPlot,
            true);
    ChartUtilities.applyCurrentTheme(localJFreeChart);
    ChartPanel localChartPanel = new ChartPanel(localJFreeChart, true);
    localChartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    add(localChartPanel);
}

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

/**
 * Creates a new scatter chart./*from w  ww .  j a v a  2  s  .com*/
 * @param title  the title.
 * @param xTimeSeries  the x time series.
 * @param xLabel  the label of the x axis.
 * @param yTimeSeries  the y time series.
 * @param yLabel  the label of the y axis.
 */
public TwoSeriesScatterChart(String title, TimeSeries xTimeSeries, String xLabel, TimeSeries yTimeSeries,
        String yLabel) {
    super(title, null, xLabel, yLabel);
    this.xTimeSeries = xTimeSeries;
    this.yTimeSeries = yTimeSeries;
    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.GRAY);
    renderer.setSeriesFillPaint(0, JamelColor.LIGHT_TRANSPARENT_RED);
    renderer.setUseFillPaint(true);
    ((XYPlot) getPlot()).setRenderer(renderer);
}

From source file:com.hello2morrow.sonargraph.jenkinsplugin.model.XYLineAndShapePlot.java

@Override
protected void applyRendering(XYPlot plot) {
    NumberAxis axis = (NumberAxis) plot.getDomainAxis();
    axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setSeriesPaint(0, DATA_COLOR);

    //Unfortunately, the tooltips are not visible, when the graph gets rendered as a PNG
    StandardXYToolTipGenerator toolTipGenerator = new StandardXYToolTipGenerator() {
        private static final long serialVersionUID = -5803780142385784897L;

        @Override//from   ww  w . j a va 2s .co m
        public String generateToolTip(XYDataset dataset, int series, int item) {
            return new StringBuilder(BUILD).append(dataset.getXValue(series, item)).append(COLON)
                    .append(dataset.getYValue(series, item)).toString();
        }
    };
    renderer.setBaseToolTipGenerator(toolTipGenerator);
}

From source file:userinterface.patientRole.LineChart.java

public LineChart(String applicationTitle, String chartTitle, XYSeries bR, XYSeries pR, XYSeries bS, XYSeries bP,
        JFrame parent) {/*w  w  w .  j a v  a 2  s.  co  m*/
    // super(applicationTitle);
    this.bR = bR;
    this.pR = pR;
    this.bS = bS;
    this.bP = bP;
    this.parent = parent;
    dataset = createDataset();
    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "Category", "Vital Signs",
            createDataset(), PlotOrientation.VERTICAL, true, true, false);
    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesPaint(3, Color.BLUE);
    renderer.setSeriesStroke(0, new BasicStroke(1.0f));
    renderer.setSeriesStroke(1, new BasicStroke(1.0f));
    renderer.setSeriesStroke(2, new BasicStroke(1.0f));
    renderer.setSeriesStroke(3, new BasicStroke(1.0f));
    plot.setRenderer(renderer);
    setContentPane(chartPanel);
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });
}

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

/**
 * Creates a new instant chart./*from   ww w .j av a2  s . c  o m*/
 * 
 * @param title  the title.
 * @param xLabel  the label of the x series.
 * @param yLabel  the label of the y series.
 */
public InstantScatterChart(String title, String xLabel, String yLabel) {
    super(title, null, xLabel, yLabel);
    this.xLabel = xLabel;
    this.yLabel = yLabel;
    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseLinesVisible(false);
    renderer.setSeriesPaint(0, new Color(0.3f, 0.3f, 0.3f, 0.5f));
    renderer.setSeriesFillPaint(0, new Color(0.3f, 0.3f, 1f, 0.5f));
    renderer.setUseFillPaint(true);
    ((XYPlot) getPlot()).setRenderer(renderer);
}

From source file:org.mustbe.consulo.xprofiler.ui.mainPanel.MemoryPlotPanel.java

public MemoryPlotPanel(int maxAge, String title) {
    super(new BorderLayout());

    totalSeries = new TimeSeries("Committed Memory");
    totalSeries.setMaximumItemAge(maxAge);
    usedSeries = new TimeSeries("Used Memory");
    usedSeries.setMaximumItemAge(maxAge);
    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    seriesCollection.addSeries(totalSeries);
    seriesCollection.addSeries(usedSeries);

    NumberAxis numberAxis = new NumberAxis("Memory (KB)");

    numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    DateAxis dateAxis = new DateAxis("Time");

    dateAxis.setAutoRange(true);/*from w w  w  .j a v a 2s  . co  m*/
    dateAxis.setLowerMargin(0);
    dateAxis.setUpperMargin(0);
    dateAxis.setTickLabelsVisible(true);
    dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));

    XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false);
    lineRenderer.setSeriesPaint(0, JBColor.RED);
    lineRenderer.setSeriesPaint(1, JBColor.GREEN);
    lineRenderer.setDefaultStroke(new BasicStroke(2F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

    XYPlot xyplot = new XYPlot(seriesCollection, dateAxis, numberAxis, lineRenderer);
    xyplot.setBackgroundPainter(new ColorPainter(JBColor.white));
    xyplot.setDomainGridlinePaint(JBColor.LIGHT_GRAY);
    xyplot.setRangeGridlinePaint(JBColor.LIGHT_GRAY);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));

    JFreeChart chart = new JFreeChart(title, new Font("SansSerif", Font.PLAIN, 14), xyplot, true);
    chart.setBackgroundPainter(new ColorPainter(JBColor.white));

    add(new ChartPanel(chart, 300, 300, 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, false,
            false, false), BorderLayout.CENTER);
}

From source file:cs.register.geraGrafico.java

public geraGrafico(String title, int type, List<partida> L) {
    super(title);
    JFreeChart chart = null;//from w  ww  . j a v a 2 s.c  o m
    switch (type) {
    case 0:
        chart = ChartFactory.createXYLineChart(title, "X", "y", datakill(L), PlotOrientation.VERTICAL, true,
                true, false);
    case 1:
        chart = ChartFactory.createXYLineChart(title, "X", "y", datakda(L), PlotOrientation.VERTICAL, true,
                true, false);
    case 2:
        chart = ChartFactory.createXYLineChart(title, "X", "y", datawld(L), PlotOrientation.VERTICAL, true,
                true, false);
    case 3:
        chart = ChartFactory.createXYLineChart(title, "X", "y", datasocore(L), PlotOrientation.VERTICAL, true,
                true, false);
    case 4:
        chart = ChartFactory.createXYLineChart(title, "X", "y", datarank(L), PlotOrientation.VERTICAL, true,
                true, false);

    }
    graf = new ChartPanel(chart);
    graf.setPreferredSize(new java.awt.Dimension(560, 367));
    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer rendrer = new XYLineAndShapeRenderer();
    rendrer.setSeriesPaint(0, Color.GREEN);
    rendrer.setSeriesStroke(0, new BasicStroke(4.0f));
    plot.setRenderer(rendrer);
    setContentPane(graf);

}