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

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

Introduction

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

Prototype

public void setSeriesShape(int series, Shape shape) 

Source Link

Document

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

Usage

From source file:projects.tgas.exec.HrDiagram.java

/**
 * Plot the HR diagram chart from the given data.
 * @param series/*from  ww w.ja  v a 2 s  .c  o m*/
 *    A {@link XYSeries} containing the HR diagram data.
 * @return
 *    A {@link JFreeChart} containing the plot.
 */
private static JFreeChart getHrChart(XYSeries series) {

    XYSeriesCollection hrData = new XYSeriesCollection();
    hrData.addSeries(series);

    // Set up the renderer
    XYLineAndShapeRenderer hrRenderer = new XYLineAndShapeRenderer();

    hrRenderer.setSeriesLinesVisible(0, false);
    hrRenderer.setSeriesShapesVisible(0, true);
    hrRenderer.setSeriesShape(0, new Ellipse2D.Double(-0.5, -0.5, 1, 1));

    // Configure axes
    NumberAxis xAxis = new NumberAxis("B - V [mag]");
    xAxis.setRange(-0.5, 2.25);

    NumberAxis yAxis = new NumberAxis("G [mag]");
    yAxis.setInverted(true);
    yAxis.setRange(-5, 13);

    // Configure plot
    XYPlot xyplot = new XYPlot(hrData, xAxis, yAxis, hrRenderer);
    xyplot.setBackgroundPaint(Color.white);

    JFreeChart hrChart = new JFreeChart("HR diagram of TGAS stars", xyplot);
    hrChart.removeLegend();
    hrChart.setBackgroundPaint(Color.white);

    return hrChart;
}

From source file:projects.hip.exec.HrDiagram.java

/**
 * Plot the HR diagram chart from the given data.
 * @param series/*w ww .j  av a  2  s .  co m*/
 *    A {@link XYSeries} containing the HR diagram data.
 * @return
 *    A {@link JFreeChart} containing the plot.
 */
private static JFreeChart getHrChart(XYSeries series) {

    XYSeriesCollection hrData = new XYSeriesCollection();
    hrData.addSeries(series);

    // Set up the renderer
    XYLineAndShapeRenderer hrRenderer = new XYLineAndShapeRenderer();

    hrRenderer.setSeriesLinesVisible(0, false);
    hrRenderer.setSeriesShapesVisible(0, true);
    hrRenderer.setSeriesShape(0, new Ellipse2D.Double(-0.5, -0.5, 1, 1));

    // Configure axes
    NumberAxis xAxis = new NumberAxis("B - V [mag]");
    xAxis.setRange(-0.5, 2.25);

    NumberAxis yAxis = new NumberAxis("H [mag]");
    yAxis.setInverted(true);
    yAxis.setRange(-5, 13);

    // Configure plot
    XYPlot xyplot = new XYPlot(hrData, xAxis, yAxis, hrRenderer);
    xyplot.setBackgroundPaint(Color.white);

    JFreeChart hrChart = new JFreeChart("HR diagram of Hipparcos stars", xyplot);
    hrChart.removeLegend();
    hrChart.setBackgroundPaint(Color.white);

    return hrChart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Breakdowns", "Production Date",
            "Hours of Operation", xydataset, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setSeriesShape(0, new Rectangle(2, 2));
    xylineandshaperenderer.setSeriesShape(1, new Rectangle(2, 2));
    xylineandshaperenderer.setBaseLinesVisible(false);
    xylineandshaperenderer.setBaseShapesFilled(true);
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setBaseToolTipGenerator(null);
    xylineandshaperenderer.setSeriesPaint(0, Color.blue);
    xylineandshaperenderer.setSeriesPaint(1, Color.red);
    xyplot.setDomainGridlineStroke(new BasicStroke(1.0F));
    xyplot.setRangeGridlineStroke(new BasicStroke(1.0F));
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setTickUnit(new NumberTickUnit(50000D));
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1));
    dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM.yy"));
    dateaxis.setVerticalTickLabels(true);
    Color color = new Color(255, 0, 0, 60);
    Color color1 = new Color(0, 255, 0, 60);
    XYBoxAnnotation xyboxannotation = new XYBoxAnnotation((new Day(1, 1, 2004)).getMiddleMillisecond(), 0.0D,
            (new Day(31, 1, 2004)).getMiddleMillisecond(), 50000D, new BasicStroke(0.0F), color, color);
    xyboxannotation.setToolTipText("Value: 2.9");
    xylineandshaperenderer.addAnnotation(xyboxannotation);
    xyboxannotation = new XYBoxAnnotation((new Day(1, 2, 2004)).getMiddleMillisecond(), 0.0D,
            (new Day(29, 2, 2004)).getMiddleMillisecond(), 50000D, new BasicStroke(0.0F), color, color);
    xyboxannotation.setToolTipText("Value: 2.5");
    xylineandshaperenderer.addAnnotation(xyboxannotation);
    xyboxannotation = new XYBoxAnnotation((new Day(1, 5, 2004)).getMiddleMillisecond(), 50000D,
            (new Day(31, 5, 2004)).getMiddleMillisecond(), 100000D, new BasicStroke(0.0F), color, color);
    xyboxannotation.setToolTipText("Value: 1.8");
    xylineandshaperenderer.addAnnotation(xyboxannotation);
    xyboxannotation = new XYBoxAnnotation((new Day(1, 6, 2005)).getMiddleMillisecond(), 0.0D,
            (new Day(30, 6, 2005)).getMiddleMillisecond(), 50000D, new BasicStroke(0.0F), color1, color1);
    xyboxannotation.setToolTipText("Value: 3.7");
    xylineandshaperenderer.addAnnotation(xyboxannotation);
    return jfreechart;
}

