Skip to content

Commit

Permalink
Merge pull request NASAWorldWind#179 from NASAWorldWind/source-format…
Browse files Browse the repository at this point in the history
…ting

Update the code formatting to be more conformant
  • Loading branch information
Beak-man authored Sep 11, 2019
2 parents 41d51d0 + 077d596 commit 101b5bf
Show file tree
Hide file tree
Showing 1,821 changed files with 127,651 additions and 164,256 deletions.
216 changes: 102 additions & 114 deletions src/com/zebraimaging/ZebraInputHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,163 +14,158 @@
* not expected to create instances of this class directly or call its methods. To use it, specify it as the
* gov.nasa.worldwind.avkey.InputHandlerClassName in the WorldWind configuration file.
*/
public class ZebraInputHandler extends AWTInputHandler
{
/** All instantiations of this class are stored for internal retrieval. */
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()
{
Iterator<ZebraInputHandler> itr = instances.iterator();
while (itr.hasNext())
{
ZebraInputHandler h = itr.next();
if (h.NeedsRefresh() == true)
{
h.SetRefresh(false);
h.getWorldWindow().redraw();
}
}
}
};

private long hwnd = 0;
private boolean arGL2Present = false;

final static TimerTask repaintContextsTask = new TimerTask() {
public void run() {
Iterator<ZebraInputHandler> itr = instances.iterator();
while (itr.hasNext()) {
ZebraInputHandler h = itr.next();
if (h.NeedsRefresh() == true) {
h.SetRefresh(false);
h.getWorldWindow().redraw();
}
}
}
};

private long hwnd = 0;
private boolean arGL2Present = false;
private boolean refresh = false;

