diff --git a/src/gov/nasa/worldwind/AbstractSceneController.java b/src/gov/nasa/worldwind/AbstractSceneController.java index 8af10b509..23e057b6a 100644 --- a/src/gov/nasa/worldwind/AbstractSceneController.java +++ b/src/gov/nasa/worldwind/AbstractSceneController.java @@ -2,25 +2,25 @@ * Copyright 2006-2009, 2017, 2020 United States Government, as represented by the * Administrator of the National Aeronautics and Space Administration. * All rights reserved. - * + * * The NASA World Wind Java (WWJ) platform is licensed under the Apache License, * Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software distributed * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. - * + * * NASA World Wind Java (WWJ) also contains the following 3rd party Open Source * software: - * + * * Jackson Parser – Licensed under Apache 2.0 * GDAL – Licensed under MIT * JOGL – Licensed under Berkeley Software Distribution (BSD) * Gluegen – Licensed under Berkeley Software Distribution (BSD) - * + * * A complete listing of 3rd Party software notices and licenses included in * NASA World Wind Java (WWJ) can be found in the WorldWindJava-v2.2 3rd-party * notices and licenses PDF found in code directory. @@ -112,7 +112,7 @@ public AbstractSceneController() } @Override - public void reinitialize() + public void reinitialize() { if (this.textRendererCache != null) this.textRendererCache.dispose(); @@ -121,7 +121,7 @@ public void reinitialize() /** Releases resources associated with this scene controller. */ @Override - public void dispose() + public void dispose() { if (this.lastPickedObjects != null) this.lastPickedObjects.clear(); @@ -139,13 +139,13 @@ public void dispose() } @Override - public GpuResourceCache getGpuResourceCache() + public GpuResourceCache getGpuResourceCache() { return this.gpuResourceCache; } @Override - public void setGpuResourceCache(GpuResourceCache gpuResourceCache) + public void setGpuResourceCache(GpuResourceCache gpuResourceCache) { this.gpuResourceCache = gpuResourceCache; } @@ -156,19 +156,19 @@ public TextRendererCache getTextRendererCache() } @Override - public Model getModel() + public Model getModel() { return this.model; } @Override - public View getView() + public View getView() { return this.view; } @Override - public void setModel(Model model) + public void setModel(Model model) { if (this.model != null) this.model.removePropertyChangeListener(this); @@ -181,7 +181,7 @@ public void setModel(Model model) } @Override - public void setView(View view) + public void setView(View view) { if (this.view != null) this.view.removePropertyChangeListener(this); @@ -195,7 +195,7 @@ public void setView(View view) } @Override - public void setVerticalExaggeration(double verticalExaggeration) + public void setVerticalExaggeration(double verticalExaggeration) { Double oldVE = this.verticalExaggeration; this.verticalExaggeration = verticalExaggeration; @@ -203,42 +203,42 @@ public void setVerticalExaggeration(double verticalExaggeration) } @Override - public double getVerticalExaggeration() + public double getVerticalExaggeration() { return this.verticalExaggeration; } /** {@inheritDoc} */ @Override - public void setPickPoint(Point pickPoint) + public void setPickPoint(Point pickPoint) { - this.pickPoint = pickPoint; + this.pickPoint = pickPoint; } /** {@inheritDoc} */ @Override - public Point getPickPoint() + public Point getPickPoint() { return this.pickPoint; } /** {@inheritDoc} */ @Override - public void setPickRectangle(Rectangle pickRect) + public void setPickRectangle(Rectangle pickRect) { this.pickRect = pickRect; } /** {@inheritDoc} */ @Override - public Rectangle getPickRectangle() + public Rectangle getPickRectangle() { return this.pickRect; } /** {@inheritDoc} */ @Override - public PickedObjectList getPickedObjectList() + public PickedObjectList getPickedObjectList() { return this.lastPickedObjects; } @@ -250,49 +250,49 @@ protected void setPickedObjectList(PickedObjectList pol) /** {@inheritDoc} */ @Override - public PickedObjectList getObjectsInPickRectangle() + public PickedObjectList getObjectsInPickRectangle() { return this.lastObjectsInPickRect; } @Override - public void setDeepPickEnabled(boolean tf) + public void setDeepPickEnabled(boolean tf) { this.deepPick = tf; } @Override - public boolean isDeepPickEnabled() + public boolean isDeepPickEnabled() { return this.deepPick; } @Override - public SectorGeometryList getTerrain() + public SectorGeometryList getTerrain() { return this.dc.getSurfaceGeometry(); } @Override - public DrawContext getDrawContext() + public DrawContext getDrawContext() { return this.dc; } @Override - public double getFramesPerSecond() + public double getFramesPerSecond() { return this.framesPerSecond; } @Override - public double getFrameTime() + public double getFrameTime() { return this.frameTime; } @Override - public void setPerFrameStatisticsKeys(Set<String> keys) + public void setPerFrameStatisticsKeys(Set<String> keys) { this.perFrameStatisticsKeys.clear(); if (keys == null) @@ -306,39 +306,39 @@ public void setPerFrameStatisticsKeys(Set<String> keys) } @Override - public Collection<PerformanceStatistic> getPerFrameStatistics() + public Collection<PerformanceStatistic> getPerFrameStatistics() { return perFrameStatistics; } @Override - public Collection<Throwable> getRenderingExceptions() + public Collection<Throwable> getRenderingExceptions() { return this.renderingExceptions; } @Override - public ScreenCreditController getScreenCreditController() + public ScreenCreditController getScreenCreditController() { return screenCreditController; } @Override - public void setScreenCreditController(ScreenCreditController screenCreditController) + public void setScreenCreditController(ScreenCreditController screenCreditController) { this.screenCreditController = screenCreditController; } /** {@inheritDoc} */ @Override - public GLRuntimeCapabilities getGLRuntimeCapabilities() + public GLRuntimeCapabilities getGLRuntimeCapabilities() { return this.glRuntimeCaps; } /** {@inheritDoc} */ @Override - public void setGLRuntimeCapabilities(GLRuntimeCapabilities capabilities) + public void setGLRuntimeCapabilities(GLRuntimeCapabilities capabilities) { if (capabilities == null) { @@ -441,7 +441,7 @@ public void setDeferOrderedRendering(boolean deferOrderedRendering) } @Override - public int repaint() + public int repaint() { this.frameTime = System.currentTimeMillis(); @@ -665,8 +665,8 @@ protected void preRender(DrawContext dc) protected void pickTerrain(DrawContext dc) { - if (dc.isPickingMode() && dc.getVisibleSector() != null && dc.getSurfaceGeometry() != null && - dc.getSurfaceGeometry().size() > 0) + if (dc.isPickingMode() && dc.getVisibleSector() != null && dc.getSurfaceGeometry() != null + && dc.getSurfaceGeometry().size() > 0) { this.pickPoints.clear(); if (dc.getPickPoint() != null) @@ -787,7 +787,10 @@ else if (pol != null && pol.size() > 1) // used to cull the number of colors that the draw context must consider with identifying the unique // pick colors in the specified screen rectangle. if (minAndMaxColorCodes == null) - minAndMaxColorCodes = new int[] {colorCode, colorCode}; + minAndMaxColorCodes = new int[] + { + colorCode, colorCode + }; else { if (minAndMaxColorCodes[0] > colorCode) @@ -839,8 +842,8 @@ protected void pick(DrawContext dc) this.lastPickedObjects = new PickedObjectList(dc.getPickedObjects()); this.lastObjectsInPickRect = new PickedObjectList(dc.getObjectsInPickRectangle()); - if (this.isDeepPickEnabled() && - (this.lastPickedObjects.hasNonTerrainObjects() || this.lastObjectsInPickRect.hasNonTerrainObjects())) + if (this.isDeepPickEnabled() + && (this.lastPickedObjects.hasNonTerrainObjects() || this.lastObjectsInPickRect.hasNonTerrainObjects())) { this.doDeepPick(dc); } @@ -987,8 +990,8 @@ protected void draw(DrawContext dc) dc.setOrderedRenderingMode(false); // Draw the diagnostic displays. - if (dc.getSurfaceGeometry() != null && dc.getModel() != null && (dc.getModel().isShowWireframeExterior() || - dc.getModel().isShowWireframeInterior() || dc.getModel().isShowTessellationBoundingVolumes())) + if (dc.getSurfaceGeometry() != null && dc.getModel() != null && (dc.getModel().isShowWireframeExterior() + || dc.getModel().isShowWireframeInterior() || dc.getModel().isShowTessellationBoundingVolumes())) { Model model = dc.getModel(); @@ -1039,7 +1042,6 @@ protected void checkGLErrors(DrawContext dc) //**************************************************************// //******************** Ordered Surface Renderable ************// //**************************************************************// - protected void preRenderOrderedSurfaceRenderables(DrawContext dc) { if (dc.getOrderedSurfaceRenderables().isEmpty()) @@ -1154,9 +1156,9 @@ protected void drawCompositeSurfaceObjects(DrawContext dc) if (tileCount == 0) return; - int attributeMask = - GL2.GL_COLOR_BUFFER_BIT // For alpha test enable, blend enable, alpha func, blend func, blend ref. - | GL2.GL_POLYGON_BIT; // For cull face enable, cull face, polygon mode. + int attributeMask + = GL2.GL_COLOR_BUFFER_BIT // For alpha test enable, blend enable, alpha func, blend func, blend ref. + | GL2.GL_POLYGON_BIT; // For cull face enable, cull face, polygon mode. GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. OGLStackHandler ogsh = new OGLStackHandler(); diff --git a/src/gov/nasa/worldwind/WorldWindowImpl.java b/src/gov/nasa/worldwind/WorldWindowImpl.java index 7a7ca29e1..d375bcba2 100644 --- a/src/gov/nasa/worldwind/WorldWindowImpl.java +++ b/src/gov/nasa/worldwind/WorldWindowImpl.java @@ -2,25 +2,25 @@ * Copyright 2006-2009, 2017, 2020 United States Government, as represented by the * Administrator of the National Aeronautics and Space Administration. * All rights reserved. - * + * * The NASA World Wind Java (WWJ) platform is licensed under the Apache License, * Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software distributed * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. - * + * * NASA World Wind Java (WWJ) also contains the following 3rd party Open Source * software: - * + * * Jackson Parser – Licensed under Apache 2.0 * GDAL – Licensed under MIT * JOGL – Licensed under Berkeley Software Distribution (BSD) * Gluegen – Licensed under Berkeley Software Distribution (BSD) - * + * * A complete listing of 3rd Party software notices and licenses included in * NASA World Wind Java (WWJ) can be found in the WorldWindJava-v2.2 3rd-party * notices and licenses PDF found in code directory. @@ -68,7 +68,7 @@ public WorldWindowImpl() * called. An OpenGL context for the window must be current. */ @Override - public void shutdown() + public void shutdown() { WorldWind.getDataFileStore().removePropertyChangeListener(this); @@ -105,7 +105,7 @@ public void shutdown() } @Override - public GpuResourceCache getGpuResourceCache() + public GpuResourceCache getGpuResourceCache() { return this.gpuResourceCache; } @@ -117,7 +117,7 @@ public void setGpuResourceCache(GpuResourceCache gpuResourceCache) } @Override - public void setModel(Model model) + public void setModel(Model model) { // model can be null, that's ok - it indicates no model. if (this.sceneController != null) @@ -125,13 +125,13 @@ public void setModel(Model model) } @Override - public Model getModel() + public Model getModel() { return this.sceneController != null ? this.sceneController.getModel() : null; } @Override - public void setView(View view) + public void setView(View view) { // view can be null, that's ok - it indicates no view. if (this.sceneController != null) @@ -139,26 +139,26 @@ public void setView(View view) } @Override - public View getView() + public View getView() { return this.sceneController != null ? this.sceneController.getView() : null; } @Override - public void setModelAndView(Model model, View view) + public void setModelAndView(Model model, View view) { this.setModel(model); this.setView(view); } @Override - public SceneController getSceneController() + public SceneController getSceneController() { return this.sceneController; } @Override - public void setSceneController(SceneController sc) + public void setSceneController(SceneController sc) { if (sc != null && this.getSceneController() != null) { @@ -169,36 +169,36 @@ public void setSceneController(SceneController sc) } @Override - public InputHandler getInputHandler() + public InputHandler getInputHandler() { return this.inputHandler; } @Override - public void setInputHandler(InputHandler inputHandler) + public void setInputHandler(InputHandler inputHandler) { this.inputHandler = inputHandler; } @Override - public void redraw() + public void redraw() { } @Override - public void redrawNow() + public void redrawNow() { } @Override - public void setPerFrameStatisticsKeys(Set<String> keys) + public void setPerFrameStatisticsKeys(Set<String> keys) { if (this.sceneController != null) this.sceneController.setPerFrameStatisticsKeys(keys); } @Override - public Collection<PerformanceStatistic> getPerFrameStatistics() + public Collection<PerformanceStatistic> getPerFrameStatistics() { if (this.sceneController == null || this.sceneController.getPerFrameStatistics() == null) return new ArrayList<PerformanceStatistic>(0); @@ -207,19 +207,19 @@ public Collection<PerformanceStatistic> getPerFrameStatistics() } @Override - public PickedObjectList getObjectsAtCurrentPosition() + public PickedObjectList getObjectsAtCurrentPosition() { return null; } @Override - public PickedObjectList getObjectsInSelectionBox() + public PickedObjectList getObjectsInSelectionBox() { return null; } @Override - public Position getCurrentPosition() + public Position getCurrentPosition() { if (this.sceneController == null) return null; @@ -261,13 +261,13 @@ protected PickedObjectList getCurrentBoxSelection() } @Override - public void addRenderingListener(RenderingListener listener) + public void addRenderingListener(RenderingListener listener) { this.eventListeners.add(RenderingListener.class, listener); } @Override - public void removeRenderingListener(RenderingListener listener) + public void removeRenderingListener(RenderingListener listener) { this.eventListeners.remove(RenderingListener.class, listener); } @@ -281,13 +281,13 @@ protected void callRenderingListeners(RenderingEvent event) } @Override - public void addPositionListener(PositionListener listener) + public void addPositionListener(PositionListener listener) { this.eventListeners.add(PositionListener.class, listener); } @Override - public void removePositionListener(PositionListener listener) + public void removePositionListener(PositionListener listener) { this.eventListeners.remove(PositionListener.class, listener); } @@ -297,7 +297,7 @@ protected void callPositionListeners(final PositionEvent event) EventQueue.invokeLater(new Runnable() { @Override - public void run() + public void run() { for (PositionListener listener : eventListeners.getListeners(PositionListener.class)) { @@ -308,13 +308,13 @@ public void run() } @Override - public void addSelectListener(SelectListener listener) + public void addSelectListener(SelectListener listener) { this.eventListeners.add(SelectListener.class, listener); } @Override - public void removeSelectListener(SelectListener listener) + public void removeSelectListener(SelectListener listener) { this.eventListeners.remove(SelectListener.class, listener); } @@ -324,7 +324,7 @@ protected void callSelectListeners(final SelectEvent event) EventQueue.invokeLater(new Runnable() { @Override - public void run() + public void run() { for (SelectListener listener : eventListeners.getListeners(SelectListener.class)) { @@ -335,13 +335,13 @@ public void run() } @Override - public void addRenderingExceptionListener(RenderingExceptionListener listener) + public void addRenderingExceptionListener(RenderingExceptionListener listener) { this.eventListeners.add(RenderingExceptionListener.class, listener); } @Override - public void removeRenderingExceptionListener(RenderingExceptionListener listener) + public void removeRenderingExceptionListener(RenderingExceptionListener listener) { this.eventListeners.remove(RenderingExceptionListener.class, listener); } @@ -351,7 +351,7 @@ protected void callRenderingExceptionListeners(final Throwable exception) EventQueue.invokeLater(new Runnable() { @Override - public void run() + public void run() { for (RenderingExceptionListener listener : eventListeners.getListeners( RenderingExceptionListener.class)) diff --git a/src/gov/nasa/worldwind/awt/AWTInputHandler.java b/src/gov/nasa/worldwind/awt/AWTInputHandler.java index b33933600..564ed3fcb 100644 --- a/src/gov/nasa/worldwind/awt/AWTInputHandler.java +++ b/src/gov/nasa/worldwind/awt/AWTInputHandler.java @@ -2,25 +2,25 @@ * Copyright 2006-2009, 2017, 2020 United States Government, as represented by the * Administrator of the National Aeronautics and Space Administration. * All rights reserved. - * + * * The NASA World Wind Java (WWJ) platform is licensed under the Apache License, * Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software distributed * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. - * + * * NASA World Wind Java (WWJ) also contains the following 3rd party Open Source * software: - * + * * Jackson Parser – Licensed under Apache 2.0 * GDAL – Licensed under MIT * JOGL – Licensed under Berkeley Software Distribution (BSD) * Gluegen – Licensed under Berkeley Software Distribution (BSD) - * + * * A complete listing of 3rd Party software notices and licenses included in * NASA World Wind Java (WWJ) can be found in the WorldWindJava-v2.2 3rd-party * notices and licenses PDF found in code directory. @@ -58,7 +58,7 @@ public class AWTInputHandler extends WWObjectImpl protected javax.swing.Timer hoverTimer = new javax.swing.Timer(600, new ActionListener() { @Override - public void actionPerformed(ActionEvent actionEvent) + public void actionPerformed(ActionEvent actionEvent) { if (AWTInputHandler.this.pickMatches(AWTInputHandler.this.hoverObjects)) { @@ -77,7 +77,7 @@ public AWTInputHandler() } @Override - public void dispose() + public void dispose() { this.hoverTimer.stop(); this.hoverTimer = null; @@ -94,7 +94,7 @@ public void dispose() } @Override - public void setEventSource(WorldWindow newWorldWindow) + public void setEventSource(WorldWindow newWorldWindow) { if (newWorldWindow != null && !(newWorldWindow instanceof Component)) { @@ -143,7 +143,7 @@ public void setEventSource(WorldWindow newWorldWindow) this.selectListener = new SelectListener() { @Override - public void selected(SelectEvent event) + public void selected(SelectEvent event) { if (event.getEventAction().equals(SelectEvent.ROLLOVER)) { @@ -165,19 +165,19 @@ public void removeHoverSelectListener() } @Override - public WorldWindow getEventSource() + public WorldWindow getEventSource() { return this.wwd; } @Override - public void setHoverDelay(int delay) + public void setHoverDelay(int delay) { this.hoverTimer.setDelay(delay); } @Override - public int getHoverDelay() + public int getHoverDelay() { return this.hoverTimer.getDelay(); } @@ -258,25 +258,25 @@ protected void setObjectsAtButtonPress(PickedObjectList objectsAtButtonPress) } @Override - public boolean isForceRedrawOnMousePressed() + public boolean isForceRedrawOnMousePressed() { return forceRedrawOnMousePressed; } @Override - public void setForceRedrawOnMousePressed(boolean forceRedrawOnMousePressed) + public void setForceRedrawOnMousePressed(boolean forceRedrawOnMousePressed) { this.forceRedrawOnMousePressed = forceRedrawOnMousePressed; } -/* + + /* public ViewInputHandler getViewInputHandler() { return viewInputHandler; } - */ - + */ @Override - public void keyTyped(KeyEvent keyEvent) + public void keyTyped(KeyEvent keyEvent) { if (this.wwd == null) { @@ -297,7 +297,7 @@ public void keyTyped(KeyEvent keyEvent) } @Override - public void keyPressed(KeyEvent keyEvent) + public void keyPressed(KeyEvent keyEvent) { if (this.wwd == null) { @@ -318,7 +318,7 @@ public void keyPressed(KeyEvent keyEvent) } @Override - public void keyReleased(KeyEvent keyEvent) + public void keyReleased(KeyEvent keyEvent) { if (this.wwd == null) { @@ -337,22 +337,23 @@ public void keyReleased(KeyEvent keyEvent) this.wwd.getView().getViewInputHandler().keyReleased(keyEvent); } } - + /** * Construct a mouse event with GL surface screen coordinates * @param e * @return */ - private MouseEvent glMouseEvent(MouseEvent awtMouseEvent) { + private MouseEvent glMouseEvent(MouseEvent awtMouseEvent) + { int[] GLmousePt = wwd.getSceneController().getDrawContext().awtPointToGLpoint(awtMouseEvent.getPoint()); MouseEvent e = new MouseEvent(awtMouseEvent.getComponent(), awtMouseEvent.getID(), - awtMouseEvent.getWhen(), awtMouseEvent.getModifiersEx(), - GLmousePt[0], GLmousePt[1], awtMouseEvent.getClickCount(), awtMouseEvent.isPopupTrigger(), - awtMouseEvent.getButton()); - + awtMouseEvent.getWhen(), awtMouseEvent.getModifiersEx(), + GLmousePt[0], GLmousePt[1], awtMouseEvent.getClickCount(), awtMouseEvent.isPopupTrigger(), + awtMouseEvent.getButton()); + if (awtMouseEvent.isConsumed()) // needed in case this method is overridden by a subclass - e.consume(); - + e.consume(); + return e; } @@ -361,19 +362,20 @@ private MouseEvent glMouseEvent(MouseEvent awtMouseEvent) { * @param e * @return */ - private MouseWheelEvent glMouseWheelEvent(MouseWheelEvent awtEv) { + private MouseWheelEvent glMouseWheelEvent(MouseWheelEvent awtEv) + { int[] GLmousePt = wwd.getSceneController().getDrawContext().awtPointToGLpoint(awtEv.getPoint()); MouseWheelEvent e = new MouseWheelEvent(awtEv.getComponent(), awtEv.getID(), - awtEv.getWhen(), awtEv.getModifiersEx(), - GLmousePt[0], GLmousePt[1], awtEv.getXOnScreen(), awtEv.getYOnScreen(), - awtEv.getClickCount(), awtEv.isPopupTrigger(), - awtEv.getScrollType(), awtEv.getScrollAmount(), - awtEv.getWheelRotation(), awtEv.getPreciseWheelRotation()); + awtEv.getWhen(), awtEv.getModifiersEx(), + GLmousePt[0], GLmousePt[1], awtEv.getXOnScreen(), awtEv.getYOnScreen(), + awtEv.getClickCount(), awtEv.isPopupTrigger(), + awtEv.getScrollType(), awtEv.getScrollAmount(), + awtEv.getWheelRotation(), awtEv.getPreciseWheelRotation()); if (awtEv.isConsumed()) // needed in case this method is overridden by a subclass - e.consume(); - - return e; + e.consume(); + + return e; } @Override @@ -394,7 +396,7 @@ public void mouseClicked(final MouseEvent awtMouseEvent) return; } MouseEvent mouseEvent = glMouseEvent(awtMouseEvent); - + PickedObjectList pickedObjects = this.wwd.getObjectsAtCurrentPosition(); this.callMouseClickedListeners(mouseEvent); @@ -434,7 +436,7 @@ else if (MouseEvent.BUTTON3 == mouseEvent.getButton()) } @Override - public void mousePressed(MouseEvent awtMouseEvent) + public void mousePressed(MouseEvent awtMouseEvent) { if (this.wwd == null) { @@ -503,7 +505,7 @@ else if (MouseEvent.BUTTON3 == mouseEvent.getButton()) } @Override - public void mouseReleased(MouseEvent awtMouseEvent) + public void mouseReleased(MouseEvent awtMouseEvent) { if (this.wwd == null) { @@ -527,7 +529,7 @@ public void mouseReleased(MouseEvent awtMouseEvent) } @Override - public void mouseEntered(MouseEvent awtMouseEvent) + public void mouseEntered(MouseEvent awtMouseEvent) { if (this.wwd == null) { @@ -547,7 +549,7 @@ public void mouseEntered(MouseEvent awtMouseEvent) } @Override - public void mouseExited(MouseEvent awtMouseEvent) + public void mouseExited(MouseEvent awtMouseEvent) { if (this.wwd == null) { @@ -575,7 +577,7 @@ public void mouseExited(MouseEvent awtMouseEvent) } @Override - public void mouseDragged(MouseEvent awtMouseEvent) + public void mouseDragged(MouseEvent awtMouseEvent) { if (this.wwd == null) return; @@ -625,7 +627,7 @@ public void mouseDragged(MouseEvent awtMouseEvent) } @Override - public void mouseMoved(MouseEvent awtMouseEvent) + public void mouseMoved(MouseEvent awtMouseEvent) { if (this.wwd == null) { @@ -655,7 +657,7 @@ public void mouseMoved(MouseEvent awtMouseEvent) } @Override - public void mouseWheelMoved(MouseWheelEvent awtMouseWheelEvent) + public void mouseWheelMoved(MouseWheelEvent awtMouseWheelEvent) { if (this.wwd == null) { @@ -675,7 +677,7 @@ public void mouseWheelMoved(MouseWheelEvent awtMouseWheelEvent) } @Override - public void focusGained(FocusEvent focusEvent) + public void focusGained(FocusEvent focusEvent) { if (this.wwd == null) { @@ -691,7 +693,7 @@ public void focusGained(FocusEvent focusEvent) } @Override - public void focusLost(FocusEvent focusEvent) + public void focusLost(FocusEvent focusEvent) { if (this.wwd == null) { @@ -719,10 +721,10 @@ protected void doHover(boolean reset) PickedObject hover = this.hoverObjects.getTopPickedObject(); PickedObject last = pickedObjects.getTopPickedObject(); - Object oh = hover == null ? null : hover.getObject() != null ? hover.getObject() : - hover.getParentLayer() != null ? hover.getParentLayer() : null; - Object ol = last == null ? null : last.getObject() != null ? last.getObject() : - last.getParentLayer() != null ? last.getParentLayer() : null; + Object oh = hover == null ? null : hover.getObject() != null ? hover.getObject() + : hover.getParentLayer() != null ? hover.getParentLayer() : null; + Object ol = last == null ? null : last.getObject() != null ? last.getObject() + : last.getParentLayer() != null ? last.getParentLayer() : null; if (oh != null && ol != null && oh.equals(ol)) { return; // object picked is the hover object. don't do anything but wait for the timer to expire. @@ -795,13 +797,13 @@ protected void cancelDrag() } @Override - public void addSelectListener(SelectListener listener) + public void addSelectListener(SelectListener listener) { this.eventListeners.add(SelectListener.class, listener); } @Override - public void removeSelectListener(SelectListener listener) + public void removeSelectListener(SelectListener listener) { this.eventListeners.remove(SelectListener.class, listener); } @@ -815,49 +817,49 @@ protected void callSelectListeners(SelectEvent event) } @Override - public void addKeyListener(KeyListener listener) + public void addKeyListener(KeyListener listener) { this.eventListeners.add(KeyListener.class, listener); } @Override - public void removeKeyListener(KeyListener listener) + public void removeKeyListener(KeyListener listener) { this.eventListeners.remove(KeyListener.class, listener); } @Override - public void addMouseListener(MouseListener listener) + public void addMouseListener(MouseListener listener) { this.eventListeners.add(MouseListener.class, listener); } @Override - public void removeMouseListener(MouseListener listener) + public void removeMouseListener(MouseListener listener) { this.eventListeners.remove(MouseListener.class, listener); } @Override - public void addMouseMotionListener(MouseMotionListener listener) + public void addMouseMotionListener(MouseMotionListener listener) { this.eventListeners.add(MouseMotionListener.class, listener); } @Override - public void removeMouseMotionListener(MouseMotionListener listener) + public void removeMouseMotionListener(MouseMotionListener listener) { this.eventListeners.remove(MouseMotionListener.class, listener); } @Override - public void addMouseWheelListener(MouseWheelListener listener) + public void addMouseWheelListener(MouseWheelListener listener) { this.eventListeners.add(MouseWheelListener.class, listener); } @Override - public void removeMouseWheelListener(MouseWheelListener listener) + public void removeMouseWheelListener(MouseWheelListener listener) { this.eventListeners.remove(MouseWheelListener.class, listener); } @@ -951,7 +953,7 @@ protected void callMouseExitedListeners(MouseEvent event) } @Override - public void propertyChange(PropertyChangeEvent event) + public void propertyChange(PropertyChangeEvent event) { if (this.wwd == null) { @@ -968,8 +970,8 @@ public void propertyChange(PropertyChangeEvent event) return; } - if (event.getPropertyName().equals(AVKey.VIEW) && - (event.getSource() == this.getWorldWindow().getSceneController())) + if (event.getPropertyName().equals(AVKey.VIEW) + && (event.getSource() == this.getWorldWindow().getSceneController())) { this.wwd.getView().getViewInputHandler().setWorldWindow(this.wwd); } diff --git a/src/gov/nasa/worldwind/awt/WorldWindowGLCanvas.java b/src/gov/nasa/worldwind/awt/WorldWindowGLCanvas.java index 3fb63c14b..cac9d6847 100644 --- a/src/gov/nasa/worldwind/awt/WorldWindowGLCanvas.java +++ b/src/gov/nasa/worldwind/awt/WorldWindowGLCanvas.java @@ -2,25 +2,25 @@ * Copyright 2006-2009, 2017, 2020 United States Government, as represented by the * Administrator of the National Aeronautics and Space Administration. * All rights reserved. - * + * * The NASA World Wind Java (WWJ) platform is licensed under the Apache License, * Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software distributed * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. - * + * * NASA World Wind Java (WWJ) also contains the following 3rd party Open Source * software: - * + * * Jackson Parser – Licensed under Apache 2.0 * GDAL – Licensed under MIT * JOGL – Licensed under Berkeley Software Distribution (BSD) * Gluegen – Licensed under Berkeley Software Distribution (BSD) - * + * * A complete listing of 3rd Party software notices and licenses included in * NASA World Wind Java (WWJ) can be found in the WorldWindJava-v2.2 3rd-party * notices and licenses PDF found in code directory. @@ -224,9 +224,9 @@ public WorldWindowGLCanvas(WorldWindow shareWith, java.awt.GraphicsDevice device } @Override - public void propertyChange(PropertyChangeEvent evt) + public void propertyChange(PropertyChangeEvent evt) { - if(this.wwd == evt.getSource()) + if (this.wwd == evt.getSource()) this.firePropertyChange(evt); //noinspection StringEquality @@ -235,7 +235,7 @@ public void propertyChange(PropertyChangeEvent evt) } @Override - public void shutdown() + public void shutdown() { WorldWind.removePropertyChangeListener(WorldWind.SHUTDOWN_EVENT, this); this.wwd.shutdown(); @@ -266,13 +266,13 @@ protected void createDefaultInputHandler() } @Override - public InputHandler getInputHandler() + public InputHandler getInputHandler() { return this.wwd.getInputHandler(); } @Override - public void setInputHandler(InputHandler inputHandler) + public void setInputHandler(InputHandler inputHandler) { if (this.wwd.getInputHandler() != null) this.wwd.getInputHandler().setEventSource(null); // remove this window as a source of events @@ -283,50 +283,50 @@ public void setInputHandler(InputHandler inputHandler) } @Override - public SceneController getSceneController() + public SceneController getSceneController() { return this.wwd.getSceneController(); } @Override - public void setSceneController(SceneController sceneController) + public void setSceneController(SceneController sceneController) { this.wwd.setSceneController(sceneController); } @Override - public GpuResourceCache getGpuResourceCache() + public GpuResourceCache getGpuResourceCache() { return this.wwd.getGpuResourceCache(); } @Override - public void redraw() + public void redraw() { this.repaint(); } @Override - public void redrawNow() + public void redrawNow() { this.wwd.redrawNow(); } @Override - public void setModel(Model model) + public void setModel(Model model) { // null models are permissible this.wwd.setModel(model); } @Override - public Model getModel() + public Model getModel() { return this.wwd.getModel(); } @Override - public void setView(View view) + public void setView(View view) { // null views are permissible if (view != null) @@ -334,130 +334,130 @@ public void setView(View view) } @Override - public View getView() + public View getView() { return this.wwd.getView(); } @Override - public void setModelAndView(Model model, View view) + public void setModelAndView(Model model, View view) { // null models/views are permissible this.setModel(model); this.setView(view); } @Override - public void addRenderingListener(RenderingListener listener) + public void addRenderingListener(RenderingListener listener) { this.wwd.addRenderingListener(listener); } @Override - public void removeRenderingListener(RenderingListener listener) + public void removeRenderingListener(RenderingListener listener) { this.wwd.removeRenderingListener(listener); } @Override - public void addSelectListener(SelectListener listener) + public void addSelectListener(SelectListener listener) { this.wwd.getInputHandler().addSelectListener(listener); this.wwd.addSelectListener(listener); } @Override - public void removeSelectListener(SelectListener listener) + public void removeSelectListener(SelectListener listener) { this.wwd.getInputHandler().removeSelectListener(listener); this.wwd.removeSelectListener(listener); } @Override - public void addPositionListener(PositionListener listener) + public void addPositionListener(PositionListener listener) { this.wwd.addPositionListener(listener); } @Override - public void removePositionListener(PositionListener listener) + public void removePositionListener(PositionListener listener) { this.wwd.removePositionListener(listener); } @Override - public void addRenderingExceptionListener(RenderingExceptionListener listener) + public void addRenderingExceptionListener(RenderingExceptionListener listener) { this.wwd.addRenderingExceptionListener(listener); } @Override - public void removeRenderingExceptionListener(RenderingExceptionListener listener) + public void removeRenderingExceptionListener(RenderingExceptionListener listener) { this.wwd.removeRenderingExceptionListener(listener); } @Override - public Position getCurrentPosition() + public Position getCurrentPosition() { return this.wwd.getCurrentPosition(); } @Override - public PickedObjectList getObjectsAtCurrentPosition() + public PickedObjectList getObjectsAtCurrentPosition() { return this.wwd.getSceneController() != null ? this.wwd.getSceneController().getPickedObjectList() : null; } @Override - public PickedObjectList getObjectsInSelectionBox() + public PickedObjectList getObjectsInSelectionBox() { return this.wwd.getSceneController() != null ? this.wwd.getSceneController().getObjectsInPickRectangle() : null; } @Override - public Object setValue(String key, Object value) + public Object setValue(String key, Object value) { return this.wwd.setValue(key, value); } @Override - public AVList setValues(AVList avList) + public AVList setValues(AVList avList) { return this.wwd.setValues(avList); } @Override - public Object getValue(String key) + public Object getValue(String key) { return this.wwd.getValue(key); } @Override - public Collection<Object> getValues() + public Collection<Object> getValues() { return this.wwd.getValues(); } @Override - public Set<Map.Entry<String, Object>> getEntries() + public Set<Map.Entry<String, Object>> getEntries() { return this.wwd.getEntries(); } @Override - public String getStringValue(String key) + public String getStringValue(String key) { return this.wwd.getStringValue(key); } @Override - public boolean hasKey(String key) + public boolean hasKey(String key) { return this.wwd.hasKey(key); } @Override - public Object removeKey(String key) + public Object removeKey(String key) { return this.wwd.removeKey(key); } @@ -493,52 +493,58 @@ public void firePropertyChange(String propertyName, Object oldValue, Object newV } @Override - public void firePropertyChange(PropertyChangeEvent propertyChangeEvent) + public void firePropertyChange(PropertyChangeEvent propertyChangeEvent) { this.wwd.firePropertyChange(propertyChangeEvent); } @Override - public AVList copy() + public AVList copy() { return this.wwd.copy(); } @Override - public AVList clearList() + public AVList clearList() { return this.wwd.clearList(); } @Override - public void setPerFrameStatisticsKeys(Set<String> keys) + public void setPerFrameStatisticsKeys(Set<String> keys) { this.wwd.setPerFrameStatisticsKeys(keys); } @Override - public Collection<PerformanceStatistic> getPerFrameStatistics() + public Collection<PerformanceStatistic> getPerFrameStatistics() { return this.wwd.getPerFrameStatistics(); } - + /** * @return current mouse pointer position in GL surface screen coordinates. */ @Override - public Point getMousePosition() throws HeadlessException { - Point mpos = super.getMousePosition(); - int [] awtPt = { mpos.x, mpos.y }; - - if (wwd.getContext() == null) return mpos; - - GLDrawable drawable = wwd.getContext().getGLDrawable(); - if (drawable == null) return mpos; - - // Convert to GL surface coordinates - int [] glSurfacePt = drawable.getNativeSurface().convertToPixelUnits(awtPt); - int glSurfaceHeight = drawable.getSurfaceHeight(); - glSurfacePt[1] = glSurfaceHeight - glSurfacePt[1] - 1; - return new Point(glSurfacePt[0], glSurfacePt[1]); + public Point getMousePosition() throws HeadlessException + { + Point mpos = super.getMousePosition(); + int[] awtPt = + { + mpos.x, mpos.y + }; + + if (wwd.getContext() == null) + return mpos; + + GLDrawable drawable = wwd.getContext().getGLDrawable(); + if (drawable == null) + return mpos; + + // Convert to GL surface coordinates + int[] glSurfacePt = drawable.getNativeSurface().convertToPixelUnits(awtPt); + int glSurfaceHeight = drawable.getSurfaceHeight(); + glSurfacePt[1] = glSurfaceHeight - glSurfacePt[1] - 1; + return new Point(glSurfacePt[0], glSurfacePt[1]); } }