java - How to convert ChartPanel Coordinates to XYPlot coordinates in JFreeChart -


I have a chartpanel with all the lists executed on it. On the event of mouse dragging, I would like to show my comment to the dragging action I'm changing coordinates. It's working fine, but the coordinates are a bit messy. Actually, I am getting coordinated which is in the context of the chart panel, which is then being converted into axis values ​​of the xyplate, because the annotations come to a strange location Has been there.

You MouseEvent to XY java2dToValue () .

Using the , the chart coordinates need to be synced. ChartPanel Mouse Handling Code

  Rectangle2D Datera = Chart Panel .getChartRenderingInfo (). GetPlotInfo () GetDataArea (); XYPlot xyPlot = chartPanel.getChart (). GetXYPlot (); // event stores a mouseAvent function / mouse event from a single location, and it later places JavaScript in place of java.awt.Point clickLocation = new Point (event.getX (), event.getY ()) ;  

Annotation code

  double x = xyPlot.getDomainAxis (). Java2dToValue (clickLocation.getX (), DataAiria, xyPlot .getDomainAxisEdge ()); Double y = xyPlot.getRangeAxis () Java2dToValue (clickLocation.getY), DataAiria, xyPlot.getRangeAxisEdge ()); String Text = DoubleTrestring (x) + "" + Double. Toasting (Y); XYText annotation annotation = new XYText annotation (text, x, y); Plot.addAnnotation (comment);  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -