放大小程序的图形大小

发布于 2024-12-29 14:45:03 字数 74 浏览 3 评论 0原文

我想将小程序的大小加倍(包括位于其上的图形和组件)。

在我开始单独更改每个坐标之前,有什么简单的方法可以完成此任务吗?

I want to double the size of an applet (including the graphics and components positioned on it).

Is there any easy way to accomplish this before I start changing every coordinate individually?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甲如呢乙后呢 2025-01-05 14:45:03

我已经有一段时间没有写Java小程序了,所以我不能准确地告诉你哪些类和接口。

但作为一般原则,您可以使用装饰器来做到这一点。创建一个实现与图形上下文对象相同的接口的类*。将实际的图形上下文传递给类的构造函数。对于类中的每个方法,在其包装的图形上下文对象上调用相同的方法。并将放大倍率设置为该类的一个字段,以便将来可以将其设为 3 倍。

然后,当您的代码获取图形对象时,将其替换为自定义类的实例,该实例应包装图形对象。

如果这是不可能的,您可能必须破解您的原始代码。但请采纳我的建议 - 这次包含一个乘法因子作为变量/字段,以便下次您可以在一次位置调整数字。

  • 或者,如果没有可用的接口,则看起来是 Graphics 类,扩展它并确保重写每个方法。

It has been a while since I wrote a Java applet, so I cannot tell you exactly which classes and interfaces.

But as a general principle you could do this with a decorator. Make a class that implements the same interface as your graphics context object*. Pass the actual graphics context to the constructor of your class. For each method on your class, call the same method on the graphic context object that it wraps. And set the magnification as a field of the class so you can make it 3x in future.

Then, when your code takes the graphics object, replace that with an instance of your custom class, which should wrap the graphics object.

If this is not possible, you may have to hack your original code. But take my advice - this time include a multiplication factor as a variable/field so that next time you can adjust the number in once place.

  • or, if there's no interface available, which looks to be the the Graphics class, extend it and be sure to override every method.
雨巷深深 2025-01-05 14:45:03

如果小程序内容缩放,您只需更改嵌入 html 页面中小程序的大小。这假设仅使用了相对或计算的坐标和布局管理器。如果元素位于绝对位置,则这将不起作用。然后,您要么必须触摸代码,要么编写一个可缩放内容的包装器,正如 Joe 建议的那样。

If the applet contents scale you just need to change the size of the applet in the embedding html page. This assumes that only relative or calculated coordinates and layout managers have been used. If elements are positioned at absolute positions, this will not work will. Then you will either have to touch the code or write a wrapper that scales the content, as Joe suggested.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文