[英]Java WorldWind : how to access AnalyticSurface on DragEvent
我正在将Java worldwind广泛用于在矩形扇区上显示数据的应用程序。 我希望能够将此数据拖到全球各地。 这种行为在世界风已经实施了的形状如SurfaceCircle (实现可移动 )通过证实BasicDragger 。
我正在尝试为AnalyticSurface实现这种行为(不实现Moveable)。 问题是DragSelectEvent .getTopObject向我返回了一个受保护的静态类,称为AnalyticSurface.ClampToGroundSurface ,而我的AnalyticSurface没有任何公共访问器。
总结一下:我创建了一个对象,并在3d地球渲染中显示了该对象,并且在此图形表示形式上发起的拖动事件返回了一个对象,该对象没有我自己对象的公共访问器,因此无法按照鼠标行为对其进行修改。
在WorldWind方面,这似乎是一个体系结构错误。 不使用反射,是否有办法访问链接到我的拖动事件的我自己的对象?
您需要做的就是扩展AnalyticSurface
并实现Movable
,然后可以使用BasicDragger
而不是编写自己的选择侦听器。
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));
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.