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

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

Introduction

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

Prototype

public void setSeriesRenderingOrder(SeriesRenderingOrder order) 

Source Link

Document

Sets the series order and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:tools.descartes.bungee.chart.ChartGenerator.java

private static XYPlot createAllocationPlot(final TimeSeriesCollection dataset) {

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(false);
    final NumberAxis rangeAxis = new NumberAxis("Resource Amount");
    rangeAxis.setAutoRangeIncludesZero(true);
    //rangeAxis.setTickUnit(new NumberTickUnit(1));
    double lower = Math.min(1, dataset.getRangeBounds(false).getLowerBound()) - 0.2;
    double upper = Math.max(2, dataset.getRangeBounds(false).getUpperBound()) + 0.2;
    rangeAxis.setRange(lower, upper);/*from  w  w  w .j av  a2s  .c  o m*/
    final XYPlot allocationPlot = new XYPlot(dataset, null, rangeAxis, renderer);
    allocationPlot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE);

    for (int i = 0; i < dataset.getSeriesCount(); i++) {
        TimeSeries series = dataset.getSeries(i);
        //addEndSeriesItem(lastDate, series);
        String description = series.getKey().toString();
        renderer.setSeriesStroke(i, new BasicStroke(STROKE_WIDTH));
        if (description.equals(AllocationSeries.CATEGORY.DEMAND.toString())) {
            renderer.setSeriesShapesVisible(i, false);
            renderer.setSeriesPaint(i, Color.RED);
        } else if (description.equals(SupplySeries.TYPE.VM_SCHEDULED.toString())) {
            renderer.setSeriesPaint(i, VARIANT_C_COLOR);
        } else if (description.equals(SupplySeries.TYPE.VM_COMPLETED.toString())) {
            renderer.setSeriesPaint(i, VARIANT_B_COLOR);
        } else if (description.equals(SupplySeries.TYPE.LB_RULE_ADAPTION.toString())) {
            if (dataset.getSeriesCount() != 2) {
                renderer.setSeriesPaint(i, VARIANT_A_COLOR);
            } else {
                renderer.setSeriesPaint(i, Color.BLUE);
            }
        } else if (description.equals(SupplySeries.TYPE.MONITORED.toString())) {
            if (dataset.getSeriesCount() != 2) {
                renderer.setSeriesPaint(i, VARIANT_D_COLOR);
            } else {
                renderer.setSeriesPaint(i, Color.BLUE);
            }
        } else {
            renderer.setSeriesPaint(i, colorForConfig(description));
        }
    }

    return allocationPlot;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.clusterchart.SimpleCluster.java

public JFreeChart createChart(DatasetMap datasets) {

    DefaultXYZDataset dataset = (DefaultXYZDataset) datasets.getDatasets().get("1");

    JFreeChart chart = ChartFactory.createBubbleChart(name, yLabel, xLabel, dataset, PlotOrientation.HORIZONTAL,
            legend, true, false);/*w w  w. jav  a  2s. c o m*/

    /*Font font = new Font("Tahoma", Font.BOLD, titleDimension);
    TextTitle title = new TextTitle(name, font);
    chart.setTitle(title);*/

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    Color colorSubInvisibleTitle = Color.decode("#FFFFFF");
    StyleLabel styleSubSubTitle = new StyleLabel("Arial", 12, colorSubInvisibleTitle);
    TextTitle subsubTitle = setStyleTitle("", styleSubSubTitle);
    chart.addSubtitle(subsubTitle);

    chart.setBackgroundPaint(color);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
    //plot.setForegroundAlpha(0.50f);
    plot.setForegroundAlpha(0.65f);

    XYItemRenderer renderer = plot.getRenderer();

    //define colors
    int seriesN = dataset.getSeriesCount();
    if (colorMap != null) {
        boolean isSerieSel = true;
        for (int i = 0; i < seriesN; i++) {
            String serieName = (String) dataset.getSeriesKey(i);
            String tmpName = serieName.replaceAll(" ", "");
            tmpName = tmpName.replace('.', ' ').trim();
            if (serie_selected != null && serie_selected.size() > 0) {
                String serieSel = serie_selected.get(tmpName).toString();
                isSerieSel = (serieSel.equalsIgnoreCase("TRUE") || serieSel.equalsIgnoreCase("YES")
                        || serieSel.equalsIgnoreCase("1")) ? true : false;
                serieName = tmpName;
            }

            if (color != null && isSerieSel) {
                Color color = (Color) colorMap.get(serieName);
                renderer.setSeriesPaint(i, color);
            } else {
                Color color = new Color(Integer.decode(defaultColor).intValue());
                renderer.setSeriesPaint(i, color);
            }
        }
    }

    // increase the margins to account for the fact that the auto-range 
    // doesn't take into account the bubble size...
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    //domainAxis.setAutoRange(true);
    domainAxis.setRange(yMin, yMax);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setLabelPaint(styleXaxesLabels.getColor());
    rangeAxis
            .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor());

    //rangeAxis.setAutoRange(true);
    rangeAxis.setRange(xMin, xMax);

    TickUnits units = null;
    if (decimalXValues == false)
        units = (TickUnits) NumberAxis.createIntegerTickUnits();
    else
        units = (TickUnits) NumberAxis.createStandardTickUnits();
    rangeAxis.setStandardTickUnits(units);

    TickUnits domainUnits = null;
    if (decimalYValues == false)
        domainUnits = (TickUnits) NumberAxis.createIntegerTickUnits();
    else
        domainUnits = (TickUnits) NumberAxis.createStandardTickUnits();
    domainAxis.setStandardTickUnits(domainUnits);

    rangeAxis.setLowerMargin(1.0);
    rangeAxis.setUpperMargin(1.0);

    domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setLabelPaint(styleYaxesLabels.getColor());
    domainAxis
            .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setTickLabelPaint(styleYaxesLabels.getColor());

    domainAxis.setLowerMargin(1.0);
    domainAxis.setUpperMargin(1.0);
    //DecimalFormat format=(new DecimalFormat("0"));
    //rangeAxis.setNumberFormatOverride(format);

    if (legend == true)
        drawLegend(chart);

    return chart;
}

From source file:org.codehaus.mojo.chronos.chart.SummaryThroughputChartSource.java

private XYPlot createThroughputPlot(ResourceBundle bundle, ReportConfig config) {
    TimeSeriesCollection dataset1 = createThroughputDataset(bundle, config);
    XYPlot throughputPlot = ChartUtil.newPlot(dataset1, bundle.getString("chronos.label.throughput.requests"),
            true);/* w ww . j a va2  s  . c o m*/
    throughputPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    throughputPlot.getRenderer().setSeriesPaint(0, Color.GREEN);
    throughputPlot.getRenderer().setSeriesPaint(1, Color.BLUE);
    throughputPlot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);

    double maxAvgThroughput = samples.getMaxAverageThroughput(config.getAverageduration(),
            config.getResponsetimedivider());
    String maxThroughputLabel = bundle.getString("chronos.label.maxaveragethroughput");
    ChartUtil.addRangeMarker(throughputPlot, maxThroughputLabel, maxAvgThroughput);
    return throughputPlot;
}

From source file:web.diva.server.unused.ProfilePlotGenerator.java

/**
 * Creates a line chart (based on an {@link XYDataset}) with default
 * settings./*from w  w w  . j  a v  a 2  s  .c om*/
 *
 * @param title the chart title (<code>null</code> permitted).
 * @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
 * @param dataset the dataset for the chart (<code>null</code> permitted).
 * @param orientation the plot orientation (horizontal or vertical)
 * (<code>null</code> NOT permitted).
 * @param legend a flag specifying whether or not a legend is required.
 * @param tooltips configure chart to generate tool tips?
 * @param urls configure chart to generate URLs?
 *
 * @return The chart.
 */
private JFreeChart createXYLineChart(String title, String[] columnIds, XYDataset dataset,
        PlotOrientation orientation, boolean legend, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    Font f = new Font("ARIAL", 1, 7);
    //        NumberAxis xAxis = new NumberAxis(xAxisLabel);
    //        xAxis.setAutoRangeIncludesZero(false);
    SymbolAxis xAxis = new SymbolAxis("", columnIds);
    xAxis.setAxisLineVisible(false);
    xAxis.setGridBandsVisible(false);
    xAxis.setVerticalTickLabels(true);
    xAxis.setVisible(true);

    xAxis.setTickLabelPaint(shadowColor);
    xAxis.setTickLabelFont(f);
    xAxis.setFixedDimension(51.0);

    boolean auto = xAxis.getAutoRangeIncludesZero();
    xAxis.setAutoRangeIncludesZero(true ^ auto);
    xAxis.setTickUnit(new NumberTickUnit(1));
    xAxis.setRange(0, columnIds.length);
    //        NumberAxis yAxis = new NumberAxis(yAxisLabel);
    NumberAxis yAxis = new NumberAxis();
    yAxis.setAutoRangeIncludesZero(true ^ auto);
    yAxis.setAxisLineVisible(false);
    yAxis.setTickLabelFont(f);
    yAxis.setTickLabelPaint(Color.BLUE);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setBaseShapesVisible(false);
    renderer.setPaint(shadowColor);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);

    plot.setBackgroundPaint(Color.WHITE);

    plot.setDomainGridlinePaint(shadowColor);
    plot.setRangeGridlinePaint(shadowColor);
    plot.setOutlinePaint(Color.BLUE);
    //        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    //        plot.setRenderer(renderer);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE);

    plot.setDomainAxis(xAxis);

    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    return chart;

}

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

private void createGraphTab(final CTabFolder parentTabFolder) {
    plotTab = new CTabItem(parentTabFolder, SWT.NONE);
    plotTab.setText(Messages.ScatterPlotDialog_Graph);

    XYPlot plot = new XYPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(java.awt.Color.WHITE);
    plot.setDomainPannable(false);//  w  ww  .  j  a v  a 2 s . com
    plot.setRangePannable(false);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);

    JFreeChart chart = new JFreeChart(EMPTY, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    chart.setBackgroundPaint(java.awt.Color.WHITE);
    chart.setBorderVisible(false);

    chartComposite = new ChartComposite2(parentTabFolder, SWT.NONE | SWT.EMBEDDED, chart, true);
    chartComposite.setLayout(new FillLayout());
    chartComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    chartComposite.setDomainZoomable(false);
    chartComposite.setRangeZoomable(false);
    chartComposite.setMap(map);
    chartComposite.addChartMouseListener(new PlotMouseListener());

    plotTab.setControl(chartComposite);

    chartComposite.pack();
}

From source file:charts.Chart.java

public static void ScatterPlot(XYSeriesCollection dataset, String title, String xAxisLabel, String yAxisLabel) {
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);
    XYToolTipGenerator toolTipGenerator = new StandardXYToolTipGenerator();
    XYURLGenerator urlGenerator = new StandardXYURLGenerator();
    XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true);//(boolean lines, boolean shapes)
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    //plot.setDataset(dataset);
    //plot.setDomainAxis(xAxis);
    //plot.setRangeAxis(yAxis);
    //plot.setRenderer(renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);//true==legend
    //INVERTER AS CORES DOS PONTOS E LEGENDA.
    if (dataset.getSeriesCount() > 1) {
        Shape s0 = plot.getLegendItems().get(0).getShape();
        Shape s1 = plot.getLegendItems().get(1).getShape();
        renderer.setSeriesShape(0, s1);/*from  ww  w  . j  a v  a2 s  .c  o  m*/
        renderer.setSeriesShape(1, s0);
        Paint p0 = plot.getLegendItems().get(0).getLinePaint();
        Paint p1 = plot.getLegendItems().get(1).getLinePaint();
        renderer.setSeriesPaint(0, p1);
        renderer.setSeriesPaint(1, p0);
    }
    //FIM DA INVERSAO.

    JFrame chartwindow = new JFrame(title);
    JPanel jpanel = new ChartPanel(chart);
    jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight));
    chartwindow.setContentPane(jpanel);
    chartwindow.pack();
    RefineryUtilities.centerFrameOnScreen(chartwindow);
    chartwindow.setVisible(true);
}

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 ww . j ava  2  s  . com*/
    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.locationtech.udig.processingtoolbox.tools.MoranScatterPlotDialog.java

