Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Partial fix of #195 #218

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/gov/nasa/worldwind/WorldWindowGLAutoDrawable.java
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,11 @@ protected void doSwapBuffers(GLAutoDrawable drawable)
*/
public void reshape(GLAutoDrawable glAutoDrawable, int x, int y, int w, int h)
{
// This is apparently necessary to enable the WWJ canvas to resize correctly with JSplitPane.
GL2 gl = this.drawable.getGL().getGL2(); // change this as needed
double dpiScalingFactor = (double) (Toolkit.getDefaultToolkit().getScreenResolution() / 96.0);
w = (int) (w * dpiScalingFactor);
h = (int) (h * dpiScalingFactor);
gl.glViewport(0, 0, w, h);
((Component) glAutoDrawable).setMinimumSize(new Dimension(0, 0));
}

Expand Down
32 changes: 32 additions & 0 deletions src/gov/nasa/worldwind/awt/WorldWindowGLCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import com.jogamp.opengl.*;
import com.jogamp.opengl.awt.GLCanvas;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.beans.*;
import java.util.*;

Expand Down Expand Up @@ -487,4 +489,34 @@ public Collection<PerformanceStatistic> getPerFrameStatistics()
{
return this.wwd.getPerFrameStatistics();
}

@Override
protected void processMouseEvent(MouseEvent e) {
double dpiScalingFactor = (double) (Toolkit.getDefaultToolkit().getScreenResolution() / 96.0);
int x = (int) (e.getPoint().x * dpiScalingFactor);
int y = (int) (e.getPoint().y * dpiScalingFactor);
MouseEvent scaledEvent = new MouseEvent((Component)e.getSource(), e.getID(),
e.getWhen(), e.getModifiersEx(), x, y, e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), false,e.getButton());
super.processMouseEvent(scaledEvent);
}

@Override
protected void processMouseMotionEvent(MouseEvent e) {
double dpiScalingFactor = (double) (Toolkit.getDefaultToolkit().getScreenResolution() / 96.0);
int x = (int) (e.getPoint().x * dpiScalingFactor);
int y = (int) (e.getPoint().y * dpiScalingFactor);
MouseEvent scaledEvent = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), e.getModifiersEx(),
x, y, e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), false, e.getButton());
super.processMouseMotionEvent(scaledEvent);
}

@Override
protected void processMouseWheelEvent(MouseWheelEvent e) {
double dpiScalingFactor = (double) (Toolkit.getDefaultToolkit().getScreenResolution() / 96.0);;
int x = (int) (e.getPoint().x * dpiScalingFactor);
int y = (int) (e.getPoint().y * dpiScalingFactor);
MouseWheelEvent scaledEvent = new MouseWheelEvent((Component) e.getSource(),
e.getID(), e.getWhen(), e.getModifiersEx(), x, y, e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), false, e.getScrollType(),e.getScrollAmount(),e.getWheelRotation());
super.processMouseWheelEvent(scaledEvent);
}
}