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

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

Introduction

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

Prototype

public void setDomainCrosshairLockedOnData(boolean flag) 

Source Link

Document

Sets the flag indicating whether or not the domain crosshair should "lock-on" to actual data values.

Usage

From source file:org.griphyn.vdl.karajan.monitor.monitors.swing.GraphPanel.java

private void createChart() {
    chart = ChartFactory.createTimeSeriesChart(null, "Time", null, null, false, false, false);
    cp = new ChartPanel(chart);
    // avoid stretching fonts and such
    cp.setMaximumDrawWidth(Integer.MAX_VALUE);
    cp.setMaximumDrawHeight(Integer.MAX_VALUE);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(UIManager.getColor("TextField.background"));
    plot.setDomainCrosshairVisible(true);
    plot.setDomainCrosshairLockedOnData(false);
    cp.addChartMouseListener(this);
    cp.setLayout(new DummyLayoutManager());
    cp.add(toolTip = new JToolTip());
    toolTip.setVisible(false);//from  w ww. ja va  2s. co  m

    cp.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseExited(MouseEvent e) {
            disableToolTip();
        }
    });
    chart.addChangeListener(new ChartChangeListener() {
        @Override
        public void chartChanged(ChartChangeEvent e) {
            if (e.getType() == ChartChangeEventType.DATASET_UPDATED) {
                updateMaxRange();
                updateToolTipLocation();
            }
        }
    });

    for (String s : enabled) {
        addSeries(sampler.getSeries(s));
    }

    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    p.add(cp, BorderLayout.CENTER);
    legend = new JPanel();
    legend.setLayout(new FlowLayout());

    rebuildLegend();

    this.add(p, BorderLayout.CENTER);
    this.add(legend, BorderLayout.SOUTH);
}

From source file:my.electrochem.ElectrochemUI.java

private ChartPanel createChartPanel() {
    //creates a line chart object
    //returns the chart panel
    String chartTitle = "i-E curve";
    String xAxisLabel = "E (V)";
    String yAxisLabel = "i (A)";

    dataset1 = createEmptyDataset();/*from   w ww .j a v a2 s .  c  o  m*/

    JFreeChart chart = ChartFactory.createScatterPlot(chartTitle, xAxisLabel, yAxisLabel, dataset1);

    XYPlot plot = chart.getXYPlot();

    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setDomainCrosshairLockedOnData(false);
    plot.setRangeCrosshairLockedOnData(false);

    /*chart.addProgressListener(new ChartProgressListener() {
    @Override
    public void chartProgress(ChartProgressEvent cpe) {
        if (cpe.getType() == ChartProgressEvent.DRAWING_FINISHED) {
            //System.out.println("Click event!!");
            XYPlot xyPlot2 = cpe.getChart().getXYPlot();
            System.out.println("drawing finished");
            System.out.println("Xreal:"+xyPlot2.getDomainCrosshairValue()
                   +"Yreal:"+xyPlot2.getRangeCrosshairValue());
            if (click) {
                System.out.println("click true");
                if (x1 == -423.0) {
                    x1 = 0.0;
                    y1 = 0.0;
                            
                }
            
                if (x1 == 0.0 && y1 == 0.0) {
                    System.out.println("print 0,0");
                    click = true;
                    x1 = xyPlot2.getDomainCrosshairValue();
                    y1 = xyPlot2.getRangeCrosshairValue();
                    //xyPlot2.clearAnnotations();
                } else {
                    xyPlot2.clearAnnotations();
                    System.out.println("true-false");
                    click = false;
                    x1 = xyPlot2.getDomainCrosshairValue();
                    y1 = xyPlot2.getRangeCrosshairValue();
                }
                      
                             
            } else {
                System.out.println("click false");
               x2 = xyPlot2.getDomainCrosshairValue();
               y2 = xyPlot2.getRangeCrosshairValue();
               createLineAnn(xyPlot2, x1, y1, x2, y2);
               click = true;
           }
       }
       }
    });*/

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    // sets paint color for each series
    //renderer.setSeriesPaint(0, Color.RED);

    // sets thickness for series (using strokes)
    //renderer.setSeriesStroke(0, new BasicStroke(5.0f));
    renderer.setBaseLinesVisible(true);
    //renderer.setSeriesLinesVisible(0, true);

    //renderer.setBaseShapesFilled(true);
    renderer.setBaseShapesVisible(false);
    //srenderer.setDrawSeriesLineAsPath(false);

    plot.setOutlinePaint(Color.BLUE);
    plot.setOutlineStroke(new BasicStroke(2.0f));
    plot.setBackgroundPaint(Color.DARK_GRAY);

    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.BLACK);

    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.BLACK);

    plot.setRenderer(renderer);

    return new ChartPanel(chart);
}

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

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

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

From source file:org.trade.ui.chart.CandlestickChart.java

/**
 * Method createChart./*w  ww  . j av  a  2s . co  m*/
 * 
 * @param strategyData
 *            StrategyData
 * @param title
 *            String
 * @return JFreeChart
 */
private JFreeChart createChart(StrategyData strategyData, String title, Tradingday tradingday) {

    DateAxis dateAxis = new DateAxis("Date");
    dateAxis.setVerticalTickLabels(true);
    dateAxis.setDateFormatOverride(new SimpleDateFormat("dd/MM hh:mm"));
    dateAxis.setTickMarkPosition(DateTickMarkPosition.START);
    NumberAxis priceAxis = new NumberAxis("Price");
    priceAxis.setAutoRange(true);
    priceAxis.setAutoRangeIncludesZero(false);
    XYPlot pricePlot = new XYPlot(strategyData.getCandleDataset(), dateAxis, priceAxis,
            strategyData.getCandleDataset().getRenderer());
    pricePlot.setOrientation(PlotOrientation.VERTICAL);
    pricePlot.setDomainPannable(true);
    pricePlot.setRangePannable(true);
    pricePlot.setDomainCrosshairVisible(true);
    pricePlot.setDomainCrosshairLockedOnData(true);
    pricePlot.setRangeCrosshairVisible(true);
    pricePlot.setRangeCrosshairLockedOnData(true);
    pricePlot.setRangeGridlinePaint(new Color(204, 204, 204));
    pricePlot.setDomainGridlinePaint(new Color(204, 204, 204));
    pricePlot.setBackgroundPaint(Color.white);

    /*
     * Calculate the number of 15min segments in this trading day. i.e.
     * 6.5hrs/15min = 26 and there are a total of 96 = one day
     */

    int segments15min = (int) (tradingday.getClose().getTime() - tradingday.getOpen().getTime())
            / (1000 * 60 * 15);

    SegmentedTimeline segmentedTimeline = new SegmentedTimeline(SegmentedTimeline.FIFTEEN_MINUTE_SEGMENT_SIZE,
            segments15min, (96 - segments15min));

    Date startDate = tradingday.getOpen();
    Date endDate = tradingday.getClose();

    if (!strategyData.getCandleDataset().getSeries(0).isEmpty()) {
        startDate = ((CandleItem) strategyData.getCandleDataset().getSeries(0).getDataItem(0)).getPeriod()
                .getStart();
        startDate = TradingCalendar.getSpecificTime(tradingday.getOpen(), startDate);
        endDate = ((CandleItem) strategyData.getCandleDataset().getSeries(0)
                .getDataItem(strategyData.getCandleDataset().getSeries(0).getItemCount() - 1)).getPeriod()
                        .getStart();
        endDate = TradingCalendar.getSpecificTime(tradingday.getClose(), endDate);
    }

    segmentedTimeline.setStartTime(startDate.getTime());
    segmentedTimeline.addExceptions(getNonTradingPeriods(startDate, endDate, tradingday.getOpen(),
            tradingday.getClose(), segmentedTimeline));
    dateAxis.setTimeline(segmentedTimeline);

    // Build Combined Plot
    CombinedDomainXYPlot mainPlot = new CombinedDomainXYPlot(dateAxis);
    mainPlot.add(pricePlot, 4);

    int axixIndex = 0;
    int datasetIndex = 0;

    /*
     * Change the List of indicators so that the candle dataset is the first
     * one in the list. The main chart must be plotted first.
     */
    List<IndicatorDataset> indicators = new ArrayList<IndicatorDataset>(0);
    for (IndicatorDataset item : strategyData.getIndicators()) {
        if (IndicatorSeries.CandleSeries.equals(item.getType(0))) {
            indicators.add(item);
        }
    }
    for (IndicatorDataset item : strategyData.getIndicators()) {
        if (!IndicatorSeries.CandleSeries.equals(item.getType(0))) {
            indicators.add(item);
        }
    }
    for (int i = 0; i < indicators.size(); i++) {
        IndicatorDataset indicator = indicators.get(i);
        if (indicator.getDisplaySeries(0)) {

            if (indicator.getSubChart(0)) {
                String axisName = "Price";
                if (IndicatorSeries.CandleSeries.equals(indicator.getType(0))) {
                    axisName = ((CandleSeries) indicator.getSeries(0)).getSymbol();
                } else {
                    org.trade.dictionary.valuetype.IndicatorSeries code = org.trade.dictionary.valuetype.IndicatorSeries
                            .newInstance(indicator.getType(0));
                    axisName = code.getDisplayName();
                }
                NumberAxis subPlotAxis = new NumberAxis(axisName);
                subPlotAxis.setAutoRange(true);
                subPlotAxis.setAutoRangeIncludesZero(false);

                XYPlot subPlot = new XYPlot((XYDataset) indicator, dateAxis, subPlotAxis,
                        indicator.getRenderer());

                subPlot.setOrientation(PlotOrientation.VERTICAL);
                subPlot.setDomainPannable(true);
                subPlot.setRangePannable(true);
                subPlot.setDomainCrosshairVisible(true);
                subPlot.setDomainCrosshairLockedOnData(true);
                subPlot.setRangeCrosshairVisible(true);
                subPlot.setRangeCrosshairLockedOnData(true);
                subPlot.setRangeGridlinePaint(new Color(204, 204, 204));
                subPlot.setDomainGridlinePaint(new Color(204, 204, 204));
                subPlot.setBackgroundPaint(Color.white);
                XYItemRenderer renderer = subPlot.getRendererForDataset((XYDataset) indicator);
                for (int seriesIndex = 0; seriesIndex < ((XYDataset) indicator)
                        .getSeriesCount(); seriesIndex++) {
                    renderer.setSeriesPaint(seriesIndex, indicator.getSeriesColor(seriesIndex));
                }
                mainPlot.add(subPlot, 1);

            } else {
                datasetIndex++;
                pricePlot.setDataset(datasetIndex, (XYDataset) indicator);
                if (IndicatorSeries.CandleSeries.equals(indicator.getType(0))) {
                    // add secondary axis
                    axixIndex++;

                    final NumberAxis axis2 = new NumberAxis(
                            ((CandleSeries) indicator.getSeries(0)).getSymbol());
                    axis2.setAutoRange(true);
                    axis2.setAutoRangeIncludesZero(false);
                    pricePlot.setRangeAxis(datasetIndex, axis2);
                    pricePlot.setRangeAxisLocation(i + 1, AxisLocation.BOTTOM_OR_RIGHT);
                    pricePlot.mapDatasetToRangeAxis(datasetIndex, axixIndex);
                    pricePlot.setRenderer(datasetIndex, new StandardXYItemRenderer());
                } else {
                    pricePlot.setRenderer(datasetIndex, indicator.getRenderer());
                }
                XYItemRenderer renderer = pricePlot.getRendererForDataset((XYDataset) indicator);

                for (int seriesIndex = 0; seriesIndex < ((XYDataset) indicator)
                        .getSeriesCount(); seriesIndex++) {
                    renderer.setSeriesPaint(seriesIndex, indicator.getSeriesColor(seriesIndex));
                }
            }
        }
    }
    JFreeChart jfreechart = new JFreeChart(title, null, mainPlot, true);
    jfreechart.setAntiAlias(false);
    return jfreechart;
}

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  .  jav a 2  s. co 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();
}

From source file:com.android.ddmuilib.log.event.EventDisplay.java

Control createCompositeChart(final Composite parent, EventLogParser logParser, String title) {
    mChart = ChartFactory.createTimeSeriesChart(null, null /* timeAxisLabel */, null /* valueAxisLabel */,
            null, /* dataset. set below */
            true /* legend */, false /* tooltips */, false /* urls */);

    // get the font to make a proper title. We need to convert the swt font,
    // into an awt font.
    Font f = parent.getFont();//  w ww .  j a  va 2s  .  co m
    FontData[] fData = f.getFontData();

    // event though on Mac OS there could be more than one fontData, we'll only use
    // the first one.
    FontData firstFontData = fData[0];

    java.awt.Font awtFont = SWTUtils.toAwtFont(parent.getDisplay(), firstFontData, true /* ensureSameSize */);

    mChart.setTitle(new TextTitle(title, awtFont));

    final XYPlot xyPlot = mChart.getXYPlot();
    xyPlot.setRangeCrosshairVisible(true);
    xyPlot.setRangeCrosshairLockedOnData(true);
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setDomainCrosshairLockedOnData(true);

    mChart.addChangeListener(new ChartChangeListener() {
        @Override
        public void chartChanged(ChartChangeEvent event) {
            ChartChangeEventType type = event.getType();
            if (type == ChartChangeEventType.GENERAL) {
                // because the value we need (rangeCrosshair and domainCrosshair) are
                // updated on the draw, but the notification happens before the draw,
                // we process the click in a future runnable!
                parent.getDisplay().asyncExec(new Runnable() {
                    @Override
                    public void run() {
                        processClick(xyPlot);
                    }
                });
            }
        }
    });

    mChartComposite = new ChartComposite(parent, SWT.BORDER, mChart, ChartComposite.DEFAULT_WIDTH,
            ChartComposite.DEFAULT_HEIGHT, ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH,
            ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT, 3000, // max draw width. We don't want it to zoom, so we put a big number
            3000, // max draw height. We don't want it to zoom, so we put a big number
            true, // off-screen buffer
            true, // properties
            true, // save
            true, // print
            true, // zoom
            true); // tooltips

    mChartComposite.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent e) {
            mValueTypeDataSetMap.clear();
            mDataSetCount = 0;
            mOccurrenceDataSet = null;
            mChart = null;
            mChartComposite = null;
            mValueDescriptorSeriesMap.clear();
            mOcurrenceDescriptorSeriesMap.clear();
        }
    });

    return mChartComposite;

}