From source file:org.gephi.ui.utils.ChartsUtils.java

/**
 * Modify a scatter plot to show lines instead or shapes or not.
 * @param scatterPlot Scatter plot to modify
 * @param enabled Indicates if lines have to be shown
 *///from  w w  w  . ja va 2 s .  c  o  m
public static void setScatterPlotLinesEnabled(final JFreeChart scatterPlot, final boolean enabled) {
    XYPlot plot = (XYPlot) scatterPlot.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    if (enabled) {
        renderer.setSeriesLinesVisible(0, true);
        renderer.setSeriesShapesVisible(0, false);
    } else {
        renderer.setSeriesLinesVisible(0, false);
        renderer.setSeriesShapesVisible(0, true);
        renderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(0, 0, 1, 1));
    }
    renderer.setSeriesPaint(0, Color.RED);

    plot.setRenderer(0, renderer);
}

From source file:y.graphs.ChartHelperELF.java

private static JFreeChart createChart(final TimeSeriesCollection dataset, Date from, Date to, Config config,
        ArrayList<ConfigSerie> series) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(Config.getResource("MsgTitleMagGraph"),
            Config.getResource("TitleDate"), Config.getResource("MsgTitleMagGraphYAxis"), dataset, true, // include legend
            true, // tooltips
            false // urls
    );//from  w  w w.j a  va2  s .  com

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    LegendTitle lt = new LegendTitle(plot);
    lt.setItemFont(new Font("Dialog", Font.PLAIN, 12));
    lt.setBackgroundPaint(Color.white);
    lt.setFrame(new BlockBorder(Color.white));
    lt.setVerticalAlignment(VerticalAlignment.CENTER);
    XYTitleAnnotation ta = new XYTitleAnnotation(config.getLegendX(), config.getLegendY(), lt,
            RectangleAnchor.TOP_RIGHT);
    ta.setMaxWidth(config.getLegendSize());
    plot.addAnnotation(ta);
    chart.removeLegend();

    plot.setBackgroundPaint(config.getColorBackgroundELF());
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    final Stroke lineStroke = new BasicStroke((float) config.getLineWidthELF());

    for (int si = 0; si < series.size(); si++) {
        final ConfigSerie cs = series.get(si);
        renderer.setSeriesLinesVisible(si, cs.isDrawLine());

        final float size = cs.getShapeSize();
        renderer.setSeriesShapesVisible(si, size > 0);
        if (size > 0)
            renderer.setSeriesShape(si, ShapeUtilities.createRegularCross(size, size));

        renderer.setSeriesStroke(si, lineStroke);
        //            renderer.setSeriesOutlineStroke(si, lineStroke);
        renderer.setSeriesPaint(si, cs.getColor());
    }
    plot.setRenderer(renderer);

    // x axis
    final DateAxis rangeAxis = (DateAxis) plot.getDomainAxis();
    //        rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits()); // Returns a collection of standard date tick units that uses the default time zone. This collection will be used by default, but you are free to create your own collection if you want to
    rangeAxis.setAutoRange(true);
    //        rangeAxis.setRange(from, to);
    rangeAxis.setLowerMargin(0.01);
    rangeAxis.setUpperMargin(0.01);

    {
        final Font axisFont = config.getAxisFont();
        if (axisFont != null) {
            rangeAxis.setLabelFont(axisFont);
            plot.getRangeAxis().setLabelFont(axisFont);
        }
    }

    final String xaxisFmt = config.getAxisFormat();

    if (xaxisFmt == null || xaxisFmt.isEmpty()) {
        double diffInDays = (to.getTime() - from.getTime()) / (1000.0 * 60.0 * 60.0 * 24.0);
        if (diffInDays < 2)
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_TIMEFMT, DateFormatSymbols.getInstance()));
        else
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_SHORTTIMEFMT, DateFormatSymbols.getInstance()));
    } else
        rangeAxis.setDateFormatOverride(new SimpleDateFormat(xaxisFmt, DateFormatSymbols.getInstance()));

    final ValueAxis domain = plot.getRangeAxis();
    if (config.getForceYmin() != 0 || config.getForceYmax() != 0)
        domain.setRange(ElfValue.valueIntToDouble(config.getForceYmin()),
                ElfValue.valueIntToDouble(config.getForceYmax()));

    // title
    final Font titleFont = config.getTitleFont();
    if (titleFont != null)
        chart.getTitle().setFont(titleFont);

    return chart;
}

From source file:y.graphs.ChartHelperSRB.java

private static JFreeChart createChart(final TimeSeriesCollection dataset, Date from, Date to, Config config,
        ArrayList<ConfigSerie> series) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(Config.getResource("MsgTitleSrbGraph"),
            Config.getResource("TitleDate"), Config.getResource("MsgTitleSrbGraphYAxis"), dataset, true, // include legend
            true, // tooltips
            false // urls
    );/*from w w w. j  a  va  2 s. c  o  m*/

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    LegendTitle lt = new LegendTitle(plot);
    lt.setItemFont(new Font("Dialog", Font.PLAIN, 12));
    lt.setBackgroundPaint(Color.white);
    lt.setFrame(new BlockBorder(Color.white));
    lt.setVerticalAlignment(VerticalAlignment.CENTER);
    XYTitleAnnotation ta = new XYTitleAnnotation(config.getLegendX(), config.getLegendY(), lt,
            RectangleAnchor.TOP_RIGHT);
    ta.setMaxWidth(config.getLegendSize());
    plot.addAnnotation(ta);
    chart.removeLegend();

    plot.setBackgroundPaint(config.getColorBackgroundSRB());
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    final Stroke lineStroke = new BasicStroke((float) config.getLineWidthSRB());

    for (int si = 0; si < series.size(); si++) {
        final ConfigSerie cs = series.get(si);
        renderer.setSeriesLinesVisible(si, cs.isDrawLine());

        final float size = cs.getShapeSize();
        renderer.setSeriesShapesVisible(si, size > 0);
        if (size > 0)
            renderer.setSeriesShape(si, ShapeUtilities.createRegularCross(size, size));

        renderer.setSeriesStroke(si, lineStroke);
        //          renderer.setSeriesOutlineStroke(si, lineStroke);
        renderer.setSeriesPaint(si, cs.getColor());
    }
    plot.setRenderer(renderer);

    // x axis
    final DateAxis rangeAxis = (DateAxis) plot.getDomainAxis();
    //      rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits()); // Returns a collection of standard date tick units that uses the default time zone. This collection will be used by default, but you are free to create your own collection if you want to
    rangeAxis.setAutoRange(true);
    //        rangeAxis.setRange(from, to);
    rangeAxis.setLowerMargin(0.01);
    rangeAxis.setUpperMargin(0.01);

    {
        final Font axisFont = config.getAxisFont();
        if (axisFont != null) {
            rangeAxis.setLabelFont(axisFont);
            plot.getRangeAxis().setLabelFont(axisFont);
        }
    }

    final String xaxisFmt = config.getAxisFormat();

    if (xaxisFmt == null || xaxisFmt.isEmpty()) {
        double diffInDays = (to.getTime() - from.getTime()) / (1000.0 * 60.0 * 60.0 * 24.0);
        if (diffInDays < 2)
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_TIMEFMT, DateFormatSymbols.getInstance()));
        else
            rangeAxis.setDateFormatOverride(
                    new SimpleDateFormat(Config.DEFAULT_SHORTTIMEFMT, DateFormatSymbols.getInstance()));
    } else
        rangeAxis.setDateFormatOverride(new SimpleDateFormat(xaxisFmt, DateFormatSymbols.getInstance()));

    final ValueAxis domain = plot.getRangeAxis();
    if (config.getForceYmin() != 0 || config.getForceYmax() != 0)
        domain.setRange(ElfValue.valueIntToDouble(config.getForceYmin()),
                ElfValue.valueIntToDouble(config.getForceYmax()));

    // title
    final Font titleFont = config.getTitleFont();
    if (titleFont != null)
        chart.getTitle().setFont(titleFont);

    return chart;
}

