Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _chartPanel.addChartMouseListener(new ChartMouseListener() {
- @Override
- public void chartMouseClicked(ChartMouseEvent cme)
- {
- MouseEvent me = cme.getTrigger();
- XYPlot plot = (XYPlot) cme.getChart().getPlot();
- if (me.getClickCount() == 2)
- {
- plot.clearAnnotations();
- }
- else
- {
- Rectangle2D dataArea = _chartPanel.getScreenDataArea();
- plot.clearAnnotations();
- ValueAxis xAxis = plot.getDomainAxis();
- ValueAxis yAxis = plot.getRangeAxis();
- double x = xAxis.java2DToValue(cme.getTrigger().getX(), dataArea, RectangleEdge.BOTTOM);
- double y = yAxis.java2DToValue(cme.getTrigger().getY(), dataArea, RectangleEdge.LEFT);
- if (!xAxis.getRange().contains(x)) {
- x = Double.NaN;
- //int seriesId = ???;
- DecimalFormat df = new DecimalFormat("#.##");
- df.setRoundingMode(RoundingMode.CEILING);
- XYPointerAnnotation pt = new XYPointerAnnotation("Lat: " + df.format(y) + "n Lon: " + df.format(x), x, y, 0.2);
- pt.setBackgroundPaint(new Color(103,154,236));
- // pt.setArrowPaintnew Color(103,154,236)d);
- pt.setFont(_font);
- pt.setPaint(Color.LIGHT_GRAY);
- plot.addAnnotation(pt);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement