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

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

Introduction

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

Prototype

public void setRangeCrosshairStroke(Stroke stroke) 

Source Link

Document

Sets the stroke used to draw the crosshairs (if visible) and sends a PlotChangeEvent to all registered listeners.

Usage

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 w w . ja v a  2s. c  om
 * @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);
}