From source file:fr.amap.commons.javafx.chart.ChartViewer.java

public static JFreeChart createBasicChart(String title, XYSeriesCollection dataset, String xAxisLabel,
        String yAxisLabel) {//from  w w  w .j  a  v a2 s.c o  m

    JFreeChart chart = ChartFactory.createXYLineChart(title, xAxisLabel, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    String fontName = "Palatino";
    chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));
    XYPlot plot = (XYPlot) chart.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().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));

    chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
    chart.getLegend().setFrame(BlockBorder.NONE);

    LegendTitle subtitle = (LegendTitle) chart.getSubtitles().get(0);
    subtitle.setHorizontalAlignment(HorizontalAlignment.LEFT);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);

        Ellipse2D.Float shape = new Ellipse2D.Float(-2.5f, -2.5f, 5.0f, 5.0f);
        renderer.setSeriesShape(0, shape);
    }

    return chart;
}

From source file:cn.InstFS.wkr.NetworkMining.UIs.TimeSeriesChart2.java

public static JFreeChart createChart(DataItems nor, DataItems abnor, String title, String protocol1,
        String protocol2) {/*from   w  w  w . java2 s .  c  o m*/
    // ?
    XYDataset xydataset1 = TimeSeriesChart1.createNormalDataset(nor, protocol1);
    JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "", "", xydataset1);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();

    XYLineAndShapeRenderer xylineandshaperenderer1 = (XYLineAndShapeRenderer) xyplot.getRenderer();
    // ??1?1

    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    java.awt.geom.Ellipse2D.Double double1 = new java.awt.geom.Ellipse2D.Double(-4D, -4D, 6D, 6D);
    // ???

    // ??
    xylineandshaperenderer1.setSeriesLinesVisible(0, true);
    xylineandshaperenderer1.setBaseShapesVisible(false);
    xylineandshaperenderer1.setSeriesShape(0, double1);
    xylineandshaperenderer1.setSeriesPaint(0, Color.blue);
    xylineandshaperenderer1.setSeriesFillPaint(0, Color.blue);
    xylineandshaperenderer1.setSeriesOutlinePaint(0, Color.blue);
    xylineandshaperenderer1.setSeriesStroke(0, new BasicStroke(0.5F));

    // ?
    XYDataset xydataset2 = TimeSeriesChart1.createNormalDataset(abnor, protocol2);
    /*      XYTextAnnotation localXYTextAnnotation = new XYTextAnnotation("aa",10,
    Double.parseDouble(abnor.getElementAt(10).getData()));
          xyplot.addAnnotation(localXYTextAnnotation);*/
    XYLineAndShapeRenderer xylineandshaperenderer2 = new XYLineAndShapeRenderer();
    int datasetcount = xyplot.getDatasetCount();
    xyplot.setDataset(datasetcount, xydataset2);
    xyplot.setRenderer(datasetcount, xylineandshaperenderer2);
    /*      System.out.println("DatasetCount="+xyplot.getDatasetCount());
                  
          for(int c=0;c<xyplot.getDatasetCount();c++){
             System.out.println("DatasetSeriesCount="+xyplot.getDataset(c).getSeriesCount());
             System.out.println("Dataset["+c+"]="+xyplot.getDataset(c).getSeriesKey(0));
          }*/

    /*   // ??? 
       xylineandshaperenderer2.setBaseShapesVisible(false);
       // ??
       xylineandshaperenderer2.setSeriesLinesVisible(0, true);
       xylineandshaperenderer2.setSeriesShape(0, double1);
       // 
       xylineandshaperenderer2.setSeriesPaint(0, Color.green);
       xylineandshaperenderer2.setSeriesFillPaint(0, Color.green);
       xylineandshaperenderer2.setSeriesOutlinePaint(0, Color.green);
            
       xylineandshaperenderer2.setUseFillPaint(true);
       xylineandshaperenderer2
    .setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
       xylineandshaperenderer2.setSeriesStroke(0, new BasicStroke(0.5F));
               
    */
    xylineandshaperenderer2.setSeriesLinesVisible(0, true);
    xylineandshaperenderer2.setBaseShapesVisible(false);
    xylineandshaperenderer2.setSeriesShape(0, double1);
    xylineandshaperenderer2.setSeriesPaint(0, Color.GREEN);
    xylineandshaperenderer2.setSeriesFillPaint(0, Color.GREEN);
    xylineandshaperenderer2.setSeriesOutlinePaint(0, Color.green);
    xylineandshaperenderer2.setSeriesStroke(0, new BasicStroke(0.5F));
    jfreechart.getLegend().setVisible(true);
    return jfreechart;

}

