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

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

Introduction

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

Prototype

public void setRangeCrosshairVisible(boolean flag) 

Source Link

Document

Sets the flag indicating whether or not the range crosshair is visible.

Usage

From source file:gov.nih.nci.ispy.ui.graphing.chart.plot.ISPYPrincipalComponentAnalysisPlot.java

private void createChart() {

    String xLabel = component1.toString();
    String yLabel = component2.toString();

    pcaChart = ChartFactory.createScatterPlot("Principal Component Analysis", xLabel, yLabel, null,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) pcaChart.getPlot();

    buildLegend();// w  w  w  .j av a2 s  . co m

    plot.setNoDataMessage(null);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    renderer.setUseOutlinePaint(true);
    plot.setRangeCrosshairVisible(false);
    plot.setDomainCrosshairVisible(false);

    //        XYShapeAnnotation annotation = new XYShapeAnnotation(new Rectangle2D.Double(25.0, 25.0, 5, 5));
    //           
    //        plot.addAnnotation(annotation);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    //should determine axis range using datapoints.
    DataRange component1Range = getDataRange(dataPoints, PCAcomponent.PC1);
    DataRange component2Range = getDataRange(dataPoints, PCAcomponent.PC2);
    DataRange component3Range = getDataRange(dataPoints, PCAcomponent.PC3);

    Double pc1AbsMax = Math.max(Math.abs(component1Range.getMaxRange()),
            Math.abs(component1Range.getMinRange()));
    Double pc2AbsMax = Math.max(Math.abs(component2Range.getMaxRange()),
            Math.abs(component2Range.getMinRange()));
    Double pc3AbsMax = Math.max(Math.abs(component3Range.getMaxRange()),
            Math.abs(component3Range.getMinRange()));

    Double maxAbsVal = Math.max(pc1AbsMax, pc2AbsMax);

    maxAbsVal = Math.max(maxAbsVal, pc3AbsMax);

    //maxAbsVal = Math.max(100.0, maxAbsVal);

    domainAxis.setAutoRangeIncludesZero(false);

    double tickUnit = 25.0;

    if (maxAbsVal <= 25.0) {
        tickUnit = 5.0;
    } else if (maxAbsVal <= 50.0) {
        tickUnit = 10.0;
    }

    domainAxis.setTickUnit(new NumberTickUnit(tickUnit));
    rangeAxis.setTickUnit(new NumberTickUnit(tickUnit));

    double glyphScaleFactor = (maxAbsVal * 2.0) / 600.0; //assuming 600 pixels for the graph

    double adjAbsVal = Math.ceil(maxAbsVal + (glyphScaleFactor * 8.0));

    //domainAxis.setRange(-maxAbsVal, maxAbsVal);
    domainAxis.setRange(-adjAbsVal, adjAbsVal);

    //rangeAxis.setRange(-maxAbsVal, maxAbsVal);
    rangeAxis.setRange(-adjAbsVal, adjAbsVal);

    createGlyphsAndAddToPlot(plot, glyphScaleFactor);

    // Paint p = new GradientPaint(0, 0, Color.white, 1000, 0, Color.green);
    //try and match the UI e9e9e9
    Paint p = new Color(233, 233, 233);

    pcaChart.setBackgroundPaint(p);
}

From source file:visualizer.datamining.dataanalysis.NeighborhoodPreservation.java

private JFreeChart createChart(XYDataset xydataset) {
    JFreeChart chart = ChartFactory.createXYLineChart("Neighborhood Preservation", "Number Neighbors",
            "Precision", xydataset, PlotOrientation.VERTICAL, true, true, false);

    chart.setBackgroundPaint(Color.WHITE);

    XYPlot xyplot = (XYPlot) chart.getPlot();
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);

    xyplot.setDomainGridlinePaint(Color.BLACK);
    xyplot.setRangeGridlinePaint(Color.BLACK);

    xyplot.setOutlinePaint(Color.BLACK);
    xyplot.setOutlineStroke(new BasicStroke(1.0f));
    xyplot.setBackgroundPaint(Color.white);
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);

    xyplot.setDrawingSupplier(new DefaultDrawingSupplier(
            new Paint[] { Color.RED, Color.BLUE, Color.GREEN, Color.MAGENTA, Color.CYAN, Color.ORANGE,
                    Color.BLACK, Color.DARK_GRAY, Color.GRAY, Color.LIGHT_GRAY, Color.YELLOW },
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));

    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setBaseShapesFilled(true);
    xylineandshaperenderer.setDrawOutlines(true);

    return chart;
}

From source file:org.n52.server.io.render.DiagramRenderer.java

protected JFreeChart renderPreChart(Map<String, OXFFeatureCollection> entireCollMap,
        String[] observedProperties, ArrayList<TimeSeriesCollection> timeSeries, Calendar begin, Calendar end) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // title
            "Date", // x-axis label
            observedProperties[0], // y-axis label
            timeSeries.get(0), // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );/*from ww  w .  jav a  2 s .  co m*/

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    // add additional datasets:
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setRange(begin.getTime(), end.getTime());
    axis.setDateFormatOverride(new SimpleDateFormat());
    axis.setTimeZone(end.getTimeZone());
    for (int i = 1; i < observedProperties.length; i++) {
        XYDataset additionalDataset = timeSeries.get(i);
        plot.setDataset(i, additionalDataset);
        plot.setRangeAxis(i, new NumberAxis(observedProperties[i]));
        // plot.getRangeAxis(i).setRange((Double)
        // overAllSeriesCollection.getMinimum(i),
        // (Double) overAllSeriesCollection.getMaximum(i));
        plot.mapDatasetToRangeAxis(i, i);
        // plot.getDataset().getXValue(i, i);
    }
    return chart;
}

From source file:pl.dpbz.poid.zadanie3.GUI.java

private void drawChartOfSoundSignal(Integer[] ints, double samplingFrequency) {
    //Rysowanie wykresu sygnau dwikowego
    final XYSeries dist = new XYSeries("P0");
    int index = 0;
    for (Integer i : ints) {
        dist.add(index / samplingFrequency, i);
        index++;//from  w w  w  .  j  a  va2 s.  c o  m
    }
    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dist);

    JFreeChart chart = ChartFactory.createXYLineChart(f.getName(), "index", "Distance", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) chart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);
    XYItemRenderer renderer = xyPlot.getRenderer();
    renderer.setSeriesPaint(0, Color.blue);
    NumberAxis domain = (NumberAxis) xyPlot.getRangeAxis();
    domain.setRange(-32768, 32768);
    //ChartDrawer.drawChart(chart);

    ChartPanel cp4 = new ChartPanel(chart);
    this.chartJPanel4.removeAll();
    this.chartJPanel4.setLayout(new java.awt.BorderLayout());
    this.chartJPanel4.add(cp4, BorderLayout.CENTER);
    this.chartJPanel4.validate();
}

From source file:org.n52.server.sos.render.DiagramRenderer.java

protected JFreeChart renderPreChart(Map<String, OXFFeatureCollection> entireCollMap,
        String[] observedProperties, ArrayList<TimeSeriesCollection> timeSeries, Calendar begin, Calendar end) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // title
            "Date", // x-axis label
            observedProperties[0], // y-axis label
            timeSeries.get(0), // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );//from   www  .jav a2s.  co  m

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    // add additional datasets:
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setRange(begin.getTime(), end.getTime());
    axis.setDateFormatOverride(new SimpleDateFormat());
    for (int i = 1; i < observedProperties.length; i++) {
        XYDataset additionalDataset = timeSeries.get(i);
        plot.setDataset(i, additionalDataset);
        plot.setRangeAxis(i, new NumberAxis(observedProperties[i]));
        // plot.getRangeAxis(i).setRange((Double)
        // overAllSeriesCollection.getMinimum(i),
        // (Double) overAllSeriesCollection.getMaximum(i));
        plot.mapDatasetToRangeAxis(i, i);
        // plot.getDataset().getXValue(i, i);
    }
    return chart;
}

From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.PrincipalComponentAnalysisPlot.java

protected void createChart() {

    String xLabel = component1.toString();
    String yLabel = component2.toString();

    pcaChart = ChartFactory.createScatterPlot("Principal Component Analysis", xLabel, yLabel, null,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) pcaChart.getPlot();

    if (!this.colorBy.equals(PCAcolorByType.NONE)) {
        buildLegend();//w w  w .  j  a v a 2 s.  c  o  m
    }

    plot.setNoDataMessage(null);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    renderer.setUseOutlinePaint(true);
    plot.setRangeCrosshairVisible(false);
    plot.setDomainCrosshairVisible(false);

    //        XYShapeAnnotation annotation = new XYShapeAnnotation(new Rectangle2D.Double(25.0, 25.0, 5, 5));
    //           
    //        plot.addAnnotation(annotation);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    //should determine axis range using datapoints.
    DataRange component1Range = getDataRange(dataPoints, PCAcomponent.PC1);
    DataRange component2Range = getDataRange(dataPoints, PCAcomponent.PC2);
    DataRange component3Range = getDataRange(dataPoints, PCAcomponent.PC3);

    Double pc1AbsMax = Math.max(Math.abs(component1Range.getMaxRange()),
            Math.abs(component1Range.getMinRange()));
    Double pc2AbsMax = Math.max(Math.abs(component2Range.getMaxRange()),
            Math.abs(component2Range.getMinRange()));
    Double pc3AbsMax = Math.max(Math.abs(component3Range.getMaxRange()),
            Math.abs(component3Range.getMinRange()));

    Double maxAbsVal = Math.max(pc1AbsMax, pc2AbsMax);

    maxAbsVal = Math.max(maxAbsVal, pc3AbsMax);

    maxAbsVal = Math.max(150.0, maxAbsVal);

    domainAxis.setAutoRangeIncludesZero(false);

    domainAxis.setRange(-maxAbsVal, maxAbsVal);
    rangeAxis.setRange(-maxAbsVal, maxAbsVal);

    domainAxis.setTickUnit(new NumberTickUnit(25.0));
    rangeAxis.setTickUnit(new NumberTickUnit(25.0));

    createGlyphsAndAddToPlot(plot);

    // Paint p = new GradientPaint(0, 0, Color.white, 1000, 0, Color.green);
    //try and match the UI e9e9e9
    Paint p = new Color(233, 233, 233);

    pcaChart.setBackgroundPaint(p);
}

From source file:org.encog.workbench.tabs.visualize.scatter.ScatterPlotTab.java

private JPanel createPanel(int xIndex, int yIndex, boolean legend) {

    XYDataset dataset = new ScatterXY(file, xIndex, yIndex);
    JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, dataset, PlotOrientation.VERTICAL,
            legend, true, false);/*from w  w  w .ja  v a  2 s .c  om*/

    XYPlot plot = (XYPlot) chart.getPlot();

    XYDotRenderer renderer = new XYDotRenderer();
    renderer.setDotWidth(4);
    renderer.setDotHeight(4);

    if (this.file.isRegression()) {
        int per = 255 / 10;
        int r = 0;
        int b = 255;
        for (int i = 0; i < file.getSeriesCount(); i++) {
            renderer.setSeriesPaint(i, new Color(r, 0, b));
            r += per;
            b -= per;
        }
    } else {
        for (int i = 0; i < file.getSeriesCount(); i++) {
            renderer.setSeriesPaint(i, COLORS[i % COLORS.length]);
        }
    }

    plot.setRenderer(renderer);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    plot.getRangeAxis().setInverted(false);

    ChartPanel result = new ChartPanel(chart);
    result.setBorder(BorderFactory.createLineBorder(Color.black));

    // we need one to draw the legend off of
    if (this.samplePlot == null)
        this.samplePlot = plot;
    //chart.removeLegend();
    return result;
}

