在Java和Eclipse Framework中以不同方式处理缩放 [英] Scaling Handled Differently in Java and Eclipse Framework

查看:96
本文介绍了在Java和Eclipse Framework中以不同方式处理缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用



左图是无比例缩放(或100%)的打印,右边是在175%缩放比例的显示器上开始打印的同一张照片。我知道您在想什么:显示器及其分辨率/缩放比例应该对打印没有影响。是的,应该。



虽然这很可悲,但并不是什么大问题。但是有一个关键点:上面的打印件是作为插件测试运行的JUnit测试用例生成的。如果我将它们作为常规的单元测试两者都运行。



显然,在OSGi上下文中启动时,Eclipse环境中的某些功能会有所不同,并且我试图找出它是什么(所以我可以防止它)。



我认为这是一个很好的难题。



如果您需要提示什么是SWT类, ,我将其范围缩小到此文件 ScalePrint.java (例如,如果我删除了<$ c的实例我的演示中的$ c> ScalePrint ,表格显示正确;但是标题仍然错误。



我可以确认错误仅存在于Eclipse 4.6中,而不存在于4.5或3.7中(这并不完全令人惊讶,因为4.6是第一个支持缩放的版本)。而且,如果我在VM选项中添加 -Dswt.autoScale = 100 以禁用缩放,它也可以按预期工作。



我可以追加测试用例,但是正如我所说,我真的不认为这与Paperclips本身有任何关系。



那么...与在普通Java应用程序中运行相同代码相比,启动整个Eclipse框架时,有什么可能破坏扩展性?

解决方案

问题是使用类 Transform ,该类本身使用静态字段 DPIUtil.deviceZoom (以 DPIUtil.autoScaleUp(float dx)的形式)。



由于 DPIUtil.deviceZoom 是一个静态字段,当与具有缩放功能的主监视器一起使用时,所有操作都会失败(因为打印机没有)。


We have a problem using Paperclips (printing library for SWT) on scaled monitors, but I don't think it has anything to do with the framework and all with the Eclipse environment.

Let's see an example:

Left is the print with no scaling (or 100%), right is the same print started on a monitor with 175% scaling. I know what you are thinking: the monitor and its resolution / scaling should have no influence on a print. Right, should.

While that's sad and all, it would not be much of a problem. But there comes the kicker: The above prints were generated by a JUnit test case run as plug-in test. If I run them as a regular unit test both work.

Clearly something in the Eclipse environment works differently when started in an OSGi context, and I'm trying to find out what it is (so I can maybe prevent it).

And I think that's a nice puzzle.

If you need a hint for what SWT class might be the , I narrowed it down to this file ScalePrint.java for the table (i.e if I remove the instance of ScalePrint from my demo, the table is displayed correctly; the header is still wrong, though).

I can confirm the error exists only in Eclipse 4.6, and not 4.5 or 3.7 (which is not entirely surprising, since 4.6 is the first version to support scaling). And if I add -Dswt.autoScale=100 to the VM options to disable scaling, it works as expected, too.

I could append my test case, but as I said, I don't really think it has anything to do with Paperclips per se.

So... what could break the scaling when the entire Eclipse framework is started compared to running the same code in a plain Java application?

解决方案

The Problem is the use of the class Transform, which itself uses the static field DPIUtil.deviceZoom (in the form of DPIUtil.autoScaleUp(float dx)).

Since DPIUtil.deviceZoom is a static field everything fails when used with a primary monitor that has scaling (since printers don't).

这篇关于在Java和Eclipse Framework中以不同方式处理缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