From source file:cn.InstFS.wkr.NetworkMining.UIs.TimeSeriesChart1.java

public static JFreeChart createChart2(ArrayList<DataItems> _nor_model, ArrayList<DataItems> _abnor_model,
        DataItems nor, DataItems abnor, Map<String, ArrayList<LinePos>> mapAB, String chartname,
        String protocol1, String protocol2) {
    XYDataset xydataset = createNormalDataset(nor, protocol1);
    JFreeChart jfreechart = ChartFactory.createXYLineChart(chartname, "", "", xydataset);
    jfreechart.getLegend().setVisible(false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    java.awt.geom.Ellipse2D.Double double1 = new java.awt.geom.Ellipse2D.Double(-4D, -4D, 6D, 6D);

    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    // ??//from   w  w w .  j a v  a 2 s  .  c om
    xylineandshaperenderer.setSeriesLinesVisible(0, true);
    xylineandshaperenderer.setBaseShapesVisible(false);
    xylineandshaperenderer.setSeriesShape(0, double1);
    xylineandshaperenderer.setSeriesPaint(0, Color.blue);
    xylineandshaperenderer.setSeriesFillPaint(0, Color.blue);
    xylineandshaperenderer.setSeriesOutlinePaint(0, Color.blue);
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(0.5F));
    // ?
    // xylineandshaperenderer.setBaseItemLabelGenerator(new
    // StandardXYItemLabelGenerator());
    // xylineandshaperenderer.setBaseItemLabelsVisible(true);
    int datasetcount0 = xyplot.getDatasetCount();

    XYDataset xydataset1 = createNormalDataset(abnor, protocol2);
    // xydataset1.
    XYLineAndShapeRenderer xylineandshaperenderer1 = new XYLineAndShapeRenderer();
    int datasetcount = xyplot.getDatasetCount();
    xyplot.setDataset(datasetcount, xydataset1);
    xyplot.setRenderer(datasetcount, xylineandshaperenderer1);
    // ???
    xylineandshaperenderer1.setBaseShapesVisible(false);
    // ??
    xylineandshaperenderer1.setSeriesLinesVisible(0, true);
    xylineandshaperenderer1.setSeriesShape(0, double1);
    // 
    xylineandshaperenderer1.setSeriesPaint(0, Color.green);
    xylineandshaperenderer1.setSeriesFillPaint(0, Color.green);
    xylineandshaperenderer1.setSeriesOutlinePaint(0, Color.green);
    xylineandshaperenderer1.setUseFillPaint(true);

    xylineandshaperenderer1.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    xylineandshaperenderer1.setSeriesStroke(0, new BasicStroke(0.5F));

    // //?
    /*
     * for (int i = 0; i < _nor_model.size(); i++) { XYDataset xydataset2 =
     * createmodeDataset(_nor_model.get(i), "_nor_model" + i);
     * XYLineAndShapeRenderer xylineandshaperenderer2 = new
     * XYLineAndShapeRenderer(); xyplot.setDataset(i + 2, xydataset2);
     * xyplot.setRenderer(2 + i, xylineandshaperenderer2); // ???
     * xylineandshaperenderer2.setBaseShapesVisible(false); // ??
     * xylineandshaperenderer2.setSeriesLinesVisible(0, true);
     * xylineandshaperenderer2.setSeriesShape(0, double1); // 
     * xylineandshaperenderer2.setSeriesPaint(0, Color.red);
     * xylineandshaperenderer2.setSeriesFillPaint(0, Color.red);
     * xylineandshaperenderer2.setSeriesOutlinePaint(0, Color.red);
     * xylineandshaperenderer2.setUseFillPaint(true);
     * xylineandshaperenderer2 .setBaseItemLabelGenerator(new
     * StandardXYItemLabelGenerator());
     * xylineandshaperenderer2.setSeriesStroke(0, new BasicStroke(2.5F));
     * 
     * } for (int i = 0; i < _abnor_model.size(); i++) { XYDataset
     * xydataset3 = createmodeDataset(_abnor_model.get(i), "_abnor_model" +
     * i); XYLineAndShapeRenderer xylineandshaperenderer3 = new
     * XYLineAndShapeRenderer(); xyplot.setDataset(i + 2 +
     * _nor_model.size(), xydataset3); xyplot.setRenderer(i + 2 +
     * _nor_model.size(), xylineandshaperenderer3); // ???
     * xylineandshaperenderer3.setBaseShapesVisible(false); // ??
     * xylineandshaperenderer3.setSeriesLinesVisible(0, true);
     * xylineandshaperenderer3.setSeriesShape(0, double1); // 
     * xylineandshaperenderer3.setSeriesPaint(0, Color.red);
     * xylineandshaperenderer3.setSeriesFillPaint(0, Color.red);
     * xylineandshaperenderer3.setSeriesOutlinePaint(0, Color.red);
     * xylineandshaperenderer3.setUseFillPaint(true);
     * xylineandshaperenderer3 .setBaseItemLabelGenerator(new
     * StandardXYItemLabelGenerator());
     * xylineandshaperenderer3.setSeriesStroke(0, new BasicStroke(2.5F));
     * 
     * }
     */
    // ??
    // 
    // /////////////////////////////////
    // ?

    XYDataset xydataset4 = createLineDataset(nor, abnor, mapAB, xyplot);

    // ??y=1
    ValueMarker valuemarker = new ValueMarker(1); // 
    valuemarker.setLabelOffsetType(LengthAdjustmentType.EXPAND);
    valuemarker.setPaint(Color.black); // ?
    valuemarker.setStroke(new BasicStroke(1.0F)); // 
    // valuemarker.setLabel(""); //?
    valuemarker.setLabelFont(new Font("SansSerif", 0, 11)); // ?
    valuemarker.setLabelPaint(Color.red);
    valuemarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    valuemarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
    xyplot.addRangeMarker(valuemarker);
    // //

    //jfreechart.getLegend().setVisible(true);
    return jfreechart;
}