From source file:edu.unibonn.kmeans.mapreduce.plotting.TimeSeriesPlotter_KMeans.java

/**
  * Creates a chart.//from ww  w.ja  v  a2  s  . co m
  * 
  * @param dataset  a dataset.
 * @param clusters 
  * 
  * @return A chart.
  */
//    private JFreeChart createChart(final XYDataset dataset, ArrayList<Cluster_DBScan> clusters) {
//
//        final JFreeChart chart = ChartFactory.createTimeSeriesChart(
//            "Sensors",
//            "Time", "Erlang",
//            dataset,
//            false, //t
//            true, //t
//            false //f
//        );
//
//        ChartUtilities.applyCurrentTheme(chart);
//        
//        //chart.setBackgroundPaint(Color.white);
//
////        final StandardLegend sl = (StandardLegend) chart.getLegend();
////        sl.setDisplaySeriesShapes(true);
//
//        final XYPlot plot = chart.getXYPlot();
//        plot.setBackgroundPaint(Color.WHITE);
//        plot.setDomainGridlinePaint(Color.white);
//        plot.setRangeGridlinePaint(Color.white);
////        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
//        plot.setDomainCrosshairVisible(true);
//        plot.setRangeCrosshairVisible(true);
//        
//        final XYItemRenderer renderer = plot.getRenderer();
//        
//        if (renderer instanceof StandardXYItemRenderer) 
//        {
//            final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
//            //rr.setPlotShapes(true);
//            rr.setShapesFilled(true);
//            rr.setItemLabelsVisible(true);
//        }
//
//        int temp_count = 0;
//        
//        //for (int i = 0; i < clusters.size(); i++)
//        for (int i = 0; (i < 11) && (i < clusters.size()); i++)
//      {
//         Cluster_DBScan current_cluster = clusters.get(i);   
//         ArrayList<Day_24d> member_time_series = current_cluster.getMembership();
//         
//         for (int j = 0; j < member_time_series.size(); j++)
//         {
//            renderer.setSeriesPaint(j+temp_count, getColor(i));
//         }
//         temp_count = temp_count + member_time_series.size();
//      }
//        
//        final DateAxis axis = (DateAxis) plot.getDomainAxis();    
//        axis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));
//        
//        final ValueAxis axis_y = plot.getRangeAxis();
//        axis_y.setRange(0, 100);
//        
//        return chart;
//
//    }

private JFreeChart createChart(final XYDataset dataset, final XYDataset dataset_centroids,
        ArrayList<Cluster_KMeans> clusters) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Sensors", "Time", "Erlang", dataset, false, //t
            true, //t
            false //f
    );

    ChartUtilities.applyCurrentTheme(chart);

    //chart.setBackgroundPaint(Color.white);

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

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    //        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final XYItemRenderer renderer = plot.getRenderer();

    if (renderer instanceof StandardXYItemRenderer) {
        final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
        //rr.setPlotShapes(true);
        rr.setShapesFilled(true);
        rr.setItemLabelsVisible(true);
    }

    int temp_count = 0;

    //for (int i = 0; i < clusters.size(); i++)
    for (int i = 0; (i < 11) && (i < clusters.size()); i++) {
        Cluster_KMeans current_cluster = clusters.get(i);
        ArrayList<Day_24d> member_time_series = current_cluster.getMembership();

        for (int j = 0; j < member_time_series.size(); j++) {
            renderer.setSeriesPaint(j + temp_count, getColor(i));
        }
        temp_count = temp_count + member_time_series.size();
    }

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));

    //final ValueAxis axis_y = plot.getRangeAxis();
    //axis_y.setRange(0, 20);

    plot.setDataset(1, dataset_centroids);
    plot.setRenderer(1, new StandardXYItemRenderer());

    for (int i = 0; (i < clusters.size()); i++) {
        //plot.getRenderer(1).setSeriesPaint(i, getColor(i));
        plot.getRenderer(1).setSeriesPaint(i, Color.BLACK);
        plot.getRenderer(1).setSeriesStroke(i, new BasicStroke(3.0f, BasicStroke.CAP_ROUND,
                BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f));
    }

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    return chart;
}

From source file:org.locationtech.udig.processingtoolbox.tools.ScatterPlotDialog.java

private void updateChart(SimpleFeatureCollection features, String xField, String yField) {
    // 1. Create a single plot containing both the scatter and line
    XYPlot plot = new XYPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(java.awt.Color.WHITE);
    plot.setDomainPannable(false);//from w  w  w .  j a  va2  s . c  om
    plot.setRangePannable(false);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);

    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    // 2. Setup Scatter plot
    // Create the scatter data, renderer, and axis
    int fontStyle = java.awt.Font.BOLD;
    FontData fontData = getShell().getDisplay().getSystemFont().getFontData()[0];
    NumberAxis xPlotAxis = new NumberAxis(xField); // Independent variable
    xPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12));
    xPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 10));

    NumberAxis yPlotAxis = new NumberAxis(yField); // Dependent variable
    yPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12));
    yPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 10));

    XYToolTipGenerator plotToolTip = new StandardXYToolTipGenerator();

    XYItemRenderer plotRenderer = new XYLineAndShapeRenderer(false, true); // Shapes only
    plotRenderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 3, 3));
    plotRenderer.setSeriesPaint(0, java.awt.Color.BLUE); // dot
    plotRenderer.setBaseToolTipGenerator(plotToolTip);

    // Set the scatter data, renderer, and axis into plot
    plot.setDataset(0, getScatterPlotData(features, xField, yField));

    xPlotAxis.setAutoRangeIncludesZero(false);
    xPlotAxis.setAutoRange(false);
    double differUpper = minMaxVisitor.getMaxX() - minMaxVisitor.getAverageX();
    double differLower = minMaxVisitor.getAverageX() - minMaxVisitor.getMinX();
    double gap = Math.abs(differUpper - differLower);
    if (differUpper > differLower) {
        xPlotAxis.setRange(minMaxVisitor.getMinX() - gap, minMaxVisitor.getMaxX());
    } else {
        xPlotAxis.setRange(minMaxVisitor.getMinX(), minMaxVisitor.getMaxX() + gap);
    }

    yPlotAxis.setAutoRangeIncludesZero(false);
    yPlotAxis.setAutoRange(false);
    differUpper = minMaxVisitor.getMaxY() - minMaxVisitor.getAverageY();
    differLower = minMaxVisitor.getAverageY() - minMaxVisitor.getMinY();
    gap = Math.abs(differUpper - differLower);
    if (differUpper > differLower) {
        yPlotAxis.setRange(minMaxVisitor.getMinY() - gap, minMaxVisitor.getMaxY());
    } else {
        yPlotAxis.setRange(minMaxVisitor.getMinY(), minMaxVisitor.getMaxY() + gap);
    }

    plot.setRenderer(0, plotRenderer);
    plot.setDomainAxis(0, xPlotAxis);
    plot.setRangeAxis(0, yPlotAxis);

    // Map the scatter to the first Domain and first Range
    plot.mapDatasetToDomainAxis(0, 0);
    plot.mapDatasetToRangeAxis(0, 0);

    // 3. Setup line
    // Create the line data, renderer, and axis
    XYItemRenderer lineRenderer = new XYLineAndShapeRenderer(true, false); // Lines only
    lineRenderer.setSeriesPaint(0, java.awt.Color.GRAY);
    lineRenderer.setSeriesPaint(1, java.awt.Color.GRAY);
    lineRenderer.setSeriesPaint(2, java.awt.Color.GRAY);

    // Set the line data, renderer, and axis into plot
    NumberAxis xLineAxis = new NumberAxis(EMPTY);
    xLineAxis.setTickMarksVisible(false);
    xLineAxis.setTickLabelsVisible(false);

    NumberAxis yLineAxis = new NumberAxis(EMPTY);
    yLineAxis.setTickMarksVisible(false);
    yLineAxis.setTickLabelsVisible(false);

    XYSeriesCollection lineDataset = new XYSeriesCollection();

    // AverageY
    XYSeries horizontal = new XYSeries("AverageY"); //$NON-NLS-1$
    horizontal.add(xPlotAxis.getRange().getLowerBound(), minMaxVisitor.getAverageY());
    horizontal.add(xPlotAxis.getRange().getUpperBound(), minMaxVisitor.getAverageY());
    lineDataset.addSeries(horizontal);

    // AverageX
    XYSeries vertical = new XYSeries("AverageX"); //$NON-NLS-1$
    vertical.add(minMaxVisitor.getAverageX(), yPlotAxis.getRange().getLowerBound());
    vertical.add(minMaxVisitor.getAverageX(), yPlotAxis.getRange().getUpperBound());
    lineDataset.addSeries(vertical);

    // Degree
    XYSeries degree = new XYSeries("Deegree"); //$NON-NLS-1$
    degree.add(xPlotAxis.getRange().getLowerBound(), yPlotAxis.getRange().getLowerBound());
    degree.add(xPlotAxis.getRange().getUpperBound(), yPlotAxis.getRange().getUpperBound());
    lineDataset.addSeries(degree);

    plot.setDataset(1, lineDataset);
    plot.setRenderer(1, lineRenderer);
    plot.setDomainAxis(1, xLineAxis);
    plot.setRangeAxis(1, yLineAxis);

    // Map the line to the second Domain and second Range
    plot.mapDatasetToDomainAxis(1, 0);
    plot.mapDatasetToRangeAxis(1, 0);

    // 4. Setup Selection
    NumberAxis xSelectionAxis = new NumberAxis(EMPTY);
    xSelectionAxis.setTickMarksVisible(false);
    xSelectionAxis.setTickLabelsVisible(false);

    NumberAxis ySelectionAxis = new NumberAxis(EMPTY);
    ySelectionAxis.setTickMarksVisible(false);
    ySelectionAxis.setTickLabelsVisible(false);

    XYItemRenderer selectionRenderer = new XYLineAndShapeRenderer(false, true); // Shapes only
    selectionRenderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 6, 6));
    selectionRenderer.setSeriesPaint(0, java.awt.Color.RED); // dot

    plot.setDataset(2, new XYSeriesCollection(new XYSeries(EMPTY)));
    plot.setRenderer(2, selectionRenderer);
    plot.setDomainAxis(2, xSelectionAxis);
    plot.setRangeAxis(2, ySelectionAxis);

    // Map the scatter to the second Domain and second Range
    plot.mapDatasetToDomainAxis(2, 0);
    plot.mapDatasetToRangeAxis(2, 0);

    // 5. Finally, Create the chart with the plot and a legend
    java.awt.Font titleFont = new Font(fontData.getName(), fontStyle, 20);
    JFreeChart chart = new JFreeChart(EMPTY, titleFont, plot, false);
    chart.setBackgroundPaint(java.awt.Color.WHITE);
    chart.setBorderVisible(false);

    chartComposite.setChart(chart);
    chartComposite.forceRedraw();
}

From source file:org.eumetsat.metop.visat.SounderInfoView.java

protected void configureSpectrumPlot(XYPlot plot) {
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setDomainCrosshairVisible(true);
    plot.setDomainCrosshairLockedOnData(true);
    plot.setRangeCrosshairVisible(false);
    plot.setNoDataMessage(NO_IFOV_SELECTED);
}