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

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

Introduction

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

Prototype

public void setSeriesOutlinePaint(int series, Paint paint) 

Source Link

Document

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

Usage

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter Plot Demo 1", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setNoDataMessage("NO DATA");
    xyplot.setDomainZeroBaselineVisible(true);
    xyplot.setRangeZeroBaselineVisible(true);
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setSeriesOutlinePaint(0, Color.black);
    xylineandshaperenderer.setUseOutlinePaint(true);
    NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    numberaxis.setTickMarkInsideLength(2.0F);
    numberaxis.setTickMarkOutsideLength(0.0F);
    NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis();
    numberaxis1.setTickMarkInsideLength(2.0F);
    numberaxis1.setTickMarkOutsideLength(0.0F);
    return jfreechart;
}

From source file:org.drugis.addis.gui.LyndOBrienChartFactory.java

public static JFreeChart buildScatterPlot(LyndOBrienModel model) {
    XYDataset data = new ScatterPlotDataset(model);
    JFreeChart chart = ChartFactory.createScatterPlot("Benefit-Risk plane", model.getXAxisName(),
            model.getYAxisName(), data, PlotOrientation.VERTICAL, false, false, false);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer();
    renderer.setSeriesOutlinePaint(0, Color.black);
    renderer.setUseOutlinePaint(true);//from   w w  w.  j ava  2  s.c o  m
    renderer.setSeriesShape(0, new Ellipse2D.Double(-2.0, 2.0, 4.0, 4.0));

    // draw lines through origin.
    chart.getXYPlot().setDomainZeroBaselineVisible(true);
    chart.getXYPlot().setRangeZeroBaselineVisible(true);

    // Explicitly set the stroke-width to avoid a rendering error in Linux
    Stroke stroke = new BasicStroke(1.0f);
    chart.getXYPlot().setDomainZeroBaselineStroke(stroke);
    return chart;
}

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

