XYPlot:注释相对于 Y 轴放置不正确

XYPlot: Annotation is placed incorrectly with respect to Y axis

我有以下代码在鼠标单击事件的 XYPlot 中生成注释。

    _chartPanel.addChartMouseListener(new ChartMouseListener() {
        @Override
        public void chartMouseClicked(ChartMouseEvent cme) 
        {
            Rectangle2D dataArea = _chartPanel.getScreenDataArea();
            XYPlot plot = (XYPlot) cme.getChart().getPlot();
            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.BOTTOM);
            if (!xAxis.getRange().contains(x)) { 
                x = Double.NaN;                  
            }                
            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(Color.red);
            pt.setArrowPaint(Color.red);
            pt.setFont(_font);
            pt.setPaint(Color.red);
            plot.addAnnotation(pt);
        }

除 Y 轴外一切正常(请参见下面的示例)。当我点击系列点(红色箭头)时,注释出现在另一个地方(相对于 X 轴的位置是正确的,而相对于 Y 轴的位置不正确)。

当您调用 java2dToValue() 计算 y 值时,您为轴位置指定了 RectangleEdge.BOTTOM,但它应该是 RectangleEdge.LEFT