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:pisco.batch.visu.BatchingChartFactory.java

public static JFreeChart createWFlowChart(Batch[] batches, String title, int capacity) {
    final XYPlot objPlot = createWFlowtimePlot(batches);
    final JFreeChart chart = createCombinedChart(title, createBatchPlot(batches, capacity), objPlot);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) objPlot.getRenderer();
    renderer.setSeriesPaint(0, B_RED);
    renderer.setSeriesFillPaint(0, B_RED);
    return chart;
}

From source file:com.joey.software.plottingToolkit.PlotingToolkit.java

/**
 * This will plot the data as series of data[1], data[2], data[3]....
 * /*from   w w w .j  a va  2  s.c o m*/
 * @param data
 * @param names
 * @param title
 * @param xlabel
 * @param ylabel
 * @return
 */
public static JFreeChart getPlot(float[][] data, String[] names, String title, String xlabel, String ylabel,
        boolean showPoints, boolean showLines) {

    // Create the chart

    JFreeChart chart = ChartFactory.createXYLineChart(title, // Title
            xlabel, // X-Axis label
            ylabel, // Y-Axis label
            new XYSeriesCollection(), // Dataset
            PlotOrientation.VERTICAL, true, // Show legend
            true, true);

    for (int i = 0; i < data.length; i++) {
        float[] xData = getXDataFloat(data[i].length);
        XYSeriesCollection datCol = getCollection(xData, data[i],
                ((names == null) || (names[i] == null) ? "" : names[i]));

        // Add the series
        chart.getXYPlot().setDataset(i, datCol);

        // Set the rendering
        XYLineAndShapeRenderer rend1 = new XYLineAndShapeRenderer(showLines, showPoints);
        rend1.setSeriesPaint(0, getPlotColor(i));
        chart.getXYPlot().setRenderer(i, rend1);
    }
    return chart;
}

From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileChartFactory.java

public static JFreeChart createDiveProfileChartPanel(DiveProfile diveProfile, Locale locale,
        LengthUnit lengthUnit) {/*from w  ww. ja  v a2  s .c o  m*/
    XYSeries depthSerie = new XYSeries(SERIE_DEPTH);
    XYSeriesCollection depthCollection = new XYSeriesCollection();
    depthCollection.addSeries(depthSerie);

    JFreeChart chart = ChartFactory.createXYAreaChart(null, getDomainLegend(locale),
            getRangeLegend(locale, lengthUnit), depthCollection, PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyp = chart.getXYPlot();

    Paint p = new GradientPaint(0f, 0f, UIAgent.getInstance().getColorWaterBottom(), 200f, 200f,
            UIAgent.getInstance().getColorWaterSurface(), false);
    xyp.setBackgroundPaint(p);
    xyp.setDomainGridlinePaint(UIAgent.getInstance().getColorWaterGrid());
    xyp.setRangeGridlinePaint(UIAgent.getInstance().getColorWaterGrid());
    ((NumberAxis) xyp.getDomainAxis()).setNumberFormatOverride(new MinutesNumberFormat());

    XYAreaRenderer renderer0 = new XYAreaRenderer();
    renderer0.setOutline(true);
    renderer0.setBaseOutlinePaint(UIAgent.getInstance().getColorWaterBottom());

    Color baseColor = UIAgent.getInstance().getColorBaseBackground();
    renderer0.setSeriesPaint(0, new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), 50));
    xyp.setRenderer(0, renderer0);

    int i = 1;

    XYSeriesCollection decoEntriesCollection = new XYSeriesCollection();
    XYSeries decoEntriesSerie = new XYSeries(SERIE_DECO_ENTRY);
    decoEntriesCollection.addSeries(decoEntriesSerie);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, false);
    renderer2.setAutoPopulateSeriesShape(false);
    renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorDecoEntries());
    renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_DECO_ENTRY]);
    xyp.setDataset(i, decoEntriesCollection);
    xyp.setRenderer(i, renderer2);

    i++;
    XYSeriesCollection ascentTooFastCollection = new XYSeriesCollection();
    XYSeries ascentTooFastSerie = new XYSeries(SERIE_WARNING_ASCENT_TOO_FAST);
    ascentTooFastCollection.addSeries(ascentTooFastSerie);
    renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, false);
    renderer2.setAutoPopulateSeriesShape(false);
    renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningAscentTooFast());
    renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_ASCENT_TOO_FAST_WARNING]);
    xyp.setDataset(i, ascentTooFastCollection);
    xyp.setRenderer(i, renderer2);

    i++;
    XYSeriesCollection decoWarningCollection = new XYSeriesCollection();
    XYSeries decoWarningSerie = new XYSeries(SERIE_DECO_STOP);
    decoWarningCollection.addSeries(decoWarningSerie);
    renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, false);
    renderer2.setAutoPopulateSeriesShape(false);
    renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningDecoCeiling());
    renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_DECO_WARNING]);
    xyp.setDataset(i, decoWarningCollection);
    xyp.setRenderer(i, renderer2);

    i++;
    XYSeriesCollection remainBottomTimeCollection = new XYSeriesCollection();
    XYSeries remainBottomTimeSerie = new XYSeries(SERIE_REMAINING_BOTTOM_TIME);
    remainBottomTimeCollection.addSeries(remainBottomTimeSerie);
    renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, false);
    renderer2.setAutoPopulateSeriesShape(false);
    renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningRemainingBottomTime());
    renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_REMAINING_BOTTOM_TIME_WARNING]);
    xyp.setDataset(i, remainBottomTimeCollection);
    xyp.setRenderer(i, renderer2);

    Map<Double, Double> depthEntries = diveProfile.getDepthEntries();
    Set<Double> ascentWarning = diveProfile.getAscentWarnings();
    Set<Double> decoWarnings = diveProfile.getDecoCeilingWarnings();
    Set<Double> remainBottomTime = diveProfile.getRemainingBottomTimeWarnings();
    Set<Double> decoEntryTime = diveProfile.getDecoEntries();

    if (depthEntries.size() > 0 && depthEntries.get(0d) == null) {
        depthEntries.put(0d, 0d);
    }

    for (Double seconds : depthEntries.keySet()) {
        double d = UnitsAgent.getInstance().convertLengthFromModel(depthEntries.get(seconds), lengthUnit);
        depthSerie.add(seconds, Double.valueOf(d));
    }

    if (null != ascentWarning) {
        for (Double seconds : ascentWarning) {
            ascentTooFastSerie.add(seconds, depthEntries.get(seconds));
        }
    }

    if (null != decoWarnings) {
        for (Double seconds : decoWarnings) {
            decoWarningSerie.add(seconds, depthEntries.get(seconds));
        }
    }

    if (null != remainBottomTime) {
        for (Double seconds : remainBottomTime) {
            remainBottomTimeSerie.add(seconds, depthEntries.get(seconds));
        }
    }

    if (null != decoEntryTime) {
        for (Double seconds : decoEntryTime) {
            decoEntriesSerie.add(seconds, depthEntries.get(seconds));
        }
    }
    return chart;
}

From source file:simulador.controle.GraficoCategorias.java

private static void renderizarGrafico(JFreeChart grafico) {

    if (DEBUG) {//from  www  . j  av  a  2 s . c o m
        System.out.println("GraficoRadiais.renderizarGrafico");
    }

    XYLineAndShapeRenderer renderizador = new XYLineAndShapeRenderer();
    int qtdSeries, aux;

    qtdSeries = grafico.getXYPlot().getDataset().getSeriesCount();
    //aux = (Color.WHITE.getRGB() - Color.BLACK.getRGB())/qtdSeries;   
    aux = 360 / qtdSeries;

    //System.out.println("aux = "+aux);
    for (int i = 0; i < qtdSeries; i++) {
        renderizador.setSeriesPaint(i, new Color(Color.HSBtoRGB((aux * i) / 360.0f, 1.0f, 1.0f)));
        renderizador.setSeriesStroke(i, new BasicStroke(1.0f));
    }

    //renderizador.setSeriesLinesVisible(0, false);

    grafico.getXYPlot().setRenderer(renderizador);

}

From source file:com.che.software.testato.util.jfreechart.LineChartGraphistUtil.java

/**
 * Colorized and transforms a given JFreeChart.
 * //  ww w.  j  a  va  2s.com
 * @author Clement HELIOU (clement.heliou@che-software.com).
 * @param lineChart the given chart.
 * @param maxAbscissaValue the max abscissa value of the chart.
 * @param xValues the x axis values list.
 * @param yValues the y axis values list.
 * @param xExcludedValues the x axis excluded values.
 * @param yExcludedValues the y axis excluded values.
 * @return the transformed chart.
 * @since August, 2011.
 */
public static JFreeChart getColorizedChartFromChart(JFreeChart lineChart, double maxAbscissaValue,
        List<MatrixResult> xValues, List<MatrixResult> yValues, List<MatrixResult> xExcludedValues,
        List<MatrixResult> yExcludedValues) {
    LOGGER.debug("getColorizedChartFromChart().");
    lineChart.setBackgroundPaint(Color.WHITE);
    XYPlot plot = (XYPlot) lineChart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesLinesVisible(1, false);
    renderer.setSeriesStroke(2, new BasicStroke(2));
    renderer.setSeriesStroke(3, new BasicStroke(2));
    renderer.setSeriesShapesVisible(2, false);
    renderer.setSeriesShapesVisible(3, false);
    renderer.setSeriesPaint(0,
            ColorUtil.getHSBColor(ColorUtil.BLUE_COLOR[0], ColorUtil.BLUE_COLOR[1], ColorUtil.BLUE_COLOR[2]));
    renderer.setSeriesPaint(1, ColorUtil.getHSBColor(ColorUtil.ORANGE_COLOR[0], ColorUtil.ORANGE_COLOR[1],
            ColorUtil.ORANGE_COLOR[2]));
    renderer.setSeriesPaint(2, ColorUtil.getHSBColor(ColorUtil.DARK_BLUE_COLOR[0], ColorUtil.DARK_BLUE_COLOR[1],
            ColorUtil.DARK_BLUE_COLOR[2]));
    renderer.setSeriesPaint(3, ColorUtil.getHSBColor(ColorUtil.DARK_BLUE_COLOR[0], ColorUtil.DARK_BLUE_COLOR[1],
            ColorUtil.DARK_BLUE_COLOR[2]));
    plot.setRenderer(renderer);
    XYTextAnnotation low = new XYTextAnnotation(
            LocaleUtil.getResourceBundleStringByName(LocaleUtil.AREA_LOW_NAME), (0.5 * maxAbscissaValue) - 1,
            maxAbscissaValue + 1),
            medium = new XYTextAnnotation(LocaleUtil.getResourceBundleStringByName(LocaleUtil.AREA_MEDIUM_NAME),
                    (1.5 * maxAbscissaValue) - 2, maxAbscissaValue + 1),
            high = new XYTextAnnotation(LocaleUtil.getResourceBundleStringByName(LocaleUtil.AREA_HIGH_NAME),
                    1.5 * maxAbscissaValue, maxAbscissaValue - 2);
    low.setFont(ColorUtil.TITLE_FONT);
    medium.setFont(ColorUtil.TITLE_FONT);
    high.setFont(ColorUtil.TITLE_FONT);
    low.setPaint(ColorUtil.getHSBColor(ColorUtil.DARK_BLUE_COLOR[0], ColorUtil.DARK_BLUE_COLOR[1],
            ColorUtil.DARK_BLUE_COLOR[2]));
    medium.setPaint(ColorUtil.getHSBColor(ColorUtil.DARK_BLUE_COLOR[0], ColorUtil.DARK_BLUE_COLOR[1],
            ColorUtil.DARK_BLUE_COLOR[2]));
    high.setPaint(ColorUtil.getHSBColor(ColorUtil.DARK_BLUE_COLOR[0], ColorUtil.DARK_BLUE_COLOR[1],
            ColorUtil.DARK_BLUE_COLOR[2]));
    plot.addAnnotation(low);
    plot.addAnnotation(medium);
    plot.addAnnotation(high);
    for (int i = 0; i < xValues.size(); i++) {
        XYTextAnnotation itemLabel = new XYTextAnnotation(xValues.get(i).getScriptLabel(),
                (yValues.get(i).getPercentage() * 100), (xValues.get(i).getPercentage() * 100) + 0.5);
        itemLabel.setFont(ColorUtil.DEFAULT_FONT);
        itemLabel.setPaint(ColorUtil.getHSBColor(ColorUtil.BLUE_COLOR[0], ColorUtil.BLUE_COLOR[1],
                ColorUtil.BLUE_COLOR[2]));
        plot.addAnnotation(itemLabel);
    }
    if (null != xExcludedValues) {
        for (int j = 0; j < xExcludedValues.size(); j++) {
            XYTextAnnotation itemLabel = new XYTextAnnotation(xExcludedValues.get(j).getScriptLabel(),
                    (yExcludedValues.get(j).getPercentage() * 100),
                    (xExcludedValues.get(j).getPercentage() * 100) + 0.5);
            itemLabel.setFont(ColorUtil.DEFAULT_FONT);
            itemLabel.setPaint(ColorUtil.getHSBColor(ColorUtil.ORANGE_COLOR[0], ColorUtil.ORANGE_COLOR[1],
                    ColorUtil.ORANGE_COLOR[2]));
            plot.addAnnotation(itemLabel);
        }
    }
    return lineChart;
}

From source file:Similaridade.GraficosSimilaridade.java

public static JFreeChart criaGrafico2LinhasComDeslocada(CapturaAtual onda1, CapturaAtual onda2,
        int deslocamento, double correlacao, Paint cor1, Paint cor2) {
    String eixoy = new String("Current ");
    // verifica se  fase ou fuga
    if (onda1.getCodEvento().getCodEvento() == 1) { // evento 1  de fuga
        eixoy = eixoy.concat("(mA)");
    } else {//from www  . j ava  2  s  .  co  m
        eixoy = eixoy.concat("(A)");
    }
    XYDataset dataset = newDataset2OndasComDeslocada(onda1, onda2, deslocamento, correlacao);

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            "Time (ms)", // x axis label
            eixoy, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            false, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();

    // Definindo valores no eixo y
    double min = (double) DatasetUtilities.findMinimumRangeValue(dataset);
    double max = (double) DatasetUtilities.findMaximumRangeValue(dataset);

    plot.getRangeAxis().setRange(min - min * 0.005, //min
            max + min * 0.005);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    renderer.setBaseStroke(new BasicStroke(1.0f));
    for (int i = 0; i < dataset.getSeriesCount(); i++) {
        renderer.setSeriesLinesVisible(i, true);
        renderer.setSeriesShapesVisible(i, false);
    }
    // Ajustar para todas as cores padro, pelo menos 10
    renderer.setSeriesPaint(0, cor1);
    renderer.setSeriesPaint(1, cor2);

    /* Cdigo para ter linhas tracejadas 
    renderer.setSeriesStroke(1, 
        new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND,
                        20.0f, new float[] {5.0f}, 0.0f) );
               
    renderer.setDrawSeriesLineAsPath(true); 
    /* Final do Codigo para tracejadas */

    plot.setRenderer(renderer);

    return chart;
}

From source file:utils.ChartUtils.java

/**
 * Update XY chart/*  w w w  .ja va 2s  .c  om*/
 * 
 * @param plot ChartPanel Plot
 * @param sortedArray Sorted array of values
 */
public static void updateXYChart(ChartPanel plot, double[] sortedArray) {

    XYPlot xyplot = plot.getChart().getXYPlot();

    double min = sortedArray[0];
    double max = sortedArray[sortedArray.length - 1];

    double median = Utils.getMedian(sortedArray);

    double q1 = Utils.getQ1(sortedArray);
    double q3 = Utils.getQ3(sortedArray);

    XYTextAnnotation annotation;

    //min-lowlimit horizontal
    XYSeries serie15 = new XYSeries("15");
    serie15.add(min, 0.5);

    //max-toplimit horizontal
    XYSeries serie16 = new XYSeries("16");
    serie16.add(max, 0.5);

    //min vertical
    XYSeries serie1 = new XYSeries("0");
    serie1.add(min, 0.45);
    serie1.add(min, 0.55);

    annotation = new XYTextAnnotation("Min", min, 0.40);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    //min-q1 horizontal
    XYSeries serie2 = new XYSeries("1");
    serie2.add(min, 0.5);
    serie2.add(q1, 0.5);

    //q1 vertical  
    XYSeries serie3 = new XYSeries("2");
    serie3.add(q1, 0.1);
    serie3.add(q1, 0.9);

    annotation = new XYTextAnnotation("Q1", q1, 0.08);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    // median 
    XYSeries serie_mediana = new XYSeries("11");
    serie_mediana.add(median, 0.1);
    serie_mediana.add(median, 0.9);

    annotation = new XYTextAnnotation("Median", median, 0.04);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    //q1-q3 horizontal sup
    XYSeries serie4 = new XYSeries("3");
    serie4.add(q1, 0.9);
    serie4.add(q3, 0.9);

    //q1-q3 horizontal inf
    XYSeries serie5 = new XYSeries("4");
    serie5.add(q1, 0.1);
    serie5.add(q3, 0.1);

    //q3 vertical
    XYSeries serie6 = new XYSeries("5");
    serie6.add(q3, 0.1);
    serie6.add(q3, 0.9);

    annotation = new XYTextAnnotation("Q3", q3, 0.08);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    //q3-max horizontal
    XYSeries serie7 = new XYSeries("6");
    serie7.add(q3, 0.5);
    serie7.add(max, 0.5);

    //max vertical
    XYSeries serie8 = new XYSeries("7");
    serie8.add(max, 0.45);
    serie8.add(max, 0.55);

    annotation = new XYTextAnnotation("Max", max, 0.4);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    XYSeriesCollection xyseriescollection = new XYSeriesCollection();

    xyseriescollection.addSeries(serie1);
    xyseriescollection.addSeries(serie2);
    xyseriescollection.addSeries(serie3);
    xyseriescollection.addSeries(serie4);
    xyseriescollection.addSeries(serie5);
    xyseriescollection.addSeries(serie6);
    xyseriescollection.addSeries(serie7);
    xyseriescollection.addSeries(serie8);
    xyseriescollection.addSeries(serie15);
    xyseriescollection.addSeries(serie16);
    xyseriescollection.addSeries(serie_mediana);

    xyplot.getRenderer().setSeriesPaint(9, Color.black);
    xyplot.getRenderer().setSeriesPaint(10, Color.black);

    xyplot.getRenderer().setSeriesPaint(0, Color.black);
    xyplot.getRenderer().setSeriesPaint(1, Color.black);
    xyplot.getRenderer().setSeriesPaint(2, Color.black);
    xyplot.getRenderer().setSeriesPaint(3, Color.black);
    xyplot.getRenderer().setSeriesPaint(4, Color.black);
    xyplot.getRenderer().setSeriesPaint(5, Color.black);
    xyplot.getRenderer().setSeriesPaint(6, Color.black);
    xyplot.getRenderer().setSeriesPaint(7, Color.black);
    xyplot.getRenderer().setSeriesPaint(8, Color.black);
    xyplot.getRenderer().setSeriesPaint(9, Color.black);
    xyplot.getRenderer().setSeriesPaint(10, Color.black);
    xyplot.getRenderer().setSeriesPaint(11, Color.black);
    xyplot.getRenderer().setSeriesPaint(12, Color.black);
    xyplot.getRenderer().setSeriesPaint(13, Color.black);

    //add dataset
    xyplot.setDataset(xyseriescollection);

    // add a second dataset and renderer... 
    XYSeriesCollection anotherserie = new XYSeriesCollection();

    XYSeries serie_point = new XYSeries("21");

    double[] yValue = { 0.47, 0.49, 0.51, 0.53 };

    for (int i = 0, j = 0; i < sortedArray.length; i++, j++) {
        if (j % 4 == 0) {
            j = 0;
        }
        serie_point.add(sortedArray[i], yValue[j]);
    }

    anotherserie.addSeries(serie_point);

    XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer(false, true);
    renderer1.setSeriesPaint(0, Color.lightGray);

    xyplot.setDataset(1, anotherserie);
    xyplot.setRenderer(1, renderer1);
}

From source file:io.sanfran.wikiTrends.extraction.plots.PlotTimeSeries.java

private static JFreeChart createChart(XYDataset dataset, String title) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title
            "Date", // x-axis label
            "Page visits", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );/*from   w w w. j  a  v a  2s  .  c  o  m*/

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(false); // if you want visible dots -> true
        renderer.setBaseShapesFilled(false); // if you want visible dots -> true

        if (seriesWidth != null) {
            for (int i = 0; i < seriesWidth.size(); i++) {
                renderer.setSeriesStroke(i, new BasicStroke(seriesWidth.get(i)));
            }
        }
        if (seriesColor != null) {
            for (int i = 0; i < seriesColor.size(); i++) {
                renderer.setSeriesPaint(i, seriesColor.get(i));
            }
        }

    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    //axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    axis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yyyy"));

    return chart;

}

From source file:org.micromanager.CRISP.CRISPFrame.java

/**
* Create a frame with a plot of the data given in XYSeries
*//*from  www  . ja v  a2s.c  o m*/
public static void plotData(String title, XYSeries data, String xTitle, String yTitle, int xLocation,
        int yLocation) {
    // JFreeChart code
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(data);
    JFreeChart chart = ChartFactory.createScatterPlot(title, // Title
            xTitle, // x-axis Label
            yTitle, // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            false, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setSeriesPaint(0, Color.black);
    renderer.setSeriesFillPaint(0, Color.white);
    renderer.setSeriesLinesVisible(0, true);
    Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
    renderer.setSeriesShape(0, circle, false);
    renderer.setUseFillPaint(true);

    ChartFrame graphFrame = new ChartFrame(title, chart);
    graphFrame.getChartPanel().setMouseWheelEnabled(true);
    graphFrame.pack();
    graphFrame.setLocation(xLocation, yLocation);
    graphFrame.setVisible(true);
}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.JFreeChartConn.java

/**
 * Updates the point-related properties of a plot.
 * /*www.  j a v  a  2 s  . co m*/
 * @param aPlot
 *            Plot to be updated.
 * @param aScatter
 *            Visual settings to be applied.
 */
private static void updateScatter(XYPlot aPlot, ScatterSettings aScatter) {
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) aPlot.getRenderer();
    renderer.setSeriesPaint(0, aScatter.getPointColor());
    final Rectangle2D ds = AbstractRenderer.DEFAULT_SHAPE.getBounds2D();
    final double x = ds.getX();
    final double y = ds.getY();
    final double w = ds.getWidth();
    final double h = ds.getHeight();
    Shape shape = null;
    switch (aScatter.getPointShape()) {
    case POINT:
        shape = new Rectangle2D.Double(x + w / 2, y + h / 2, 1, 1);
        renderer.setBaseShapesFilled(true);
        break;
    case CIRCLE:
        shape = new Ellipse2D.Double(x, y, w, h);
        renderer.setBaseShapesFilled(false);
        break;
    case FILLED_CIRCLE:
        shape = new Ellipse2D.Double(x, y, w, h);
        renderer.setBaseShapesFilled(true);
        break;
    case SQUARE:
        shape = new Rectangle2D.Double(x, y, w, h);
        renderer.setBaseShapesFilled(false);
        break;
    case FILLED_SQUARE:
        shape = new Rectangle2D.Double(x, y, w, h);
        renderer.setBaseShapesFilled(true);
        break;
    case CROSS:
        shape = new Cross(x, y, w, h);
        renderer.setBaseShapesFilled(false);
    }
    renderer.setSeriesShape(0, shape);
}