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

2D overlay : EmulGL and native should have the same code when dealing with HiDPI #304

Open
jzy3d opened this issue Sep 15, 2022 · 1 comment
Projects
Milestone

Comments

@jzy3d
Copy link
Owner

jzy3d commented Sep 15, 2022

Currently, some specific code is required when handling 2D overlays with JOGL (native) and EmulGL charts.

IViewOverlay impl JOGL : AWTNativeViewOverlay) EmulGL : EmulGLViewOverlay
Similar Applies pixel scale to G2D Applies pixel scale to G2D
Different canvas.getRendererHeight() is pixel scaled canvas.getRendererHeight() is not pixel scaled

This result in lot of code area where we use canvas.isNative() to apply different formulae for the layout in EmulGL or Native (e.g. View2DLayout).

Code would be simpler and more readable if EmulGLCanvas could return a scaled renderer height/width.

@jzy3d jzy3d added this to the 2.3.0 milestone Sep 15, 2022
@jzy3d
Copy link
Owner Author

jzy3d commented Sep 16, 2022

Another way of dealing with HiDPI for Windows would be

      setLayout(new BorderLayout() {
          @Override
          public void layoutContainer(Container target) {
              synchronized (target.getTreeLock()) {
                  Insets insets = target.getInsets();
                  int top = insets.top;
                  int bottom = target.getHeight() - insets.bottom;
                  int left = insets.left;
                  int right = target.getWidth() - insets.right;

                  Graphics graphics = getGraphics();
                  AffineTransform transform = ((Graphics2D) graphics).getTransform();
                  double scaleX = transform.getScaleX();
                  double scaleY = transform.getScaleY();

                  int width = right - left;
                  int height = bottom - top;
                  width *= scaleX;
                  height *= scaleY;

                  renWin.setBounds(left, top, width, height);
              }
          }
      });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Jzy3D
Awaiting triage
Development

No branches or pull requests

1 participant