Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. _chartPanel.addChartMouseListener(new ChartMouseListener() {
  2. @Override
  3. public void chartMouseClicked(ChartMouseEvent cme)
  4. {
  5. MouseEvent me = cme.getTrigger();
  6. XYPlot plot = (XYPlot) cme.getChart().getPlot();
  7. if (me.getClickCount() == 2)
  8. {
  9. plot.clearAnnotations();
  10. }
  11. else
  12. {
  13. Rectangle2D dataArea = _chartPanel.getScreenDataArea();
  14. plot.clearAnnotations();
  15. ValueAxis xAxis = plot.getDomainAxis();
  16. ValueAxis yAxis = plot.getRangeAxis();
  17. double x = xAxis.java2DToValue(cme.getTrigger().getX(), dataArea, RectangleEdge.BOTTOM);
  18. double y = yAxis.java2DToValue(cme.getTrigger().getY(), dataArea, RectangleEdge.LEFT);
  19. if (!xAxis.getRange().contains(x)) {
  20. x = Double.NaN;
  21.  
  22. //int seriesId = ???;
  23.  
  24. DecimalFormat df = new DecimalFormat("#.##");
  25. df.setRoundingMode(RoundingMode.CEILING);
  26. XYPointerAnnotation pt = new XYPointerAnnotation("Lat: " + df.format(y) + "n Lon: " + df.format(x), x, y, 0.2);
  27. pt.setBackgroundPaint(new Color(103,154,236));
  28. // pt.setArrowPaintnew Color(103,154,236)d);
  29. pt.setFont(_font);
  30. pt.setPaint(Color.LIGHT_GRAY);
  31. plot.addAnnotation(pt);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement