在的Java Swing / AWT的页转到效应 [英] The Page Turn Effect in Java Swing/AWT

查看:139
本文介绍了在的Java Swing / AWT的页转到效应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现翻页效果在Swing / AWT。该理论是pretty多解释 rel=\"nofollow\">。我的问题是,由于该页面包含文本,它是用正确的挥杆/ AWT组件?此外,为了获得一个更深一点,我应该怎么处理这个问题?我的意思是我的理论在我面前摆出来,我知道的工具,我需要使用,但我从来没有做过这样的事与Swing / AWT,我需要掌握的Swing / AWT的所有细节才能够做到此?

I would like to implement the page turn effect in Swing/AWT. The theory is pretty much explained here. My question is that since the page is to contain text, which is the correct swing/awt component to use? Also, to get a little deeper, how should I approach this problem? I mean I have the theory laid out before me, I know the tool I need to use, but I have never done anything like this with Swing/AWT, do I need to master all the minutiae of Swing/AWT to be able to do this?

推荐答案

不管你做什么,你就必须实现自己的绘图程序。当你打算动用打算不与其他部件绘制文本的最有特色的文本(它会倾斜,旋转一段时间,并在页面的移动可视边缘剪切),你也将有绘制文本。

Whatever you do, you will have to implement your own drawing routines. As the text you intend to draw is going to not share most characteristics of the text drawn with other components (it will be angled, rotating over time, and clipped at a moving visible "edge" of the page), you will also have to draw the text.

在秋千上,在所有非控制台程序中的文本将作为任何图形原始绘制到屏幕上。这需要一些学习;尤其是在行间距,字间距,自动换行等的详细信息。

In SWING, and in all non-console programs the text is drawn to the screen as would any graphics primitive. It takes a bit of learning; especially in the details of line spacing, letter spacing, word wrapping, etc.

这意味着我会考虑一个新的秋千UI组件。 下面是如何编写自定义画一个。根据不同的细节,你可能要重用的典范。通常很容易只写比的图,并在同一时间的模型的图。但是,必须平衡与现有模型的适合性的观点的需要。

That means I'd consider a new swing UI component. Here's how to write custom painting for one. Depending on the details, you may want to reuse a model. Generally it is easier to only write a view than a view and a model at the same time; however, you must balance the needs of the view with the suitability of the existing model.

如果您选择一个现有的模型,Document接口是什么,你应该code你对视图。你可以把你的领导从JTextPane的或JTextArea中的视图组件,depeding上,如果你想添加样式,以文本的能力。

If you choose an existing model, the Document interface is what you should code your view against. You can take your lead from the JTextPane or JTextArea view components, depeding on if you want the ability to "add style" to your text.

不要忘记,观点实际上没有做画在一个结构良好的Swing组件。如果那样的话,就不会是能够被剥皮(跟随平台的主题)。这意味着,当你将提供一个Swing视图(通常像JPagedBook一个名称模式),这一观点将必须连接到UIDelegate由它来完成视图的实际绘制。这允许每个视图多个UIDelegates,用含有如何呈现(平局)的说明,其方式认为是与平台的外观和感觉一致的每个UIDelegate

Don't forget that the view actually doesn't do the painting in a well structured Swing component. If it did, then it would not be able to be skinned (to follow the platform's theme). This means that while you will provide a Swing view (typically with a name pattern like JPagedBook), that view will have to be coupled to a UIDelegate which does the actual drawing of the view. This allows multiple UIDelegates for each view, with each UIDelegate containing the instructions of how to render (draw) the view in a manner that is consistent with the look-and-feel of the platform.

解决这个问题的最大的问题通常是额外的工作涉及到正确支持的外观和感觉,缺乏适当的UIDelegate注册知识(所以当视图绘制,它发现的东西,将画它)。这是值得额外的几个小时(或几天的夫妇,如果GUI组件编程是有点新的给你),使它象秋千其余工作。最终你就会有不一样的感觉图书馆的独立的部分组件。

The biggest issues around this is typically the extra work involved to properly support look-and-feel, and the lack of knowledge of proper UIDelegate registration (so when the view draws, it finds something that will draw it). It's worth the extra few hours (or couple of days if GUI component programming is sort of new to you) to make it work like the rest of Swing. In the end you'll have a component that doesn't feel like a "separate" part of the library.

这篇关于在的Java Swing / AWT的页转到效应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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