private void createGraphTab(final CTabFolder parentTabFolder) {
    plotTab = new CTabItem(parentTabFolder, SWT.NONE);
    plotTab.setText(Messages.MoranScatterPlotDialog_Graph);

    XYPlot plot = new XYPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(java.awt.Color.WHITE);
    plot.setDomainPannable(false);/*from  w w  w.j  a  va  2s. c om*/
    plot.setRangePannable(false);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);

    JFreeChart chart = new JFreeChart(EMPTY, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    chart.setBackgroundPaint(java.awt.Color.WHITE);
    chart.setBorderVisible(false);

    chartComposite = new ChartComposite2(parentTabFolder, SWT.NONE | SWT.EMBEDDED, chart, true);
    chartComposite.setLayout(new FillLayout());
    chartComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    chartComposite.setDomainZoomable(false);
    chartComposite.setRangeZoomable(false);
    chartComposite.setMap(map);
    chartComposite.addChartMouseListener(new PlotMouseListener());

    plotTab.setControl(chartComposite);

    chartComposite.pack();
}

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

private void createGraphTab(final CTabFolder parentTabFolder) {
    plotTab = new CTabItem(parentTabFolder, SWT.NONE);
    plotTab.setText(Messages.ScatterPlotDialog_Graph);

    XYPlot plot = new XYPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(java.awt.Color.WHITE);
    plot.setDomainPannable(false);/*from w ww  .j  a  v a2 s .co m*/
    plot.setRangePannable(false);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);

    JFreeChart chart = new JFreeChart(EMPTY, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    chart.setBackgroundPaint(java.awt.Color.WHITE);
    chart.setBorderVisible(false);

    chartComposite = new ChartComposite3(parentTabFolder, SWT.NONE | SWT.EMBEDDED, chart, true);
    chartComposite.setLayout(new FillLayout());
    chartComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    chartComposite.setDomainZoomable(false);
    chartComposite.setRangeZoomable(false);
    chartComposite.setMap(map);
    chartComposite.addChartMouseListener(new PlotMouseListener());

    plotTab.setControl(chartComposite);

    chartComposite.pack();
}

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

private void updateChart(SimpleFeatureCollection features, String propertyName, String morani) {
    // 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   ww w .  ja v  a  2s .  c  o m*/
    plot.setRangePannable(false);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);

    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setDomainCrosshairLockedOnData(true);
    plot.setRangeCrosshairLockedOnData(true);
    plot.setDomainCrosshairPaint(java.awt.Color.CYAN);
    plot.setRangeCrosshairPaint(java.awt.Color.CYAN);

    plot.setDomainGridlinePaint(java.awt.Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(java.awt.Color.LIGHT_GRAY);

    // 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(propertyName); // ZScore
    xPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12));
    xPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 10));

    NumberAxis yPlotAxis = new NumberAxis("lagged " + propertyName); //$NON-NLS-1$
    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));
    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); // dot

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

    plot.setDataset(1, getLinePlotData(crossCenter));
    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
    String title = "Moran's I = " + morani; //$NON-NLS-1$
    java.awt.Font titleFont = new Font(fontData.getName(), fontStyle, 20);
    JFreeChart chart = new JFreeChart(title, titleFont, plot, false);
    chart.setBackgroundPaint(java.awt.Color.WHITE);
    chart.setBorderVisible(false);

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