[英]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.