diff --git a/gluegen-java-src.zip b/gluegen-java-src.zip new file mode 100644 index 0000000000..46ac8a66d7 Binary files /dev/null and b/gluegen-java-src.zip differ diff --git a/gluegen-rt-natives-linux-amd64.jar b/gluegen-rt-natives-linux-amd64.jar index 826d6d6fa9..a38e206e8e 100644 Binary files a/gluegen-rt-natives-linux-amd64.jar and b/gluegen-rt-natives-linux-amd64.jar differ diff --git a/gluegen-rt-natives-windows-amd64.jar b/gluegen-rt-natives-windows-amd64.jar index 2d1fe14112..4321279253 100644 Binary files a/gluegen-rt-natives-windows-amd64.jar and b/gluegen-rt-natives-windows-amd64.jar differ diff --git a/gluegen-rt.jar b/gluegen-rt.jar index aef08ef85c..7292d87a4f 100644 Binary files a/gluegen-rt.jar and b/gluegen-rt.jar differ diff --git a/gluegen.jar b/gluegen.jar new file mode 100644 index 0000000000..869a6cf4bc Binary files /dev/null and b/gluegen.jar differ diff --git a/jogl-all-natives-linux-amd64.jar b/jogl-all-natives-linux-amd64.jar index 55953e236b..c093b4476f 100644 Binary files a/jogl-all-natives-linux-amd64.jar and b/jogl-all-natives-linux-amd64.jar differ diff --git a/jogl-all-natives-windows-amd64.jar b/jogl-all-natives-windows-amd64.jar index 4384250365..c8d513b585 100644 Binary files a/jogl-all-natives-windows-amd64.jar and b/jogl-all-natives-windows-amd64.jar differ diff --git a/jogl-all.jar b/jogl-all.jar index dbbde557f5..fe7887c58b 100644 Binary files a/jogl-all.jar and b/jogl-all.jar differ diff --git a/jogl-java-src.zip b/jogl-java-src.zip new file mode 100644 index 0000000000..f761968f56 Binary files /dev/null and b/jogl-java-src.zip differ diff --git a/src/gov/nasa/worldwind/AbstractSceneController.java b/src/gov/nasa/worldwind/AbstractSceneController.java index 0e2cd922c7..8af10b5099 100644 --- a/src/gov/nasa/worldwind/AbstractSceneController.java +++ b/src/gov/nasa/worldwind/AbstractSceneController.java @@ -75,15 +75,15 @@ public abstract class AbstractSceneController extends WWObjectImpl implements Sc protected double frameTime; protected double pickTime; /** - * The pick point in AWT screen coordinates, or null if the pick point is disabled. Initially + * The pick point in GL surface screen coordinates, or null if the pick point is disabled. Initially * null. */ - protected Point pickPoint = null; + private Point pickPoint = null; /** - * The pick rectangle in AWT screen coordinates, or null if the pick rectangle is disabled. Initially + * The pick rectangle in GL surface screen coordinates, or null if the pick rectangle is disabled. Initially * null. */ - protected Rectangle pickRect = null; + private Rectangle pickRect = null; protected boolean deepPick = false; protected GpuResourceCache gpuResourceCache; protected TextRendererCache textRendererCache = new TextRendererCache(); @@ -111,7 +111,8 @@ public AbstractSceneController() this.setVerticalExaggeration(Configuration.getDoubleValue(AVKey.VERTICAL_EXAGGERATION, 1d)); } - public void reinitialize() + @Override + public void reinitialize() { if (this.textRendererCache != null) this.textRendererCache.dispose(); @@ -119,7 +120,8 @@ public void reinitialize() } /** Releases resources associated with this scene controller. */ - public void dispose() + @Override + public void dispose() { if (this.lastPickedObjects != null) this.lastPickedObjects.clear(); @@ -136,12 +138,14 @@ public void dispose() this.textRendererCache.dispose(); } - public GpuResourceCache getGpuResourceCache() + @Override + public GpuResourceCache getGpuResourceCache() { return this.gpuResourceCache; } - public void setGpuResourceCache(GpuResourceCache gpuResourceCache) + @Override + public void setGpuResourceCache(GpuResourceCache gpuResourceCache) { this.gpuResourceCache = gpuResourceCache; } @@ -151,17 +155,20 @@ public TextRendererCache getTextRendererCache() return textRendererCache; } - public Model getModel() + @Override + public Model getModel() { return this.model; } - public View getView() + @Override + public View getView() { return this.view; } - public void setModel(Model model) + @Override + public void setModel(Model model) { if (this.model != null) this.model.removePropertyChangeListener(this); @@ -173,7 +180,8 @@ public void setModel(Model model) this.firePropertyChange(AVKey.MODEL, oldModel, model); } - public void setView(View view) + @Override + public void setView(View view) { if (this.view != null) this.view.removePropertyChangeListener(this); @@ -186,44 +194,51 @@ public void setView(View view) this.firePropertyChange(AVKey.VIEW, oldView, view); } - public void setVerticalExaggeration(double verticalExaggeration) + @Override + public void setVerticalExaggeration(double verticalExaggeration) { Double oldVE = this.verticalExaggeration; this.verticalExaggeration = verticalExaggeration; this.firePropertyChange(AVKey.VERTICAL_EXAGGERATION, oldVE, verticalExaggeration); } - public double getVerticalExaggeration() + @Override + public double getVerticalExaggeration() { return this.verticalExaggeration; } /** {@inheritDoc} */ - public void setPickPoint(Point pickPoint) + @Override + public void setPickPoint(Point pickPoint) { - this.pickPoint = pickPoint; + this.pickPoint = pickPoint; } /** {@inheritDoc} */ - public Point getPickPoint() + @Override + public Point getPickPoint() { return this.pickPoint; } /** {@inheritDoc} */ - public void setPickRectangle(Rectangle pickRect) + @Override + public void setPickRectangle(Rectangle pickRect) { this.pickRect = pickRect; } /** {@inheritDoc} */ - public Rectangle getPickRectangle() + @Override + public Rectangle getPickRectangle() { return this.pickRect; } /** {@inheritDoc} */ - public PickedObjectList getPickedObjectList() + @Override + public PickedObjectList getPickedObjectList() { return this.lastPickedObjects; } @@ -234,42 +249,50 @@ protected void setPickedObjectList(PickedObjectList pol) } /** {@inheritDoc} */ - public PickedObjectList getObjectsInPickRectangle() + @Override + public PickedObjectList getObjectsInPickRectangle() { return this.lastObjectsInPickRect; } - public void setDeepPickEnabled(boolean tf) + @Override + public void setDeepPickEnabled(boolean tf) { this.deepPick = tf; } - public boolean isDeepPickEnabled() + @Override + public boolean isDeepPickEnabled() { return this.deepPick; } - public SectorGeometryList getTerrain() + @Override + public SectorGeometryList getTerrain() { return this.dc.getSurfaceGeometry(); } - public DrawContext getDrawContext() + @Override + public DrawContext getDrawContext() { return this.dc; } - public double getFramesPerSecond() + @Override + public double getFramesPerSecond() { return this.framesPerSecond; } - public double getFrameTime() + @Override + public double getFrameTime() { return this.frameTime; } - public void setPerFrameStatisticsKeys(Set keys) + @Override + public void setPerFrameStatisticsKeys(Set keys) { this.perFrameStatisticsKeys.clear(); if (keys == null) @@ -282,34 +305,40 @@ public void setPerFrameStatisticsKeys(Set keys) } } - public Collection getPerFrameStatistics() + @Override + public Collection getPerFrameStatistics() { return perFrameStatistics; } - public Collection getRenderingExceptions() + @Override + public Collection getRenderingExceptions() { return this.renderingExceptions; } - public ScreenCreditController getScreenCreditController() + @Override + public ScreenCreditController getScreenCreditController() { return screenCreditController; } - public void setScreenCreditController(ScreenCreditController screenCreditController) + @Override + public void setScreenCreditController(ScreenCreditController screenCreditController) { this.screenCreditController = screenCreditController; } /** {@inheritDoc} */ - public GLRuntimeCapabilities getGLRuntimeCapabilities() + @Override + public GLRuntimeCapabilities getGLRuntimeCapabilities() { return this.glRuntimeCaps; } /** {@inheritDoc} */ - public void setGLRuntimeCapabilities(GLRuntimeCapabilities capabilities) + @Override + public void setGLRuntimeCapabilities(GLRuntimeCapabilities capabilities) { if (capabilities == null) { @@ -411,7 +440,8 @@ public void setDeferOrderedRendering(boolean deferOrderedRendering) this.deferOrderedRendering = deferOrderedRendering; } - public int repaint() + @Override + public int repaint() { this.frameTime = System.currentTimeMillis(); @@ -994,7 +1024,6 @@ protected void draw(DrawContext dc) * * @param dc the relevant DrawContext */ - @SuppressWarnings({"UNUSED_SYMBOL", "UnusedDeclaration"}) protected void checkGLErrors(DrawContext dc) { GL gl = dc.getGL(); diff --git a/src/gov/nasa/worldwind/SceneController.java b/src/gov/nasa/worldwind/SceneController.java index 2cbf20ee7b..7b93ad2664 100644 --- a/src/gov/nasa/worldwind/SceneController.java +++ b/src/gov/nasa/worldwind/SceneController.java @@ -128,7 +128,7 @@ public interface SceneController extends WWObject, Disposable double getFrameTime(); /** - * Specifies the current pick point in AWT screen coordinates, or null to indicate that there is no + * Specifies the current pick point in GL surface screen coordinates, or null to indicate that there is no * pick point. Each frame, this scene controller determines which objects are drawn at the pick point and places * them in a PickedObjectList. This list can be accessed by calling {@link #getPickedObjectList()}. *

@@ -140,7 +140,7 @@ public interface SceneController extends WWObject, Disposable void setPickPoint(Point pickPoint); /** - * Returns the current pick point in AWT screen coordinates. + * Returns the current pick point in GL surface coordinates. * * @return the current pick point, or null if no pick point is current. * @@ -149,7 +149,7 @@ public interface SceneController extends WWObject, Disposable Point getPickPoint(); /** - * Specifies the current pick rectangle in AWT screen coordinates, or null to indicate that there is no + * Specifies the current pick rectangle in GL surface coordinates, or null to indicate that there is no * pick rectangle. Each frame, this scene controller determines which objects intersect the pick rectangle and * places them in a PickedObjectList. This list can be accessed by calling {@link #getObjectsInPickRectangle()}. *

@@ -161,7 +161,7 @@ public interface SceneController extends WWObject, Disposable void setPickRectangle(Rectangle pickRect); /** - * Returns the current pick rectangle in AWT screen coordinates. + * Returns the current pick rectangle in GL surface coordinates. * * @return the current pick rectangle, or null if no pick rectangle is current. * diff --git a/src/gov/nasa/worldwind/WorldWindowImpl.java b/src/gov/nasa/worldwind/WorldWindowImpl.java index 51da668096..7a7ca29e13 100644 --- a/src/gov/nasa/worldwind/WorldWindowImpl.java +++ b/src/gov/nasa/worldwind/WorldWindowImpl.java @@ -28,7 +28,6 @@ package gov.nasa.worldwind; -import com.jogamp.nativewindow.ScalableSurface; import gov.nasa.worldwind.avlist.AVKey; import gov.nasa.worldwind.cache.*; import gov.nasa.worldwind.event.*; @@ -68,7 +67,8 @@ public WorldWindowImpl() * Causes resources used by the WorldWindow to be freed. The WorldWindow cannot be used once this method is * called. An OpenGL context for the window must be current. */ - public void shutdown() + @Override + public void shutdown() { WorldWind.getDataFileStore().removePropertyChangeListener(this); @@ -104,7 +104,8 @@ public void shutdown() sc.dispose(); } - public GpuResourceCache getGpuResourceCache() + @Override + public GpuResourceCache getGpuResourceCache() { return this.gpuResourceCache; } @@ -115,42 +116,49 @@ public void setGpuResourceCache(GpuResourceCache gpuResourceCache) this.sceneController.setGpuResourceCache(this.gpuResourceCache); } - public void setModel(Model model) + @Override + public void setModel(Model model) { // model can be null, that's ok - it indicates no model. if (this.sceneController != null) this.sceneController.setModel(model); } - public Model getModel() + @Override + public Model getModel() { return this.sceneController != null ? this.sceneController.getModel() : null; } - public void setView(View view) + @Override + public void setView(View view) { // view can be null, that's ok - it indicates no view. if (this.sceneController != null) this.sceneController.setView(view); } - public View getView() + @Override + public View getView() { return this.sceneController != null ? this.sceneController.getView() : null; } - public void setModelAndView(Model model, View view) + @Override + public void setModelAndView(Model model, View view) { this.setModel(model); this.setView(view); } - public SceneController getSceneController() + @Override + public SceneController getSceneController() { return this.sceneController; } - public void setSceneController(SceneController sc) + @Override + public void setSceneController(SceneController sc) { if (sc != null && this.getSceneController() != null) { @@ -160,31 +168,37 @@ public void setSceneController(SceneController sc) this.sceneController = sc; } - public InputHandler getInputHandler() + @Override + public InputHandler getInputHandler() { return this.inputHandler; } - public void setInputHandler(InputHandler inputHandler) + @Override + public void setInputHandler(InputHandler inputHandler) { this.inputHandler = inputHandler; } - public void redraw() + @Override + public void redraw() { } - public void redrawNow() + @Override + public void redrawNow() { } - public void setPerFrameStatisticsKeys(Set keys) + @Override + public void setPerFrameStatisticsKeys(Set keys) { if (this.sceneController != null) this.sceneController.setPerFrameStatisticsKeys(keys); } - public Collection getPerFrameStatistics() + @Override + public Collection getPerFrameStatistics() { if (this.sceneController == null || this.sceneController.getPerFrameStatistics() == null) return new ArrayList(0); @@ -192,17 +206,20 @@ public Collection getPerFrameStatistics() return this.sceneController.getPerFrameStatistics(); } - public PickedObjectList getObjectsAtCurrentPosition() + @Override + public PickedObjectList getObjectsAtCurrentPosition() { return null; } - public PickedObjectList getObjectsInSelectionBox() + @Override + public PickedObjectList getObjectsInSelectionBox() { return null; } - public Position getCurrentPosition() + @Override + public Position getCurrentPosition() { if (this.sceneController == null) return null; @@ -243,12 +260,14 @@ protected PickedObjectList getCurrentBoxSelection() return pol != null && pol.size() > 0 ? pol : null; } - public void addRenderingListener(RenderingListener listener) + @Override + public void addRenderingListener(RenderingListener listener) { this.eventListeners.add(RenderingListener.class, listener); } - public void removeRenderingListener(RenderingListener listener) + @Override + public void removeRenderingListener(RenderingListener listener) { this.eventListeners.remove(RenderingListener.class, listener); } @@ -261,12 +280,14 @@ protected void callRenderingListeners(RenderingEvent event) } } - public void addPositionListener(PositionListener listener) + @Override + public void addPositionListener(PositionListener listener) { this.eventListeners.add(PositionListener.class, listener); } - public void removePositionListener(PositionListener listener) + @Override + public void removePositionListener(PositionListener listener) { this.eventListeners.remove(PositionListener.class, listener); } @@ -275,7 +296,8 @@ protected void callPositionListeners(final PositionEvent event) { EventQueue.invokeLater(new Runnable() { - public void run() + @Override + public void run() { for (PositionListener listener : eventListeners.getListeners(PositionListener.class)) { @@ -285,12 +307,14 @@ public void run() }); } - public void addSelectListener(SelectListener listener) + @Override + public void addSelectListener(SelectListener listener) { this.eventListeners.add(SelectListener.class, listener); } - public void removeSelectListener(SelectListener listener) + @Override + public void removeSelectListener(SelectListener listener) { this.eventListeners.remove(SelectListener.class, listener); } @@ -299,7 +323,8 @@ protected void callSelectListeners(final SelectEvent event) { EventQueue.invokeLater(new Runnable() { - public void run() + @Override + public void run() { for (SelectListener listener : eventListeners.getListeners(SelectListener.class)) { @@ -309,12 +334,14 @@ public void run() }); } - public void addRenderingExceptionListener(RenderingExceptionListener listener) + @Override + public void addRenderingExceptionListener(RenderingExceptionListener listener) { this.eventListeners.add(RenderingExceptionListener.class, listener); } - public void removeRenderingExceptionListener(RenderingExceptionListener listener) + @Override + public void removeRenderingExceptionListener(RenderingExceptionListener listener) { this.eventListeners.remove(RenderingExceptionListener.class, listener); } @@ -323,7 +350,8 @@ protected void callRenderingExceptionListeners(final Throwable exception) { EventQueue.invokeLater(new Runnable() { - public void run() + @Override + public void run() { for (RenderingExceptionListener listener : eventListeners.getListeners( RenderingExceptionListener.class)) @@ -341,32 +369,4 @@ public static GpuResourceCache createGpuResourceCache() long cacheSize = Configuration.getLongValue(AVKey.TEXTURE_CACHE_SIZE, FALLBACK_TEXTURE_CACHE_SIZE); return new BasicGpuResourceCache((long) (0.8 * cacheSize), cacheSize); } - - /** - * Configures JOGL's surface pixel scaling on the specified - * ScalableSurface to ensure backward compatibility with - * WorldWind applications developed prior to JOGL pixel scaling's - * introduction.This method is used by GLCanvas and - * GLJPanel to effectively disable JOGL's surface pixel scaling - * by requesting a 1:1 scale.

- * Since v2.2.0, JOGL defaults to using high-dpi pixel scales where - * possible. This causes WorldWind screen elements such as placemarks, the - * compass, the world map, the view controls, and the scale bar (plus many - * more) to appear smaller than they are intended to on screen. The high-dpi - * default also has the effect of degrading WorldWind rendering performance. - * - * @param surface The surface to configure. - */ - public static void configureIdentityPixelScale(ScalableSurface surface) - { - if (surface == null) - { - String message = Logging.getMessage("nullValue.SurfaceIsNull"); - Logging.logger().severe(message); - throw new IllegalArgumentException(message); - } - - float[] identityScale = new float[] {ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE}; - surface.setSurfaceScale(identityScale); - } } diff --git a/src/gov/nasa/worldwind/awt/AWTInputHandler.java b/src/gov/nasa/worldwind/awt/AWTInputHandler.java index 3697849cdc..b339336007 100644 --- a/src/gov/nasa/worldwind/awt/AWTInputHandler.java +++ b/src/gov/nasa/worldwind/awt/AWTInputHandler.java @@ -57,7 +57,8 @@ public class AWTInputHandler extends WWObjectImpl protected boolean forceRedrawOnMousePressed = Configuration.getBooleanValue(AVKey.REDRAW_ON_MOUSE_PRESSED, false); protected javax.swing.Timer hoverTimer = new javax.swing.Timer(600, new ActionListener() { - public void actionPerformed(ActionEvent actionEvent) + @Override + public void actionPerformed(ActionEvent actionEvent) { if (AWTInputHandler.this.pickMatches(AWTInputHandler.this.hoverObjects)) { @@ -75,7 +76,8 @@ public AWTInputHandler() { } - public void dispose() + @Override + public void dispose() { this.hoverTimer.stop(); this.hoverTimer = null; @@ -91,7 +93,8 @@ public void dispose() this.objectsAtButtonPress = null; } - public void setEventSource(WorldWindow newWorldWindow) + @Override + public void setEventSource(WorldWindow newWorldWindow) { if (newWorldWindow != null && !(newWorldWindow instanceof Component)) { @@ -139,7 +142,8 @@ public void setEventSource(WorldWindow newWorldWindow) this.selectListener = new SelectListener() { - public void selected(SelectEvent event) + @Override + public void selected(SelectEvent event) { if (event.getEventAction().equals(SelectEvent.ROLLOVER)) { @@ -160,17 +164,20 @@ public void removeHoverSelectListener() this.wwd.removeSelectListener(selectListener); } - public WorldWindow getEventSource() + @Override + public WorldWindow getEventSource() { return this.wwd; } - public void setHoverDelay(int delay) + @Override + public void setHoverDelay(int delay) { this.hoverTimer.setDelay(delay); } - public int getHoverDelay() + @Override + public int getHoverDelay() { return this.hoverTimer.getDelay(); } @@ -250,12 +257,14 @@ protected void setObjectsAtButtonPress(PickedObjectList objectsAtButtonPress) this.objectsAtButtonPress = objectsAtButtonPress; } - public boolean isForceRedrawOnMousePressed() + @Override + public boolean isForceRedrawOnMousePressed() { return forceRedrawOnMousePressed; } - public void setForceRedrawOnMousePressed(boolean forceRedrawOnMousePressed) + @Override + public void setForceRedrawOnMousePressed(boolean forceRedrawOnMousePressed) { this.forceRedrawOnMousePressed = forceRedrawOnMousePressed; } @@ -266,7 +275,8 @@ public ViewInputHandler getViewInputHandler() } */ - public void keyTyped(KeyEvent keyEvent) + @Override + public void keyTyped(KeyEvent keyEvent) { if (this.wwd == null) { @@ -286,7 +296,8 @@ public void keyTyped(KeyEvent keyEvent) } } - public void keyPressed(KeyEvent keyEvent) + @Override + public void keyPressed(KeyEvent keyEvent) { if (this.wwd == null) { @@ -306,7 +317,8 @@ public void keyPressed(KeyEvent keyEvent) } } - public void keyReleased(KeyEvent keyEvent) + @Override + public void keyReleased(KeyEvent keyEvent) { if (this.wwd == null) { @@ -325,8 +337,47 @@ public void keyReleased(KeyEvent keyEvent) this.wwd.getView().getViewInputHandler().keyReleased(keyEvent); } } - - public void mouseClicked(final MouseEvent mouseEvent) + + /** + * Construct a mouse event with GL surface screen coordinates + * @param e + * @return + */ + 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()); + + if (awtMouseEvent.isConsumed()) // needed in case this method is overridden by a subclass + e.consume(); + + return e; + } + + /** + * Construct a mouse wheel event with GL surface screen coordinates + * @param e + * @return + */ + 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()); + + if (awtEv.isConsumed()) // needed in case this method is overridden by a subclass + e.consume(); + + return e; + } + + @Override + public void mouseClicked(final MouseEvent awtMouseEvent) { if (this.wwd == null) { @@ -338,11 +389,12 @@ public void mouseClicked(final MouseEvent mouseEvent) return; } - if (mouseEvent == null) + if (awtMouseEvent == null) { return; } - + MouseEvent mouseEvent = glMouseEvent(awtMouseEvent); + PickedObjectList pickedObjects = this.wwd.getObjectsAtCurrentPosition(); this.callMouseClickedListeners(mouseEvent); @@ -381,20 +433,22 @@ else if (MouseEvent.BUTTON3 == mouseEvent.getButton()) } } - public void mousePressed(MouseEvent mouseEvent) + @Override + public void mousePressed(MouseEvent awtMouseEvent) { if (this.wwd == null) { return; } - if (mouseEvent == null) + if (awtMouseEvent == null) { return; } // Determine if the mouse point has changed since the last mouse move event. This can happen if user switches to // another window, moves the mouse, and then switches back to the WorldWind window. + MouseEvent mouseEvent = glMouseEvent(awtMouseEvent); boolean mousePointChanged = !mouseEvent.getPoint().equals(this.mousePoint); this.mousePoint = mouseEvent.getPoint(); @@ -448,18 +502,20 @@ else if (MouseEvent.BUTTON3 == mouseEvent.getButton()) } } - public void mouseReleased(MouseEvent mouseEvent) + @Override + public void mouseReleased(MouseEvent awtMouseEvent) { if (this.wwd == null) { return; } - if (mouseEvent == null) + if (awtMouseEvent == null) { return; } + MouseEvent mouseEvent = glMouseEvent(awtMouseEvent); this.mousePoint = mouseEvent.getPoint(); this.callMouseReleasedListeners(mouseEvent); if (!mouseEvent.isConsumed()) @@ -470,36 +526,40 @@ public void mouseReleased(MouseEvent mouseEvent) this.cancelDrag(); } - public void mouseEntered(MouseEvent mouseEvent) + @Override + public void mouseEntered(MouseEvent awtMouseEvent) { if (this.wwd == null) { return; } - if (mouseEvent == null) + if (awtMouseEvent == null) { return; } + MouseEvent mouseEvent = glMouseEvent(awtMouseEvent); this.callMouseEnteredListeners(mouseEvent); this.wwd.getView().getViewInputHandler().mouseEntered(mouseEvent); this.cancelHover(); this.cancelDrag(); } - public void mouseExited(MouseEvent mouseEvent) + @Override + public void mouseExited(MouseEvent awtMouseEvent) { if (this.wwd == null) { return; } - if (mouseEvent == null) + if (awtMouseEvent == null) { return; } + MouseEvent mouseEvent = glMouseEvent(awtMouseEvent); this.callMouseExitedListeners(mouseEvent); this.wwd.getView().getViewInputHandler().mouseExited(mouseEvent); @@ -514,16 +574,18 @@ public void mouseExited(MouseEvent mouseEvent) this.cancelDrag(); } - public void mouseDragged(MouseEvent mouseEvent) + @Override + public void mouseDragged(MouseEvent awtMouseEvent) { if (this.wwd == null) return; - if (mouseEvent == null) + if (awtMouseEvent == null) { return; } + MouseEvent mouseEvent = glMouseEvent(awtMouseEvent); Point prevMousePoint = this.mousePoint; this.mousePoint = mouseEvent.getPoint(); this.callMouseDraggedListeners(mouseEvent); @@ -562,18 +624,20 @@ public void mouseDragged(MouseEvent mouseEvent) } } - public void mouseMoved(MouseEvent mouseEvent) + @Override + public void mouseMoved(MouseEvent awtMouseEvent) { if (this.wwd == null) { return; } - if (mouseEvent == null) + if (awtMouseEvent == null) { return; } + MouseEvent mouseEvent = glMouseEvent(awtMouseEvent); this.mousePoint = mouseEvent.getPoint(); this.callMouseMovedListeners(mouseEvent); @@ -590,25 +654,28 @@ public void mouseMoved(MouseEvent mouseEvent) } } - public void mouseWheelMoved(MouseWheelEvent mouseWheelEvent) + @Override + public void mouseWheelMoved(MouseWheelEvent awtMouseWheelEvent) { if (this.wwd == null) { return; } - if (mouseWheelEvent == null) + if (awtMouseWheelEvent == null) { return; } + MouseWheelEvent mouseWheelEvent = glMouseWheelEvent(awtMouseWheelEvent); this.callMouseWheelMovedListeners(mouseWheelEvent); if (!mouseWheelEvent.isConsumed()) this.wwd.getView().getViewInputHandler().mouseWheelMoved(mouseWheelEvent); } - public void focusGained(FocusEvent focusEvent) + @Override + public void focusGained(FocusEvent focusEvent) { if (this.wwd == null) { @@ -623,7 +690,8 @@ public void focusGained(FocusEvent focusEvent) this.wwd.getView().getViewInputHandler().focusGained(focusEvent); } - public void focusLost(FocusEvent focusEvent) + @Override + public void focusLost(FocusEvent focusEvent) { if (this.wwd == null) { @@ -726,12 +794,14 @@ protected void cancelDrag() this.isDragging = false; } - public void addSelectListener(SelectListener listener) + @Override + public void addSelectListener(SelectListener listener) { this.eventListeners.add(SelectListener.class, listener); } - public void removeSelectListener(SelectListener listener) + @Override + public void removeSelectListener(SelectListener listener) { this.eventListeners.remove(SelectListener.class, listener); } @@ -744,42 +814,50 @@ protected void callSelectListeners(SelectEvent event) } } - public void addKeyListener(KeyListener listener) + @Override + public void addKeyListener(KeyListener listener) { this.eventListeners.add(KeyListener.class, listener); } - public void removeKeyListener(KeyListener listener) + @Override + public void removeKeyListener(KeyListener listener) { this.eventListeners.remove(KeyListener.class, listener); } - public void addMouseListener(MouseListener listener) + @Override + public void addMouseListener(MouseListener listener) { this.eventListeners.add(MouseListener.class, listener); } - public void removeMouseListener(MouseListener listener) + @Override + public void removeMouseListener(MouseListener listener) { this.eventListeners.remove(MouseListener.class, listener); } - public void addMouseMotionListener(MouseMotionListener listener) + @Override + public void addMouseMotionListener(MouseMotionListener listener) { this.eventListeners.add(MouseMotionListener.class, listener); } - public void removeMouseMotionListener(MouseMotionListener listener) + @Override + public void removeMouseMotionListener(MouseMotionListener listener) { this.eventListeners.remove(MouseMotionListener.class, listener); } - public void addMouseWheelListener(MouseWheelListener listener) + @Override + public void addMouseWheelListener(MouseWheelListener listener) { this.eventListeners.add(MouseWheelListener.class, listener); } - public void removeMouseWheelListener(MouseWheelListener listener) + @Override + public void removeMouseWheelListener(MouseWheelListener listener) { this.eventListeners.remove(MouseWheelListener.class, listener); } @@ -872,7 +950,8 @@ protected void callMouseExitedListeners(MouseEvent event) } } - public void propertyChange(PropertyChangeEvent event) + @Override + public void propertyChange(PropertyChangeEvent event) { if (this.wwd == null) { diff --git a/src/gov/nasa/worldwind/awt/WorldWindowGLCanvas.java b/src/gov/nasa/worldwind/awt/WorldWindowGLCanvas.java index 8a9942751b..3fb63c14ba 100644 --- a/src/gov/nasa/worldwind/awt/WorldWindowGLCanvas.java +++ b/src/gov/nasa/worldwind/awt/WorldWindowGLCanvas.java @@ -94,7 +94,6 @@ public WorldWindowGLCanvas() this.createView(); this.createDefaultInputHandler(); WorldWind.addPropertyChangeListener(WorldWind.SHUTDOWN_EVENT, this); - WorldWindowImpl.configureIdentityPixelScale(this); this.wwd.endInitialization(); } catch (Exception e) @@ -132,7 +131,6 @@ public WorldWindowGLCanvas(WorldWindow shareWith) this.createView(); this.createDefaultInputHandler(); WorldWind.addPropertyChangeListener(WorldWind.SHUTDOWN_EVENT, this); - WorldWindowImpl.configureIdentityPixelScale(this); this.wwd.endInitialization(); } catch (Exception e) @@ -172,7 +170,6 @@ public WorldWindowGLCanvas(WorldWindow shareWith, java.awt.GraphicsDevice device this.createView(); this.createDefaultInputHandler(); WorldWind.addPropertyChangeListener(WorldWind.SHUTDOWN_EVENT, this); - WorldWindowImpl.configureIdentityPixelScale(this); this.wwd.endInitialization(); } catch (Exception e) @@ -216,7 +213,6 @@ public WorldWindowGLCanvas(WorldWindow shareWith, java.awt.GraphicsDevice device this.createView(); this.createDefaultInputHandler(); WorldWind.addPropertyChangeListener(WorldWind.SHUTDOWN_EVENT, this); - WorldWindowImpl.configureIdentityPixelScale(this); this.wwd.endInitialization(); } catch (Exception e) @@ -227,7 +223,8 @@ public WorldWindowGLCanvas(WorldWindow shareWith, java.awt.GraphicsDevice device } } - public void propertyChange(PropertyChangeEvent evt) + @Override + public void propertyChange(PropertyChangeEvent evt) { if(this.wwd == evt.getSource()) this.firePropertyChange(evt); @@ -237,7 +234,8 @@ public void propertyChange(PropertyChangeEvent evt) this.shutdown(); } - public void shutdown() + @Override + public void shutdown() { WorldWind.removePropertyChangeListener(WorldWind.SHUTDOWN_EVENT, this); this.wwd.shutdown(); @@ -267,12 +265,14 @@ protected void createDefaultInputHandler() this.setInputHandler((InputHandler) WorldWind.createConfigurationComponent(AVKey.INPUT_HANDLER_CLASS_NAME)); } - public InputHandler getInputHandler() + @Override + public InputHandler getInputHandler() { return this.wwd.getInputHandler(); } - public void setInputHandler(InputHandler inputHandler) + @Override + public void setInputHandler(InputHandler inputHandler) { if (this.wwd.getInputHandler() != null) this.wwd.getInputHandler().setEventSource(null); // remove this window as a source of events @@ -282,153 +282,182 @@ public void setInputHandler(InputHandler inputHandler) inputHandler.setEventSource(this); } - public SceneController getSceneController() + @Override + public SceneController getSceneController() { return this.wwd.getSceneController(); } - public void setSceneController(SceneController sceneController) + @Override + public void setSceneController(SceneController sceneController) { this.wwd.setSceneController(sceneController); } - public GpuResourceCache getGpuResourceCache() + @Override + public GpuResourceCache getGpuResourceCache() { return this.wwd.getGpuResourceCache(); } - public void redraw() + @Override + public void redraw() { this.repaint(); } - public void redrawNow() + @Override + public void redrawNow() { this.wwd.redrawNow(); } - public void setModel(Model model) + @Override + public void setModel(Model model) { // null models are permissible this.wwd.setModel(model); } - public Model getModel() + @Override + public Model getModel() { return this.wwd.getModel(); } - public void setView(View view) + @Override + public void setView(View view) { // null views are permissible if (view != null) this.wwd.setView(view); } - public View getView() + @Override + public View getView() { return this.wwd.getView(); } - public void setModelAndView(Model model, View view) + @Override + public void setModelAndView(Model model, View view) { // null models/views are permissible this.setModel(model); this.setView(view); } - public void addRenderingListener(RenderingListener listener) + @Override + public void addRenderingListener(RenderingListener listener) { this.wwd.addRenderingListener(listener); } - public void removeRenderingListener(RenderingListener listener) + @Override + public void removeRenderingListener(RenderingListener listener) { this.wwd.removeRenderingListener(listener); } - public void addSelectListener(SelectListener listener) + @Override + public void addSelectListener(SelectListener listener) { this.wwd.getInputHandler().addSelectListener(listener); this.wwd.addSelectListener(listener); } - public void removeSelectListener(SelectListener listener) + @Override + public void removeSelectListener(SelectListener listener) { this.wwd.getInputHandler().removeSelectListener(listener); this.wwd.removeSelectListener(listener); } - public void addPositionListener(PositionListener listener) + @Override + public void addPositionListener(PositionListener listener) { this.wwd.addPositionListener(listener); } - public void removePositionListener(PositionListener listener) + @Override + public void removePositionListener(PositionListener listener) { this.wwd.removePositionListener(listener); } - public void addRenderingExceptionListener(RenderingExceptionListener listener) + @Override + public void addRenderingExceptionListener(RenderingExceptionListener listener) { this.wwd.addRenderingExceptionListener(listener); } - public void removeRenderingExceptionListener(RenderingExceptionListener listener) + @Override + public void removeRenderingExceptionListener(RenderingExceptionListener listener) { this.wwd.removeRenderingExceptionListener(listener); } - public Position getCurrentPosition() + @Override + public Position getCurrentPosition() { return this.wwd.getCurrentPosition(); } - public PickedObjectList getObjectsAtCurrentPosition() + @Override + public PickedObjectList getObjectsAtCurrentPosition() { return this.wwd.getSceneController() != null ? this.wwd.getSceneController().getPickedObjectList() : null; } - public PickedObjectList getObjectsInSelectionBox() + @Override + public PickedObjectList getObjectsInSelectionBox() { return this.wwd.getSceneController() != null ? this.wwd.getSceneController().getObjectsInPickRectangle() : null; } - public Object setValue(String key, Object value) + @Override + public Object setValue(String key, Object value) { return this.wwd.setValue(key, value); } - public AVList setValues(AVList avList) + @Override + public AVList setValues(AVList avList) { return this.wwd.setValues(avList); } - public Object getValue(String key) + @Override + public Object getValue(String key) { return this.wwd.getValue(key); } - public Collection getValues() + @Override + public Collection getValues() { return this.wwd.getValues(); } - public Set> getEntries() + @Override + public Set> getEntries() { return this.wwd.getEntries(); } - public String getStringValue(String key) + @Override + public String getStringValue(String key) { return this.wwd.getStringValue(key); } - public boolean hasKey(String key) + @Override + public boolean hasKey(String key) { return this.wwd.hasKey(key); } - public Object removeKey(String key) + @Override + public Object removeKey(String key) { return this.wwd.removeKey(key); } @@ -463,28 +492,53 @@ public void firePropertyChange(String propertyName, Object oldValue, Object newV super.firePropertyChange(propertyName, oldValue, newValue); } - public void firePropertyChange(PropertyChangeEvent propertyChangeEvent) + @Override + public void firePropertyChange(PropertyChangeEvent propertyChangeEvent) { this.wwd.firePropertyChange(propertyChangeEvent); } - public AVList copy() + @Override + public AVList copy() { return this.wwd.copy(); } - public AVList clearList() + @Override + public AVList clearList() { return this.wwd.clearList(); } - public void setPerFrameStatisticsKeys(Set keys) + @Override + public void setPerFrameStatisticsKeys(Set keys) { this.wwd.setPerFrameStatisticsKeys(keys); } - public Collection getPerFrameStatistics() + @Override + public Collection 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]); + } } diff --git a/src/gov/nasa/worldwind/awt/WorldWindowGLJPanel.java b/src/gov/nasa/worldwind/awt/WorldWindowGLJPanel.java index 5630b5b874..0b2a37322c 100644 --- a/src/gov/nasa/worldwind/awt/WorldWindowGLJPanel.java +++ b/src/gov/nasa/worldwind/awt/WorldWindowGLJPanel.java @@ -93,7 +93,6 @@ public WorldWindowGLJPanel() this.createView(); this.createDefaultInputHandler(); WorldWind.addPropertyChangeListener(WorldWind.SHUTDOWN_EVENT, this); - WorldWindowImpl.configureIdentityPixelScale(this); this.wwd.endInitialization(); } catch (Exception e) @@ -131,7 +130,6 @@ public WorldWindowGLJPanel(WorldWindow shareWith) this.createView(); this.createDefaultInputHandler(); WorldWind.addPropertyChangeListener(WorldWind.SHUTDOWN_EVENT, this); - WorldWindowImpl.configureIdentityPixelScale(this); this.wwd.endInitialization(); } catch (Exception e) @@ -175,7 +173,6 @@ public WorldWindowGLJPanel(WorldWindow shareWith, GLCapabilities capabilities, this.createView(); this.createDefaultInputHandler(); WorldWind.addPropertyChangeListener(WorldWind.SHUTDOWN_EVENT, this); - WorldWindowImpl.configureIdentityPixelScale(this); this.wwd.endInitialization(); } catch (Exception e) diff --git a/src/gov/nasa/worldwind/event/SelectEvent.java b/src/gov/nasa/worldwind/event/SelectEvent.java index ac07024c64..0100deae12 100644 --- a/src/gov/nasa/worldwind/event/SelectEvent.java +++ b/src/gov/nasa/worldwind/event/SelectEvent.java @@ -65,7 +65,6 @@ * @author tag * @version $Id: SelectEvent.java 1171 2013-02-11 21:45:02Z dcollins $ */ -@SuppressWarnings({"StringEquality"}) public class SelectEvent extends WWEvent { /** The user clicked the left mouse button while the cursor was over picked object. */ @@ -96,15 +95,15 @@ public class SelectEvent extends WWEvent * The user has selected one or more of objects using a selection box. A box rollover event is generated every frame * if one or more objects intersect the box, in which case the event's pickedObjects list contain the selected * objects. A box rollover event is generated once when the selection becomes empty, in which case the event's - * pickedObjects is null. In either case, the event's pickRect contains the selection box bounds in AWT - * screen coordinates. + * pickedObjects is null. In either case, the event's pickRect contains the + * selection box bounds in GL surface coordinates. */ public static final String BOX_ROLLOVER = "gov.nasa.worldwind.SelectEvent.BoxRollover"; private final String eventAction; - private final Point pickPoint; - private final Rectangle pickRect; - private final MouseEvent mouseEvent; + private final Point pickPoint; // GL surface coordinates + private final Rectangle pickRect; // GL surface coordinates + private final MouseEvent mouseEvent; // GL surface coordinates private final PickedObjectList pickedObjects; public SelectEvent(Object source, String eventAction, MouseEvent mouseEvent, PickedObjectList pickedObjects) diff --git a/src/gov/nasa/worldwind/geom/LatLon.java b/src/gov/nasa/worldwind/geom/LatLon.java index acc1e29a7b..30e3385205 100644 --- a/src/gov/nasa/worldwind/geom/LatLon.java +++ b/src/gov/nasa/worldwind/geom/LatLon.java @@ -1272,6 +1272,7 @@ public static boolean locationsCrossDateLine(Iterable location LatLon pos = null; for (LatLon posNext : locations) { + if (posNext == null) break; if (pos != null) { // A segment cross the line if end pos have different longitude signs diff --git a/src/gov/nasa/worldwind/geom/Sector.java b/src/gov/nasa/worldwind/geom/Sector.java index 5b1e73092c..9a38490d96 100644 --- a/src/gov/nasa/worldwind/geom/Sector.java +++ b/src/gov/nasa/worldwind/geom/Sector.java @@ -284,6 +284,7 @@ public static Sector boundingSector(Iterable locations) { double maxLon = Angle.NEG180.getDegrees(); for (LatLon p : locations) { + if (p == null) break; double lat = p.getLatitude().getDegrees(); if (lat < minLat) { minLat = lat; diff --git a/src/gov/nasa/worldwind/layers/CompassLayer.java b/src/gov/nasa/worldwind/layers/CompassLayer.java index 2c4bcb7cf8..0116a3fcf6 100644 --- a/src/gov/nasa/worldwind/layers/CompassLayer.java +++ b/src/gov/nasa/worldwind/layers/CompassLayer.java @@ -67,17 +67,20 @@ public class CompassLayer extends AbstractLayer protected class OrderedIcon implements OrderedRenderable { - public double getDistanceFromEye() + @Override + public double getDistanceFromEye() { return 0; } - public void pick(DrawContext dc, Point pickPoint) + @Override + public void pick(DrawContext dc, Point pickPoint) { CompassLayer.this.draw(dc); } - public void render(DrawContext dc) + @Override + public void render(DrawContext dc) { CompassLayer.this.draw(dc); } @@ -295,7 +298,8 @@ public void setLocationOffset(Vec4 locationOffset) this.locationOffset = locationOffset; } - protected void doRender(DrawContext dc) + @Override + protected void doRender(DrawContext dc) { if (dc.isContinuous2DGlobe() && this.frameStampForDrawing == dc.getFrameTimeStamp()) return; @@ -305,7 +309,8 @@ protected void doRender(DrawContext dc) this.frameStampForDrawing = dc.getFrameTimeStamp(); } - protected void doPick(DrawContext dc, Point pickPoint) + @Override + protected void doPick(DrawContext dc, Point pickPoint) { if (dc.isContinuous2DGlobe() && this.frameStampForPicking == dc.getFrameTimeStamp()) return; @@ -414,7 +419,7 @@ protected void draw(DrawContext dc) Vec4 center = new Vec4(locationSW.x + width * scale / 2, locationSW.y + height * scale / 2, 0); double px = dc.getPickPoint().x - center.x; - double py = viewport.getHeight() - dc.getPickPoint().y - center.y; + double py = dc.getPickPoint().y - center.y; Angle pickHeading = Angle.fromRadians(Math.atan2(px, py)); pickHeading = pickHeading.degrees >= 0 ? pickHeading : pickHeading.addDegrees(360); po.setValue("Heading", pickHeading); diff --git a/src/gov/nasa/worldwind/layers/TerrainProfileLayer.java b/src/gov/nasa/worldwind/layers/TerrainProfileLayer.java index d675ad6699..8f1303ff6e 100644 --- a/src/gov/nasa/worldwind/layers/TerrainProfileLayer.java +++ b/src/gov/nasa/worldwind/layers/TerrainProfileLayer.java @@ -148,7 +148,6 @@ public TerrainProfileLayer() { * * @return true if the profile graph is minimized. */ - @SuppressWarnings({"UnusedDeclaration"}) public boolean getIsMinimized() { return this.isMinimized; } @@ -171,7 +170,6 @@ public void setIsMinimized(boolean state) { * * @return true if the profile graph is maximized. */ - @SuppressWarnings({"UnusedDeclaration"}) public boolean getIsMaximized() { return this.isMaximized; } @@ -262,7 +260,6 @@ public double getOpacity() { * * @return the graphic-to-viewport scale factor. */ - @SuppressWarnings({"UnusedDeclaration"}) public double getToViewportScale() { return toViewportScale; } @@ -275,7 +272,6 @@ public double getToViewportScale() { * * @param toViewportScale the graphic to viewport scale factor. */ - @SuppressWarnings({"UnusedDeclaration"}) public void setToViewportScale(double toViewportScale) { this.toViewportScale = toViewportScale; } @@ -305,7 +301,6 @@ public void setPosition(String position) { * * @return the screen location of the graph center if set (can be null). */ - @SuppressWarnings({"UnusedDeclaration"}) public Point getLocationCenter() { return this.locationCenter; } @@ -325,7 +320,6 @@ public void setLocationCenter(Point point) { * * @return the location offset. Will be null if no offset has been specified. */ - @SuppressWarnings({"UnusedDeclaration"}) public Vec4 getLocationOffset() { return locationOffset; } @@ -349,7 +343,6 @@ public void setLocationOffset(Vec4 locationOffset) { * * @return the layer's resize behavior. */ - @SuppressWarnings({"UnusedDeclaration"}) public String getResizeBehavior() { return resizeBehavior; } @@ -365,7 +358,6 @@ public String getResizeBehavior() { * * @param resizeBehavior the desired resize behavior */ - @SuppressWarnings({"UnusedDeclaration"}) public void setResizeBehavior(String resizeBehavior) { this.resizeBehavior = resizeBehavior; } @@ -384,7 +376,6 @@ public void setBorderWidth(int borderWidth) { this.borderWidth = borderWidth; } - @SuppressWarnings({"UnusedDeclaration"}) public String getUnit() { return this.unit; } @@ -503,7 +494,6 @@ public double getProfileLenghtFactor() { * * @return the profile start position lat/lon. */ - @SuppressWarnings({"UnusedDeclaration"}) public LatLon getStartLatLon() { return this.startLatLon; } @@ -527,7 +517,6 @@ public void setStartLatLon(LatLon latLon) { * * @return the profile end position lat/lon. */ - @SuppressWarnings({"UnusedDeclaration"}) public LatLon getEndLatLon() { return this.endLatLon; } @@ -551,7 +540,6 @@ public void setEndLatLon(LatLon latLon) { * * @return the number of elevation samples in the profile. */ - @SuppressWarnings({"UnusedDeclaration"}) public int getSamples() { return this.samples; } @@ -561,7 +549,6 @@ public int getSamples() { * * @param number the number of elevation samples in the profile. */ - @SuppressWarnings({"UnusedDeclaration"}) public void setSamples(int number) { this.samples = Math.abs(number); } @@ -589,7 +576,6 @@ public void setZeroBased(boolean state) { * * @return the object position the graph follows. */ - @SuppressWarnings({"UnusedDeclaration"}) public Position getObjectPosition() { return this.objectPosition; } @@ -609,7 +595,6 @@ public void setObjectPosition(Position pos) { * * @return the object heading the graph follows. */ - @SuppressWarnings({"UnusedDeclaration"}) public Angle getObjectHeading() { return this.objectHeading; } @@ -629,7 +614,6 @@ public void setObjectHeading(Angle heading) { * * @return the path positions that the profile follows. */ - @SuppressWarnings({"UnusedDeclaration"}) public List getPathPositions() { return this.pathPositions; } @@ -708,7 +692,6 @@ public void setPathType(String pathType) { * * @return the Path used to render the profile line on the ground. */ - @SuppressWarnings({"UnusedDeclaration"}) public Path getProfileLine() { return this.selectionShape; } @@ -718,7 +701,6 @@ public Path getProfileLine() { * * @return the Path used to render the picked position on the terrain. */ - @SuppressWarnings({"UnusedDeclaration"}) public Path getPickedLine() { return this.selectionShape; } @@ -728,7 +710,6 @@ public Path getPickedLine() { * * @return true is the profile line is displayed over the ground. */ - @SuppressWarnings({"UnusedDeclaration"}) public boolean isShowProfileLine() { return this.showProfileLine; } @@ -747,7 +728,6 @@ public void setShowProfileLine(boolean state) { * * @return true if the picked line is displayed over the ground. */ - @SuppressWarnings({"UnusedDeclaration"}) public boolean isShowPickedLine() { return this.showPickedLine; } @@ -757,7 +737,6 @@ public boolean isShowPickedLine() { * * @param state if the picked line should be displayed over the ground. */ - @SuppressWarnings({"UnusedDeclaration"}) public void setShowPickedLine(boolean state) { this.showPickedLine = state; } @@ -986,6 +965,7 @@ protected void drawGraph(DrawContext dc, Dimension dimension) { (byte) this.color.getBlue(), (byte) 100); gl.glBegin(GL2.GL_TRIANGLE_STRIP); for (i = 0; i < this.samples; i++) { + if (this.positions[i] == null) break; x = i * lengthStep * stepX; y = (this.positions[i].getElevation() - min) * stepY; gl.glVertex3d(x, 0, 0); @@ -997,6 +977,7 @@ protected void drawGraph(DrawContext dc, Dimension dimension) { gl.glColor4d(colorRGB[0], colorRGB[1], colorRGB[2], this.getOpacity()); gl.glBegin(GL2.GL_LINE_STRIP); for (i = 0; i < this.samples; i++) { + if (this.positions[i] == null) break; x = i * lengthStep * stepX; y = (this.positions[i].getElevation() - min) * stepY; gl.glVertex3d(x, y, 0); @@ -1274,12 +1255,11 @@ protected Position computePickPosition(DrawContext dc, Vec4 locationSW, Dimensio this.pickedSample = -1; Point pickPoint = dc.getPickPoint(); if (pickPoint != null && this.positions != null && !this.follow.equals(FOLLOW_CURSOR)) { - Rectangle viewport = dc.getView().getViewport(); // Check if pickpoint is inside the graph if (pickPoint.getX() >= locationSW.getX() && pickPoint.getX() < locationSW.getX() + mapSize.width - && viewport.height - pickPoint.getY() >= locationSW.getY() - && viewport.height - pickPoint.getY() < locationSW.getY() + mapSize.height) { + && pickPoint.getY() >= locationSW.getY() + && pickPoint.getY() < locationSW.getY() + mapSize.height) { // Find sample - Note: only works when graph expends over the full width int sample = (int) (((double) (pickPoint.getX() - locationSW.getX()) / mapSize.width) * this.samples); if (sample >= 0 && sample < this.samples) { diff --git a/src/gov/nasa/worldwind/layers/ViewControlsSelectListener.java b/src/gov/nasa/worldwind/layers/ViewControlsSelectListener.java index 35b79f478e..5f1c3fb356 100644 --- a/src/gov/nasa/worldwind/layers/ViewControlsSelectListener.java +++ b/src/gov/nasa/worldwind/layers/ViewControlsSelectListener.java @@ -496,7 +496,7 @@ protected Angle computePanHeading(OrbitView view, ScreenAnnotation control) double size = control.getAttributes().getSize().width * control.getAttributes().getScale(); Vec4 center = new Vec4(control.getScreenPoint().x, control.getScreenPoint().y + size / 2, 0); double px = lastPickPoint.x - center.x; - double py = view.getViewport().getHeight() - lastPickPoint.y - center.y; + double py = lastPickPoint.y - center.y; Angle heading = view.getHeading().add(Angle.fromRadians(Math.atan2(px, py))); heading = heading.degrees >= 0 ? heading : heading.addDegrees(360); return heading; @@ -508,7 +508,7 @@ protected Angle computePanAmount(Globe globe, OrbitView view, ScreenAnnotation c double size = control.getAttributes().getSize().width * control.getAttributes().getScale(); Vec4 center = new Vec4(control.getScreenPoint().x, control.getScreenPoint().y + size / 2, 0); double px = lastPickPoint.x - center.x; - double py = view.getViewport().getHeight() - lastPickPoint.y - center.y; + double py = lastPickPoint.y - center.y; double pickDistance = Math.sqrt(px * px + py * py); double pickDistanceFactor = Math.min(pickDistance / 10, 5); @@ -547,7 +547,7 @@ protected Angle computeLookPitch(OrbitView view, ScreenAnnotation control, doubl // Compute last pick point 'pitch' relative to look control center on y double size = control.getAttributes().getSize().width * control.getAttributes().getScale(); Vec4 center = new Vec4(control.getScreenPoint().x, control.getScreenPoint().y + size / 2, 0); - double py = view.getViewport().getHeight() - lastPickPoint.y - center.y; + double py = lastPickPoint.y - center.y; double pickDistanceFactor = Math.min(Math.abs(py) / 3000, 5) * Math.signum(py); // New pitch Angle pitch = view.getPitch().add(Angle.fromRadians(pitchStep * pickDistanceFactor)); diff --git a/src/gov/nasa/worldwind/layers/WorldMapLayer.java b/src/gov/nasa/worldwind/layers/WorldMapLayer.java index 5d8c84f534..151d8b451b 100644 --- a/src/gov/nasa/worldwind/layers/WorldMapLayer.java +++ b/src/gov/nasa/worldwind/layers/WorldMapLayer.java @@ -700,11 +700,11 @@ protected Position computePickPosition(DrawContext dc, Vec4 locationSW, Dimensio // Check if pickpoint is inside the map if (pickPoint.getX() >= locationSW.getX() && pickPoint.getX() < locationSW.getX() + mapSize.width - && viewport.height - pickPoint.getY() >= locationSW.getY() - && viewport.height - pickPoint.getY() < locationSW.getY() + mapSize.height) + && pickPoint.getY() >= locationSW.getY() + && pickPoint.getY() < locationSW.getY() + mapSize.height) { double lon = (pickPoint.getX() - locationSW.getX()) / mapSize.width * 360 - 180; - double lat = (viewport.height - pickPoint.getY() - locationSW.getY()) / mapSize.height * 180 - 90; + double lat = (pickPoint.getY() - locationSW.getY()) / mapSize.height * 180 - 90; double pickAltitude = 1000e3; pickPosition = new Position(Angle.fromDegrees(lat), Angle.fromDegrees(lon), pickAltitude); } diff --git a/src/gov/nasa/worldwind/pick/PickSupport.java b/src/gov/nasa/worldwind/pick/PickSupport.java index de36c75420..002107ce1e 100644 --- a/src/gov/nasa/worldwind/pick/PickSupport.java +++ b/src/gov/nasa/worldwind/pick/PickSupport.java @@ -135,7 +135,7 @@ public PickedObject getTopObject(DrawContext dc, Point pickPoint) * objects are currently registered with this PickSupport. * * @param dc the draw context which receives the picked object. - * @param pickPoint the point in AWT screen coordinates. + * @param pickPoint the point in GL surface coordinates. * @param layer the layer associated with the picked object. * * @return the picked object added to the draw context, or null if no picked object is drawn at the @@ -166,11 +166,11 @@ public PickedObject resolvePick(DrawContext dc, Point pickPoint, Layer layer) } /** - * Adds a picked object registered with this PickSupport that is drawn at the specified point in AWT screen + * Adds a picked object registered with this PickSupport that is drawn at the specified point in GL surface * coordinates (if one exists) to the draw context's list of picked objects. * * @param dc the draw context which receives the picked object. - * @param pickPoint the point in AWT screen coordinates. + * @param pickPoint the point in GL surface coordinates. * @param layer the layer associated with the picked object. * * @return the picked object added to the draw context, or null if no picked object is drawn at the @@ -195,7 +195,7 @@ protected PickedObject doResolvePick(DrawContext dc, Point pickPoint, Layer laye * screen coordinates (if any) to the draw context's list of picked objects. * * @param dc the draw context which receives the picked objects. - * @param pickRect the rectangle in AWT screen coordinates. + * @param pickRect the rectangle in GL surface coordinates. * @param layer the layer associated with the picked objects. */ protected void doResolvePick(DrawContext dc, Rectangle pickRect, Layer layer) @@ -226,7 +226,7 @@ protected void doResolvePick(DrawContext dc, Rectangle pickRect, Layer layer) } /** - * Returns the framebuffer RGB color for a point in AWT screen coordinates, formatted as a pick color code. The red, + * Returns the framebuffer RGB color for a point in GL surface coordinates, formatted as a pick color code. The red, * green, and blue components are each stored as an 8-bit unsigned integer, and packed into bits 0-23 of the * returned integer as follows: bits 16-23 are red, bits 8-15 are green, and bits 0-7 are blue. This format is * consistent with the RGB integers used to create the pick colors. @@ -235,7 +235,7 @@ protected void doResolvePick(DrawContext dc, Rectangle pickRect, Layer layer) * outside the draw context's drawable area. * * @param dc the draw context to return a color for. - * @param pickPoint the point to return a color for, in AWT screen coordinates. + * @param pickPoint the point to return a color for, in GL surface coordinates. * * @return the RGB color corresponding to the specified point. */ diff --git a/src/gov/nasa/worldwind/render/AbstractAnnotation.java b/src/gov/nasa/worldwind/render/AbstractAnnotation.java index 25cb16b38f..82cbad8bff 100644 --- a/src/gov/nasa/worldwind/render/AbstractAnnotation.java +++ b/src/gov/nasa/worldwind/render/AbstractAnnotation.java @@ -462,7 +462,6 @@ protected void drawTopLevelAnnotation(DrawContext dc, int x, int y, int width, i } } - @SuppressWarnings({"UnusedDeclaration"}) protected void applyScreenTransform(DrawContext dc, int x, int y, int width, int height, double scale) { double finalScale = scale * this.computeScale(dc); @@ -475,7 +474,6 @@ protected void applyScreenTransform(DrawContext dc, int x, int y, int width, int gl.glTranslated(-width / 2, 0, 0); } - @SuppressWarnings({"UnusedDeclaration"}) protected double computeScale(DrawContext dc) { double scale = this.attributes.getScale(); @@ -489,7 +487,6 @@ protected double computeScale(DrawContext dc) return scale; } - @SuppressWarnings({"UnusedDeclaration"}) protected double computeOpacity(DrawContext dc) { double opacity = this.attributes.getOpacity(); @@ -616,7 +613,6 @@ protected void drawBackgroundImage(DrawContext dc, int width, int height, double this.doDrawBackgroundTexture(dc, width, height, opacity, pickPosition, texture); } - @SuppressWarnings({"UnusedDeclaration"}) protected void doDrawBackgroundTexture(DrawContext dc, int width, int height, double opacity, Position pickPosition, WWTexture texture) { @@ -660,7 +656,6 @@ protected void doDrawBackgroundTexture(DrawContext dc, int width, int height, do } } - @SuppressWarnings({"UnusedDeclaration"}) protected void applyBackgroundTextureState(DrawContext dc, int width, int height, double opacity, WWTexture texture) { @@ -721,7 +716,6 @@ protected void transformImageCoordsToBackgroundImageCoords(DrawContext dc, WWTex * @param texture the texture to transform from Annotation background image coordinates to Annotation geometry * coordinates. */ - @SuppressWarnings({"UnusedDeclaration"}) protected void transformBackgroundImageCoordsToAnnotationCoords(DrawContext dc, int width, int height, WWTexture texture) { @@ -750,7 +744,6 @@ protected void transformBackgroundImageCoordsToAnnotationCoords(DrawContext dc, //******************** Border Rendering **********************// //**************************************************************// - @SuppressWarnings({"UnusedDeclaration"}) protected void drawBorder(DrawContext dc, int width, int height, double opacity, Position pickPosition) { if (this.getAttributes().getBorderWidth() <= 0) @@ -813,8 +806,7 @@ protected void drawText(DrawContext dc, int width, int height, double opacity, P return; java.awt.Rectangle screenInsetBounds = this.transformByModelview(dc, insetBounds); - java.awt.Point glPickPoint = this.glPointFromAWTPoint(dc, dc.getPickPoint()); - if (!screenInsetBounds.contains(glPickPoint)) + if (!screenInsetBounds.contains(dc.getPickPoint())) return; } @@ -897,7 +889,6 @@ protected void drawPlainText(DrawContext dc, int x, int y, int lineHeight, doubl } } - @SuppressWarnings({"UnusedDeclaration"}) protected void drawHTML(DrawContext dc, int x, int y, int lineHeight, double opacity, Object pickObject, Position pickPosition, String text) { @@ -941,14 +932,12 @@ protected void drawChildren(DrawContext dc, int width, int height, double opacit } } - @SuppressWarnings({"UnusedDeclaration"}) protected void doDrawChildren(DrawContext dc, java.awt.Rectangle bounds, double opacity, Position pickPosition) { this.layoutManager.setPickSupport(this.pickSupport); this.layoutManager.drawAnnotations(dc, bounds, this.childList, opacity, pickPosition); } - @SuppressWarnings({"UnusedDeclaration"}) protected void beginDrawChildren(DrawContext dc, java.awt.Rectangle bounds) { this.layoutManager.beginDrawAnnotations(dc, bounds); @@ -1051,15 +1040,6 @@ protected java.awt.Rectangle transformByModelview(DrawContext dc, java.awt.Recta return new java.awt.Rectangle((int) origin.x, (int) origin.y, (int) size.x, (int) size.y); } - protected java.awt.Point glPointFromAWTPoint(DrawContext dc, java.awt.Point awtPoint) - { - if (dc.getView() == null || dc.getView().getViewport() == null) - return null; - - java.awt.Rectangle viewport = dc.getView().getViewport(); - return new java.awt.Point(awtPoint.x, viewport.height - awtPoint.y - 1); - } - //**************************************************************// //******************** Text Utilities ************************// //**************************************************************// diff --git a/src/gov/nasa/worldwind/render/AbstractBrowserBalloon.java b/src/gov/nasa/worldwind/render/AbstractBrowserBalloon.java index 9c77cd54fc..a4d6b2bd29 100644 --- a/src/gov/nasa/worldwind/render/AbstractBrowserBalloon.java +++ b/src/gov/nasa/worldwind/render/AbstractBrowserBalloon.java @@ -1731,7 +1731,7 @@ protected void drawResizeControl(DrawContext dc, OrderedBrowserBalloon obb) // Compute the screen rectangle in AWT coordinates (origin top left). Rectangle awtScreenRect = new Rectangle(obb.screenRect.x, - dc.getView().getViewport().height - obb.screenRect.y - obb.screenRect.height, + obb.screenRect.y - obb.screenRect.height, obb.screenRect.width, obb.screenRect.height); Color color = dc.getUniquePickColor(); diff --git a/src/gov/nasa/worldwind/render/DrawContext.java b/src/gov/nasa/worldwind/render/DrawContext.java index 750955b933..ffc935a719 100644 --- a/src/gov/nasa/worldwind/render/DrawContext.java +++ b/src/gov/nasa/worldwind/render/DrawContext.java @@ -345,14 +345,14 @@ public interface DrawContext extends WWObject, Disposable Color getClearColor(); /** - * Returns the framebuffer RGB color for a point in AWT screen coordinates, formatted as a pick color code. The red, + * Returns the framebuffer RGB color for a point in GL surface coordinates, formatted as a pick color code. The red, * green, and blue components are each stored as an 8-bit unsigned integer, and packed into bits 0-23 of the * returned integer as follows: bits 16-23 are red, bits 8-15 are green, and bits 0-7 are blue. This format is * consistent with the RGB integers used to create the pick colors in getUniquePickColor. *

* This returns 0 if the point contains the clear color, or is outside this draw context's drawable area. * - * @param point the point to return a color for, in AWT screen coordinates. + * @param point the point to return a color for, in GL surface coordinates. * * @return the RGB color corresponding to the specified point. * @@ -361,7 +361,7 @@ public interface DrawContext extends WWObject, Disposable int getPickColorAtPoint(Point point); /** - * Returns an array of the unique framebuffer RGB colors within a rectangle in AWT screen coordinates, formatted as + * Returns an array of the unique framebuffer RGB colors within a rectangle in GL surface coordinates, formatted as * pick color codes. The red, green, and blue components are each stored as an 8-bit unsigned integer, and packed * into bits 0-23 of the returned integers as follows: bits 16-23 are red, bits 8-15 are green, and bits 0-7 are * blue. This format is consistent with the RGB integers used to create the pick colors in getUniquePickColor. @@ -376,7 +376,7 @@ public interface DrawContext extends WWObject, Disposable * the colors that must be considered by this method and the caller. When specified, these integers must be * formatted exactly as the integers this method returns. * - * @param rectangle the rectangle to return unique colors for, in AWT screen coordinates. + * @param rectangle the rectangle to return unique colors for, in GL surface coordinates. * @param minAndMaxColorCodes an two element array representing the minimum and maximum RGB colors to return. May be * null to specify that all color codes must be returned. * @@ -502,7 +502,7 @@ public interface DrawContext extends WWObject, Disposable SurfaceTileRenderer getGeographicSurfaceTileRenderer(); /** - * Returns the current pick point in AWT screen coordinates. + * Returns the current pick point in GL surface coordinates. * * @return the current pick point, or null if no pick point is available. * @@ -511,7 +511,7 @@ public interface DrawContext extends WWObject, Disposable Point getPickPoint(); /** - * Specifies the current pick point in AWT screen coordinates, or null to indicate that there is no + * Specifies the current pick point in GL surface coordinates, or null to indicate that there is no * pick point. During each pick traversal, layers determine if their contents are drawn at the pick point. If so, * layers add each unique picked object to a PickedObjectList on this draw context by calling {@link * #addPickedObject(gov.nasa.worldwind.pick.PickedObject)}. This list can be accessed by calling {@link @@ -525,7 +525,7 @@ public interface DrawContext extends WWObject, Disposable void setPickPoint(Point pickPoint); /** - * Returns the current pick rectangle in AWT screen coordinates. + * Returns the current pick rectangle in GL surface coordinates. * * @return the current pick rectangle, or null if no pick rectangle is current. * @@ -534,7 +534,7 @@ public interface DrawContext extends WWObject, Disposable Rectangle getPickRectangle(); /** - * Specifies the current pick rectangle in AWT screen coordinates, or null to indicate that there is no + * Specifies the current pick rectangle in GL surface coordinates, or null to indicate that there is no * pick rectangle. During each pick traversal, layers determine if their contents intersect the pick rectangle. If * so, layers add each unique picked object to a PickedObjectList on this draw context by calling {@link * #addObjectInPickRectangle(gov.nasa.worldwind.pick.PickedObject)}. This is list can be accessed by calling {@link @@ -1046,4 +1046,9 @@ public interface DrawContext extends WWObject, Disposable boolean is2DGlobe(); boolean isContinuous2DGlobe(); + + /** + * Convert AWT effective screen location to GL surface location using DPI scaling. + */ + int [] awtPointToGLpoint(Point pt); } diff --git a/src/gov/nasa/worldwind/render/DrawContextImpl.java b/src/gov/nasa/worldwind/render/DrawContextImpl.java index 4c3cf88c92..eaed5cc1c7 100644 --- a/src/gov/nasa/worldwind/render/DrawContextImpl.java +++ b/src/gov/nasa/worldwind/render/DrawContextImpl.java @@ -87,15 +87,15 @@ public class DrawContextImpl extends WWObjectImpl implements DrawContext protected boolean pickingMode = false; protected boolean deepPickingMode = false; /** - * Indicates the current pick point in AWT screen coordinates, or null to indicate that there is no + * Indicates the current pick point in GL screen coordinates, or null to indicate that there is no * pick point. Initially null. */ - protected Point pickPoint = null; + private Point pickPoint = null; /** - * Indicates the current pick rectangle in AWT screen coordinates, or null to indicate that there is no + * Indicates the current pick rectangle in GL screen coordinates, or null to indicate that there is no * pick rectangle. Initially null. */ - protected Rectangle pickRect = null; + private Rectangle pickRect = null; protected boolean isOrderedRenderingMode = false; protected boolean preRenderMode = false; protected Point viewportCenterScreenPoint = null; @@ -154,7 +154,8 @@ public OrderedRenderableEntry(OrderedRenderable orderedRenderable, double distan protected PriorityQueue orderedRenderables = new PriorityQueue(100, new Comparator() { - public int compare(OrderedRenderableEntry orA, OrderedRenderableEntry orB) + @Override + public int compare(OrderedRenderableEntry orA, OrderedRenderableEntry orB) { double eA = orA.distanceFromEye; double eB = orB.distanceFromEye; @@ -171,47 +172,56 @@ public int compare(OrderedRenderableEntry orA, OrderedRenderableEntry orB) * * @throws com.jogamp.opengl.GLException - If an OpenGL context is not current when this method is called. */ - public void dispose() + @Override + public void dispose() { this.geographicSurfaceTileRenderer.dispose(); } - public final GL getGL() + @Override + public final GL getGL() { return this.getGLContext().getGL(); } - public final GLU getGLU() + @Override + public final GLU getGLU() { return this.glu; } - public final GLContext getGLContext() + @Override + public final GLContext getGLContext() { return this.glContext; } - public final int getDrawableHeight() + @Override + public final int getDrawableHeight() { return this.getGLDrawable().getSurfaceHeight(); } - public final int getDrawableWidth() + @Override + public final int getDrawableWidth() { return this.getGLDrawable().getSurfaceWidth(); } - public final GLDrawable getGLDrawable() + @Override + public final GLDrawable getGLDrawable() { return this.getGLContext().getGLDrawable(); } - public GLRuntimeCapabilities getGLRuntimeCapabilities() + @Override + public GLRuntimeCapabilities getGLRuntimeCapabilities() { return this.glRuntimeCaps; } - public void setGLRuntimeCapabilities(GLRuntimeCapabilities capabilities) + @Override + public void setGLRuntimeCapabilities(GLRuntimeCapabilities capabilities) { if (capabilities == null) { @@ -223,7 +233,8 @@ public void setGLRuntimeCapabilities(GLRuntimeCapabilities capabilities) this.glRuntimeCaps = capabilities; } - public final void initialize(GLContext glContext) + @Override + public final void initialize(GLContext glContext) { if (glContext == null) { @@ -252,7 +263,8 @@ public final void initialize(GLContext glContext) this.currentLayer = null; } - public final void setModel(Model model) + @Override + public final void setModel(Model model) { this.model = model; if (this.model == null) @@ -263,53 +275,63 @@ public final void setModel(Model model) this.globe = g; } - public final Model getModel() + @Override + public final Model getModel() { return this.model; } - public final LayerList getLayers() + @Override + public final LayerList getLayers() { return this.model.getLayers(); } - public final Sector getVisibleSector() + @Override + public final Sector getVisibleSector() { return this.visibleSector; } - public final void setVisibleSector(Sector s) + @Override + public final void setVisibleSector(Sector s) { // don't check for null - it is possible that no globe is active, no view is active, no sectors visible, etc. this.visibleSector = s; } - public void setSurfaceGeometry(SectorGeometryList surfaceGeometry) + @Override + public void setSurfaceGeometry(SectorGeometryList surfaceGeometry) { this.surfaceGeometry = surfaceGeometry; } - public SectorGeometryList getSurfaceGeometry() + @Override + public SectorGeometryList getSurfaceGeometry() { return surfaceGeometry; } - public final Globe getGlobe() + @Override + public final Globe getGlobe() { return this.globe != null ? this.globe : this.model.getGlobe(); } - public final void setView(View view) + @Override + public final void setView(View view) { this.view = view; } - public final View getView() + @Override + public final View getView() { return this.view; } - public final void setGLContext(GLContext glContext) + @Override + public final void setGLContext(GLContext glContext) { if (glContext == null) { @@ -321,27 +343,32 @@ public final void setGLContext(GLContext glContext) this.glContext = glContext; } - public final double getVerticalExaggeration() + @Override + public final double getVerticalExaggeration() { return verticalExaggeration; } - public final void setVerticalExaggeration(double verticalExaggeration) + @Override + public final void setVerticalExaggeration(double verticalExaggeration) { this.verticalExaggeration = verticalExaggeration; } - public GpuResourceCache getTextureCache() + @Override + public GpuResourceCache getTextureCache() { return this.gpuResourceCache; } - public GpuResourceCache getGpuResourceCache() + @Override + public GpuResourceCache getGpuResourceCache() { return this.gpuResourceCache; } - public void setGpuResourceCache(GpuResourceCache gpuResourceCache) + @Override + public void setGpuResourceCache(GpuResourceCache gpuResourceCache) { if (gpuResourceCache == null) { @@ -353,12 +380,14 @@ public void setGpuResourceCache(GpuResourceCache gpuResourceCache) this.gpuResourceCache = gpuResourceCache; } - public TextRendererCache getTextRendererCache() + @Override + public TextRendererCache getTextRendererCache() { return textRendererCache; } - public void setTextRendererCache(TextRendererCache textRendererCache) + @Override + public void setTextRendererCache(TextRendererCache textRendererCache) { if (textRendererCache == null) { @@ -370,12 +399,14 @@ public void setTextRendererCache(TextRendererCache textRendererCache) this.textRendererCache = textRendererCache; } - public AnnotationRenderer getAnnotationRenderer() + @Override + public AnnotationRenderer getAnnotationRenderer() { return annotationRenderer; } - public void setAnnotationRenderer(AnnotationRenderer ar) + @Override + public void setAnnotationRenderer(AnnotationRenderer ar) { if (ar == null) { @@ -386,57 +417,68 @@ public void setAnnotationRenderer(AnnotationRenderer ar) annotationRenderer = ar; } - public LightingModel getStandardLightingModel() + @Override + public LightingModel getStandardLightingModel() { return standardLighting; } - public void setStandardLightingModel(LightingModel standardLighting) + @Override + public void setStandardLightingModel(LightingModel standardLighting) { this.standardLighting = standardLighting; } - public Point getPickPoint() + @Override + public Point getPickPoint() { return this.pickPoint; } - public void setPickPoint(Point pickPoint) + @Override + public void setPickPoint(Point pickPoint) { - this.pickPoint = pickPoint; + this.pickPoint = pickPoint; } - public Rectangle getPickRectangle() + @Override + public Rectangle getPickRectangle() { return this.pickRect; } - public void setPickRectangle(Rectangle pickRect) + @Override + public void setPickRectangle(Rectangle pickRect) { this.pickRect = pickRect; } - public Point getViewportCenterScreenPoint() + @Override + public Point getViewportCenterScreenPoint() { return viewportCenterScreenPoint; } - public void setViewportCenterScreenPoint(Point viewportCenterScreenPoint) + @Override + public void setViewportCenterScreenPoint(Point viewportCenterScreenPoint) { this.viewportCenterScreenPoint = viewportCenterScreenPoint; } - public Position getViewportCenterPosition() + @Override + public Position getViewportCenterPosition() { return viewportCenterPosition; } - public void setViewportCenterPosition(Position viewportCenterPosition) + @Override + public void setViewportCenterPosition(Position viewportCenterPosition) { this.viewportCenterPosition = viewportCenterPosition; } - public void addPickedObjects(PickedObjectList pickedObjects) + @Override + public void addPickedObjects(PickedObjectList pickedObjects) { if (pickedObjects == null) { @@ -457,7 +499,8 @@ public void addPickedObjects(PickedObjectList pickedObjects) } } - public void addPickedObject(PickedObject pickedObject) + @Override + public void addPickedObject(PickedObject pickedObject) { if (null == pickedObject) { @@ -472,17 +515,20 @@ public void addPickedObject(PickedObject pickedObject) this.pickedObjects.add(pickedObject); } - public PickedObjectList getPickedObjects() + @Override + public PickedObjectList getPickedObjects() { return this.pickedObjects; } - public PickedObjectList getObjectsInPickRectangle() + @Override + public PickedObjectList getObjectsInPickRectangle() { return this.objectsInPickRect; } - public void addObjectInPickRectangle(PickedObject pickedObject) + @Override + public void addObjectInPickRectangle(PickedObject pickedObject) { if (pickedObject == null) { @@ -494,7 +540,8 @@ public void addObjectInPickRectangle(PickedObject pickedObject) this.objectsInPickRect.add(pickedObject); } - public Color getUniquePickColor() + @Override + public Color getUniquePickColor() { this.uniquePickNumber++; @@ -512,7 +559,8 @@ public Color getUniquePickColor() return new Color(this.uniquePickNumber, true); // has alpha } - public Color getUniquePickColorRange(int count) + @Override + public Color getUniquePickColorRange(int count) { if (count < 1) return null; @@ -532,13 +580,15 @@ public Color getUniquePickColorRange(int count) return new Color(range.location, true); // return a pointer to the beginning of the requested range } - public Color getClearColor() + @Override + public Color getClearColor() { return this.clearColor; } /** {@inheritDoc} */ - public int getPickColorAtPoint(Point point) + @Override + public int getPickColorAtPoint(Point point) { if (point == null) { @@ -547,10 +597,8 @@ public int getPickColorAtPoint(Point point) throw new IllegalArgumentException(msg); } - // Translate the point from AWT screen coordinates to OpenGL screen coordinates. - Rectangle viewport = this.getView().getViewport(); int x = point.x; - int y = viewport.height - point.y - 1; + int y = point.y; // Read the framebuffer color at the specified point in OpenGL screen coordinates as a 24-bit RGB value. if (this.pixelColors == null || this.pixelColors.capacity() < 3) @@ -566,7 +614,8 @@ public int getPickColorAtPoint(Point point) } /** {@inheritDoc} */ - public int[] getPickColorsInRectangle(Rectangle rectangle, int[] minAndMaxColorCodes) + @Override + public int[] getPickColorsInRectangle(Rectangle rectangle, int[] minAndMaxColorCodes) { if (rectangle == null) { @@ -577,10 +626,7 @@ public int[] getPickColorsInRectangle(Rectangle rectangle, int[] minAndMaxColorC Rectangle viewport = this.getView().getViewport(); - // Transform the rectangle from AWT screen coordinates to OpenGL screen coordinates and compute its intersection - // with the viewport. Transformation to GL coordinates must be done prior to computing the intersection, because - // the viewport is in GL coordinates. The resultant rectangle represents the area that's valid to read from GL. - Rectangle r = new Rectangle(rectangle.x, viewport.height - rectangle.y - 1, rectangle.width, rectangle.height); + Rectangle r = new Rectangle(rectangle.x, rectangle.y, rectangle.width, rectangle.height); r = r.intersection(viewport); if (r.isEmpty()) // Return null if the rectangle is empty. @@ -641,52 +687,62 @@ public int[] getPickColorsInRectangle(Rectangle rectangle, int[] minAndMaxColorC return array; } - public boolean isPickingMode() + @Override + public boolean isPickingMode() { return this.pickingMode; } - public void enablePickingMode() + @Override + public void enablePickingMode() { this.pickingMode = true; } - public void disablePickingMode() + @Override + public void disablePickingMode() { this.pickingMode = false; } - public boolean isDeepPickingEnabled() + @Override + public boolean isDeepPickingEnabled() { return this.deepPickingMode; } - public void setDeepPickingEnabled(boolean tf) + @Override + public void setDeepPickingEnabled(boolean tf) { this.deepPickingMode = tf; } - public boolean isPreRenderMode() + @Override + public boolean isPreRenderMode() { return preRenderMode; } - public void setPreRenderMode(boolean preRenderMode) + @Override + public void setPreRenderMode(boolean preRenderMode) { this.preRenderMode = preRenderMode; } - public boolean isOrderedRenderingMode() + @Override + public boolean isOrderedRenderingMode() { return this.isOrderedRenderingMode; } - public void setOrderedRenderingMode(boolean tf) + @Override + public void setOrderedRenderingMode(boolean tf) { this.isOrderedRenderingMode = tf; } - public DeclutteringTextRenderer getDeclutteringTextRenderer() + @Override + public DeclutteringTextRenderer getDeclutteringTextRenderer() { return declutteringTextRenderer; } @@ -703,7 +759,8 @@ public boolean isContinuous2DGlobe() return this.globe instanceof Globe2D && ((Globe2D) this.getGlobe()).isContinuous(); } - public void addOrderedRenderable(OrderedRenderable orderedRenderable) + @Override + public void addOrderedRenderable(OrderedRenderable orderedRenderable) { if (null == orderedRenderable) { @@ -716,7 +773,8 @@ public void addOrderedRenderable(OrderedRenderable orderedRenderable) } /** {@inheritDoc} */ - public void addOrderedRenderable(OrderedRenderable orderedRenderable, boolean isBehind) + @Override + public void addOrderedRenderable(OrderedRenderable orderedRenderable, boolean isBehind) { if (null == orderedRenderable) { @@ -734,14 +792,16 @@ public void addOrderedRenderable(OrderedRenderable orderedRenderable, boolean is new OrderedRenderableEntry(orderedRenderable, eyeDistance, System.nanoTime(), this)); } - public OrderedRenderable peekOrderedRenderables() + @Override + public OrderedRenderable peekOrderedRenderables() { OrderedRenderableEntry ore = this.orderedRenderables.peek(); return ore != null ? ore.or : null; } - public OrderedRenderable pollOrderedRenderables() + @Override + public OrderedRenderable pollOrderedRenderables() { OrderedRenderableEntry ore = this.orderedRenderables.poll(); @@ -810,7 +870,8 @@ public ClutterFilter getClutterFilter() return this.clutterFilter; } - public void applyClutterFilter() + @Override + public void applyClutterFilter() { if (this.getClutterFilter() == null) return; @@ -826,7 +887,8 @@ public void applyClutterFilter() // Sort the declutterables front-to-back. Collections.sort(declutterableArray, new Comparator() { - public int compare(OrderedRenderableEntry orA, OrderedRenderableEntry orB) + @Override + public int compare(OrderedRenderableEntry orA, OrderedRenderableEntry orB) { double eA = orA.distanceFromEye; double eB = orB.distanceFromEye; @@ -854,7 +916,8 @@ public int compare(OrderedRenderableEntry orA, OrderedRenderableEntry orB) } /** {@inheritDoc} */ - public void addOrderedSurfaceRenderable(OrderedRenderable orderedRenderable) + @Override + public void addOrderedSurfaceRenderable(OrderedRenderable orderedRenderable) { if (orderedRenderable == null) { @@ -867,7 +930,8 @@ public void addOrderedSurfaceRenderable(OrderedRenderable orderedRenderable) } /** {@inheritDoc} */ - public Queue getOrderedSurfaceRenderables() + @Override + public Queue getOrderedSurfaceRenderables() { return this.orderedSurfaceRenderables; } @@ -903,7 +967,8 @@ public Queue getOrderedSurfaceRenderables() // } // } - public void drawUnitQuad() + @Override + public void drawUnitQuad() { GL2 gl = this.getGL().getGL2(); // GL initialization checks for GL2 compatibility. @@ -915,7 +980,8 @@ public void drawUnitQuad() gl.glEnd(); } - public void drawUnitQuad(TextureCoords texCoords) + @Override + public void drawUnitQuad(TextureCoords texCoords) { GL2 gl = this.getGL().getGL2(); // GL initialization checks for GL2 compatibility. @@ -931,7 +997,8 @@ public void drawUnitQuad(TextureCoords texCoords) gl.glEnd(); } - public void drawUnitQuadOutline() + @Override + public void drawUnitQuadOutline() { GL2 gl = this.getGL().getGL2(); // GL initialization checks for GL2 compatibility. @@ -943,7 +1010,8 @@ public void drawUnitQuadOutline() gl.glEnd(); } - public void drawNormals(float length, FloatBuffer vBuf, FloatBuffer nBuf) + @Override + public void drawNormals(float length, FloatBuffer vBuf, FloatBuffer nBuf) { if (vBuf == null || nBuf == null) return; @@ -971,7 +1039,8 @@ public void drawNormals(float length, FloatBuffer vBuf, FloatBuffer nBuf) gl.glEnd(); } - public Vec4 getPointOnTerrain(Angle latitude, Angle longitude) + @Override + public Vec4 getPointOnTerrain(Angle latitude, Angle longitude) { if (latitude == null || longitude == null) { @@ -997,28 +1066,33 @@ public Vec4 getPointOnTerrain(Angle latitude, Angle longitude) return null; } - public SurfaceTileRenderer getGeographicSurfaceTileRenderer() + @Override + public SurfaceTileRenderer getGeographicSurfaceTileRenderer() { return this.geographicSurfaceTileRenderer; } - public Collection getPerFrameStatistics() + @Override + public Collection getPerFrameStatistics() { return this.perFrameStatistics; } - public void setPerFrameStatisticsKeys(Set statKeys, Collection stats) + @Override + public void setPerFrameStatisticsKeys(Set statKeys, Collection stats) { this.perFrameStatisticsKeys = statKeys; this.perFrameStatistics = stats; } - public Set getPerFrameStatisticsKeys() + @Override + public Set getPerFrameStatisticsKeys() { return perFrameStatisticsKeys; } - public void setPerFrameStatistic(String key, String displayName, Object value) + @Override + public void setPerFrameStatistic(String key, String displayName, Object value) { if (this.perFrameStatistics == null || this.perFrameStatisticsKeys == null) return; @@ -1041,7 +1115,8 @@ public void setPerFrameStatistic(String key, String displayName, Object value) this.perFrameStatistics.add(new PerformanceStatistic(key, displayName, value)); } - public void setPerFrameStatistics(Collection stats) + @Override + public void setPerFrameStatistics(Collection stats) { if (stats == null) { @@ -1059,17 +1134,20 @@ public void setPerFrameStatistics(Collection stats) } } - public long getFrameTimeStamp() + @Override + public long getFrameTimeStamp() { return this.frameTimestamp; } - public void setFrameTimeStamp(long frameTimeStamp) + @Override + public void setFrameTimeStamp(long frameTimeStamp) { this.frameTimestamp = frameTimeStamp; } - public List getVisibleSectors(double[] resolutions, long timeLimit, Sector sector) + @Override + public List getVisibleSectors(double[] resolutions, long timeLimit, Sector sector) { if (resolutions == null) { @@ -1106,19 +1184,22 @@ else if (this.visibleSectors.getSectorSize() == resolutions[resolutions.length - return this.visibleSectors.getSectors(); } - public void setCurrentLayer(Layer layer) + @Override + public void setCurrentLayer(Layer layer) { this.currentLayer = layer; } - public Layer getCurrentLayer() + @Override + public Layer getCurrentLayer() { return this.currentLayer; } protected LinkedHashMap credits = new LinkedHashMap(); - public void addScreenCredit(ScreenCredit credit) + @Override + public void addScreenCredit(ScreenCredit credit) { if (credit == null) { @@ -1130,27 +1211,32 @@ public void addScreenCredit(ScreenCredit credit) this.credits.put(credit, this.frameTimestamp); } - public Map getScreenCredits() + @Override + public Map getScreenCredits() { return this.credits; } - public int getRedrawRequested() + @Override + public int getRedrawRequested() { return redrawRequested; } - public void setRedrawRequested(int redrawRequested) + @Override + public void setRedrawRequested(int redrawRequested) { this.redrawRequested = redrawRequested; } - public PickPointFrustumList getPickFrustums() + @Override + public PickPointFrustumList getPickFrustums() { return this.pickFrustumList; } - public void setPickPointFrustumDimension(Dimension dim) + @Override + public void setPickPointFrustumDimension(Dimension dim) { if (dim == null) { @@ -1169,25 +1255,20 @@ public void setPickPointFrustumDimension(Dimension dim) this.pickPointFrustumDimension = new Dimension(dim); } - public Dimension getPickPointFrustumDimension() + @Override + public Dimension getPickPointFrustumDimension() { return this.pickPointFrustumDimension; } - public void addPickPointFrustum() + @Override + public void addPickPointFrustum() { //Compute the current picking frustum if (getPickPoint() != null) { - Rectangle viewport = getView().getViewport(); - - double viewportWidth = viewport.getWidth() <= 0.0 ? 1.0 : viewport.getWidth(); - double viewportHeight = viewport.getHeight() <= 0.0 ? 1.0 : viewport.getHeight(); - - //Get the pick point and translate screen center to zero Point ptCenter = new Point(getPickPoint()); - ptCenter.y = (int) viewportHeight - ptCenter.y; - ptCenter.translate((int) (-viewportWidth / 2), (int) (-viewportHeight / 2)); + ptCenter.translate(-viewportCenterScreenPoint.x, -viewportCenterScreenPoint.y); //Number of pixels around pick point to include in frustum int offsetX = pickPointFrustumDimension.width / 2; @@ -1199,7 +1280,9 @@ public void addPickPointFrustum() //Compute the distance to the near plane in screen coordinates double width = getView().getFieldOfView().tanHalfAngle() * getView().getNearClipDistance(); - double x = width / (viewportWidth / 2.0); + double viewportWidth = getView().getViewport().getWidth(); + if (viewportWidth <= 0.0) viewportWidth = 1.0; + double x = width / (viewportWidth/2); double screenDist = getView().getNearClipDistance() / x; //Create the four vectors that define the top-left, top-right, bottom-left, and bottom-right vectors @@ -1213,10 +1296,10 @@ public void addPickPointFrustum() getView().getNearClipDistance(), getView().getFarClipDistance()); //Create the screen rectangle associated with this frustum - Rectangle rectScreen = new Rectangle(getPickPoint().x - offsetX, - (int) viewportHeight - getPickPoint().y - offsetY, - pickPointFrustumDimension.width, - pickPointFrustumDimension.height); + Rectangle rectScreen = new Rectangle(getPickPoint().x - offsetX + 1, + getPickPoint().y - offsetY - 1, + pickPointFrustumDimension.width, + pickPointFrustumDimension.height); //Transform the frustum to Model Coordinates Matrix modelviewTranspose = getView().getModelviewMatrix().getTranspose(); @@ -1227,24 +1310,21 @@ public void addPickPointFrustum() } } - public void addPickRectangleFrustum() + @Override + public void addPickRectangleFrustum() { // Do nothing if the pick rectangle is either null or has zero dimension. if (this.getPickRectangle() == null || this.getPickRectangle().isEmpty()) return; - View view = this.getView(); - - Rectangle viewport = view.getViewport(); - double viewportWidth = viewport.getWidth() <= 0.0 ? 1.0 : viewport.getWidth(); - double viewportHeight = viewport.getHeight() <= 0.0 ? 1.0 : viewport.getHeight(); - - // Get the pick rectangle, transform it from AWT screen coordinates to OpenGL screen coordinates, then translate + // Get the pick rectangle, transform it from GL surface coordinates to OpenGL screen coordinates, then translate // it such that the screen's center is at the origin. Rectangle pr = new Rectangle(this.getPickRectangle()); - pr.y = (int) viewportHeight - pr.y; - pr.translate((int) (-viewportWidth / 2), (int) (-viewportHeight / 2)); + pr.translate(-viewportCenterScreenPoint.x, -viewportCenterScreenPoint.y); + double viewportWidth = view.getViewport().getWidth(); + if (viewportWidth <= 0.0) viewportWidth = 1.0; + // Create the four vectors that define the top-left, top-right, bottom-left, and bottom-right corners of the // pick rectangle in screen coordinates. double screenDist = viewportWidth / (2 * view.getFieldOfView().tanHalfAngle()); @@ -1265,22 +1345,24 @@ public void addPickRectangleFrustum() // Create the screen rectangle in OpenGL screen coordinates associated with this frustum. We translate the // specified pick rectangle from AWT coordinates to GL coordinates by inverting the y axis. Rectangle screenRect = new Rectangle(this.getPickRectangle()); - screenRect.y = (int) viewportHeight - screenRect.y; this.pickFrustumList.add(new PickPointFrustum(frustum, screenRect)); } - public Collection getRenderingExceptions() + @Override + public Collection getRenderingExceptions() { return this.renderingExceptions; } - public void setRenderingExceptions(Collection exceptions) + @Override + public void setRenderingExceptions(Collection exceptions) { this.renderingExceptions = exceptions; } - public void addRenderingException(Throwable t) + @Override + public void addRenderingException(Throwable t) { // If the renderingExceptions Collection is non-null, it's used as the data structure that accumulates rendering // exceptions. Otherwise this DrawContext ignores all rendering exceptions passed to this method. @@ -1297,7 +1379,8 @@ public void addRenderingException(Throwable t) this.renderingExceptions.add(t); } - public void pushProjectionOffest(Double offset) + @Override + public void pushProjectionOffest(Double offset) { // Modify the projection transform to shift the depth values slightly toward the camera in order to // ensure the lines are selected during depth buffering. @@ -1313,7 +1396,8 @@ public void pushProjectionOffest(Double offset) gl.glLoadMatrixf(pm, 0); } - public void popProjectionOffest() + @Override + public void popProjectionOffest() { GL2 gl = this.getGL().getGL2(); // GL initialization checks for GL2 compatibility. @@ -1325,7 +1409,8 @@ public void popProjectionOffest() public static final float DEFAULT_DEPTH_OFFSET_FACTOR = 1f; public static final float DEFAULT_DEPTH_OFFSET_UNITS = 1f; - public void drawOutlinedShape(OutlinedShape renderer, Object shape) + @Override + public void drawOutlinedShape(OutlinedShape renderer, Object shape) { // Draw the outlined shape using a multiple pass algorithm. The motivation for this algorithm is twofold: // @@ -1433,7 +1518,8 @@ public void drawOutlinedShape(OutlinedShape renderer, Object shape) } } - public void beginStandardLighting() + @Override + public void beginStandardLighting() { if (this.standardLighting != null) { @@ -1442,7 +1528,8 @@ public void beginStandardLighting() } } - public void endStandardLighting() + @Override + public void endStandardLighting() { if (this.standardLighting != null) { @@ -1450,7 +1537,8 @@ public void endStandardLighting() } } - public boolean isSmall(Extent extent, int numPixels) + @Override + public boolean isSmall(Extent extent, int numPixels) { return extent != null && extent.getDiameter() <= numPixels * this.getView().computePixelSizeAtDistance( // burkey couldnt we make this minimum dimension @@ -1458,29 +1546,34 @@ public boolean isSmall(Extent extent, int numPixels) extent.getCenter())); // -- so box could return small when one dim is narrow? } // i see really skinny telephone poles that dont need to be rendered at distance but are tall - public Terrain getTerrain() + @Override + public Terrain getTerrain() { return this.terrain; } - public Vec4 computeTerrainPoint(Angle lat, Angle lon, double offset) + @Override + public Vec4 computeTerrainPoint(Angle lat, Angle lon, double offset) { return this.getTerrain().getSurfacePoint(lat, lon, offset); } protected Terrain terrain = new Terrain() { - public Globe getGlobe() + @Override + public Globe getGlobe() { return DrawContextImpl.this.getGlobe(); } - public double getVerticalExaggeration() + @Override + public double getVerticalExaggeration() { return DrawContextImpl.this.getVerticalExaggeration(); } - public Vec4 getSurfacePoint(Position position) + @Override + public Vec4 getSurfacePoint(Position position) { if (position == null) { @@ -1504,7 +1597,8 @@ public Vec4 getSurfacePoint(Position position) return pt; } - public Vec4 getSurfacePoint(Angle latitude, Angle longitude, double metersOffset) + @Override + public Vec4 getSurfacePoint(Angle latitude, Angle longitude, double metersOffset) { if (latitude == null || longitude == null) { @@ -1529,7 +1623,8 @@ public Vec4 getSurfacePoint(Angle latitude, Angle longitude, double metersOffset return pt; } - public Intersection[] intersect(Position pA, Position pB) + @Override + public Intersection[] intersect(Position pA, Position pB) { SectorGeometryList sectorGeometry = DrawContextImpl.this.getSurfaceGeometry(); if (sectorGeometry == null) @@ -1544,7 +1639,8 @@ public Intersection[] intersect(Position pA, Position pB) return sectorGeometry.intersect(new Line(ptA, ptB.subtract3(ptA))); } - public Intersection[] intersect(Position pA, Position pB, int altitudeMode) + @Override + public Intersection[] intersect(Position pA, Position pB, int altitudeMode) { if (pA == null || pB == null) { @@ -1570,7 +1666,8 @@ else if (altitudeMode == WorldWind.CLAMP_TO_GROUND) return this.intersect(new Position(pA, altitudeA), new Position(pB, altitudeB)); } - public Double getElevation(LatLon location) + @Override + public Double getElevation(LatLon location) { if (location == null) { @@ -1589,25 +1686,29 @@ public Double getElevation(LatLon location) } }; - public void restoreDefaultBlending() + @Override + public void restoreDefaultBlending() { this.getGL().glBlendFunc(GL.GL_ONE, GL.GL_ZERO); this.getGL().glDisable(GL.GL_BLEND); } - public void restoreDefaultCurrentColor() + @Override + public void restoreDefaultCurrentColor() { GL2 gl = this.getGL().getGL2(); // GL initialization checks for GL2 compatibility. gl.glColor4f(1, 1, 1, 1); } - public void restoreDefaultDepthTesting() + @Override + public void restoreDefaultDepthTesting() { this.getGL().glEnable(GL.GL_DEPTH_TEST); this.getGL().glDepthMask(true); } - public Vec4 computePointFromPosition(Position position, int altitudeMode) + @Override + public Vec4 computePointFromPosition(Position position, int altitudeMode) { if (position == null) { @@ -1636,4 +1737,22 @@ else if (altitudeMode == WorldWind.RELATIVE_TO_GROUND) return point; } + + /** {@inheritDoc} */ + @Override + public int [] awtPointToGLpoint(Point pt) { + if (pt == null) return null; + + int [] awtPt = { pt.x, pt.y }; + if (glContext == null) return awtPt; + + GLDrawable drawable = glContext.getGLDrawable(); + if (drawable == null) return awtPt; + + // Convert to GL surface coordinates + int [] glSurfacePt = drawable.getNativeSurface().convertToPixelUnits(awtPt); + int glSurfaceHeight = drawable.getSurfaceHeight(); + glSurfacePt[1] = glSurfaceHeight - glSurfacePt[1] - 1; + return glSurfacePt; + } } diff --git a/src/gov/nasa/worldwind/render/Path.java b/src/gov/nasa/worldwind/render/Path.java index dbb8d5fef5..a72fa785a4 100644 --- a/src/gov/nasa/worldwind/render/Path.java +++ b/src/gov/nasa/worldwind/render/Path.java @@ -569,7 +569,7 @@ public PickedObject getTopObject(DrawContext dc, Point pickPoint) { * AVKey.ORDINAL_LIST. * * @param dc the draw context which receives the picked objects. - * @param pickRect the rectangle in AWT screen coordinates. + * @param pickRect the rectangle in GL surface coordinates. * @param layer the layer associated with the picked objects. */ @SuppressWarnings({"unchecked"}) diff --git a/src/gov/nasa/worldwind/render/ScreenAnnotationBalloon.java b/src/gov/nasa/worldwind/render/ScreenAnnotationBalloon.java index 82dbae6710..863a50d62c 100644 --- a/src/gov/nasa/worldwind/render/ScreenAnnotationBalloon.java +++ b/src/gov/nasa/worldwind/render/ScreenAnnotationBalloon.java @@ -68,7 +68,8 @@ public ScreenAnnotationBalloon(String text, Point point) } /** {@inheritDoc} */ - protected ScreenAnnotation createAnnotation() + @Override + protected ScreenAnnotation createAnnotation() { ScreenAnnotation annotation = new ScreenAnnotation(this.getDecodedText(), this.screenPoint); @@ -79,22 +80,22 @@ protected ScreenAnnotation createAnnotation() } /** {@inheritDoc} */ - protected ScreenAnnotation getAnnotation() + @Override + protected ScreenAnnotation getAnnotation() { return this.annotation; } /** {@inheritDoc} */ - protected void computePosition(DrawContext dc) + @Override + protected void computePosition(DrawContext dc) { - Rectangle viewport = dc.getView().getViewport(); - - int y = (int) viewport.getHeight() - this.screenPoint.y - 1; - this.getAnnotation().setScreenPoint(new Point(this.screenPoint.x, y)); + this.getAnnotation().setScreenPoint(new Point(this.screenPoint)); } /** {@inheritDoc} */ - public void setScreenLocation(Point point) + @Override + public void setScreenLocation(Point point) { if (point == null) { @@ -107,7 +108,8 @@ public void setScreenLocation(Point point) } /** {@inheritDoc} */ - public Point getScreenLocation() + @Override + public Point getScreenLocation() { return this.screenPoint; } diff --git a/src/gov/nasa/worldwind/render/ScreenBrowserBalloon.java b/src/gov/nasa/worldwind/render/ScreenBrowserBalloon.java index f90914b995..65d1660ca4 100644 --- a/src/gov/nasa/worldwind/render/ScreenBrowserBalloon.java +++ b/src/gov/nasa/worldwind/render/ScreenBrowserBalloon.java @@ -82,13 +82,15 @@ protected OrderedBrowserBalloon createOrderedRenderable() } /** {@inheritDoc} */ - public Point getScreenLocation() + @Override + public Point getScreenLocation() { return this.screenLocation; } /** {@inheritDoc} */ - public void setScreenLocation(Point point) + @Override + public void setScreenLocation(Point point) { if (point == null) { @@ -111,7 +113,8 @@ public void setScreenLocation(Point point) * * @param dc the current draw context. */ - protected void computeBalloonPoints(DrawContext dc, OrderedBrowserBalloon obb) + @Override + protected void computeBalloonPoints(DrawContext dc, OrderedBrowserBalloon obb) { this.screenOffset = null; obb.screenRect = null; @@ -130,12 +133,11 @@ protected void computeBalloonPoints(DrawContext dc, OrderedBrowserBalloon obb) // bottom left). Note: The screen offset denotes how to place the screen reference point relative to the frame. // For example, an offset of (-10, -10) in pixels places the reference point below and to the left of the frame. // Since the screen reference point is fixed, the frame appears to move relative to the reference point. - int y = dc.getView().getViewport().height - this.screenLocation.y; - obb.screenRect = new Rectangle(this.screenLocation.x - this.screenOffset.x, y - this.screenOffset.y, + obb.screenRect = new Rectangle(this.screenLocation.x - this.screenOffset.x, this.screenLocation.y - this.screenOffset.y, size.width, size.height); // Compute the screen extent as the rectangle containing the balloon's screen rectangle and its screen point. obb.screenExtent = new Rectangle(obb.screenRect); - obb.screenExtent.add(this.screenLocation.x, y); + obb.screenExtent.add(this.screenLocation.x, this.screenLocation.y); // Compute the pickable screen extent as the screen extent, plus the width of the balloon's pickable outline. // This extent is used during picking to ensure that the balloon's outline is pickable when it exceeds the // balloon's screen extent. @@ -147,7 +149,8 @@ protected void computeBalloonPoints(DrawContext dc, OrderedBrowserBalloon obb) } /** {@inheritDoc} */ - protected void setupDepthTest(DrawContext dc, OrderedBrowserBalloon obb) + @Override + protected void setupDepthTest(DrawContext dc, OrderedBrowserBalloon obb) { dc.getGL().glDisable(GL.GL_DEPTH_TEST); } diff --git a/src/gov/nasa/worldwind/render/ScreenCredit.java b/src/gov/nasa/worldwind/render/ScreenCredit.java index e4a38a4d03..3e4c0533e6 100644 --- a/src/gov/nasa/worldwind/render/ScreenCredit.java +++ b/src/gov/nasa/worldwind/render/ScreenCredit.java @@ -47,6 +47,4 @@ public interface ScreenCredit extends Renderable void setLink(String link); String getLink(); - - public void pick(DrawContext dc, java.awt.Point pickPoint); } diff --git a/src/gov/nasa/worldwind/render/ScreenCreditController.java b/src/gov/nasa/worldwind/render/ScreenCreditController.java index aa2ae11949..d060ecc0e4 100644 --- a/src/gov/nasa/worldwind/render/ScreenCreditController.java +++ b/src/gov/nasa/worldwind/render/ScreenCreditController.java @@ -70,7 +70,8 @@ public ScreenCreditController(WorldWindow wwd) wwd.addSelectListener(this); } - public void dispose() + @Override + public void dispose() { wwd.removeSelectListener(this); if (wwd.getSceneController() == this) @@ -87,7 +88,7 @@ public void setEnabled(boolean enabled) this.enabled = enabled; } - public void pick(DrawContext dc, Point pickPoint) + public void pick(DrawContext dc, @SuppressWarnings("unused") Point pickPoint) { if (dc == null) { @@ -113,13 +114,13 @@ public void pick(DrawContext dc, Point pickPoint) Rectangle viewport = new Rectangle(x, y, creditWidth, creditHeight); credit.setViewport(viewport); - credit.pick(dc, pickPoint); x += (separation + creditWidth); } } - public void render(DrawContext dc) + @Override + public void render(DrawContext dc) { if (dc == null) { @@ -136,7 +137,7 @@ public void render(DrawContext dc) Set> credits = dc.getScreenCredits().entrySet(); - int y = dc.getView().getViewport().height - (bottomMargin + creditHeight / 2); + int y = bottomMargin + creditHeight / 2; int x = leftMargin + creditWidth / 2; for (Map.Entry entry : credits) @@ -156,7 +157,8 @@ public void render(DrawContext dc) } } - public void selected(SelectEvent event) + @Override + public void selected(SelectEvent event) { if (event.getMouseEvent() != null && event.getMouseEvent().isConsumed()) return; diff --git a/src/gov/nasa/worldwind/render/TextRenderer.java b/src/gov/nasa/worldwind/render/TextRenderer.java index 7ed52bbb85..d25c14f4fc 100644 --- a/src/gov/nasa/worldwind/render/TextRenderer.java +++ b/src/gov/nasa/worldwind/render/TextRenderer.java @@ -71,6 +71,8 @@ package gov.nasa.worldwind.render; import com.jogamp.common.nio.Buffers; +import com.jogamp.nativewindow.NativeSurface; +import com.jogamp.nativewindow.ScalableSurface; import com.jogamp.opengl.GLExtensions; import com.jogamp.opengl.util.FPSAnimator; import com.jogamp.opengl.util.awt.TextureRenderer; @@ -318,7 +320,18 @@ public TextRenderer(Font font, boolean antialiased, public TextRenderer(Font font, boolean antialiased, boolean useFractionalMetrics, RenderDelegate renderDelegate, boolean mipmap) { - this.font = font; + + NativeSurface surface = GLContext.getCurrent().getGLDrawable().getNativeSurface(); + if (surface instanceof ScalableSurface) { + // DPI scaling for surface + float[] surfaceScale = new float[2]; + ((ScalableSurface) surface).getCurrentSurfaceScale(surfaceScale); + float newSize = font.getSize() * surfaceScale[0]; + this.font = font.deriveFont(newSize); + } else { + this.font = font; + } + this.antialiased = antialiased; this.useFractionalMetrics = useFractionalMetrics; this.mipmap = mipmap; diff --git a/src/gov/nasa/worldwind/util/layertree/LayerTree.java b/src/gov/nasa/worldwind/util/layertree/LayerTree.java index 0b4ee0937a..ca504bb616 100644 --- a/src/gov/nasa/worldwind/util/layertree/LayerTree.java +++ b/src/gov/nasa/worldwind/util/layertree/LayerTree.java @@ -27,6 +27,8 @@ */ package gov.nasa.worldwind.util.layertree; +import java.awt.Point; + import gov.nasa.worldwind.avlist.AVKey; import gov.nasa.worldwind.render.Offset; import gov.nasa.worldwind.util.Logging; @@ -87,11 +89,11 @@ public LayerTree(LayerTreeModel model) * Creates a new LayerTree with an empty LayerTreeModel and the specified screen * location. * - * @param offset the screen location of the tree's upper left corner, relative to the screen's upper left corner. + * @param offset the screen location of the tree's lower left corner, relative to the screen's lower left corner. * * @throws IllegalArgumentException if offset is null. */ - public LayerTree(Offset offset) + public LayerTree(Point offset) { if (offset == null) { @@ -107,12 +109,12 @@ public LayerTree(Offset offset) * Creates a new LayerTree with the specified model and the specified screen location. * * @param model the tree model to use. - * @param offset the screen location of the tree's upper left corner, relative to the screen's upper left corner. + * @param offset the screen location of the tree's lower left corner, relative to the screen's lower left corner. (GL surface pixels) * * @throws IllegalArgumentException if model is null, or if offset is * null. */ - public LayerTree(LayerTreeModel model, Offset offset) + public LayerTree(LayerTreeModel model, Point offset) { if (model == null) { @@ -139,7 +141,7 @@ public LayerTree(LayerTreeModel model, Offset offset) * @param model this tree's model to use, or null to create a new LayerTreeModel. * @param offset the screen location of this tree's upper left corner, or null to use the default. */ - protected void initialize(LayerTreeModel model, Offset offset) + protected void initialize(LayerTreeModel model, Point offset) { if (model == null) model = this.createTreeModel(); @@ -167,10 +169,10 @@ protected LayerTreeModel createTreeModel() * * @return new TreeLayout. */ - protected TreeLayout createTreeLayout(Offset offset) + protected TreeLayout createTreeLayout(Point offset) { if (offset == null) - offset = DEFAULT_OFFSET; + offset = new Point(DEFAULT_OFFSET.getX().intValue(), DEFAULT_OFFSET.getY().intValue()); BasicTreeLayout layout = new BasicTreeLayout(this, offset); layout.getFrame().setFrameTitle(DEFAULT_FRAME_TITLE); @@ -196,7 +198,8 @@ protected TreeLayout createTreeLayout(Offset offset) } /** {@inheritDoc} */ - public LayerTreeModel getModel() + @Override + public LayerTreeModel getModel() { return (LayerTreeModel) super.getModel(); } diff --git a/src/gov/nasa/worldwind/util/tree/BasicTreeLayout.java b/src/gov/nasa/worldwind/util/tree/BasicTreeLayout.java index 8bb6c85172..f87da8f212 100644 --- a/src/gov/nasa/worldwind/util/tree/BasicTreeLayout.java +++ b/src/gov/nasa/worldwind/util/tree/BasicTreeLayout.java @@ -160,7 +160,7 @@ public BasicTreeLayout(Tree tree) */ public BasicTreeLayout(Tree tree, int x, int y) { - this(tree, new Offset((double) x, (double) y, AVKey.PIXELS, AVKey.INSET_PIXELS)); + this(tree, new Point(x, y)); } /** @@ -170,7 +170,7 @@ public BasicTreeLayout(Tree tree, int x, int y) * @param screenLocation The location of the upper left corner of the tree frame. The offset is interpreted relative * to the lower left corner of the screen. */ - public BasicTreeLayout(Tree tree, Offset screenLocation) + public BasicTreeLayout(Tree tree, Point screenLocation) { this.tree = tree; this.frame = this.createFrame(); @@ -186,7 +186,8 @@ public BasicTreeLayout(Tree tree, Offset screenLocation) // events between TreeLayout and Tree. this.tree.addPropertyChangeListener(new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent propertyChangeEvent) + @Override + public void propertyChange(PropertyChangeEvent propertyChangeEvent) { // Ignore events originated by this TreeLayout, and repaint events. There is no need to recompute the // tree layout just because a repaint was triggered. @@ -341,7 +342,8 @@ public void setDrawNodeStateSymbol(boolean drawNodeStateSymbol) } /** {@inheritDoc} */ - public long getUpdateTime() + @Override + public long getUpdateTime() { return this.updateTime; } @@ -364,7 +366,8 @@ protected ScrollFrame createFrame() * * @return Size of the rendered tree. */ - public Dimension getSize(DrawContext dc, Dimension frameSize) + @Override + public Dimension getSize(DrawContext dc, Dimension frameSize) { this.updateAttributes(dc); @@ -472,7 +475,8 @@ protected boolean mustDisplayNode(TreeNode node, int level) } /** {@inheritDoc} */ - public void preRender(DrawContext dc) + @Override + public void preRender(DrawContext dc) { // Adjust scroll position if an application has requested that the layout scroll to make a node visible. this.scrollToNode(dc); @@ -481,7 +485,8 @@ public void preRender(DrawContext dc) } /** {@inheritDoc} */ - public void render(DrawContext dc) + @Override + public void render(DrawContext dc) { this.frame.render(dc); } @@ -514,7 +519,8 @@ protected synchronized void scrollToNode(DrawContext dc) } /** {@inheritDoc} */ - public void renderScrollable(DrawContext dc, Point location, Dimension frameSize, Rectangle clipBounds) + @Override + public void renderScrollable(DrawContext dc, Point location, Dimension frameSize, Rectangle clipBounds) { TreeModel model = this.tree.getModel(); TreeNode root = model.getRoot(); @@ -1321,7 +1327,8 @@ protected Rectangle findNodeBounds(TreeNode needle, TreeNode haystack, DrawConte } /** {@inheritDoc} */ - public synchronized void makeVisible(TreePath path) + @Override + public synchronized void makeVisible(TreePath path) { TreeNode node = this.tree.getNode(path); if (node == null) @@ -1345,7 +1352,7 @@ public synchronized void makeVisible(TreePath path) * * @return Screen location, measured in pixels from the upper left corner of the screen. */ - public Offset getScreenLocation() + public Point getScreenLocation() { return this.frame.getScreenLocation(); } @@ -1356,19 +1363,21 @@ public Offset getScreenLocation() * * @param screenLocation New screen location. */ - public void setScreenLocation(Offset screenLocation) + public void setScreenLocation(Point screenLocation) { frame.setScreenLocation(screenLocation); } /** {@inheritDoc} */ - public TreeAttributes getAttributes() + @Override + public TreeAttributes getAttributes() { return this.normalAttributes; } /** {@inheritDoc} */ - public void setAttributes(TreeAttributes attributes) + @Override + public void setAttributes(TreeAttributes attributes) { if (attributes == null) { @@ -1464,7 +1473,8 @@ public boolean isHighlighted() * * @param highlighted True if the tree should be highlighted. */ - public void setHighlighted(boolean highlighted) + @Override + public void setHighlighted(boolean highlighted) { this.highlighted = highlighted; } diff --git a/src/gov/nasa/worldwind/util/tree/DragControl.java b/src/gov/nasa/worldwind/util/tree/DragControl.java index ac0b8e0e28..8f6edace36 100644 --- a/src/gov/nasa/worldwind/util/tree/DragControl.java +++ b/src/gov/nasa/worldwind/util/tree/DragControl.java @@ -101,7 +101,7 @@ else if (event.isDragEnd()) /** * Called when a drag begins. This implementation saves the first drag point to {@link #dragRefPoint}. * - * @param point Point at which dragging started. + * @param point Point at which dragging started (GL surface pixels) */ protected void beginDrag(Point point) { @@ -111,7 +111,7 @@ protected void beginDrag(Point point) /** * Called for each point within a drag action. * - * @param point Current drag point. + * @param point Current drag point. (GL surface pixels) */ protected abstract void drag(Point point); diff --git a/src/gov/nasa/worldwind/util/tree/FrameResizeControl.java b/src/gov/nasa/worldwind/util/tree/FrameResizeControl.java index 69f3f26776..fcfb13b54d 100644 --- a/src/gov/nasa/worldwind/util/tree/FrameResizeControl.java +++ b/src/gov/nasa/worldwind/util/tree/FrameResizeControl.java @@ -28,13 +28,11 @@ package gov.nasa.worldwind.util.tree; -import gov.nasa.worldwind.avlist.AVKey; import gov.nasa.worldwind.render.*; import gov.nasa.worldwind.util.AbstractResizeHotSpot; import java.awt.*; import java.awt.event.*; -import java.awt.geom.*; /** * A screen control for resizing a frame. This class handles the resize input events, but does does not actually draw @@ -89,15 +87,15 @@ protected void setSize(Dimension newSize) @Override protected Point getScreenPoint() { - Point2D point2D = this.frame.getScreenPoint(); - return new Point((int)point2D.getX(), (int)point2D.getY()); + Point point = this.frame.getScreenLocation(); + return new Point(point); } /** {@inheritDoc} */ @Override protected void setScreenPoint(Point newPoint) { - this.frame.setScreenLocation(new Offset(newPoint.getX(), newPoint.getY(), AVKey.PIXELS, AVKey.INSET_PIXELS)); + this.frame.setScreenLocation(newPoint); } /** {@inheritDoc} */ @@ -113,7 +111,8 @@ protected Dimension getMinimumSize() * * @param event The event to handle. */ - public void mouseWheelMoved(MouseWheelEvent event) + @Override + public void mouseWheelMoved(MouseWheelEvent event) { if (event == null || event.isConsumed()) return; diff --git a/src/gov/nasa/worldwind/util/tree/ScrollBar.java b/src/gov/nasa/worldwind/util/tree/ScrollBar.java index 431a8084a5..a973053661 100644 --- a/src/gov/nasa/worldwind/util/tree/ScrollBar.java +++ b/src/gov/nasa/worldwind/util/tree/ScrollBar.java @@ -683,7 +683,8 @@ public boolean isAutoScrolling() * * @param dc the DrawContext to be used */ - public void render(DrawContext dc) + @Override + public void render(DrawContext dc) { if (dc.getFrameTimeStamp() != this.frameNumber) { @@ -1110,7 +1111,9 @@ protected void beginDrag(Point point) this.dragRefValue = this.scrollBar.getValue(); } - protected void drag(Point point) + /** {@inheritDoc} */ + @Override + protected void drag(Point point) { int delta; int adjustment; @@ -1118,7 +1121,10 @@ protected void drag(Point point) if (AVKey.VERTICAL.equals(scrollBar.getOrientation())) { - delta = point.y - this.dragRefPoint.y; + // scroll bar zero position is at the top in GL surface coordinates. + // 'point' will be in GL surface coordinates, so moving the mouse + // towards the bottom of the screen yields a smaller y value. + delta = this.dragRefPoint.y - point.y; screenDimension = this.scrollBar.scrollBounds.height - this.scrollBar.getMinScrollKnobSize(); } else diff --git a/src/gov/nasa/worldwind/util/tree/ScrollFrame.java b/src/gov/nasa/worldwind/util/tree/ScrollFrame.java index ebb1d63c6e..6111066332 100644 --- a/src/gov/nasa/worldwind/util/tree/ScrollFrame.java +++ b/src/gov/nasa/worldwind/util/tree/ScrollFrame.java @@ -98,7 +98,7 @@ public class ScrollFrame extends DragControl implements PreRenderable, Renderabl protected Scrollable contents; /** Indicates the location of the upper left corner of the frame. */ - protected Offset screenLocation; + protected Point screenLocation; /** Indicates whether or not to draw a title bar in the frame. Default is true. */ protected boolean drawTitleBar = true; @@ -209,11 +209,6 @@ public class ScrollFrame extends DragControl implements PreRenderable, Renderabl protected long frameNumber = -1; /** Indicates that the frame must be regenerated because the size or attributes have changed. */ protected boolean mustRecomputeFrameGeometry = true; - /** - * Indicates the location of the upper left corner of the frame, in AWT coordinates (origin at the upper left corner - * of the screen. - */ - protected Point2D awtScreenPoint; /** Bounds of the full frame. */ protected Rectangle frameBounds; /** Bounds of the frame inside the frame border. */ @@ -262,7 +257,7 @@ public ScrollFrame() */ public ScrollFrame(int x, int y) { - this(new Offset((double) x, (double) y, AVKey.PIXELS, AVKey.INSET_PIXELS)); + this(new Point(x, y)); } /** @@ -270,7 +265,7 @@ public ScrollFrame(int x, int y) * * @param screenLocation initial location of the upper left corner of the frame. */ - public ScrollFrame(Offset screenLocation) + public ScrollFrame(Point screenLocation) { super(null); this.setScreenLocation(screenLocation); @@ -628,43 +623,32 @@ public Rectangle getBounds(DrawContext dc) { this.updateBounds(dc); - return new Rectangle((int) this.awtScreenPoint.getX(), (int) this.awtScreenPoint.getY(), this.frameSize.width, + return new Rectangle(screenLocation.x, screenLocation.y, this.frameSize.width, this.frameSize.height); } /** - * Get the location of the upper left corner of the tree, measured in screen coordinates with the origin at the - * upper left corner of the screen. + * Get the location of the lower left corner of the tree, measured in screen + * coordinates with the origin at the lower left corner of the screen. * - * @return Screen location, measured in pixels from the upper left corner of the screen. + * @return Screen location, measured in GL surface pixels from the lower left corner of the screen. */ - public Offset getScreenLocation() + public Point getScreenLocation() { return this.screenLocation; } /** - * Set the location of the upper left corner of the tree, measured in screen coordinates with the origin at the - * upper left corner of the screen. + * Set the location of the lower left corner of the tree, measured in GL surface coordinates + * with the origin at the lower left corner of the screen. * * @param screenLocation New screen location. */ - public void setScreenLocation(Offset screenLocation) + public void setScreenLocation(Point screenLocation) { this.screenLocation = screenLocation; } - /** - * Get the location of the upper left corner of the frame, measured from the upper left corner of the screen. - * - * @return The location of the upper left corner of the frame. This method will return null until the has been - * rendered. - */ - protected Point2D getScreenPoint() - { - return this.awtScreenPoint; - } - /** * Indicates the frame attributes used to draw the frame when it is not highlighted. * @@ -1043,9 +1027,10 @@ protected int computeTileTextureDimension(Dimension frameSize, Dimension content } /** {@inheritDoc} */ - public void preRender(DrawContext dc) + @Override + public void preRender(DrawContext dc) { - Offset screenLocation = this.getScreenLocation(); + Point screenLocation = this.getScreenLocation(); if (screenLocation == null) return; @@ -1057,8 +1042,7 @@ public void preRender(DrawContext dc) Point pickPoint = dc.getPickPoint(); if (pickPoint != null) { - int glY = dc.getView().getViewport().height - pickPoint.y; - this.setHighlighted(this.pickBounds.contains(new Point(pickPoint.x, glY))); + this.setHighlighted(this.pickBounds.contains(pickPoint)); } this.determineActiveAttributes(); @@ -1078,9 +1062,10 @@ public void preRender(DrawContext dc) } /** {@inheritDoc} */ - public void render(DrawContext dc) + @Override + public void render(DrawContext dc) { - Offset screenLocation = this.getScreenLocation(); + Point screenLocation = this.getScreenLocation(); if (screenLocation == null || this.frameBounds == null) return; @@ -1244,26 +1229,23 @@ public void updateBounds(DrawContext dc) if (!this.frameSize.equals(previousFrameSize)) this.mustRecomputeFrameGeometry = true; - // Compute point in OpenGL coordinates - Point2D upperLeft = this.screenLocation.computeOffset(viewport.width, viewport.height, 1.0, 1.0); - - this.awtScreenPoint = new Point((int) upperLeft.getX(), (int) (viewport.height - upperLeft.getY())); + // Set frame bounds + this.frameBounds = new Rectangle(screenLocation.x, screenLocation.y, + this.frameSize.width, this.frameSize.height); - this.frameBounds = new Rectangle((int) upperLeft.getX(), (int) upperLeft.getY() - this.frameSize.height, - this.frameSize.width, this.frameSize.height); - - // Compute the pickable screen extent as the frame extent, plus the width of the frame's pickable outline. - // This extent is used during picking to ensure that the frame's outline is pickable when it exceeds the - // frame's screen extent. + // Compute the pickable screen extent in GL surface coordinates as the frame extent, + // plus the width of the frame's pickable outline. + // This extent is used during picking to ensure that the frame's outline is pickable + // when it exceeds the frame's screen extent. this.pickBounds = new Rectangle( this.frameBounds.x - this.borderPickWidth / 2, this.frameBounds.y - this.borderPickWidth / 2, this.frameBounds.width + this.borderPickWidth, this.frameBounds.height + this.borderPickWidth); - this.innerBounds = new Rectangle((int) upperLeft.getX() + this.frameBorder, - (int) upperLeft.getY() - frameSize.height + this.frameBorder, frameSize.width - this.frameBorder * 2, - frameSize.height - this.frameBorder * 2); + this.innerBounds = new Rectangle(frameBounds.x + this.frameBorder, + frameBounds.y + this.frameBorder, frameSize.width - this.frameBorder * 2, + frameSize.height - this.frameBorder * 2); // If the content size has yet not been computed, compute it now. if (contentSize == null) @@ -2269,18 +2251,17 @@ protected void beginDrag(Point point) { if (this.isEnableMove()) { - Point2D location = this.awtScreenPoint; - this.dragRefPoint = new Point((int) location.getX() - point.x, (int) location.getY() - point.y); + this.dragRefPoint = new Point( screenLocation.x - point.x, screenLocation.y - point.y); } } - public void drag(Point point) + @Override + public void drag(Point point) { if (this.isEnableMove()) { - double x = point.x + this.dragRefPoint.x; - double y = point.y + this.dragRefPoint.y; - this.setScreenLocation(new Offset(x, y, AVKey.PIXELS, AVKey.INSET_PIXELS)); + Point pt = new Point(point.x + this.dragRefPoint.x, point.y + this.dragRefPoint.y); + this.setScreenLocation(pt); } } @@ -2293,8 +2274,8 @@ public void selected(SelectEvent event) super.selected(event); // Minimize the frame if the title bar was double clicked. - Rectangle titleBarBounds = new Rectangle((int) this.awtScreenPoint.getX() + this.frameBorder, - (int) this.awtScreenPoint.getY() + this.frameBorder * 2, this.innerBounds.width, this.titleBarHeight); + Rectangle titleBarBounds = new Rectangle(this.screenLocation.x + this.frameBorder, + this.screenLocation.y + this.frameBorder * 2, this.innerBounds.width, this.titleBarHeight); if (event.isLeftDoubleClick()) { @@ -2475,7 +2456,8 @@ class TextureTile implements Comparable * @return -1 if this tile was accessed less recently than that tile, 0 if the access times are the same, or 1 * if this tile was accessed more recently. */ - public int compareTo(TextureTile that) + @Override + public int compareTo(TextureTile that) { if (that == null) { diff --git a/src/gov/nasa/worldwind/view/BasicView.java b/src/gov/nasa/worldwind/view/BasicView.java index 2857760067..22809dbe66 100644 --- a/src/gov/nasa/worldwind/view/BasicView.java +++ b/src/gov/nasa/worldwind/view/BasicView.java @@ -591,7 +591,7 @@ public void goTo(Position position, double distance) public Line computeRayFromScreenPoint(double x, double y) { return ViewUtil.computeRayFromScreenPoint(this, x, y, - this.modelview, this.projection, this.viewport); + this.modelview, this.projection); } public Position computePositionFromScreenPoint(double x, double y) diff --git a/src/gov/nasa/worldwind/view/ViewUtil.java b/src/gov/nasa/worldwind/view/ViewUtil.java index e2dbd2d988..dbd8d97c68 100644 --- a/src/gov/nasa/worldwind/view/ViewUtil.java +++ b/src/gov/nasa/worldwind/view/ViewUtil.java @@ -536,7 +536,7 @@ public static Angle normalizedRoll(Angle unnormalizedRoll) } public static Line computeRayFromScreenPoint(View view, double x, double y, - Matrix modelview, Matrix projection, java.awt.Rectangle viewport) + Matrix modelview, Matrix projection) { if (modelview == null || projection == null) { @@ -544,12 +544,6 @@ public static Line computeRayFromScreenPoint(View view, double x, double y, Logging.logger().severe(message); throw new IllegalArgumentException(message); } - if (viewport == null) - { - String message = Logging.getMessage("nullValue.RectangleIsNull"); - Logging.logger().severe(message); - throw new IllegalArgumentException(message); - } // Compute a ray originating from the view, and passing through the screen point (x, y). // @@ -566,9 +560,8 @@ public static Line computeRayFromScreenPoint(View view, double x, double y, if (eye == null) return null; - double yInGLCoords = viewport.height - y - 1; - Vec4 a = view.unProject(new Vec4(x, yInGLCoords, 0, 0)); - Vec4 b = view.unProject(new Vec4(x, yInGLCoords, 1, 0)); + Vec4 a = view.unProject(new Vec4(x, y, 0, 0)); + Vec4 b = view.unProject(new Vec4(x, y, 1, 0)); if (a == null || b == null) return null; diff --git a/src/gov/nasa/worldwind/view/orbit/OrbitViewInputHandler.java b/src/gov/nasa/worldwind/view/orbit/OrbitViewInputHandler.java index f429cc0b49..3d622eda72 100644 --- a/src/gov/nasa/worldwind/view/orbit/OrbitViewInputHandler.java +++ b/src/gov/nasa/worldwind/view/orbit/OrbitViewInputHandler.java @@ -159,7 +159,6 @@ protected void onMoveTo(Position focalPosition, ViewInputAttributes.DeviceAttrib } } - @SuppressWarnings("UnusedParameters") protected void onMoveTo2D(Position focalPosition, ViewInputAttributes.DeviceAttributes deviceAttributes, ViewInputAttributes.ActionAttributes actionAttribs) { @@ -314,7 +313,6 @@ protected void onHorizontalTranslateRel(Angle forwardChange, Angle sideChange, } } - @SuppressWarnings("UnusedParameters") protected void onHorizontalTranslate2D(double forwardInput, double sideInput, double totalForwardInput, double totalSideInput, ViewInputAttributes.DeviceAttributes deviceAttributes, @@ -335,9 +333,9 @@ protected void onHorizontalTranslate2D(double forwardInput, double sideInput, Point p1 = constrainToSourceBounds(this.getMouseDownPoint(), this.getWorldWindow()); Point p2 = constrainToSourceBounds(this.getMousePoint(), this.getWorldWindow()); Line ray1 = ViewUtil.computeRayFromScreenPoint(orbitView, p1.x, p1.y, this.mouseDownModelview, - this.mouseDownProjection, this.mouseDownViewport); + this.mouseDownProjection); Line ray2 = ViewUtil.computeRayFromScreenPoint(orbitView, p2.x, p2.y, this.mouseDownModelview, - this.mouseDownProjection, this.mouseDownViewport); + this.mouseDownProjection); // Compute a model coordinate plane passing through the position under the cursor when the mouse button was // pressed. Fall back to a plane normal to the globe if the cursor was off the globe. @@ -400,7 +398,6 @@ protected void onResetHeading(ViewInputAttributes.ActionAttributes actionAttribs * * @param actionAttribs input that caused the change. */ - @SuppressWarnings("UnusedParameters") protected void onResetRoll(ViewInputAttributes.ActionAttributes actionAttribs) { View view = this.getView(); diff --git a/src/gov/nasa/worldwindx/applications/worldwindow/core/ToolTipAnnotation.java b/src/gov/nasa/worldwindx/applications/worldwindow/core/ToolTipAnnotation.java index 53e831a7c2..c8bf39e19a 100644 --- a/src/gov/nasa/worldwindx/applications/worldwindow/core/ToolTipAnnotation.java +++ b/src/gov/nasa/worldwindx/applications/worldwindow/core/ToolTipAnnotation.java @@ -98,7 +98,7 @@ protected void doRenderNow(DrawContext dc) protected Point adjustDrawPointToViewport(Point point, Rectangle bounds, Rectangle viewport) { int x = point.x; - int y = (int) viewport.getHeight() - point.y - 1; + int y = point.y; if (x + this.getOffsetX() + bounds.getWidth() > viewport.getWidth()) x = (int) (viewport.getWidth() - bounds.getWidth()) - 1 - this.getOffsetX(); diff --git a/src/gov/nasa/worldwindx/examples/analytics/AnalyticSurfaceLegend.java b/src/gov/nasa/worldwindx/examples/analytics/AnalyticSurfaceLegend.java index 85d358249b..1daa69884b 100644 --- a/src/gov/nasa/worldwindx/examples/analytics/AnalyticSurfaceLegend.java +++ b/src/gov/nasa/worldwindx/examples/analytics/AnalyticSurfaceLegend.java @@ -158,7 +158,8 @@ public int getHeight(DrawContext dc) return this.screenImage.getImageHeight(dc); } - public void render(DrawContext dc) + @Override + public void render(DrawContext dc) { if (dc == null) { @@ -225,27 +226,32 @@ public static AnalyticSurfaceLegend.LabelAttributes createLegendLabelAttributes( { return new AnalyticSurfaceLegend.LabelAttributes() { - public double getValue() + @Override + public double getValue() { return value; } - public String getText() + @Override + public String getText() { return text; } - public Font getFont() + @Override + public Font getFont() { return font; } - public Color getColor() + @Override + public Color getColor() { return color; } - public Point2D getOffset() + @Override + public Point2D getOffset() { return new Point2D.Double(xOffset, yOffset); } @@ -320,18 +326,16 @@ protected void drawLabel(DrawContext dc, LabelAttributes attr, double x, double tr.beginRendering(viewport.width, viewport.height); try { - double yInGLCoords = viewport.height - y - 1; - // Draw the text outline, in a contrasting color. tr.setColor(WWUtil.computeContrastingColor(color)); - tr.draw(text, (int) x - 1, (int) yInGLCoords - 1); - tr.draw(text, (int) x + 1, (int) yInGLCoords - 1); - tr.draw(text, (int) x + 1, (int) yInGLCoords + 1); - tr.draw(text, (int) x - 1, (int) yInGLCoords + 1); + tr.draw(text, (int) x - 1, (int) y - 1); + tr.draw(text, (int) x + 1, (int) y - 1); + tr.draw(text, (int) x + 1, (int) y + 1); + tr.draw(text, (int) x - 1, (int) y + 1); // Draw the text over its outline, in the specified color. tr.setColor(color); - tr.draw(text, (int) x, (int) yInGLCoords); + tr.draw(text, (int) x, (int) y); } finally { @@ -411,7 +415,8 @@ public LabelRenderable(AnalyticSurfaceLegend legend, LabelAttributes attr, doubl this.orderedLabel = new OrderedLabel(legend, attr, x, y, halign, valign); } - public void render(DrawContext dc) + @Override + public void render(DrawContext dc) { dc.addOrderedRenderable(this.orderedLabel); } @@ -437,17 +442,20 @@ public OrderedLabel(AnalyticSurfaceLegend legend, LabelAttributes attr, double x this.valign = valign; } - public double getDistanceFromEye() + @Override + public double getDistanceFromEye() { return 0; } - public void render(DrawContext dc) + @Override + public void render(DrawContext dc) { this.legend.drawLabel(dc, this.attr, this.x, this.y, this.halign, this.valign); } - public void pick(DrawContext dc, Point pickPoint) + @Override + public void pick(DrawContext dc, Point pickPoint) { // Intentionally left blank. } diff --git a/src/gov/nasa/worldwindx/examples/kml/KMLViewer.java b/src/gov/nasa/worldwindx/examples/kml/KMLViewer.java index 12b60e1fa9..759426f6f4 100644 --- a/src/gov/nasa/worldwindx/examples/kml/KMLViewer.java +++ b/src/gov/nasa/worldwindx/examples/kml/KMLViewer.java @@ -37,7 +37,6 @@ import gov.nasa.worldwind.layers.RenderableLayer; import gov.nasa.worldwind.ogc.kml.*; import gov.nasa.worldwind.ogc.kml.impl.KMLController; -import gov.nasa.worldwind.render.Offset; import gov.nasa.worldwind.util.*; import javax.swing.*; @@ -76,7 +75,7 @@ public AppFrame() // Add the on-screen layer tree, refreshing model with the WorldWindow's current layer list. We // intentionally refresh the tree's model before adding the layer that contains the tree itself. This // prevents the tree's layer from being displayed in the tree itself. - this.layerTree = new LayerTree(new Offset(20d, 160d, AVKey.PIXELS, AVKey.INSET_PIXELS)); + this.layerTree = new LayerTree(new Point(20, 160)); this.layerTree.getModel().refresh(this.getWwd().getModel().getLayers()); // Set up a layer to display the on-screen layer tree in the WorldWindow. This layer is not displayed in @@ -119,7 +118,8 @@ protected void addDocumentLayer(KMLRoot document) // Set up to receive SSLHandshakeExceptions that occur during resource retrieval. WorldWind.getRetrievalService().setSSLExceptionListener(new RetrievalService.SSLExceptionListener() { - public void onException(Throwable e, String path) + @Override + public void onException(Throwable e, String path) { System.out.println(path); System.out.println(e); @@ -164,14 +164,16 @@ protected void addKMLLayer(KMLRoot kmlRoot) // we ensure that the network link tree view appearance is consistent with the KML specification. layerNode.addPropertyChangeListener(AVKey.RETRIEVAL_STATE_SUCCESSFUL, new PropertyChangeListener() { - public void propertyChange(final PropertyChangeEvent event) + @Override + public void propertyChange(final PropertyChangeEvent event) { if (event.getSource() instanceof KMLNetworkLinkTreeNode) { // Manipulate the tree on the EDT. SwingUtilities.invokeLater(new Runnable() { - public void run() + @Override + public void run() { ((KMLNetworkLinkTreeNode) event.getSource()).expandOpenContainers(layerTree); getWwd().redraw(); @@ -213,7 +215,8 @@ public WorkerThread(Object kmlSource, AppFrame appFrame) * If loading the KML source fails, this prints the exception and its stack trace to the standard error stream, * but otherwise does nothing. */ - public void run() + @Override + public void run() { try { @@ -226,7 +229,8 @@ public void run() final KMLRoot finalKMLRoot = kmlRoot; SwingUtilities.invokeLater(new Runnable() { - public void run() + @Override + public void run() { appFrame.addKMLLayer(finalKMLRoot); } @@ -287,7 +291,8 @@ protected static void makeMenu(final AppFrame appFrame) JMenuItem openFileMenuItem = new JMenuItem(new AbstractAction("Open File...") { - public void actionPerformed(ActionEvent actionEvent) + @Override + public void actionPerformed(ActionEvent actionEvent) { try { @@ -311,7 +316,8 @@ public void actionPerformed(ActionEvent actionEvent) JMenuItem openURLMenuItem = new JMenuItem(new AbstractAction("Open URL...") { - public void actionPerformed(ActionEvent actionEvent) + @Override + public void actionPerformed(ActionEvent actionEvent) { try { @@ -334,6 +340,7 @@ public void actionPerformed(ActionEvent actionEvent) public static void main(String[] args) { //noinspection UnusedDeclaration - final AppFrame af = (AppFrame) start("WorldWind KML Viewer", AppFrame.class); + @SuppressWarnings("unused") + final AppFrame af = (AppFrame) start("WorldWind KML Viewer", AppFrame.class); } } diff --git a/src/gov/nasa/worldwindx/examples/util/BalloonController.java b/src/gov/nasa/worldwindx/examples/util/BalloonController.java index f1708c1e95..ccd2c2abd9 100644 --- a/src/gov/nasa/worldwindx/examples/util/BalloonController.java +++ b/src/gov/nasa/worldwindx/examples/util/BalloonController.java @@ -163,6 +163,19 @@ public void setBalloonOffset(int balloonOffset) //*********************** Event handling *****************************// //********************************************************************// + /** + * Construct a mouse event with GL surface screen coordinates + * @param e + * @return + */ + 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(), + awtMouseEvent.getClickCount(), GLmousePt[0], GLmousePt[1], awtMouseEvent.isPopupTrigger(), + awtMouseEvent.getButton()); + return e; + } /** * Handle a mouse click. If the top picked object has a balloon attached to it the balloon will be made visible. A * balloon may be attached to a KML feature, or to any picked object though {@link AVKey#BALLOON}. @@ -170,11 +183,13 @@ public void setBalloonOffset(int balloonOffset) * @param e Mouse event */ @Override - public void mouseClicked(MouseEvent e) + public void mouseClicked(MouseEvent awtEv) { - if (e == null || e.isConsumed()) + if (awtEv == null || awtEv.isConsumed()) return; + MouseEvent e = glMouseEvent(awtEv); + // Implementation note: handle the balloon with a mouse listener instead of a select listener so that the balloon // can be turned off if the user clicks on the terrain. try @@ -219,6 +234,9 @@ public void mouseClicked(MouseEvent e) // Wrap the handler in a try/catch to keep exceptions from bubbling up Logging.logger().warning(ex.getMessage() != null ? ex.getMessage() : ex.toString()); } + + if (e.isConsumed()) + awtEv.consume(); } @Override @@ -248,7 +266,8 @@ else if (this.resizeController != null && !this.resizeController.isResizing()) } } - @SuppressWarnings("deprecation") + @Override + @SuppressWarnings("deprecation") public void selected(SelectEvent event) { if (event == null || event.isConsumed() @@ -984,8 +1003,7 @@ protected void showBalloon(Balloon balloon, Position position) Vec4 screenVec4 = this.wwd.getView().project( this.wwd.getModel().getGlobe().computePointFromPosition(position)); - Point screenPoint = new Point((int) screenVec4.x, - (int) (this.wwd.getView().getViewport().height - screenVec4.y)); + Point screenPoint = new Point((int) screenVec4.x, (int) screenVec4.y); // If the balloon is attached to the screen rather than the globe, move it to the // current point. Otherwise move it to the position under the current point. @@ -1327,8 +1345,7 @@ protected Point getBalloonPointForScreenOverlay(KMLScreenOverlay overlay) Rectangle viewport = this.wwd.getView().getViewport(); Point2D point2D = offset.computeOffset(viewport.width, viewport.height, 1d, 1d); - int y = (int) point2D.getY(); - return new Point((int) point2D.getX(), viewport.height - y); + return new Point((int) point2D.getX(), (int) point2D.getY()); } /** @@ -1504,7 +1521,8 @@ public DocumentRetrievalTask(String url, KMLRoot context, String featureRef, lon * gov.nasa.worldwind.ogc.kml.KMLRoot, String)}. If an exception occurs, or the timeout is exceeded, schedule a * callback on the EDT to {@link BalloonController#onDocumentFailed(String, Exception)} */ - public void run() + @Override + public void run() { KMLRoot root = null; @@ -1544,7 +1562,8 @@ else if (docSource != null) final KMLRoot pinnedRoot = root; // Final ref that can be accessed by anonymous class SwingUtilities.invokeLater(new Runnable() { - public void run() + @Override + public void run() { BalloonController.this.onDocumentLoaded(docUrl, pinnedRoot, featureRef); } @@ -1558,7 +1577,8 @@ public void run() // Schedule a callback on the EDT to report the error to the BalloonController SwingUtilities.invokeLater(new Runnable() { - public void run() + @Override + public void run() { BalloonController.this.onDocumentFailed(docUrl, e); } diff --git a/src/gov/nasa/worldwindx/examples/util/LayerManagerLayer.java b/src/gov/nasa/worldwindx/examples/util/LayerManagerLayer.java index 57dd7465f2..24a72f8714 100644 --- a/src/gov/nasa/worldwindx/examples/util/LayerManagerLayer.java +++ b/src/gov/nasa/worldwindx/examples/util/LayerManagerLayer.java @@ -644,7 +644,7 @@ protected void drag(SelectEvent event) Point cursorOffset = new Point(event.getMouseEvent().getPoint().x - this.dragRefCursorPoint.x, event.getMouseEvent().getPoint().y - this.dragRefCursorPoint.y); Point targetPoint = new Point(this.dragRefPoint.x + cursorOffset.x, - this.dragRefPoint.y - cursorOffset.y); + this.dragRefPoint.y + cursorOffset.y); this.moveTo(targetPoint); event.consume(); } diff --git a/src/gov/nasa/worldwindx/examples/util/ScreenSelector.java b/src/gov/nasa/worldwindx/examples/util/ScreenSelector.java index ec266fd0b8..b6a42bdbbd 100644 --- a/src/gov/nasa/worldwindx/examples/util/ScreenSelector.java +++ b/src/gov/nasa/worldwindx/examples/util/ScreenSelector.java @@ -163,8 +163,8 @@ public void endSelection(Point point) maxX = this.startPoint.x; } - // Compute the selection's extremes along the y axis. The selection is defined in AWT screen coordinates, so - // the origin is in the upper left corner and the y axis points down. + // Compute the selection's extremes along the y axis. The selection is defined in GL surface coordinates, so + // the origin is in the lower left corner and the y axis points up. double minY, maxY; if (this.startPoint.y < this.endPoint.y) { @@ -185,7 +185,7 @@ public void endSelection(Point point) if (minY == maxY && minX < maxX) minY = maxY - 1; - this.rect.setRect(minX, maxY, maxX - minX, maxY - minY); + this.rect.setRect(minX, minY, maxX - minX, maxY - minY); } public void clearSelection() @@ -215,17 +215,20 @@ public void setBorderColor(Color color) this.borderColor = color; } - public double getDistanceFromEye() + @Override + public double getDistanceFromEye() { return 0; // Screen rectangle is drawn on top of other ordered renderables, except other screen objects. } - public void pick(DrawContext dc, Point pickPoint) + @Override + public void pick(DrawContext dc, Point pickPoint) { // Intentionally left blank. SelectionRectangle is not pickable. } - public void render(DrawContext dc) + @Override + public void render(DrawContext dc) { if (dc == null) { @@ -270,7 +273,7 @@ protected void drawOrderedRenderable(DrawContext dc) gl.glOrtho(0, viewport.getWidth(), 0, viewport.getHeight(), -1, 1); // l, r, b, t, n, f this.BEogsh.pushModelviewIdentity(gl); gl.glTranslated(0.5, 0.5, 0.0); - gl.glTranslated(selection.getX(), viewport.getHeight() - selection.getY(), 0); + gl.glTranslated(selection.getX(), selection.getY(), 0); gl.glScaled(selection.getWidth() - 1, selection.getHeight() - 1, 1); // Disable the depth test and enable blending so this screen rectangle appears on top of the existing @@ -460,12 +463,14 @@ protected void sendMessage(Message message) } } - public void mouseClicked(MouseEvent mouseEvent) + @Override + public void mouseClicked(MouseEvent mouseEvent) { // Intentionally left blank. ScreenSelector does not respond to mouse clicked events. } - public void mousePressed(MouseEvent mouseEvent) + @Override + public void mousePressed(MouseEvent mouseEvent) { if (mouseEvent == null) // Ignore null events. return; @@ -478,7 +483,8 @@ public void mousePressed(MouseEvent mouseEvent) mouseEvent.consume(); // Consume the mouse event to prevent the view from responding to it. } - public void mouseReleased(MouseEvent mouseEvent) + @Override + public void mouseReleased(MouseEvent mouseEvent) { if (mouseEvent == null) // Ignore null events. return; @@ -491,17 +497,20 @@ public void mouseReleased(MouseEvent mouseEvent) mouseEvent.consume(); // Consume the mouse event to prevent the view from responding to it. } - public void mouseEntered(MouseEvent mouseEvent) + @Override + public void mouseEntered(MouseEvent mouseEvent) { // Intentionally left blank. ScreenSelector does not respond to mouse entered events. } - public void mouseExited(MouseEvent mouseEvent) + @Override + public void mouseExited(MouseEvent mouseEvent) { // Intentionally left blank. ScreenSelector does not respond to mouse exited events. } - public void mouseDragged(MouseEvent mouseEvent) + @Override + public void mouseDragged(MouseEvent mouseEvent) { if (mouseEvent == null) // Ignore null events. return; @@ -513,7 +522,8 @@ public void mouseDragged(MouseEvent mouseEvent) mouseEvent.consume(); // Consume the mouse event to prevent the view from responding to it. } - public void mouseMoved(MouseEvent mouseEvent) + @Override + public void mouseMoved(MouseEvent mouseEvent) { // Intentionally left blank. ScreenSelector does not respond to mouse moved events. } @@ -530,8 +540,7 @@ protected void selectionStarted(MouseEvent mouseEvent) this.sendMessage(new Message(SELECTION_STARTED, this)); } - @SuppressWarnings({"UnusedParameters"}) - protected void selectionEnded(MouseEvent mouseEvent) + protected void selectionEnded(@SuppressWarnings("unused") MouseEvent mouseEvent) { this.selectionRect.clearSelection(); this.getWwd().getSceneController().setPickRectangle(null); @@ -577,19 +586,20 @@ protected Point limitPointToWorldWindow(Point point) int x = point.x; if (x < viewport.x) x = viewport.x; - if (x > viewport.x + viewport.width) - x = viewport.x + viewport.width; + if (x >= viewport.x + viewport.width) + x = viewport.x + viewport.width - 1; int y = point.y; if (y < viewport.y) y = viewport.y; - if (y > viewport.y + viewport.height) - y = viewport.y + viewport.height; + if (y >= viewport.y + viewport.height) + y = viewport.y + viewport.height - 1; return new Point(x, y); } - public void selected(SelectEvent event) + @Override + public void selected(SelectEvent event) { try { diff --git a/src/gov/nasa/worldwindx/examples/util/ToolTipAnnotation.java b/src/gov/nasa/worldwindx/examples/util/ToolTipAnnotation.java index 5113946db4..ab47aad371 100644 --- a/src/gov/nasa/worldwindx/examples/util/ToolTipAnnotation.java +++ b/src/gov/nasa/worldwindx/examples/util/ToolTipAnnotation.java @@ -116,7 +116,7 @@ protected void doRenderNow(DrawContext dc) protected Point adjustDrawPointToViewport(Point point, Rectangle bounds, Rectangle viewport) { int x = point.x; - int y = (int) viewport.getHeight() - point.y - 1; + int y = point.y; if (x + this.getOffsetX() + bounds.getWidth() > viewport.getWidth()) x = (int) (viewport.getWidth() - bounds.getWidth()) - 1 - this.getOffsetX();