📄 orbitviewinputsupport.java
字号:
return pitch;
}
private static double limitZoom(double zoom, OrbitViewLimits viewLimits)
{
zoom = normalizedZoom(zoom);
zoom = BasicOrbitViewLimits.limitZoom(zoom, viewLimits);
return zoom;
}
private static double normalizedZoom(double unnormalizedZoom)
{
return unnormalizedZoom < 0 ? -1 : unnormalizedZoom;
}
public double getCenterMinEpsilon()
{
return this.centerMinEpsilon;
}
public void setCenterMinEpsilon(double centerMinEpsilon)
{
if (centerMinEpsilon < 0)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", centerMinEpsilon);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.centerMinEpsilon = centerMinEpsilon;
}
public double getHeadingMinEpsilon()
{
return headingMinEpsilon;
}
public void setHeadingMinEpsilon(double headingMinEpsilon)
{
if (headingMinEpsilon < 0)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", headingMinEpsilon);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.headingMinEpsilon = headingMinEpsilon;
}
public double getPitchMinEpsilon()
{
return this.pitchMinEpsilon;
}
public void setPitchMinEpsilon(double pitchMinEpsilon)
{
if (pitchMinEpsilon < 0)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", pitchMinEpsilon);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.pitchMinEpsilon = pitchMinEpsilon;
}
public double getZoomMinEpsilon()
{
return this.zoomMinEpsilon;
}
public void setZoomMinEpsilon(double zoomMinEpsilon)
{
if (zoomMinEpsilon < 0)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", zoomMinEpsilon);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.zoomMinEpsilon = zoomMinEpsilon;
}
public double getCenterSmoothing()
{
return this.centerSmoothing;
}
public void setCenterSmoothing(double centerSmoothing)
{
if (centerSmoothing < 0 || centerSmoothing > 1)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", centerSmoothing);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.centerSmoothing = centerSmoothing;
}
public double getHeadingSmoothing()
{
return this.headingSmoothing;
}
public void setHeadingSmoothing(double headingSmoothing)
{
if (headingSmoothing < 0 || headingSmoothing > 1)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", headingSmoothing);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.headingSmoothing = headingSmoothing;
}
public double getPitchSmoothing()
{
return this.pitchSmoothing;
}
public void setPitchSmoothing(double pitchSmoothing)
{
if (pitchSmoothing < 0 || pitchSmoothing > 1)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", pitchSmoothing);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.pitchSmoothing = pitchSmoothing;
}
public double getZoomSmoothing()
{
return this.zoomSmoothing;
}
public void setZoomSmoothing(double zoomSmoothing)
{
if (zoomSmoothing < 0 || zoomSmoothing > 1)
{
String message = Logging.getMessage("generic.ArgumentOutOfRange", zoomSmoothing);
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.zoomSmoothing = zoomSmoothing;
}
public void moveViewTowardTargets(OrbitView view)
{
if (view == null)
return;
// Clear any locally tracked view state.
isViewChanged();
isTargetStopped();
if (this.centerTarget != null)
moveTowardCenterTarget(view);
if (this.headingTarget != null)
moveTowardHeadingTarget(view);
if (this.pitchTarget != null)
moveTowardPitchTarget(view);
if (this.zoomTarget >= 0)
moveTowardZoomTarget(view);
refreshView(view);
if (isTargetStopped() && !hasTargets())
{
if (isViewOutOfFocus())
focusView(view);
clearTargets();
view.firePropertyChange(AVKey.VIEW_QUIET, null, view);
}
}
private void moveTowardCenterTarget(OrbitView view)
{
Position nextCenter = this.centerTarget;
Position curCenter = view.getCenterPosition();
double latlonDifference = LatLon.greatCircleDistance(nextCenter, curCenter).degrees;
double elevDifference = Math.abs(nextCenter.getElevation() - curCenter.getElevation());
boolean stopMoving = Math.max(latlonDifference, elevDifference) < this.centerMinEpsilon;
if (!stopMoving)
{
double interpolant = 1 - this.centerSmoothing;
nextCenter = new Position(
Angle.mix(interpolant, curCenter.getLatitude(), this.centerTarget.getLatitude()),
Angle.mix(interpolant, curCenter.getLongitude(), this.centerTarget.getLongitude()),
(1 - interpolant) * curCenter.getElevation() + interpolant * this.centerTarget.getElevation());
}
try
{
// Clear any previous collision state the view may have.
view.hadCollisions();
view.setCenterPosition(nextCenter);
// If the change caused a collision, update the target center position with the
// elevation that resolved the collision.
if (view.hadCollisions())
this.centerTarget = new Position(
this.centerTarget, view.getCenterPosition().getElevation());
flagViewChanged();
setViewOutOfFocus(true);
}
catch (Exception e)
{
String message = Logging.getMessage("generic.ExceptionWhileChangingView");
Logging.logger().log(java.util.logging.Level.SEVERE, message, e);
stopMoving = true;
}
// If target is close, cancel future value changes.
if (stopMoving)
{
this.centerTarget = null;
flagTargetStopped();
}
}
private void moveTowardHeadingTarget(OrbitView view)
{
Angle nextHeading = this.headingTarget;
Angle curHeading = view.getHeading();
double difference = Math.abs(nextHeading.subtract(curHeading).degrees);
boolean stopMoving = difference < this.headingMinEpsilon;
if (!stopMoving)
{
double interpolant = 1 - this.headingSmoothing;
nextHeading = Angle.mix(interpolant, curHeading, this.headingTarget);
}
try
{
view.setHeading(nextHeading);
flagViewChanged();
}
catch (Exception e)
{
String message = Logging.getMessage("generic.ExceptionWhileChangingView");
Logging.logger().log(java.util.logging.Level.SEVERE, message, e);
stopMoving = true;
}
// If target is close, cancel future value changes.
if (stopMoving)
{
this.headingTarget = null;
flagTargetStopped();
}
}
private void moveTowardPitchTarget(OrbitView view)
{
Angle nextPitch = this.pitchTarget;
Angle curPitch = view.getPitch();
double difference = Math.abs(nextPitch.subtract(curPitch).degrees);
boolean stopMoving = difference < this.pitchMinEpsilon;
if (!stopMoving)
{
double interpolant = 1 - this.pitchSmoothing;
nextPitch = Angle.mix(interpolant, curPitch, this.pitchTarget);
}
try
{
// Clear any previous collision state the view may have.
view.hadCollisions();
view.setPitch(nextPitch);
// If the change caused a collision, cancel future pitch changes.
if (view.hadCollisions())
stopMoving = true;
flagViewChanged();
}
catch (Exception e)
{
String message = Logging.getMessage("generic.ExceptionWhileChangingView");
Logging.logger().log(java.util.logging.Level.SEVERE, message, e);
stopMoving = true;
}
// If target is close, cancel future value changes.
if (stopMoving)
{
this.pitchTarget = null;
flagTargetStopped();
}
}
private void moveTowardZoomTarget(OrbitView view)
{
double nextZoom = this.zoomTarget;
double curZoom = view.getZoom();
double difference = Math.abs(nextZoom - curZoom);
boolean stopMoving = difference < this.zoomMinEpsilon;
if (!stopMoving)
{
double interpolant = 1 - this.zoomSmoothing;
nextZoom = (1 - interpolant) * curZoom + interpolant * this.zoomTarget;
}
try
{
view.setZoom(nextZoom);
flagViewChanged();
}
catch (Exception e)
{
String message = Logging.getMessage("generic.ExceptionWhileChangingView");
Logging.logger().log(java.util.logging.Level.SEVERE, message, e);
stopMoving = true;
}
// If target is close, cancel future value changes.
if (stopMoving)
{
this.zoomTarget = -1;
flagTargetStopped();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -