Example usage for org.jfree.chart.plot XYPlot setRenderer

List of usage examples for org.jfree.chart.plot XYPlot setRenderer

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setRenderer.

Prototype

public void setRenderer(XYItemRenderer renderer) 

Source Link

Document

Sets the renderer for the primary dataset and sends a change event to all registered listeners.

Usage

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

/**
 * Creates a line chart.//from  w  w w .ja  v a 2  s.  com
 * 
 * @param title
 * @param categoryAxisLabel
 *            (X-Axis label)
 * @param valueAxisLabel
 *            (Y-Axis label)
 * @param dataset
 * @param includeZero
 *            True when zero shall be included to the axis range.
 * @return JfreeChart instance.
 */
public JFreeChart createXYLineSplineChart(String title, String categoryAxisLabel, String valueAxisLabel,
        XYDataset dataset, boolean includeZero, boolean drawShapes) {
    JFreeChart chart = ChartFactory.createXYLineChart(title, categoryAxisLabel, valueAxisLabel, dataset,
            this.orientation, this.drawLegend, false, false);
    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);
    chart.setAntiAlias(true);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundAlpha(0.4f);
    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLowerMargin(0.025);
    domainAxis.setUpperMargin(0.025);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(includeZero);
    plot.setRenderer(new XYSplineRenderer(100));
    XYSplineRenderer renderer = (XYSplineRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    renderer.setSeriesPaint(2, Color.green);
    renderer.setSeriesPaint(3, Color.darkGray);
    renderer.setSeriesPaint(4, Color.yellow);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseShapesVisible(drawShapes);
    renderer.setBaseShapesFilled(true);
    return chart;
}

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

/**
 * Creates a chart.// w w w  . j a v a2 s . c  o m
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(IntervalXYDataset dataset) {
    JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            false, rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL,
            // !legendPanelOn,                       // include legend
            false, //no legend
            true, false);

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    XYPlot plot = chart.getXYPlot();
    plot.setRenderer(new ClusteredXYBarRenderer());

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    XYItemRenderer renderer = plot.getRenderer();
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());
    // OPTIONAL CUSTOMISATION COMPLETED.
    return chart;
}

From source file:test.integ.be.fedict.performance.util.PerformanceResultDialog.java

private JFreeChart getPerformanceChart(int intervalSize, List<PerformanceData> performance,
        int expectedRevoked) {
    TimeSeries series = new TimeSeries("Success");
    TimeSeries revokedSeries = new TimeSeries("Revoked");
    TimeSeries failureSeries = new TimeSeries("Failures");

    performance.remove(performance.size() - 1);
    if (performance.isEmpty()) {
        JOptionPane.showMessageDialog(null, "test did not run long enough");
        return null;
    }//from   w  w  w.j a v a2s .  co  m

    JFreeChart chart;

    int totalCount = 0;
    int totalRevoked = 0;
    int totalFailures = 0;

    for (PerformanceData performanceEntry : performance) {
        series.add(new Second(performanceEntry.getDate()), performanceEntry.getCount());
        totalCount += performanceEntry.getCount();

        revokedSeries.add(new Second(performanceEntry.getDate()), performanceEntry.getRevoked());
        totalRevoked += performanceEntry.getRevoked();

        failureSeries.add(new Second(performanceEntry.getDate()), performanceEntry.getFailures());
        totalFailures += performanceEntry.getFailures();
    }

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);
    dataset.addSeries(revokedSeries);
    dataset.addSeries(failureSeries);
    chart = ChartFactory.createTimeSeriesChart("eID Trust Service Performance History",
            "Time (interval size " + intervalSize + " msec)", "Number of XKMS requests", dataset, true, false,
            false);

    chart.addSubtitle(new TextTitle(performance.get(0).getDate().toString() + " - "
            + performance.get(performance.size() - 1).getDate().toString()));

    TextTitle info = new TextTitle("Total number of successful requests: " + totalCount);
    info.setTextAlignment(HorizontalAlignment.LEFT);
    info.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(info);

    TextTitle info2 = new TextTitle(
            "Total number of revoked: " + totalRevoked + " expected=" + expectedRevoked);
    info2.setPosition(RectangleEdge.BOTTOM);
    info2.setTextAlignment(HorizontalAlignment.LEFT);
    chart.addSubtitle(info2);

    TextTitle info3 = new TextTitle("Total number of failures: " + totalFailures);
    info3.setPosition(RectangleEdge.BOTTOM);
    info3.setTextAlignment(HorizontalAlignment.LEFT);
    chart.addSubtitle(info3);

    chart.setBackgroundPaint(Color.WHITE);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));
    ValueAxis valueAxis = plot.getRangeAxis();
    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRangeGridlinePaint(Color.black);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRenderer(renderer);

    return chart;
}

From source file:regresiones.RegresionMultiple.java

private void pintar(Double[] Yestimada, JTabbedPane resultados, Double[][] auxiliar) {
    // mostramos resultados para la pestaa resultados***********************************************************************
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBackground(Color.white);
    JLabel titulo = new JLabel("Resultados");//creamos el titulo
    panel.add(titulo, BorderLayout.PAGE_START);//lo agregamos al inicio
    jtable = new JTable();//creamos la tabla a mostrar
    jtable.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
    jtable.setFont(new java.awt.Font("Arial", 1, 14));
    jtable.setColumnSelectionAllowed(true);
    jtable.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
    jtable.setInheritsPopupMenu(true);//w w w  .  ja  va  2s  .com
    jtable.setMinimumSize(new java.awt.Dimension(80, 80));
    String[] titulos = { "X1", "X2", "Y", "Y estimada", "X1^2", "X2^2", "X1*Y", "X2*Y", "Y-Y estimada" };//los titulos de la tabla
    arregloFinal = new String[N][9];
    DecimalFormat formato = new DecimalFormat("0.00");
    for (int i = 0; i < N; i++) {//armamos el arreglo
        arregloFinal[i][0] = datos[i][0] + "";
        arregloFinal[i][1] = datos[i][1] + "";
        arregloFinal[i][2] = datos[i][2] + "";
        arregloFinal[i][3] = formato.format(Yestimada[i]);
        arregloFinal[i][4] = formato.format(auxiliar[i][0]);
        arregloFinal[i][5] = formato.format(auxiliar[i][1]);
        arregloFinal[i][6] = formato.format(auxiliar[i][2]);
        arregloFinal[i][7] = formato.format(auxiliar[i][3]);
        arregloFinal[i][8] = formato.format(auxiliar[i][4]);
    }
    DefaultTableModel TableModel = new DefaultTableModel(arregloFinal, titulos);
    jtable.setModel(TableModel);
    JScrollPane jScrollPane1 = new JScrollPane();
    jScrollPane1.setViewportView(jtable);
    jtable.getColumnModel().getSelectionModel()
            .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    panel.add(jScrollPane1, BorderLayout.CENTER);
    JPanel panel2 = new JPanel(new GridLayout(0, 6));//creo un panel con rejilla de 4 columnas
    JLabel etiquetaN = new JLabel("N");
    JTextField cajaN = new JTextField();
    cajaN.setText(N + "");
    cajaN.setEditable(false);

    JLabel etiquetaK = new JLabel("K");
    JTextField cajaK = new JTextField();
    cajaK.setText("2");
    cajaK.setEditable(false);

    JLabel etiquetab0 = new JLabel("b0");
    JTextField cajab0 = new JTextField();
    cajab0.setText(formato.format(b0) + "");
    cajab0.setEditable(false);

    JLabel etiquetab1 = new JLabel("b1");
    JTextField cajab1 = new JTextField();
    cajab1.setText(formato.format(b1) + "");
    cajab1.setEditable(false);

    JLabel etiquetab2 = new JLabel("b2");
    JTextField cajab2 = new JTextField();
    cajab2.setText(formato.format(b2) + "");
    cajab2.setEditable(false);

    JLabel etiquetaSe = new JLabel("Se");
    JTextField cajaSe = new JTextField();
    cajaSe.setText(Se + "");
    cajaSe.setEditable(false);
    cajaSe.setAutoscrolls(true);

    JButton botonI = new JButton("Exportar a PDF");
    botonI.addActionListener(this);

    panel2.add(etiquetaN);
    panel2.add(cajaN);
    panel2.add(etiquetaK);
    panel2.add(cajaK);
    panel2.add(etiquetab2);
    panel2.add(etiquetab0);
    panel2.add(cajab0);
    panel2.add(etiquetab1);
    panel2.add(cajab1);
    panel2.add(etiquetab2);
    panel2.add(cajab2);
    panel2.add(etiquetaSe);
    panel2.add(cajaSe);
    panel2.add(botonI);
    panel.add(panel2, BorderLayout.SOUTH);//agrego el panel2 con rejilla en el panel principal al sur
    resultados.addTab("resultado", panel);
    //**************************************************************************************
    //intervalos de confianza
    JPanel intervalos = new JPanel(new BorderLayout());
    JPanel variables = new JPanel(new GridLayout(0, 2));
    JLabel variableX1 = new JLabel("X1");
    cajaVariableX1 = new JTextField();
    JLabel variableX2 = new JLabel("X2");
    cajaVariableX2 = new JTextField();
    boton = new JButton("calcular");
    boton.addActionListener(this);
    JLabel variableEfectividad = new JLabel("Efectividad");
    String[] efectividades = { "80", "85", "90", "95", "99" };
    combo = new JComboBox(efectividades);
    variables.add(variableX1);
    variables.add(cajaVariableX1);
    variables.add(variableX2);
    variables.add(cajaVariableX2);
    variables.add(variableEfectividad);
    variables.add(combo);
    variables.add(boton);
    intervalos.add(variables, BorderLayout.NORTH);
    jtable2 = new JTable();//creamos la tabla a mostrar
    jtable2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
    jtable2.setFont(new java.awt.Font("Arial", 1, 14));
    jtable2.setColumnSelectionAllowed(true);
    jtable2.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
    jtable2.setInheritsPopupMenu(true);
    jtable2.setMinimumSize(new java.awt.Dimension(80, 80));
    String[] titulos2 = { "Y estimada", "Li", "Ls" };//los titulos de la tabla
    String[][] pruebaIntervalos = { { "", "", "" } };
    DefaultTableModel TableModel2 = new DefaultTableModel(pruebaIntervalos, titulos2);
    jtable2.setModel(TableModel2);
    JScrollPane jScrollPane2 = new JScrollPane();
    jScrollPane2.setViewportView(jtable2);
    jtable2.getColumnModel().getSelectionModel()
            .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    intervalos.add(jScrollPane2, BorderLayout.CENTER);
    resultados.addTab("intervalos", intervalos);
    //***************************************************************************
    JPanel graficas = new JPanel(new GridLayout(0, 1));
    XYDataset dataset = createSampleDataset(Yestimada, 1);
    JFreeChart chart = ChartFactory.createXYLineChart("Grafica 1 - X1", "X", "Y", dataset,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(1, true);
    plot.setRenderer(renderer);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
    graficas.add(chartPanel);//agregamos la primer grafica
    //********** creamos la segunda grafica
    XYDataset dataset2 = createSampleDataset(Yestimada, 2);
    JFreeChart chart2 = ChartFactory.createXYLineChart("Grafica 2 -X2", "X", "Y", dataset2,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot2 = (XYPlot) chart2.getPlot();
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, true);
    renderer2.setSeriesShapesVisible(0, true);
    renderer2.setSeriesLinesVisible(1, true);
    renderer2.setSeriesShapesVisible(1, true);
    plot2.setRenderer(renderer2);
    final ChartPanel chartPanel2 = new ChartPanel(chart2);
    chartPanel2.setPreferredSize(new java.awt.Dimension(500, 300));
    graficas.add(chartPanel2);
    resultados.addTab("graficas", graficas);
}

From source file:regression.gui.RegressionChart.java

/**
 * Creates a chart.// www  .  j a v a2 s  .c o  m
 *
 * @param dataset the data for the chart.
 *
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createScatterPlot("Wykres funkcji regresji", // chart title
            "X", // x axis label
            "Y", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesShape(0, ShapeUtilities.createRegularCross(3, 3));
    renderer.setSeriesShape(2, ShapeUtilities.createRegularCross(3, 3));
    renderer.setSeriesLinesVisible(0, false);

    renderer.setSeriesShapesVisible(1, false);
    renderer.setSeriesLinesVisible(2, false);
    plot.setRenderer(renderer);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return chart;

}

From source file:Servlet3.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {//from  w  ww.j av  a  2 s . c o m
        System.out.println("inside servlet");
        String a = request.getParameter("countryf");
        String c = request.getParameter("submit");
        String b = request.getParameter("paramf");

        String CurentUID = request.getParameter("UIDvalue2f");
        String URLRequest = request.getRequestURL().append('?').append(request.getQueryString()).toString();
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, 1);
        SimpleDateFormat format1 = new SimpleDateFormat("EEE MMM dd hh:mm:ss yyyy");
        String date1 = cal.getTime().toString();

        System.out.println("inside servlet");

        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con = DriverManager.getConnection("jdbc:odbc:server");

        // To Insert data to UserActivity table for Recent Activities Tab
        Statement sthistoryinsert3 = con.createStatement();
        String insertstring = "Insert into UserActivity values('" + CurentUID + "','" + date1
                + "','Future Data Forecast','" + a + "','" + b + "','" + URLRequest + "')";
        sthistoryinsert3.executeUpdate(insertstring);
        sthistoryinsert3.close();
        System.out.println("\n Step 1");
        Statement st = con.createStatement();
        XYSeriesCollection dataset = new XYSeriesCollection();
        XYSeries series = new XYSeries(b);

        String query = "SELECT [2000],[2012] FROM country where CountryName='" + a + "' AND SeriesName='" + b
                + "'";
        System.out.println(query);
        ResultSet rs = st.executeQuery(query);
        if (rs == null)
            System.out.println("\n no rows ");
        else
            System.out.println("Rows present ");
        rs.next();

        Double start = Double.parseDouble(rs.getString(1));
        Double end = Double.parseDouble(rs.getString(2));
        Double period = 13.0;
        Double growth = Math.pow((end / start), (1 / period)) - 1;
        System.out.println("growth percentage =" + growth);
        rs.close();
        String query2 = "select [2011],[2012] from country where CountryName='" + a + "' AND SeriesName='" + b
                + "'";
        rs = st.executeQuery(query2);
        rs.next();
        series.add(2011, Double.parseDouble(rs.getString(1)));
        Double second = Double.parseDouble(rs.getString(2));
        series.add(2012, second);

        Double growthvalue = second + (second * growth);

        series.add(2013, growthvalue);
        for (int i = 2014; i <= 2016; i++) {
            System.out.println("actual growth value = " + growthvalue);
            series.add((i++), (growthvalue + growthvalue * growth));
            growthvalue = growthvalue + growthvalue * growth;
        }
        rs.close();
        dataset.addSeries(series);
        DecimalFormat format_2Places = new DecimalFormat("0.00");
        growth = growth * 100;
        growth = Double.valueOf(format_2Places.format(growth));
        JFreeChart chart = ChartFactory.createXYLineChart(
                "Energy forecasting for " + a + " based on " + b + " with growth value estimated at " + growth
                        + "% ",
                "Year", "Energy consumed in millions", dataset, PlotOrientation.VERTICAL, true, true, false);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        chart.setBackgroundPaint(Color.white);
        final XYPlot plot = chart.getXYPlot();
        plot.setBackgroundPaint(Color.white);
        plot.setDomainGridlinesVisible(true);
        plot.setRangeGridlinesVisible(true);
        plot.setDomainGridlinePaint(Color.black);
        plot.setRangeGridlinePaint(Color.black);

        final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        renderer.setSeriesLinesVisible(2, false);
        renderer.setSeriesShapesVisible(2, false);
        plot.setRenderer(renderer);
        // To insert colored Pie Chart into the PDF file using
        // iText now   
        if (c.equals("View Graph in Browser")) {
            ChartUtilities.writeChartAsPNG(bos, chart, 700, 500);
            response.setContentType("image/png");
            OutputStream out = new BufferedOutputStream(response.getOutputStream());
            out.write(bos.toByteArray());
            out.flush();
            out.close();
        }

        else {
            int width = 640; /* Width of our chart */
            int height = 480; /* Height of our chart */
            Document PieChart = new Document(new com.itextpdf.text.Rectangle(width, height));
            java.util.Date date = new java.util.Date();
            String chartname = "My_Colored_Chart" + date.getTime() + ".pdf";
            PdfWriter writer = PdfWriter.getInstance(PieChart, new FileOutputStream(chartname));
            PieChart.open();

            PieChart.addTitle("Pie-Chart");
            PieChart.addAuthor("MUurugappan");

            PdfContentByte Add_Chart_Content = writer.getDirectContent();
            PdfTemplate template_Chart_Holder = Add_Chart_Content.createTemplate(width, height);
            Graphics2D Graphics_Chart = template_Chart_Holder.createGraphics(width, height,
                    new DefaultFontMapper());
            Rectangle2D Chart_Region = new Rectangle2D.Double(0, 0, 540, 380);
            chart.draw(Graphics_Chart, Chart_Region);
            Graphics_Chart.dispose();
            Add_Chart_Content.addTemplate(template_Chart_Holder, 0, 0);
            PieChart.close();

            PdfReader reader = new PdfReader(chartname);
            PdfStamper stamper = null;
            try {
                stamper = new PdfStamper(reader, bos);
            } catch (DocumentException e) {
                e.printStackTrace();
            }
            try {
                stamper.close();
            } catch (DocumentException e) {

                e.printStackTrace();
            }

            // set response headers to view PDF
            response.setHeader("Expires", "0");
            response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
            response.setHeader("Pragma", "public");
            response.setContentType("application/pdf");
            response.setContentLength(bos.size());

            OutputStream os = response.getOutputStream();
            bos.writeTo(os);
            os.flush();
            os.close();
        }
    }

    catch (Exception i) {
        i.printStackTrace();
    }

}

