Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key method #114

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions src/com/zebraimaging/ZebraInputHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ public class ZebraInputHandler extends AWTInputHandler
/** All instantiations of this class are stored for internal retrieval. */
private static List<ZebraInputHandler> instances = new ArrayList<ZebraInputHandler>();
private static Timer repaintContextsTimer = null;

final static TimerTask repaintContextsTask = new TimerTask()
{
public void run()
public void run()
{
Iterator<ZebraInputHandler> 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()
{
/**
Expand All @@ -49,7 +49,7 @@ public ZebraInputHandler()
* (b) Not using the Zebra integration tools.
*/
try
{
{
System.loadLibrary("arGL2Integrator");
arGL2Present = true;
instances.add(this);
Expand All @@ -59,7 +59,7 @@ public ZebraInputHandler()
{
System.out.println("FAILED to load arGL2Integrator.dll");
}

if (repaintContextsTimer == null)
{
repaintContextsTimer = new Timer();
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/gov/nasa/worldwind/Restorable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
* <code>restoreState</code> and passing the XML document.
*
*
* @return an XML document string describing the object's state.
*/
String getRestorableState();
Expand Down
4 changes: 1 addition & 3 deletions src/gov/nasa/worldwind/animation/AngleAnimator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -150,7 +150,5 @@ private Angle nextAngle(double interpolant)
interpolant,
this.begin,
this.end);


}
}
2 changes: 1 addition & 1 deletion src/gov/nasa/worldwind/animation/AnimationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public boolean stepAnimators()

/**
* Returns <code>true</code> if the controller has any active <code>Animations</code>
*
*
* @return true if there are any active animations in this <code>CompountAnimation</code>
*/
public boolean hasActiveAnimation()
Expand Down
2 changes: 1 addition & 1 deletion src/gov/nasa/worldwind/animation/BasicAnimator.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class BasicAnimator implements Animator

/**
* Constructs a <code>BasicAnimator</code>. Sets the <code>Animator</code>'s <code>Interpolator</code> to
* <code>null</code>.
* <code>null</code>.
*/
public BasicAnimator()
{
Expand Down
4 changes: 2 additions & 2 deletions src/gov/nasa/worldwind/animation/DoubleAnimator.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public DoubleAnimator(Interpolator interpolator,
{
this.interpolator = new ScheduledInterpolator(10000);
}

if (propertyAccessor == null)
{
String message = Logging.getMessage("nullValue.ViewPropertyAccessorIsNull");
Expand Down Expand Up @@ -90,5 +90,5 @@ public Double nextDouble(double interpolant)
this.end);
}


}
4 changes: 2 additions & 2 deletions src/gov/nasa/worldwind/animation/PositionAnimator.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
public class PositionAnimator extends BasicAnimator
{

protected Position begin;
protected Position end;
protected final PropertyAccessor.PositionAccessor propertyAccessor;
Expand Down Expand Up @@ -47,7 +47,7 @@ public PositionAnimator(
this.end = end;
this.propertyAccessor = propertyAccessor;
}

public void setBegin(Position begin)
{
this.begin = begin;
Expand Down
2 changes: 1 addition & 1 deletion src/gov/nasa/worldwind/animation/SmoothInterpolator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.

}
89 changes: 41 additions & 48 deletions src/gov/nasa/worldwind/awt/AWTInputHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public boolean inputActionPerformed(AbstractViewInputHandler inputHandler, KeyEv
}
return true;
}
}
}

AnimationController uiAnimControl = new AnimationController();
AnimationController gotoAnimControl = new AnimationController();
Expand Down Expand Up @@ -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,
Expand Down