From source file:fi.smaa.jsmaa.gui.views.CriterionView.java

private JPanel buildValueFunctionChartPanel(ScaleCriterion criterion) {
    UtilityFunctionDataset dataset = new UtilityFunctionDataset(criterion);

    JFreeChart chart = ChartFactory.createXYLineChart("", "x", "v(x)", dataset, PlotOrientation.VERTICAL, false,
            true, true);//ww  w.  j  av a2  s  .co  m

    final XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(0, renderer);
    renderer.setSeriesPaint(0, Color.black);
    renderer.setSeriesShape(0, ShapeUtilities.createDiamond(3.0f));
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());

    ValueAxis rAxis = plot.getRangeAxis();
    rAxis.setAutoRange(false);
    rAxis.setRange(new Range(-0.03, 1.03));
    ValueAxis dAxis = plot.getDomainAxis();
    dAxis.setLowerMargin(0.03);
    dAxis.setUpperMargin(0.03);

    ChartPanel chartPanel = new ChartPanel(chart, false, true, true, false, true);
    chartPanel.addChartMouseListener(new ValueFunctionMouseListener(chartPanel, criterion, parent));

    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);
    chartPanel.setDisplayToolTips(true);
    chartPanel.setToolTipText("Click to add/remove partial value function points");
    chartPanel.setMouseWheelEnabled(false);
    chartPanel.setMouseZoomable(false);

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

    FormLayout layout = new FormLayout("left:pref", "p, 3dlu, p");

    PanelBuilder builder = new PanelBuilder(layout);
    CellConstraints cc = new CellConstraints();
    builder.add(chartPanel, cc.xy(1, 1));
    builder.add(new ValueFunctionPointsPanel(criterion), cc.xy(1, 3));

    return builder.getPanel();
}

From source file:com.att.aro.ui.view.diagnostictab.GraphPanel.java

private void setCrossHair(double crossHairValue) {
    // set the cross hair values of plot and sub-plots
    Plot mainplot = getAdvancedGraph().getPlot();
    if (mainplot instanceof CombinedDomainXYPlot) {
        combinedPlot = (CombinedDomainXYPlot) mainplot;
        List<?> plots = combinedPlot.getSubplots();
        for (Object p : plots) {
            if (p instanceof XYPlot) {
                XYPlot subPlot = (XYPlot) p;
                subPlot.setDomainCrosshairLockedOnData(false);
                subPlot.setDomainCrosshairValue(crossHairValue);
                subPlot.setDomainCrosshairVisible(true);
            }/*from  w ww.  j a  va2s  . c om*/
        }
        combinedPlot.setDomainCrosshairLockedOnData(false);
        combinedPlot.setDomainCrosshairValue(crossHairValue, true);
        combinedPlot.setDomainCrosshairVisible(true);
    }
    getHandlePanel().setHandlePosition(getHandleCoordinate());

}

From source file:ch.algotrader.client.chart.ChartTab.java

public void init(ChartDefinitionVO chartDefinition) {

    // remove all components first
    this.removeAll();

    resetPopupMenu();//  www  .j  av a  2  s. c om

    this.chartDefinition = chartDefinition;

    // create the plot
    XYPlot plot = new XYPlot();

    // add gridlines
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);

    // create the JFreeChart
    JFreeChart chart = new JFreeChart(plot);
    this.setChart(chart);

    // init the maps
    this.bars = new HashMap<>();
    this.indicators = new HashMap<>();
    this.markers = new HashMap<>();
    this.markersSelectionStatus = new HashMap<>();

    // init domain axis
    initDomainAxis(chartDefinition);

    // init range axis
    initRangeAxis(chartDefinition);

    // create a subtitle
    TextTitle title = new TextTitle();
    title.setFont(new Font("SansSerif", 0, 9));
    chart.addSubtitle(title);

    // crosshair
    plot.setDomainCrosshairVisible(true);
    plot.setDomainCrosshairLockedOnData(true);
    plot.setRangeCrosshairVisible(true);
    plot.setDomainCrosshairLockedOnData(true);
}