Example usage for org.jfree.chart ChartFactory createScatterPlot

List of usage examples for org.jfree.chart ChartFactory createScatterPlot

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createScatterPlot.

Prototype

public static JFreeChart createScatterPlot(String title, String xAxisLabel, String yAxisLabel,
        XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) 

Source Link

Document

Creates a scatter plot with default settings.

Usage

From source file:de.laures.cewolf.taglib.CewolfChartFactory.java

public static JFreeChart getChartInstance(String chartType, String title, String xAxisLabel, String yAxisLabel,
        Dataset data) throws ChartValidationException {
    // first check the dynamically registered chart types
    CewolfChartFactory factory = (CewolfChartFactory) factories.get(chartType);
    if (factory != null) {
        // custom factory found, use it
        return factory.getChartInstance(title, xAxisLabel, yAxisLabel, data);
    }//from  w  w  w .j a v a2 s  .c o  m

    switch (getChartTypeConstant(chartType)) {
    case XY:
        check(data, XYDataset.class, chartType);
        return ChartFactory.createXYLineChart(title, xAxisLabel, yAxisLabel, (XYDataset) data,
                PlotOrientation.VERTICAL, true, true, true);
    case PIE:
        check(data, PieDataset.class, chartType);
        return ChartFactory.createPieChart(title, (PieDataset) data, true, true, true);
    case AREA_XY:
        check(data, XYDataset.class, chartType);
        return ChartFactory.createXYAreaChart(title, xAxisLabel, yAxisLabel, (XYDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case SCATTER:
        check(data, XYDataset.class, chartType);
        return ChartFactory.createScatterPlot(title, xAxisLabel, yAxisLabel, (XYDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case AREA:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createAreaChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case HORIZONTAL_BAR:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createBarChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.HORIZONTAL, true, false, false);
    case HORIZONTAL_BAR_3D:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createBarChart3D(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.HORIZONTAL, true, false, false);
    case LINE:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createLineChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case STACKED_HORIZONTAL_BAR:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createStackedBarChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.HORIZONTAL, true, false, false);
    case STACKED_VERTICAL_BAR:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createStackedBarChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case STACKED_VERTICAL_BAR_3D:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createStackedBarChart3D(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case VERTICAL_BAR:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createBarChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case VERTICAL_BAR_3D:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createBarChart3D(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case TIME_SERIES:
        check(data, XYDataset.class, chartType);
        return ChartFactory.createTimeSeriesChart(title, xAxisLabel, yAxisLabel, (XYDataset) data, true, false,
                false);
    case CANDLE_STICK:
        check(data, OHLCDataset.class, chartType);
        return ChartFactory.createCandlestickChart(title, xAxisLabel, yAxisLabel, (OHLCDataset) data, true);
    case HIGH_LOW:
        check(data, OHLCDataset.class, chartType);
        return ChartFactory.createHighLowChart(title, xAxisLabel, yAxisLabel, (OHLCDataset) data, true);
    case GANTT:
        check(data, IntervalCategoryDataset.class, chartType);
        return ChartFactory.createGanttChart(title, xAxisLabel, yAxisLabel, (IntervalCategoryDataset) data,
                true, false, false);
    case WIND:
        check(data, WindDataset.class, chartType);
        return ChartFactory.createWindPlot(title, xAxisLabel, yAxisLabel, (WindDataset) data, true, false,
                false);
    //case SIGNAL :
    //  check(data, SignalsDataset.class, chartType);
    //  return ChartFactory.createSignalChart(title, xAxisLabel, yAxisLabel, (SignalsDataset) data, true);
    case VERRTICAL_XY_BAR:
        check(data, IntervalXYDataset.class, chartType);
        return ChartFactory.createXYBarChart(title, xAxisLabel, true, yAxisLabel, (IntervalXYDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case PIE_3D:
        check(data, PieDataset.class, chartType);
        return ChartFactory.createPieChart3D(title, (PieDataset) data, true, false, false);
    case METER:
        check(data, ValueDataset.class, chartType);
        MeterPlot plot = new MeterPlot((ValueDataset) data);
        JFreeChart chart = new JFreeChart(title, plot);
        return chart;
    case STACKED_AREA:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createStackedAreaChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case BUBBLE:
        check(data, XYZDataset.class, chartType);
        return ChartFactory.createBubbleChart(title, xAxisLabel, yAxisLabel, (XYZDataset) data,
                PlotOrientation.VERTICAL, true, false, false);

    case AUSTER_CICLOS:
        check(data, IntervalCategoryDataset.class, chartType);
        return ChartFactory.createAusterCiclosChart((IntervalCategoryDataset) data);

    default:
        throw new UnsupportedChartTypeException(chartType + " is not supported.");
    }
}

From source file:fr.irit.smac.libs.tooling.plot.server.AgentPlotChart.java

public JFreeChart getJFreeChart() {
    if (chart == null) {
        switch (chartType) {
        case LINE:
            chart = ChartFactory.createXYLineChart("", // chart
                    // title
                    "X", // x axis label
                    "Y", // y axis label
                    getDataset(), // data
                    PlotOrientation.VERTICAL, true, // include legend
                    true, // tooltips
                    false // urls
            );/* ww w . ja v  a  2 s  .  co  m*/
            break;
        case PLOT:
            chart = ChartFactory.createScatterPlot("", // chart
                    // title
                    "X", // x axis label
                    "Y", // y axis label
                    getDataset(), // data
                    PlotOrientation.VERTICAL, true, // include legend
                    true, // tooltips
                    false // urls
            );
            break;

        }
        XYPlot plot = (XYPlot) chart.getPlot();
        plot.setBackgroundPaint(Color.white);
        plot.setRangeGridlinePaint(Color.black);
    }
    return chart;
}

From source file:org.micromanager.asidispim.Utils.PlotUtils.java

/**
 * Create a frame with a plot of the data given in XYSeries overwrite any
 * previously created frame with the same title
 *
        /*from  ww w  .  j a  v  a  2  s  . c  om*/
 * @param title shown in the top of the plot
 * @param data array with data series to be plotted
 * @param xTitle Title of the X axis
 * @param yTitle Title of the Y axis
 * @param showShapes whether or not to draw shapes at the data points
 * @param annotation to be shown in plot
 * @return Frame that displays the data
 */
public Frame plotDataN(String title, XYSeries[] data, String xTitle, String yTitle, boolean[] showShapes,
        String annotation) {

    // if we already have a plot open with this title, close it, but remember
    // its position
    Frame[] gfs = ChartFrame.getFrames();
    for (Frame f : gfs) {
        if (f.getTitle().equals(title)) {
            f.dispose();
        }
    }

    // JFreeChart code
    XYSeriesCollection dataset = new XYSeriesCollection();
    // calculate min and max to scale the graph
    double minX, minY, maxX, maxY;
    minX = data[0].getMinX();
    minY = data[0].getMinY();
    maxX = data[0].getMaxX();
    maxY = data[0].getMaxY();
    for (XYSeries d : data) {
        dataset.addSeries(d);
        if (d.getMinX() < minX) {
            minX = d.getMinX();
        }
        if (d.getMaxX() > maxX) {
            maxX = d.getMaxX();
        }
        if (d.getMinY() < minY) {
            minY = d.getMinY();
        }
        if (d.getMaxY() > maxY) {
            maxY = d.getMaxY();
        }
    }

    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);

    for (int i = 0; i < data.length; i++) {
        renderer.setSeriesFillPaint(i, Color.white);
        renderer.setSeriesLinesVisible(i, true);
    }

    renderer.setSeriesPaint(0, Color.blue);
    Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
    renderer.setSeriesShape(0, circle, false);

    if (data.length > 1) {
        renderer.setSeriesPaint(1, Color.red);
        Shape square = new Rectangle2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
        renderer.setSeriesShape(1, square, false);
    }
    if (data.length > 2) {
        renderer.setSeriesPaint(2, Color.darkGray);
        Shape rect = new Rectangle2D.Float(-2.0f, -1.0f, 4.0f, 2.0f);
        renderer.setSeriesShape(2, rect, false);
    }
    if (data.length > 3) {
        renderer.setSeriesPaint(3, Color.magenta);
        Shape rect = new Rectangle2D.Float(-1.0f, -2.0f, 2.0f, 4.0f);
        renderer.setSeriesShape(3, rect, false);
    }

    for (int i = 0; i < data.length; i++) {
        if (showShapes.length > i && !showShapes[i]) {
            renderer.setSeriesShapesVisible(i, false);
        }
    }

    XYAnnotation an = new XYTextAnnotation(annotation, maxX - 0.01, maxY);
    plot.addAnnotation(an);

    renderer.setUseFillPaint(true);

    final MyChartFrame graphFrame = new MyChartFrame(title, chart);
    graphFrame.getChartPanel().setMouseWheelEnabled(true);
    graphFrame.pack();
    graphFrame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent arg0) {
            graphFrame.dispose();
        }
    });

    graphFrame.setVisible(true);

    return graphFrame;
}

From source file:org.deeplearning4j.examples.dataexamples.CSVPlotter.java

/**
 * Generate an xy plot of the datasets provided.
 *//*  w  w w . ja  v a 2s  .  c om*/
private static void plotDataset(ArrayList<DataSet> DataSetList) {

    XYSeriesCollection c = new XYSeriesCollection();

    int dscounter = 1; //use to name the dataseries
    for (DataSet ds : DataSetList) {
        INDArray features = ds.getFeatures();
        INDArray outputs = ds.getLabels();

        int nRows = features.rows();
        XYSeries series = new XYSeries("S" + dscounter);
        for (int i = 0; i < nRows; i++) {
            series.add(features.getDouble(i), outputs.getDouble(i));
        }

        c.addSeries(series);
    }

    String title = "title";
    String xAxisLabel = "xAxisLabel";
    String yAxisLabel = "yAxisLabel";
    PlotOrientation orientation = PlotOrientation.VERTICAL;
    boolean legend = false;
    boolean tooltips = false;
    boolean urls = false;
    JFreeChart chart = ChartFactory.createScatterPlot(title, xAxisLabel, yAxisLabel, c, orientation, legend,
            tooltips, urls);
    JPanel panel = new ChartPanel(chart);

    JFrame f = new JFrame();
    f.add(panel);
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.pack();
    f.setTitle("Training Data");

    f.setVisible(true);
}

From source file:regression.gui.RegressionChart.java

/**
 * Creates a chart./*  w ww  .j  av  a  2 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:GUI.PlotCreator.java

private ChartPanel createWindDirectionByTimePanel() {
    JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "Time(Hours)", "Wind Direction",
            createWindDirectionByTime(), PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) jfreechart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);
    XYItemRenderer renderer = xyPlot.getRenderer();
    renderer.setSeriesPaint(0, Color.BLACK);
    NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis();
    domain.setTickUnit(new NumberTickUnit(1.0));
    domain.setVerticalTickLabels(true);/*w w  w.java2s . co m*/

    return new ChartPanel(jfreechart);
}

From source file:org.gwaspi.reports.PlinkReportLoaderCombined.java

private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome,
        XYSeriesCollection tempChrData, boolean showlables) {
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    renderer.setSeriesVisibleInLegend(0, showlables);
    renderer.setSeriesVisibleInLegend(1, showlables);
    //renderer.setBaseShape(new Ellipse2D.Float(0, 0, 2,2), false);

    if (combinedPlot.getSubplots().isEmpty()) {
        LogAxis rangeAxis = new LogAxis("P value");
        rangeAxis.setBase(10);// w  w  w.  java2s. c  om
        rangeAxis.setInverted(true);
        rangeAxis.setNumberFormatOverride(GenericReportGenerator.FORMAT_P_VALUE);

        rangeAxis.setTickMarkOutsideLength(2.0f);
        rangeAxis.setMinorTickCount(2);
        rangeAxis.setMinorTickMarksVisible(true);
        rangeAxis.setAxisLineVisible(true);
        rangeAxis.setAutoRangeMinimumSize(0.0000005);
        rangeAxis.setLowerBound(1d);
        //rangeAxis.setAutoRangeIncludesZero(false);

        combinedPlot.setRangeAxis(0, rangeAxis);
    }

    JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", tempChrData,
            PlotOrientation.VERTICAL, true, false, false);

    XYPlot subplot = (XYPlot) subchart.getPlot();
    subplot.setRenderer(renderer);
    subplot.setBackgroundPaint(null);

    final Marker thresholdLine = new ValueMarker(0.0000005);
    thresholdLine.setPaint(Color.red);
    if (showlables) {
        thresholdLine.setLabel("P = 510??");
    }
    thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    subplot.addRangeMarker(thresholdLine);

    NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis();
    chrAxis.setAxisLineVisible(false);
    chrAxis.setTickLabelsVisible(false);
    chrAxis.setTickMarksVisible(false);
    chrAxis.setAutoRangeIncludesZero(false);
    //combinedPlot.setGap(0);
    combinedPlot.add(subplot, 1);
}

From source file:web.diva.server.model.PCAGenerator.java

public PCAImageResult generateChart(String path, PCAResults pcaResults, int[] subSelectionData, int[] selection,
        boolean zoom, boolean selectAll, String imgName, double w, double h, DivaDataset divaDataset) {
    XYDataset dataset = this.createDataset(pcaResults.getPoints(), subSelectionData, selection, zoom,
            divaDataset);/*from  w  w w .j av  a  2 s .  c  om*/
    final JFreeChart chart = ChartFactory.createScatterPlot("", // chart title
            "Principal Component" + (pcaResults.getPcai() + 1), // x axis label
            "Principal Component " + (pcaResults.getPcaii() + 1), // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.WHITE);
    XYDotRenderer renderer = new XYDotRenderer();
    renderer.setDotHeight(5);
    renderer.setDotWidth(5);

    if (selectAll) {
        int i = 0;
        for (String col : seriesList.keySet()) {
            if (col.equalsIgnoreCase("unGrouped")) {
                col = "#000000";
            }
            renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col));
            i++;
        }

    } else if (selection == null) {
        renderer.setPaint(Color.LIGHT_GRAY);
        int i = 0;
        for (String col : seriesList.keySet()) {
            if (col.equalsIgnoreCase("unGrouped")) {
                col = "#000000";
            }
            renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col));
            i++;
        }
    } else {
        int i = 0;
        for (String col : seriesList.keySet()) {
            if (col.equalsIgnoreCase("unGrouped")) {
                renderer.setSeriesPaint(i, Color.LIGHT_GRAY);
            } else {
                renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col));

            }
            i++;
        }
    }
    plot.setRenderer(renderer);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE);
    NumberAxis xAxis = new NumberAxis("Principal Component" + (pcaResults.getPcai() + 1));
    xAxis.setVerticalTickLabels(true);
    boolean auto = xAxis.getAutoRangeIncludesZero();
    xAxis.setAutoRangeIncludesZero(true ^ auto);
    NumberAxis yAxis = new NumberAxis("Principal Component" + (pcaResults.getPcaii() + 1));
    yAxis.setAutoRangeIncludesZero(true ^ auto);
    yAxis.setTickUnit(new NumberTickUnit(1));
    plot.setDomainAxis(0, xAxis);
    plot.setRangeAxis(0, yAxis);

    double MaxX = xAxis.getRange().getUpperBound();
    double MinX = xAxis.getRange().getLowerBound();
    double MaxY = yAxis.getRange().getUpperBound();
    double MinY = yAxis.getRange().getLowerBound();

    chartRenderingInfo.clear();
    String imgUrl = imgGenerator.saveToFile(chart, w, h, path, chartRenderingInfo, imgName);
    PCAImageResult imgUtilRes = new PCAImageResult();
    imgUtilRes.setImgString(imgUrl);
    imgUtilRes.setDataAreaMaxX(chartRenderingInfo.getPlotInfo().getDataArea().getMaxX());
    imgUtilRes.setDataAreaMaxY(chartRenderingInfo.getPlotInfo().getDataArea().getMaxY());
    imgUtilRes.setDataAreaMinY(chartRenderingInfo.getPlotInfo().getDataArea().getMinY());
    imgUtilRes.setDataAreaMinX(chartRenderingInfo.getPlotInfo().getDataArea().getMinX());
    imgUtilRes.setMaxX(MaxX);
    imgUtilRes.setMaxY(MaxY);
    imgUtilRes.setMinX(MinX);
    imgUtilRes.setMinY(MinY);
    return imgUtilRes;
}

From source file:tmn.dev.project.Player.java

/**
 * Generate a plot of batting average over the span of a season and write
 * the plot to a PNG file./*  ww  w . j av  a 2s  .  c  o  m*/
 * 
 * @return The String representation of the name of the PNG file containing
 *         the plot.
 * @throws IOException
 */
private String createBAPlot() throws IOException {

    // Create a scatter plot for batting average over the season
    // Game number on the x axis, Batting average on the y axis
    JFreeChart chart = ChartFactory.createScatterPlot("Batting Average Throughout the Season", "Game Number",
            "Batting Average", new XYSeriesCollection(baGame), PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = chart.getXYPlot();
    // Set the axis ranges to provide an appropriate zoom
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setRange(baGame.getMinX(), baGame.getMaxX());
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setRange(baGame.getMinY() - .02, baGame.getMaxY() + .02);
    // Set the tick labels on the y axis to the typical BA format
    yAxis.setNumberFormatOverride(new DecimalFormat(".000"));

    // Create the String representation of the /images directory
    String imgDirStr = System.getProperty("user.dir") + System.getProperty("file.separator") + "images";

    // If the directory doesn't already exist, create it
    File imgDir = new File(imgDirStr);
    if (!imgDir.exists() && !imgDir.isDirectory())
        imgDir.mkdir();

    // Create the batting average PNG files
    String fileName = imgDirStr + System.getProperty("file.separator") + this.getId() + ".png";
    File imgFile = new File(fileName);

    // If the file already exists, append a number in parentheses
    int index = 0;
    while (!imgFile.createNewFile()) {
        // Append (<index>).html after the Player ID
        fileName = imgDirStr + System.getProperty("file.separator") + this.getId() + "(" + ++index + ")"
                + ".png";
        // Try to create a file with this name
        imgFile = new File(fileName);
    }

    // Write the plot to the PNG file that was created
    ChartUtilities.saveChartAsPNG(imgFile, chart, 800, 450);

    return imgFile.getName();
}

From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.GpsScatterPlotUIComponent.java

/***********************************************************************************************
 * Customise the XYPlot of a new chart, e.g. for fixed range axes.
 * Remember that a GPS Scatter Plot has no ChannelSelector.
 *
 * @param datasettype/*w ww.j a va2  s . c  o  m*/
 * @param primarydataset
 * @param secondarydatasets
 * @param updatetype
 * @param displaylimit
 * @param channelselector
 * @param debug
 *
 * @return JFreeChart
 */

public JFreeChart createCustomisedChart(final DatasetType datasettype, final XYDataset primarydataset,
        final List<XYDataset> secondarydatasets, final DataUpdateType updatetype, final int displaylimit,
        final ChannelSelectorUIComponentInterface channelselector, final boolean debug) {
    final String SOURCE = "GpsScatterPlotUIComponent.createCustomisedChart() ";
    final JFreeChart jFreeChart;
    final XYPlot plot;
    final Stroke strokeCrosshair;
    final XYDotRenderer renderer;
    final ValueAxis axisRange;
    final NumberAxis axisDomain;

    // See ChartHelper for other calls to ChartFactory
    // Note that no ChannelSector means no way to control the legend, so turn it off
    jFreeChart = ChartFactory.createScatterPlot(MSG_WAITING_FOR_DATA, MSG_WAITING_FOR_DATA,
            MSG_WAITING_FOR_DATA, primarydataset, PlotOrientation.VERTICAL, false, //channelselector.hasLegend(),
            true, false);

    jFreeChart.setBackgroundPaint(UIComponentPlugin.DEFAULT_COLOUR_CANVAS.getColor());

    // Experimental chart configuration
    jFreeChart.getTitle().setFont(UIComponentPlugin.DEFAULT_FONT.getFont().deriveFont(20.0f));

    plot = (XYPlot) jFreeChart.getPlot();

    plot.setBackgroundPaint(ChartHelper.COLOR_PLOT);
    plot.setDomainGridlinePaint(ChartHelper.COLOR_GRIDLINES);
    plot.setRangeGridlinePaint(ChartHelper.COLOR_GRIDLINES);
    plot.setAxisOffset(ChartHelper.PLOT_RECTANGLE_INSETS);

    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);

    plot.setDomainCrosshairVisible(true);
    plot.setDomainCrosshairLockedOnData(false);

    plot.setRangeCrosshairVisible(true);
    plot.setRangeCrosshairLockedOnData(true);

    // Make the Crosshair more visible by changing the width from the default
    strokeCrosshair = new BasicStroke(2.0f, // The width of this BasicStroke
            BasicStroke.CAP_BUTT, // The decoration of the ends of a BasicStroke
            BasicStroke.JOIN_BEVEL, // The decoration applied where path segments meet
            0.0f, // The limit to trim the miter join
            new float[] { 2.0f, 2.0f }, // The array representing the dashing pattern
            0.0f); // The offset to start the dashing pattern
    plot.setDomainCrosshairStroke(strokeCrosshair);
    plot.setRangeCrosshairStroke(strokeCrosshair);

    renderer = new XYDotRenderer();
    renderer.setDotWidth(2);
    renderer.setDotHeight(2);
    plot.setRenderer(renderer);

    axisDomain = (NumberAxis) plot.getDomainAxis();
    axisRange = plot.getRangeAxis();

    // Remember that a GPS Scatter Plot has no ChannelSelector
    if (canAutorange()) {
        // The fix could be anywhere...
        axisDomain.setAutoRangeIncludesZero(false);
        axisDomain.setAutoRange(true);
        axisRange.setAutoRange(true);
    } else {
        // Allow range to full global extents!
        axisDomain.setRange(getLinearFixedMinY(), getLinearFixedMaxY());
        axisRange.setRange(-90.0, 90.0);
    }

    return (jFreeChart);
}