From source file:Util.PacketGenerator.java

public static void GenerateGraph() {
    try {// w  w  w.  j  av a2  s. co  m
        for (int j = 6; j <= 6; j++) {
            File real = new File("D:\\Mestrado\\SketchMatrix\\trunk\\Simulations\\Analise\\Scenario1\\Topology"
                    + j + "\\Real.csv");
            for (int k = 1; k <= 4; k++) {
                File simu = new File(
                        "D:\\Mestrado\\SketchMatrix\\trunk\\Simulations\\Analise\\Scenario1\\Topology" + j
                                + "\\SimulacaoInstancia" + k + ".csv");

                FileInputStream simuFIS = new FileInputStream(simu);
                DataInputStream simuDIS = new DataInputStream(simuFIS);
                BufferedReader simuBR = new BufferedReader(new InputStreamReader(simuDIS));

                FileInputStream realFIS = new FileInputStream(real);
                DataInputStream realDIS = new DataInputStream(realFIS);
                BufferedReader realBR = new BufferedReader(new InputStreamReader(realDIS));

                String lineSimu = simuBR.readLine();
                String lineReal = realBR.readLine();

                XYSeries matrix = new XYSeries("Matriz", false, true);
                while (lineSimu != null && lineReal != null) {

                    lineSimu = lineSimu.replaceAll(",", ".");
                    String[] simuMatriz = lineSimu.split(";");
                    String[] realMatriz = lineReal.split(";");

                    for (int i = 0; i < simuMatriz.length; i++) {
                        try {
                            Integer valorReal = Integer.parseInt(realMatriz[i]);
                            Float valorSimu = Float.parseFloat(simuMatriz[i]);
                            matrix.add(valorReal.doubleValue() / 1000.0, valorSimu.doubleValue() / 1000.0);
                        } catch (NumberFormatException ex) {

                        }
                    }
                    lineSimu = simuBR.readLine();
                    lineReal = realBR.readLine();
                }

                simuFIS.close();
                simuDIS.close();
                simuBR.close();

                realFIS.close();
                realDIS.close();
                realBR.close();

                double maxPlot = Double.max(matrix.getMaxX(), matrix.getMaxY()) * 1.1;
                XYSeries middle = new XYSeries("Referncia");
                ;
                middle.add(0, 0);
                middle.add(maxPlot, maxPlot);
                XYSeries max = new XYSeries("Superior 20%");
                max.add(0, 0);
                max.add(maxPlot, maxPlot * 1.2);
                XYSeries min = new XYSeries("Inferior 20%");
                min.add(0, 0);
                min.add(maxPlot, maxPlot * 0.8);

                XYSeriesCollection dataset = new XYSeriesCollection();
                dataset.addSeries(middle);
                dataset.addSeries(matrix);
                dataset.addSeries(max);
                dataset.addSeries(min);
                JFreeChart chart;
                if (k == 4) {
                    chart = ChartFactory.createXYLineChart("Matriz de Trfego", "Real", "CMO-MT", dataset);
                } else {
                    chart = ChartFactory.createXYLineChart("Matriz de Trfego", "CMO-MT", "Zhao", dataset);
                }
                chart.setBackgroundPaint(Color.WHITE);
                chart.getPlot().setBackgroundPaint(Color.WHITE);
                chart.getTitle().setFont(new Font("Times New Roman", Font.BOLD, 13));

                chart.getLegend().setItemFont(new Font("Times New Roman", Font.TRUETYPE_FONT, 10));

                chart.getXYPlot().getDomainAxis().setLabelFont(new Font("Times New Roman", Font.BOLD, 10));
                chart.getXYPlot().getDomainAxis()
                        .setTickLabelFont(new Font("Times New Roman", Font.TRUETYPE_FONT, 1));
                chart.getXYPlot().getRangeAxis().setLabelFont(new Font("Times New Roman", Font.BOLD, 10));
                chart.getXYPlot().getRangeAxis()
                        .setTickLabelFont(new Font("Times New Roman", Font.TRUETYPE_FONT, 1));

                XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer();

                renderer.setSeriesLinesVisible(1, false);
                renderer.setSeriesShapesVisible(1, true);

                renderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER,
                        10.0f, new float[] { 0.1f }, 0.0f));
                renderer.setSeriesShape(1, new Ellipse2D.Float(-1.5f, -1.5f, 3f, 3f));
                renderer.setSeriesStroke(2, new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER,
                        10.0f, new float[] { 3.0f }, 0.0f));
                renderer.setSeriesStroke(3, new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER,
                        10.0f, new float[] { 3.0f }, 0.0f));

                renderer.setSeriesPaint(0, Color.BLACK);
                renderer.setSeriesPaint(1, Color.BLACK);
                renderer.setSeriesPaint(2, Color.BLACK);
                renderer.setSeriesPaint(3, Color.BLACK);

                int width = (int) (192 * 1.5f); /* Width of the image */

                int height = (int) (144 * 1.5f); /* Height of the image */

                File XYChart = new File(
                        "D:\\Mestrado\\SketchMatrix\\trunk\\Simulations\\Analise\\Scenario1\\Topology" + j
                                + "\\SimulacaoInstancia" + k + ".jpeg");
                ChartUtilities.saveChartAsJPEG(XYChart, chart, width, height);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}