From source file:org.hsh.bfr.db.gui.dbtable.editoren.MyChartDialog.java

/**
 * Creates a chart.//from  w  ww.  j  a va 2 s.  co m
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset, String xAxis, String yAxis) {

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

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setDisplaySeriesShapes(true);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    //plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, false);
    plot.setRenderer(renderer);

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:GUI.PlotCreator.java

private ChartPanel createSeaCurrentSpeedByHPanel() {
    JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "H", "Sea Current Speed",
            createSeaCurrentSpeedDataByH(), PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) jfreechart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);
    //XYItemRenderer renderer = xyPlot.getRenderer();
    NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis();
    domain.setVerticalTickLabels(true);//ww w.  ja v  a 2  s .com
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    xyPlot.setRenderer(renderer);
    return new ChartPanel(jfreechart);
}

From source file:GUI.PlotCreator.java

private ChartPanel createSeaCurrentDirectionByHPanel() {
    JFreeChart jfreechart = ChartFactory.createScatterPlot("Sea Current Direction Plot", "H",
            "Sea Current Direction", createSeaCurrentDirectionDataByH(), PlotOrientation.VERTICAL, true, true,
            false);//from   ww w  .  j  av a 2s  .c  o m
    XYPlot xyPlot = (XYPlot) jfreechart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);
    //XYItemRenderer renderer = xyPlot.getRenderer();
    NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis();
    domain.setVerticalTickLabels(true);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    xyPlot.setRenderer(renderer);
    return new ChartPanel(jfreechart);
}

From source file:GUI.PlotCreator.java

private ChartPanel createEquirectangularErrorPanel(ArrayList<double[]> dataToDisplay) {
    title = "Equirectangular vs Haversine - Error Plot";
    JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "Distance Between Points (meters)", "Error",
            createEquirectangularErrorData(dataToDisplay), PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) jfreechart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);
    //XYItemRenderer renderer = xyPlot.getRenderer();
    NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis();
    domain.setVerticalTickLabels(true);// w  w w .jav a2 s  .c  o m
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    xyPlot.setRenderer(renderer);
    return new ChartPanel(jfreechart);
}