private static JFreeChart createChart() {
    XYDataset xydataset = createDataset(1, 1.0D);
    JFreeChart jfreechart = ChartFactory.createXYLineChart("XYLineAndShapeRenderer Demo 2", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    TextTitle texttitle = new TextTitle(
            "This chart shows various combinations of the useFillPaint and useOutlinePaint flags.");
    texttitle.setFont(new Font("Dialog", 0, 10));
    jfreechart.addSubtitle(texttitle);//from  w ww. jav  a 2 s . c  o m
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    java.awt.geom.Ellipse2D.Double double1 = new java.awt.geom.Ellipse2D.Double(-4D, -4D, 8D, 8D);
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setSeriesShape(0, double1);
    xylineandshaperenderer.setSeriesPaint(0, Color.red);
    xylineandshaperenderer.setSeriesFillPaint(0, Color.yellow);
    xylineandshaperenderer.setSeriesOutlinePaint(0, Color.gray);
    XYDataset xydataset1 = createDataset(2, 2D);
    XYLineAndShapeRenderer xylineandshaperenderer1 = new XYLineAndShapeRenderer();
    xyplot.setDataset(1, xydataset1);
    xyplot.setRenderer(1, xylineandshaperenderer1);
    xylineandshaperenderer1.setSeriesShape(0, double1);
    xylineandshaperenderer1.setSeriesPaint(0, Color.red);
    xylineandshaperenderer1.setSeriesFillPaint(0, Color.yellow);
    xylineandshaperenderer1.setSeriesOutlinePaint(0, Color.gray);
    xylineandshaperenderer1.setUseFillPaint(true);
    XYDataset xydataset2 = createDataset(3, 3D);
    XYLineAndShapeRenderer xylineandshaperenderer2 = new XYLineAndShapeRenderer();
    xyplot.setDataset(2, xydataset2);
    xyplot.setRenderer(2, xylineandshaperenderer2);
    xylineandshaperenderer2.setSeriesShape(0, double1);
    xylineandshaperenderer2.setSeriesPaint(0, Color.red);
    xylineandshaperenderer2.setSeriesFillPaint(0, Color.yellow);
    xylineandshaperenderer2.setSeriesOutlinePaint(0, Color.gray);
    xylineandshaperenderer2.setUseOutlinePaint(true);
    XYDataset xydataset3 = createDataset(4, 4D);
    XYLineAndShapeRenderer xylineandshaperenderer3 = new XYLineAndShapeRenderer();
    xyplot.setDataset(3, xydataset3);
    xyplot.setRenderer(3, xylineandshaperenderer3);
    xylineandshaperenderer3.setSeriesShape(0, double1);
    xylineandshaperenderer3.setSeriesPaint(0, Color.red);
    xylineandshaperenderer3.setSeriesFillPaint(0, Color.yellow);
    xylineandshaperenderer3.setSeriesOutlinePaint(0, Color.gray);
    xylineandshaperenderer3.setUseOutlinePaint(true);
    xylineandshaperenderer3.setUseFillPaint(true);
    XYDataset xydataset4 = createDataset(5, 5D);
    XYLineAndShapeRenderer xylineandshaperenderer4 = new XYLineAndShapeRenderer();
    xyplot.setDataset(4, xydataset4);
    xyplot.setRenderer(4, xylineandshaperenderer4);
    xylineandshaperenderer4.setSeriesShape(0, double1);
    xylineandshaperenderer4.setSeriesPaint(0, Color.red);
    xylineandshaperenderer4.setSeriesFillPaint(0, Color.yellow);
    xylineandshaperenderer4.setSeriesOutlinePaint(0, Color.gray);
    xylineandshaperenderer4.setUseOutlinePaint(true);
    xylineandshaperenderer4.setUseFillPaint(true);
    xylineandshaperenderer4.setDrawOutlines(false);
    return jfreechart;
}

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 ww  w  .j av  a 2  s .  c om
    // ?
    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 . ja v a  2  s  .  c  o  m
    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:cn.InstFS.wkr.NetworkMining.UIs.TimeSeriesChart1.java

public static XYDataset createLineDataset(DataItems dataitems1, DataItems dataitems2,
        Map<String, ArrayList<LinePos>> mapAB, XYPlot xyplot) {
    // ????//from   ww  w  . j av  a 2s .c o m
    int modelcount = mapAB.keySet().size();
    long off1 = dataitems1.getElementAt(0).getTime().getTime();
    long off2 = dataitems2.getElementAt(0).getTime().getTime();
    long unit = 0;
    if (dataitems1.getLength() > 0) {
        unit = dataitems1.getElementAt(1).getTime().getTime() - off1;
    } else {
        unit = 3600000;
    }

    XYSeriesCollection xyseriescollection = new XYSeriesCollection();
    // ??

    int colorindex = 0;
    int renderercount = 2;
    for (Object se : mapAB.keySet()) {
        ArrayList<LinePos> s = mapAB.get(se);
        int oneModelCount = s.size();

        ArrayList<DataItems> dslist = new ArrayList<DataItems>();
        Iterator it = s.iterator();

        System.out.println("**************");
        System.out.println("?=" + se + ":=" + oneModelCount);

        XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer();
        // ???
        xylineandshaperenderer.setBaseShapesVisible(false);
        // ??
        xylineandshaperenderer.setSeriesLinesVisible(0, true);
        // xylineandshaperenderer.setSeriesShape(0, double1); //?
        // 
        xylineandshaperenderer.setSeriesPaint(0, getcolor(colorindex % 9));
        xylineandshaperenderer.setSeriesFillPaint(0, getcolor(colorindex % 9));
        xylineandshaperenderer.setSeriesOutlinePaint(0, getcolor(colorindex % 9));
        colorindex++;
        xylineandshaperenderer.setUseFillPaint(true);
        xylineandshaperenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());

        xylineandshaperenderer.setBaseShapesVisible(false);
        xylineandshaperenderer.setSeriesStroke(0,
                new BasicStroke(1.0F, 1, 1, 1.0F, new float[] { 15F, 12F }, 0.0F)); // 
        xylineandshaperenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
        xylineandshaperenderer.setBaseItemLabelsVisible(false);

        while (it.hasNext()) {
            LinePos temp = (LinePos) it.next();

            DataItem d1 = new DataItem();
            d1 = dataitems1.getElementAt(temp.A_start);
            DataItem d2 = new DataItem();
            d2 = dataitems2.getElementAt(temp.B_start);
            DataItems ds1 = new DataItems();
            ds1.add1Data(d1);
            ds1.add1Data(d2);
            // dslist.add(ds1);
            XYDataset xydataset1 = createmodeDataset(ds1, off1, se.toString() + ":" + 1, unit);

            DataItem d3 = new DataItem();
            d3 = dataitems1.getElementAt(temp.A_end);
            DataItem d4 = new DataItem();
            d4 = dataitems2.getElementAt(temp.B_end);
            DataItems ds2 = new DataItems();
            ds2.add1Data(d3);
            ds2.add1Data(d4);
            // dslist.add(ds2);
            XYDataset xydataset2 = createmodeDataset(ds2, off1, se.toString() + ":" + 2, unit);

            int datasetCount = xyplot.getDatasetCount();
            XYTextAnnotation localXYTextAnnotation = null;
            int modelx = (temp.A_start + temp.B_end) / 2;
            double modely = (Double.parseDouble(dataitems2.getElementAt(temp.A_start).getData())
                    + Double.parseDouble(dataitems1.getElementAt(temp.B_end).getData())) / 2;
            /*System.out.println("se=" + se + "::" + "x=" + modelx + "y="
                  + modely);*/
            localXYTextAnnotation = new XYTextAnnotation("" + se + ":" + oneModelCount, modelx, modely);
            xyplot.addAnnotation(localXYTextAnnotation);
            /*System.out.println("datasetCount=" + datasetCount);*/

            xyplot.setDataset(datasetCount, xydataset1);
            xyplot.setRenderer(datasetCount, xylineandshaperenderer);
            xyplot.setDataset(datasetCount + 1, xydataset2);
            xyplot.setRenderer(datasetCount + 1, xylineandshaperenderer);

        }

    }
    return xyseriescollection;
}

From source file:Demo.ScatterGraph.java

private JFreeChart CreateChart(int x, int y) {
    dataSet = new DefaultXYDataset();
    AddDataSet(x, y);/*from w w w .j av  a2  s .c  o  m*/

    JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter", paraType_list.get(x),
            paraType_list.get(y), dataSet, PlotOrientation.VERTICAL, true, false, false);

    XYPlot plot = (XYPlot) jfreechart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    plot.setDomainGridlinesVisible(true);
    plot.setNoDataMessage("no data");

    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) plot.getRenderer();
    xylineandshaperenderer.setSeriesOutlinePaint(0, Color.WHITE);
    xylineandshaperenderer.setUseOutlinePaint(true);
    xylineandshaperenderer.setSeriesPaint(0, Color.BLUE);

    return jfreechart;
}

From source file:org.openscience.cdk.applications.taverna.basicutilities.ChartTool.java

/**
 * Creates a scatter plot./*from  w  ww .j av a  2 s .  c om*/
 * 
 * @param dataset
 * @param header
 * @param xAxis
 * @param yAxis
 * @return
 */
public JFreeChart createScatterPlot(XYDataset dataset, String header, String xAxis, String yAxis) {
    JFreeChart chart = ChartFactory.createScatterPlot(header, xAxis, yAxis, dataset, PlotOrientation.VERTICAL,
            true, false, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setNoDataMessage("NO DATA");
    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);
    XYLineAnnotation annotation = new XYLineAnnotation(-1000000, -1000000, 1000000, 1000000);
    plot.addAnnotation(annotation);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesOutlinePaint(0, Color.black);
    renderer.setUseOutlinePaint(true);
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    domainAxis.setTickMarkInsideLength(2.0f);
    domainAxis.setTickMarkOutsideLength(0.0f);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setTickMarkInsideLength(2.0f);
    rangeAxis.setTickMarkOutsideLength(0.0f);

    return chart;
}

From source file:org.openscience.cdk.applications.taverna.basicutilities.ChartTool.java

/**
 * Creates a residue plot.//from w w w  .ja va 2 s. co m
 * 
 * @param yValues
 * @param header
 * @param xAxis
 * @param yAxis
 * @param seriesNames
 * @return
 */
public JFreeChart createResiduePlot(List<Double[]> yValues, String header, String xAxis, String yAxis,
        List<String> seriesNames) {
    LinkedList<XYLineAnnotation> lines = new LinkedList<XYLineAnnotation>();
    DefaultXYDataset xyDataSet = new DefaultXYDataset();
    for (int j = 0; j < yValues.size(); j++) {
        XYSeries series = new XYSeries(seriesNames.get(j));
        for (int i = 0; i < yValues.get(j).length; i++) {
            series.add(i + 1, yValues.get(j)[i]);
            float dash[] = { 10.0f };
            BasicStroke stroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f,
                    dash, 0.0f);
            XYLineAnnotation annotation = new XYLineAnnotation(i + 1, 0, i + 1, yValues.get(j)[i], stroke,
                    Color.BLUE);
            lines.add(annotation);
        }
        xyDataSet.addSeries(seriesNames.get(j), series.toArray());
    }
    JFreeChart chart = ChartFactory.createScatterPlot(header, xAxis, yAxis, xyDataSet, PlotOrientation.VERTICAL,
            true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setNoDataMessage("NO DATA");
    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);
    for (int i = 0; i < lines.size(); i++) {
        plot.addAnnotation(lines.get(i));
    }
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesOutlinePaint(0, Color.black);
    renderer.setUseOutlinePaint(true);
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    domainAxis.setTickMarkInsideLength(2.0f);
    domainAxis.setTickMarkOutsideLength(0.0f);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setTickMarkInsideLength(2.0f);
    rangeAxis.setTickMarkOutsideLength(0.0f);

    return chart;
}

From source file:desmoj.extensions.grafic.util.Plotter.java

/**
  * Build a JPanel with plotType of a DesmoJ time-series dataset.
 * When allowMultipleValues is set, multiple range values of a time value are allowed.
 * In the opposite Case only the last range value of a time value is accepted.
 * In the case ts.getShowTimeSpansInReport() the data values are interpreted as
 * a timespan in a appropriate time unit. 
  * @param ts               DesmoJ time-series dataset
  * @param plotType          possible Values: 
  *                         Plotter.TimeSeries_ScatterPlot, 
  *                         Plotter.TimeSeries_StepChart
  *                         Plotter.TimeSeries_LinePlot
 * @param allowMultipleValues/*from w w w .jav a2 s. c om*/
 * @return
 */
private JPanel getTimeSeriesPanel(TimeSeries ts, int plotType, boolean allowMultipleValues) {
    JFreeChart chart;
    TimeSeriesDataSetAdapter dataset = new TimeSeriesDataSetAdapter(ts, allowMultipleValues);
    switch (plotType) {
    case Plotter.TimeSeries_LineChart:
        chart = ChartFactory.createXYLineChart(ts.getName(), "Time", "Observation", dataset,
                PlotOrientation.VERTICAL, false, false, false);
        break;
    case Plotter.TimeSeries_ScatterPlot:
        chart = ChartFactory.createScatterPlot(ts.getName(), "Time", "Observation", dataset,
                PlotOrientation.VERTICAL, false, false, false);
        break;
    case Plotter.TimeSeries_StepChart:
        chart = ChartFactory.createXYStepChart(ts.getName(), "Time", "Observation", dataset,
                PlotOrientation.VERTICAL, false, false, false);
        break;
    default:
        chart = ChartFactory.createScatterPlot(ts.getName(), "Time", "Observation", dataset,
                PlotOrientation.VERTICAL, false, false, false);
        break;
    }
    if (ts.getDescription() != null)
        chart.setTitle(ts.getDescription());

    XYPlot xyplot = (XYPlot) chart.getPlot();
    xyplot.setNoDataMessage("NO DATA");
    if (ts.getShowTimeSpansInReport() && !dataset.isValid())
        xyplot.setNoDataMessage("NO VALID TIMESPANS");
    xyplot.setDomainZeroBaselineVisible(false);
    xyplot.setRangeZeroBaselineVisible(false);

    DateAxis dateAxis = new DateAxis();
    xyplot.setDomainAxis(dateAxis);
    this.configureDomainAxis(dateAxis);

    String numberLabel;
    if (!dataset.isValid())
        numberLabel = "Unit: invalid";
    else if (ts.getShowTimeSpansInReport())
        numberLabel = "Unit: timespan [" + dataset.getRangeTimeUnit().name() + "]";
    else if (ts.getUnit() != null)
        numberLabel = "Unit: [" + ts.getUnit() + "]";
    else
        numberLabel = "Unit: unknown";
    NumberAxis numberAxis = new NumberAxis();
    xyplot.setRangeAxis(numberAxis);
    this.configureRangeAxis(numberAxis, numberLabel);

    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setSeriesOutlinePaint(0, Color.black);
    xylineandshaperenderer.setUseOutlinePaint(true);

    ChartPanel panel = new ChartPanel(chart);
    panel.setVerticalAxisTrace(false);
    panel.setHorizontalAxisTrace(false);
    panel.setPopupMenu(null);
    panel.setDomainZoomable(false);
    panel.setRangeZoomable(false);

    return panel;
}