Java WorldWind:如何访问DrageEvent上的AnalyticSurface

Java WorldWind:如何访问DrageEvent上的AnalyticSurface,java,reflection,protected,worldwind,Java,Reflection,Protected,Worldwind,我将Java worldwind广泛用于一个在矩形扇区上显示数据的应用程序。我希望能够在全球范围内拖动这些数据。这种行为已经在WorldWind中为形状(实现)实现,如中所示 我正在尝试为实现这样的行为(而不是实现Moveable)。问题是.getTopObject返回一个受保护的静态类,该类在没有公共访问器的情况下调用到我的AnalyticSurface 总而言之:我创建了一个对象,并在3d earth渲染中显示它,将启动的事件拖到该图形表示上会返回一个对象,该对象对我自己的对象没有公共访问器

我将Java worldwind广泛用于一个在矩形扇区上显示数据的应用程序。我希望能够在全球范围内拖动这些数据。这种行为已经在WorldWind中为形状(实现)实现,如中所示

我正在尝试为实现这样的行为(而不是实现Moveable)。问题是.getTopObject返回一个受保护的静态类,该类在没有公共访问器的情况下调用到我的AnalyticSurface

总而言之:我创建了一个对象,并在3d earth渲染中显示它,将启动的事件拖到该图形表示上会返回一个对象,该对象对我自己的对象没有公共访问器,因此无法按照鼠标行为对其进行修改


这似乎是WorldWind方面的一个架构错误。在不使用反射的情况下,是否有办法访问链接到拖动事件的我自己的对象?

您需要做的就是扩展
分析曲面
并实现
可移动
,然后您可以使用
基本标签
而不是编写自己的选择侦听器

public class DraggableAnalyticSurface extends AnalyticSurface implements Movable {
    @Override
    public Position getReferencePosition() {
        return this.referencePos;
    }

    @Override
    public void move(Position position) {
        // not needed by BasicDragger
    }

    @Override
    public void moveTo(Position position) {
        final double latDelta = this.referencePos.getLatitude().degrees
                                - position.getLatitude().degrees;
        final double lonDelta = this.referencePos.getLongitude().degrees
                                - position.getLongitude().degrees;

        final double newMinLat = this.sector.getMinLatitude().degrees - latDelta;
        final double newMinLon = this.sector.getMinLongitude().degrees - lonDelta;
        final double newMaxLat = this.sector.getMaxLatitude().degrees - latDelta;
        final double newMaxLon = this.sector.getMaxLongitude().degrees - lonDelta;

        this.setSector(Sector.fromDegrees(newMinLat, newMaxLat, newMinLon, newMaxLon));
    }
}

您只需扩展
AnalyticSurface
并实现
Movable
,然后就可以使用
BasicDragger
而不是编写自己的select侦听器

public class DraggableAnalyticSurface extends AnalyticSurface implements Movable {
    @Override
    public Position getReferencePosition() {
        return this.referencePos;
    }

    @Override
    public void move(Position position) {
        // not needed by BasicDragger
    }

    @Override
    public void moveTo(Position position) {
        final double latDelta = this.referencePos.getLatitude().degrees
                                - position.getLatitude().degrees;
        final double lonDelta = this.referencePos.getLongitude().degrees
                                - position.getLongitude().degrees;

        final double newMinLat = this.sector.getMinLatitude().degrees - latDelta;
        final double newMinLon = this.sector.getMinLongitude().degrees - lonDelta;
        final double newMaxLat = this.sector.getMaxLatitude().degrees - latDelta;
        final double newMaxLon = this.sector.getMaxLongitude().degrees - lonDelta;

        this.setSector(Sector.fromDegrees(newMinLat, newMaxLat, newMinLon, newMaxLon));
    }
}