diff --git a/src/com/zebraimaging/ZebraInputHandler.java b/src/com/zebraimaging/ZebraInputHandler.java index 1e855876b8..a1a1e12d47 100644 --- a/src/com/zebraimaging/ZebraInputHandler.java +++ b/src/com/zebraimaging/ZebraInputHandler.java @@ -19,28 +19,28 @@ public class ZebraInputHandler extends AWTInputHandler /** All instantiations of this class are stored for internal retrieval. */ private static List instances = new ArrayList(); private static Timer repaintContextsTimer = null; - + final static TimerTask repaintContextsTask = new TimerTask() { - public void run() + public void run() { Iterator itr = instances.iterator(); while (itr.hasNext()) { - ZebraInputHandler h = itr.next(); + ZebraInputHandler h = itr.next(); if (h.NeedsRefresh() == true) { h.SetRefresh(false); h.getWorldWindow().redraw(); - } + } } } }; - + private long hwnd = 0; - private boolean arGL2Present = false; + private boolean arGL2Present = false; private boolean refresh = false; - + public ZebraInputHandler() { /** @@ -49,7 +49,7 @@ public ZebraInputHandler() * (b) Not using the Zebra integration tools. */ try - { + { System.loadLibrary("arGL2Integrator"); arGL2Present = true; instances.add(this); @@ -59,7 +59,7 @@ public ZebraInputHandler() { System.out.println("FAILED to load arGL2Integrator.dll"); } - + if (repaintContextsTimer == null) { repaintContextsTimer = new Timer(); @@ -68,21 +68,21 @@ public ZebraInputHandler() } private synchronized void SetRefresh(boolean value) - { + { refresh = value; } - + private synchronized boolean NeedsRefresh() { return refresh; } - + public void keyPressed(KeyEvent e) { boolean consumed = false; if (arGL2Present) consumed = zebraKeyPressed(getGLCanvasHandle(), e.getKeyCode()); - if (consumed == true) + if (consumed) e.consume(); else super.keyPressed(e); @@ -93,7 +93,7 @@ public void keyReleased(KeyEvent e) boolean consumed = false; if (arGL2Present) consumed = zebraKeyReleased(getGLCanvasHandle(), e.getKeyCode()); - if (consumed == true) + if (consumed) e.consume(); else super.keyReleased(e); @@ -104,7 +104,7 @@ public void mouseClicked(MouseEvent e) boolean consumed = false; if (arGL2Present) consumed = zebraMouseReleased(getGLCanvasHandle(), e.getButton(), e.getX(), e.getY()); - if (consumed == true) + if (consumed) e.consume(); else super.mouseClicked(e); @@ -115,7 +115,7 @@ public void mousePressed(MouseEvent e) boolean consumed = false; if (arGL2Present) consumed = zebraMousePressed(getGLCanvasHandle(), e.getButton(), e.getX(), e.getY()); - if (consumed == true) + if (consumed) e.consume(); else super.mousePressed(e); @@ -126,7 +126,7 @@ public void mouseReleased(MouseEvent e) boolean consumed = false; if (arGL2Present) consumed = zebraMouseReleased(getGLCanvasHandle(), e.getButton(), e.getX(), e.getY()); - if (consumed == true) + if (consumed) e.consume(); else super.mouseReleased(e); @@ -143,7 +143,7 @@ public void mouseDragged(MouseEvent e) boolean consumed = false; if (arGL2Present) consumed = zebraMouseMoved(getGLCanvasHandle(), button, e.getX(), e.getY()); - if (consumed == true) + if (consumed) e.consume(); else super.mouseDragged(e); @@ -154,7 +154,7 @@ public void mouseWheelMoved(MouseWheelEvent e) boolean consumed = false; if (arGL2Present) consumed = zebraMouseWheel(getGLCanvasHandle(), e.getWheelRotation()); - if (consumed == true) + if (consumed) e.consume(); else super.mouseWheelMoved(e); @@ -198,7 +198,7 @@ private static ZebraInputHandler getInstance(long hwnd) // Java static methods executed by arGL2Integrator.dll via JNI public static void forceRepaint(long hwnd) - { + { /** Force the instance of the ZebraViewInputHandler class to redraw it's associated OpenGL window. */ ZebraInputHandler h = getInstance(hwnd); if (h != null) diff --git a/src/gov/nasa/worldwind/Restorable.java b/src/gov/nasa/worldwind/Restorable.java index ea3d0c9eb5..669835be27 100644 --- a/src/gov/nasa/worldwind/Restorable.java +++ b/src/gov/nasa/worldwind/Restorable.java @@ -27,7 +27,7 @@ public interface Restorable /** * Returns an XML document string describing the object's state. This state can be restored later by calling * restoreState and passing the XML document. - * + * * @return an XML document string describing the object's state. */ String getRestorableState(); diff --git a/src/gov/nasa/worldwind/animation/AngleAnimator.java b/src/gov/nasa/worldwind/animation/AngleAnimator.java index 3125354726..b62b12a384 100644 --- a/src/gov/nasa/worldwind/animation/AngleAnimator.java +++ b/src/gov/nasa/worldwind/animation/AngleAnimator.java @@ -112,7 +112,7 @@ public Angle getEnd() /** * Get the {@link gov.nasa.worldwind.util.PropertyAccessor} in use by this animation - * + * * @return the {@link gov.nasa.worldwind.util.PropertyAccessor} in use by this animation */ public PropertyAccessor.AngleAccessor getPropertyAccessor() @@ -150,7 +150,5 @@ private Angle nextAngle(double interpolant) interpolant, this.begin, this.end); - - } } diff --git a/src/gov/nasa/worldwind/animation/AnimationController.java b/src/gov/nasa/worldwind/animation/AnimationController.java index 5eef377394..8d0d1ce603 100644 --- a/src/gov/nasa/worldwind/animation/AnimationController.java +++ b/src/gov/nasa/worldwind/animation/AnimationController.java @@ -84,7 +84,7 @@ public boolean stepAnimators() /** * Returns true if the controller has any active Animations - * + * * @return true if there are any active animations in this CompountAnimation */ public boolean hasActiveAnimation() diff --git a/src/gov/nasa/worldwind/animation/BasicAnimator.java b/src/gov/nasa/worldwind/animation/BasicAnimator.java index cff870e8a1..4ed8970ccf 100644 --- a/src/gov/nasa/worldwind/animation/BasicAnimator.java +++ b/src/gov/nasa/worldwind/animation/BasicAnimator.java @@ -27,7 +27,7 @@ public class BasicAnimator implements Animator /** * Constructs a BasicAnimator. Sets the Animator's Interpolator to - * null. + * null. */ public BasicAnimator() { diff --git a/src/gov/nasa/worldwind/animation/DoubleAnimator.java b/src/gov/nasa/worldwind/animation/DoubleAnimator.java index bb33a91405..444d8ad742 100644 --- a/src/gov/nasa/worldwind/animation/DoubleAnimator.java +++ b/src/gov/nasa/worldwind/animation/DoubleAnimator.java @@ -28,7 +28,7 @@ public DoubleAnimator(Interpolator interpolator, { this.interpolator = new ScheduledInterpolator(10000); } - + if (propertyAccessor == null) { String message = Logging.getMessage("nullValue.ViewPropertyAccessorIsNull"); @@ -90,5 +90,5 @@ public Double nextDouble(double interpolant) this.end); } - + } diff --git a/src/gov/nasa/worldwind/animation/PositionAnimator.java b/src/gov/nasa/worldwind/animation/PositionAnimator.java index 14645e7518..acc5fdceb3 100644 --- a/src/gov/nasa/worldwind/animation/PositionAnimator.java +++ b/src/gov/nasa/worldwind/animation/PositionAnimator.java @@ -14,7 +14,7 @@ */ public class PositionAnimator extends BasicAnimator { - + protected Position begin; protected Position end; protected final PropertyAccessor.PositionAccessor propertyAccessor; @@ -47,7 +47,7 @@ public PositionAnimator( this.end = end; this.propertyAccessor = propertyAccessor; } - + public void setBegin(Position begin) { this.begin = begin; diff --git a/src/gov/nasa/worldwind/animation/SmoothInterpolator.java b/src/gov/nasa/worldwind/animation/SmoothInterpolator.java index d6d9fbc499..456360d1cb 100644 --- a/src/gov/nasa/worldwind/animation/SmoothInterpolator.java +++ b/src/gov/nasa/worldwind/animation/SmoothInterpolator.java @@ -42,5 +42,5 @@ protected static double basicInterpolant(double interpolant, double startInterpo // ============== Helper Functions ======================= // // Map amount range [startAmount, stopAmount] to [0, 1] when amount is inside range. - + } diff --git a/src/gov/nasa/worldwind/awt/AWTInputHandler.java b/src/gov/nasa/worldwind/awt/AWTInputHandler.java index 8c4f78a581..032a5e8d49 100644 --- a/src/gov/nasa/worldwind/awt/AWTInputHandler.java +++ b/src/gov/nasa/worldwind/awt/AWTInputHandler.java @@ -246,62 +246,17 @@ public ViewInputHandler getViewInputHandler() public void keyTyped(KeyEvent keyEvent) { - if (this.wwd == null) - { - return; - } - - if (keyEvent == null) - { - return; - } - - this.callKeyTypedListeners(keyEvent); - - if (!keyEvent.isConsumed()) - { - this.wwd.getView().getViewInputHandler().keyTyped(keyEvent); - } + keyMethod(keyEvent, 1); } public void keyPressed(KeyEvent keyEvent) { - if (this.wwd == null) - { - return; - } - - if (keyEvent == null) - { - return; - } - - this.callKeyPressedListeners(keyEvent); - - if (!keyEvent.isConsumed()) - { - this.wwd.getView().getViewInputHandler().keyPressed(keyEvent); - } + keyMethod(keyEvent, 2); } public void keyReleased(KeyEvent keyEvent) { - if (this.wwd == null) - { - return; - } - - if (keyEvent == null) - { - return; - } - - this.callKeyReleasedListeners(keyEvent); - - if (!keyEvent.isConsumed()) - { - this.wwd.getView().getViewInputHandler().keyReleased(keyEvent); - } + keyMethod(keyEvent, 3); } public void mouseClicked(final MouseEvent mouseEvent) @@ -786,6 +741,44 @@ protected void callKeyTypedListeners(KeyEvent event) } } + private void keyMethod(KeyEvent keyEvent, int caseNumber) + { + if (this.wwd == null) + { + return; + } + + if (keyEvent == null) + { + return; + } + + switch (caseNumber) + { + case 1: + this.callKeyTypedListeners(keyEvent); + if (!keyEvent.isConsumed()) + { + this.wwd.getView().getViewInputHandler().keyTyped(keyEvent); + } + break; + case 2: + this.callKeyPressedListeners(keyEvent); + if (!keyEvent.isConsumed()) + { + this.wwd.getView().getViewInputHandler().keyPressed(keyEvent); + } + break; + case 3: + this.callKeyReleasedListeners(keyEvent); + if (!keyEvent.isConsumed()) + { + this.wwd.getView().getViewInputHandler().keyReleased(keyEvent); + } + break; + } + } + protected void callMousePressedListeners(MouseEvent event) { for (MouseListener listener : this.eventListeners.getListeners(MouseListener.class)) diff --git a/src/gov/nasa/worldwind/view/firstperson/FlyViewInputHandler.java b/src/gov/nasa/worldwind/view/firstperson/FlyViewInputHandler.java index 3637ad96a7..7755cb6916 100644 --- a/src/gov/nasa/worldwind/view/firstperson/FlyViewInputHandler.java +++ b/src/gov/nasa/worldwind/view/firstperson/FlyViewInputHandler.java @@ -76,7 +76,7 @@ public boolean inputActionPerformed(AbstractViewInputHandler inputHandler, KeyEv } return true; } - } + } AnimationController uiAnimControl = new AnimationController(); AnimationController gotoAnimControl = new AnimationController(); @@ -182,7 +182,7 @@ public FlyViewInputHandler() RollActionListener rollActionListener = new RollActionListener(); this.getAttributes().setActionListener( ViewInputAttributes.DEVICE_KEYBOARD, ViewInputAttributes.VIEW_ROLL_KEYS, rollActionListener); - + // Arrow Keys horizontal translate this.getAttributes().setValues(ViewInputAttributes.DEVICE_KEYBOARD, ViewInputAttributes.VIEW_HORIZONTAL_TRANS_KEYS,