List of usage examples for org.jfree.chart.plot CombinedDomainXYPlot setDomainCrosshairVisible
public void setDomainCrosshairVisible(boolean flag)
From source file:de.codesourcery.eve.skills.ui.components.impl.PriceHistoryComponent.java
private JPanel createFreeChartPanel2() { /*/* w w w. j a va2s.com*/ * Price plot. */ final StandardXYItemRenderer renderer1 = new StandardXYItemRenderer(); renderer1.setDrawSeriesLineAsPath(false); final ValueAxis priceAxis = new NumberAxis("ISK"); currentDataSets.pricePlot = new XYPlot(currentDataSets.prices, null, priceAxis, renderer1); currentDataSets.pricePlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); /* * Buy/sell volume plot. */ final StandardXYItemRenderer renderer2 = // XYBarRenderer new StandardXYItemRenderer(); final ValueAxis volumeAxis = new NumberAxis("Units"); TimeSeriesCollection volumes = new TimeSeriesCollection(); volumes.addSeries(currentDataSets.buyVolume); volumes.addSeries(currentDataSets.sellVolume); currentDataSets.volumePlot = new XYPlot(volumes, null, volumeAxis, renderer2); currentDataSets.volumePlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); /* * Combined plot. */ final ValueAxis dateAxis = new DateAxis("Date"); final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(dateAxis); plot.setGap(10.0); plot.add(currentDataSets.pricePlot, 2); plot.add(currentDataSets.volumePlot, 1); plot.setOrientation(PlotOrientation.VERTICAL); /* * Create chart. */ chart = new JFreeChart(item.getName(), JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd")); changeDateRange((DisplayRange) this.dateRangeChooser.getSelectedItem()); // display chart ChartPanel chartPanel = new ChartPanel(chart); // chartPanel.setMouseZoomable(true, false); return chartPanel; }
From source file:com.att.aro.diagnostics.GraphPanel.java
/** * Sets the Cross hair value./*from w w w . j a v a 2 s . c om*/ */ private void setCrossHair(double crossHairValue) { // set the cross hair values of plot and sub-plots Plot mainplot = advancedGraph.getPlot(); if (mainplot instanceof CombinedDomainXYPlot) { 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); } } combinedPlot.setDomainCrosshairLockedOnData(false); combinedPlot.setDomainCrosshairValue(crossHairValue, true); combinedPlot.setDomainCrosshairVisible(true); } handlePanel.setHandlePosition(getHandleCoordinate()); }