@Override public void chartMouseMoved(ChartMouseEventFX event) { Rectangle2D dataArea = this.chartViewer.getCanvas().getRenderingInfo().getPlotInfo().getDataArea(); JFreeChart chart = event.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis xAxis = plot.getDomainAxis(); double x = xAxis.java2DToValue(event.getTrigger().getX(), dataArea, RectangleEdge.BOTTOM); // make the crosshairs disappear if the mouse is out of range if (!xAxis.getRange().contains(x)) { x = Double.NaN; } double y = DatasetUtils.findYValue(plot.getDataset(), 0, x); this.xCrosshair.setValue(x); this.yCrosshair.setValue(y); }
public void dispatchMouseMovedEvent(Point2D point, MouseEvent e) { double x = point.getX(); double y = point.getY(); ChartEntity entity = this.info.getEntityCollection().getEntity(x, y); ChartMouseEventFX event = new ChartMouseEventFX(this.chart, e, entity); for (ChartMouseListenerFX listener : this.chartMouseListeners) { listener.chartMouseMoved(event); } }
public void dispatchMouseClickedEvent(Point2D point, MouseEvent e) { double x = point.getX(); double y = point.getY(); ChartEntity entity = this.info.getEntityCollection().getEntity(x, y); ChartMouseEventFX event = new ChartMouseEventFX(this.chart, e, entity); for (ChartMouseListenerFX listener : this.chartMouseListeners) { listener.chartMouseClicked(event); } }
@Override public void chartMouseClicked(ChartMouseEventFX event) { // relay the event from the canvas to our registered listeners for (ChartMouseListenerFX listener: this.chartMouseListeners) { listener.chartMouseClicked(event); } }
@Override public void chartMouseMoved(ChartMouseEventFX event) { // relay the event from the canvas to our registered listeners for (ChartMouseListenerFX listener: this.chartMouseListeners) { listener.chartMouseMoved(event); } }
@Override public void chartMouseClicked(ChartMouseEventFX event) { // ignore }
/** * Write the event to the console, just to illustrate. * * @param event event info. */ @Override public void chartMouseClicked(ChartMouseEventFX event) { System.out.println(event); }
/** * Write the event to the console, just to illustrate. * * @param event event info. */ @Override public void chartMouseMoved(ChartMouseEventFX event) { System.out.println(event); }