public ZebraInputHandler()
{

public ZebraInputHandler() {
/**
* Attempt to load zebraIntegrator. If it's not found, assume we're either:
* (a) Not connected to the Zebra UPSD Dynamic Display.
* (b) Not using the Zebra integration tools.
* Attempt to load zebraIntegrator. If it's not found, assume we're either: (a) Not connected to the Zebra UPSD
* Dynamic Display. (b) Not using the Zebra integration tools.
*/
try
{
try {
System.loadLibrary("arGL2Integrator");
arGL2Present = true;
instances.add(this);
System.out.println("Loaded arGL2Integrator successfully");
}
catch (UnsatisfiedLinkError e)
{
} catch (UnsatisfiedLinkError e) {
System.out.println("FAILED to load arGL2Integrator.dll");
}

if (repaintContextsTimer == null)
{
repaintContextsTimer = new Timer();
repaintContextsTimer.scheduleAtFixedRate(repaintContextsTask, 0, 10);

if (repaintContextsTimer == null) {
repaintContextsTimer = new Timer();
repaintContextsTimer.scheduleAtFixedRate(repaintContextsTask, 0, 10);
}
}

private synchronized void SetRefresh(boolean value)
{
refresh = value;
private synchronized void SetRefresh(boolean value) {
refresh = value;
}

private synchronized boolean NeedsRefresh()
{
return refresh;
}

public void keyPressed(KeyEvent e)
{

private synchronized boolean NeedsRefresh() {
return refresh;
}

public void keyPressed(KeyEvent e) {
boolean consumed = false;
if (arGL2Present)
if (arGL2Present) {
consumed = zebraKeyPressed(getGLCanvasHandle(), e.getKeyCode());
if (consumed == true)
}
if (consumed == true) {
e.consume();
else
} else {
super.keyPressed(e);
}
}

public void keyReleased(KeyEvent e)
{
public void keyReleased(KeyEvent e) {
boolean consumed = false;
if (arGL2Present)
if (arGL2Present) {
consumed = zebraKeyReleased(getGLCanvasHandle(), e.getKeyCode());
if (consumed == true)
}
if (consumed == true) {
e.consume();
else
} else {
super.keyReleased(e);
}
}

public void mouseClicked(MouseEvent e)
{
public void mouseClicked(MouseEvent e) {
boolean consumed = false;
if (arGL2Present)
if (arGL2Present) {
consumed = zebraMouseReleased(getGLCanvasHandle(), e.getButton(), e.getX(), e.getY());
if (consumed == true)
}
if (consumed == true) {
e.consume();
else
} else {
super.mouseClicked(e);
}
}

public void mousePressed(MouseEvent e)
{
public void mousePressed(MouseEvent e) {
boolean consumed = false;
if (arGL2Present)
if (arGL2Present) {
consumed = zebraMousePressed(getGLCanvasHandle(), e.getButton(), e.getX(), e.getY());
if (consumed == true)
}
if (consumed == true) {
e.consume();
else
} else {
super.mousePressed(e);
}
}

public void mouseReleased(MouseEvent e)
{
public void mouseReleased(MouseEvent e) {
boolean consumed = false;
if (arGL2Present)
if (arGL2Present) {
consumed = zebraMouseReleased(getGLCanvasHandle(), e.getButton(), e.getX(), e.getY());
if (consumed == true)
}
if (consumed == true) {
e.consume();
else
} else {
super.mouseReleased(e);
}
}

public void mouseDragged(MouseEvent e)
{
/** The mouseDragged event does not populate the button field of MouseEvent. Therefore it must be done manually. */
public void mouseDragged(MouseEvent e) {
/**
* The mouseDragged event does not populate the button field of MouseEvent. Therefore it must be done manually.
*/
int button = 0;
button = (e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) == InputEvent.BUTTON1_DOWN_MASK ? 1 : button;
button = (e.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) == InputEvent.BUTTON2_DOWN_MASK ? 2 : button;
button = (e.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) == InputEvent.BUTTON3_DOWN_MASK ? 3 : button;

boolean consumed = false;
if (arGL2Present)
if (arGL2Present) {
consumed = zebraMouseMoved(getGLCanvasHandle(), button, e.getX(), e.getY());
if (consumed == true)
}
if (consumed == true) {
e.consume();
else
} else {
super.mouseDragged(e);
}
}

public void mouseWheelMoved(MouseWheelEvent e)
{
public void mouseWheelMoved(MouseWheelEvent e) {
boolean consumed = false;
if (arGL2Present)
if (arGL2Present) {
consumed = zebraMouseWheel(getGLCanvasHandle(), e.getWheelRotation());
if (consumed == true)
}
if (consumed == true) {
e.consume();
else
} else {
super.mouseWheelMoved(e);
}
}

private long getGLCanvasHandle()
{
private long getGLCanvasHandle() {
/**
* Returns the win32 HWND handle of the GLCanvas component by calling native
* C++ code in arGL2Integrator.
* Returns the win32 HWND handle of the GLCanvas component by calling native C++ code in arGL2Integrator.
*/
if (hwnd == 0)
{
if (hwnd == 0) {
WorldWindow ww = this.getWorldWindow();
if (ww != null)
{
if (ww != null) {
WorldWindowGLCanvas wwgl = (WorldWindowGLCanvas) ww;
GLCanvas glc = wwgl;
Canvas cv = glc;
Expand All @@ -182,60 +177,53 @@ private long getGLCanvasHandle()
return hwnd;
}

private static ZebraInputHandler getInstance(long hwnd)
{
private static ZebraInputHandler getInstance(long hwnd) {
Iterator<ZebraInputHandler> itr = instances.iterator();
while (itr.hasNext())
{
while (itr.hasNext()) {
ZebraInputHandler h = itr.next();
if (h.hwnd == hwnd)
if (h.hwnd == hwnd) {
return h;
}
}

return null;
}

// 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. */
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)
{
h.SetRefresh(true);
//h.refresh = true;
if (h != null) {
h.SetRefresh(true);
//h.refresh = true;
}
}

public static double[] getModelviewMatrix(long hwnd)
{
public static double[] getModelviewMatrix(long hwnd) {
double[] matrix = new double[16];

ZebraInputHandler h = getInstance(hwnd);
if (h != null)
{
if (h != null) {
h.getWorldWindow().getView().getModelviewMatrix().toArray(matrix, 0, false);
}

return matrix;
}

public static double[] getProjectionMatrix(long hwnd)
{
public static double[] getProjectionMatrix(long hwnd) {
double[] matrix = new double[16];

ZebraInputHandler h = getInstance(hwnd);
if (h != null)
{
if (h != null) {
h.getWorldWindow().getView().getProjectionMatrix().toArray(matrix, 0, false);
}

return matrix;
}

// Methods imported from the zebra's arGL2Integrator.dll library and executed by java

public native boolean zebraKeyPressed(long hwnd, int keyCode);

public native boolean zebraKeyReleased(long hwnd, int keyCode);
Expand Down
16 changes: 8 additions & 8 deletions src/config/DataFileStore.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0"?>
<!--
~ Copyright (C) 2012 United States Government as represented by the Administrator of the
~ National Aeronautics and Space Administration.
~ All Rights Reserved.
-->
~ Copyright (C) 2012 United States Government as represented by the Administrator of the
~ National Aeronautics and Space Administration.
~ All Rights Reserved.
-->

<!--
~ WorldWind data-file store configuration
~
~ $Id: DataFileStore.xml 1171 2013-02-11 21:45:02Z dcollins $
-->
~ WorldWind data-file store configuration
~
~ $Id: DataFileStore.xml 1171 2013-02-11 21:45:02Z dcollins $
-->
<dataFileStore>
<readLocations>
<!-- The read locations are searched, in the given order, when WorldWind needs a data or image file. -->
Expand Down
8 changes: 4 additions & 4 deletions src/config/Earth/AlaskaFAASectionals.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2012 United States Government as represented by the Administrator of the
~ National Aeronautics and Space Administration.
~ All Rights Reserved.
-->
~ Copyright (C) 2012 United States Government as represented by the Administrator of the
~ National Aeronautics and Space Administration.
~ All Rights Reserved.
-->

<!--$Id: AlaskaFAASectionals.xml 2048 2014-06-09 16:39:45Z tgaskins $-->
<Layer version="1" layerType="TiledImageLayer">
Expand Down
8 changes: 4 additions & 4 deletions src/config/Earth/AsterWCS.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2012 United States Government as represented by the Administrator of the
~ National Aeronautics and Space Administration.
~ All Rights Reserved.
-->
~ Copyright (C) 2012 United States Government as represented by the Administrator of the
~ National Aeronautics and Space Administration.
~ All Rights Reserved.
-->

<!--$Id: AsterWCS.xml 2089 2014-06-24 21:39:21Z tgaskins $-->
<ElevationModel version="1" modelType="Compound">
Expand Down
8 changes: 4 additions & 4 deletions src/config/Earth/BMNG256.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2012 United States Government as represented by the Administrator of the
~ National Aeronautics and Space Administration.
~ All Rights Reserved.
-->
~ Copyright (C) 2012 United States Government as represented by the Administrator of the
~ National Aeronautics and Space Administration.
~ All Rights Reserved.
-->

<!--Blue Marble Next generation 2004 + Bathymetry imagery, using the default month (May).-->
<!--$Id: BMNG256.xml 1865 2014-03-13 21:00:05Z tgaskins $-->
Expand Down
Loading

0 comments on commit 101b5bf

Please sign in to comment.