《使用JAVA开发连连看游戏后毕业设计外文文献及翻译.docx》由会员分享,可在线阅读,更多相关《使用JAVA开发连连看游戏后毕业设计外文文献及翻译.docx(13页珍藏版)》请在三一文库上搜索。
1、毕业设计说明书英文文献及中文翻译班 级: 学号: 姓 名: 学 院: 专 业: 指导教师: The Java 2 user interfaceGraphical and user interface capabilities have progressed in leaps and bounds since the early days of the Java language. The Java 2 platform contains a sophisticated cross-platform user interface architecture that consists of num
2、erous high-level components, an advanced feature-rich device-independent graphics system, and a host of multimedia extensions. In this article, well explore this progression, examine the capabilities of the current version 1.3 in detail, and finish by looking to the future to see what release 1.4 wi
3、ll offer.Prior to the release of the Java 2 platform, the Abstract Window Toolkit (AWT) was the extent of the Java platforms graphical capabilities. Various technologies, such as Swing, were introduced as optional extensions. With the Java 2 platform, most of these extensions have found their way in
4、to the core as part of the Java Foundation Classes (JFC). JFC refers to the entire set of graphical and user interface technologies included in the Java 2 platform, including AWT and Swing. In this article, well explore each of the major components of the JFC and then discuss some of the optional ex
5、tensions.The heart of the JFC: SwingSwing, a GUI toolkit with a rich set of components, forms the heart of the JFCs user interface capabilities. It is both a replacement for the components the AWT provides and also a big step forward.When integration was the priorityIn the first releases of the JDK,
6、 integration with the native platform was considered a priority and so the AWT provided components that were implemented using the native components of each platform (in the Java programming vernacular, these are now known as heavyweight components). For example, on UNIX platforms the java.awt.Butto
7、n class was implemented with a Motif PushButton widget. The same Java application had a different appearance on each platform, but the intention was that the different implementations were functionally equivalent. Of course, this is where the problems start. For simple interfaces, the equivalence is
8、 true, but the model breaks down as complexity increases simply because the components are different, and they will always behave slightly differently in some situations no matter how many bugs are fixed and how many times parts of the AWT are rewritten.The other problem that cropped up by placing a
9、 priority on integration was functionality. The AWT provided only a limited set of components because of the lowest common denominator approach - a particular component or function can only be provided if it is available on every platform. A classic example is mouse buttons. Back in JDK 1.0.2, there
10、 was no way to distinguish between mouse button presses because the Macintosh had only one mouse button, and so every other platform had to behave as if it too supported only one mouse button.As the language became more of a platform in its own right, the approach to GUIs moved toward identical appe
11、arance and behavior across all platforms. To achieve this goal, the native components have to be abandoned as much as possible. But, clearly, some native code is still required. You cant make a window appear on UNIX without X System Window calls being involved.Enter Swing, which achieved this goal b
12、y making use of a subset of the AWT, including the basic drawing operations and the certain classes in the java.awt package: Container, Window, Panel, Dialog, and Frame. Best of all possible approachesSwing does not completely follow the Java language as a platform route. Instead, it combines the be
13、st of both approaches by offering a bridge back to the native platforms.The mechanism for establishing this bridge is referred to as Pluggable Look-and-Feels (which is pretty close to the concept of themes, popular in the Linux community). Each Swing component has a model of its functionality and a
14、separate appearance (the look-and-feel), which can be set in advance or changed on the fly.Swing provides a Java look-and-feel (previously known as Metal), separate ones for the Windows and Motif platforms, and one for the Macintosh platform (as an extra option). The platform look-and-feels dont use
15、 the native components of the platform like the AWT does. Instead, they use lightweight components that are drawn to have the same appearance as the native components. This is good for functionality, but there are always some differences in look or behavior, so complex interfaces will never be ident
16、ical to ones that use native components.Furthermore, you can roll your own look-and-feel, which is a great ability to have when crafting one for highly specialized applications or when providing a corporate look-and-feel across a range of applications.Platform-independent drag and dropJDK 1.1 added
17、a general mechanism, found in the java.awt.datatransfer package, that enabled the transferring of data between and within applications, as well as the ability to manipulate the system clipboard.The java.awt.dnd package was introduced in the Java 2 version. This package builds on the data-transfer me
18、chanism by providing drag-and-drop facilities that can operate in a platform-independent manner within a single Java application or between two Java applications. It can also behave in a platform-dependent manner in order to integrate with the drag-and-drop facilities of the native platform.The Drag
19、 and Drop (DND) API is quite challenging to use because it operates at a high level of abstraction to support the different ways in which it can work and because it is designed to operate on arbitrary datatypes, as specified by the java.awt.datatransfer.Transferable interface. Lets take a look at an
20、 example.Enabling the disabled: AccessibilityThe JFC Accessibility API equips Java applications so they can be accessed by users of all abilities, including people with sight-, hearing-, or dexterity-related difficulties. These might include the inability to discern visible or auditory cues or to op
21、erate a pointing device.Two of the most important features of accessibility support are screen readers and magnifiers. Screen readers allow users to interact with a GUI by creating an off-screen representation of the interface and passing this to a speech synthesizer or a Braille terminal. Screen ma
22、gnifiers provide an enlarged window of the screen, typically from 2 to 16 times the normal size. They generally keep track of pointer movements and changes in input focus and adjust the enlarged view accordingly. In addition, techniques such as font smoothing may be used to create a clearer picture.
23、The Java Accessibility BridgeSome host systems, such as Microsoft Windows, provide their own accessibility features. By default, Java applications do not fully support them. For example, with native applications the screen magnifier detects when the input focus is switched to a different user interf
24、ace component, such as by using the Tab key, and it adjusts the portion of the screen that is being magnified to show the component that now has the input focus.However, Swing applications use lightweight components, which are treated as images by the operating system, instead of discrete components
25、. This means the screen magnifier cannot track changes in input focus in the same way as with native applications.This is exactly the problem the Java Accessibility Bridge for Windows solves. It creates a map between events relating to lightweight components and native system events. By using the Br
26、idge, Java applications that support the Accessibility API are then fully integrated with the Windows accessibility support.From primitive to advanced: Java 2DBefore the Java 2 platform, graphical capabilities in the language were rather primitive, limited to solid lines of single-pixel thickness; a
27、 few geometric shapes such as ovals, arcs, and polygons; and basic image-drawing functionality. All that changed with the introduction of the Java 2D API, which contains a substantial feature set.The core of this API is provided by the java.awt.Graphics2D class, which is a subclass of java.awt.Graph
28、ics. The remainder of the API is provided by other packages within the java.awt hierarchy, including java.awt.color, java.awt.font, and java.awt.geom.The java.awt.Graphics2D classThis class is a subclass of java.awt.Graphics, the class that provided graphical capabilities prior to the Java 2 release
29、. The reason for this arrangement: backwards compatibility. Components are still rendered by calling their paint() method, which takes a Graphics object.In the current version of the language, though, the object is really a Graphics2D object. This means that a paint() method can either use the Graph
30、ics object as a Graphics object (using the old drawing methods) or cast it to a Graphics2D object. If it uses the second option, then any of the additional capabilities of the 2D API can be used.The java.awt.geom packageThe java.awt.geom package provides a number of classes relating to two-dimension
31、al geometry, such as Arc2D, Line2D, Rectangle2D, Ellipse2D, and CubicCurve2D. Each of these is an abstract class, complete with two non-abstract inner classes called Double and Float (which are subclasses of the abstract outer class).These classes allow the various geometric shapes to be constructed
32、 with coordinates of either double or float precision. For example, newEllipse2D.Float(x,y,w,h) will construct an ellipse bounded by a rectangle of width w and height h, at position (x,y), in which x, y, w, and h are all floating-point values.Also in this package is the AffineTransform class, which
33、forms a core element of the 2D API. An affine transformation is one in which parallel lines remain parallel after the transformation. Examples of this type of transformation include such actions as translation, rotation, scaling, shearing, or any combination of these. Each transformation can be repr
34、esented by a 3x3 matrix that specifies the mapping between source and destination points for the transformation.Instances of the AffineTransform class can be created directly from a matrix of floating-point values, although they are more usually created by specifying one or more translation, rotatio
35、n, scaling, or shearing operations. Mostly double-precision values are used, and angles are measured in radians (not degrees as used by the Arc2D class).Text renderingThe text capabilities of the Java 2D API are impressive. They include:Anti-aliasing and hinting for improved output qualityThe abilit
36、y to use all the system-installed fontsThe ability to apply the same operations (rotation, scaling, painting, clipping, and so on) to text as to graphic objectsSupport for adding embedded attributes to strings (such as font, size, weight, and even images)Support for bi-directional text (to enable ri
37、ght-to-left character runs like you would encounter in Arabic and Hebrew)Primary and secondary cursors that can navigate through text containing both right-to-left and left-to-right character runsAdvanced font-measurement capabilities, surpassing those of the old java.awt.FontMetrics classLayout cap
38、abilities to word-wrap and justify multi-line text Multimedia options: Java Media APIsThe Java Media APIs are a set of resources covering an extensive range of multimedia technologies. Some of them, such as the 2D and sound APIs, are part of the core J2SE platform; the rest are currently optional ex
39、tensions, but some of them will no doubt find their way into the core in the future. The other APIs in this area are Java 3D, Advanced Imaging, Image I/O, the Java Media Framework (JMF), and Speech.Java 3DThe Java 3D API provides a set of object-oriented interfaces that support a simple, high-level
40、programming model, enabling developers to build, render, and control the behavior of 3D objects and visual environments.The API includes a detailed specification document and implementation for packages javax.media.j3d and javax.vecmath.Advanced ImagingOperations covered by this specification enhanc
41、e a users ability to manipulate images. It includes such operations as contrast enhancement, cropping, scaling, geometric warping, and frequency domain processing.This type of functionality is applicable to various fields, such as astronomy, medical imaging, scientific visualization, meteorology, an
42、d photography.Image I/OThis API defines a pluggable framework for reading and writing images of various formats. This new API is being designed through the Java Community Process.Java Media Framework (JMF)The JMF is an API for incorporating audio, video, and other time-based media into Java applicat
43、ions and applets. This optional package extends the multimedia capabilities of the J2SE platform.SpeechThe Java Speech API allows developers to incorporate speech technology into user interfaces for Java applets and applications. The API specifies a cross-platform interface to support command-and-co
44、ntrol recognizers, dictation systems, and speech synthesizers.This blanket API is divided into several specifications:Java Speech API Specification (JSAPI) Java Speech API Programmers Guide Java Speech API Grammar Format Specification (JSGF) Java Speech API Markup Language Specification (JSML) There
45、 is no Sun reference implementation for this API, but there are numerous third-party implementations, including Speech for Java (available from IBM alphaWorks), which uses ViaVoice to support voice-command recognition, dictation, and text-to-speech synthesis.Java 2 用户界面自从Java语言出现的早期到现在,图形和用户界面功能已取得了
46、飞跃式的发展。Java2平台包含一个复杂的跨平台的用户界面体系结构,它的组成包括众多的高级组件、一个先进的,功能丰富的,独立于设备的图形系统和许多的多媒体扩展。在本文中,我们将探究这个进步,详细审视当前1.3版本的功能,最后展望一下未来,看看发行版1.4会提供些什么。请点击文章顶部或底部的讨论,在论坛与本文作者和其他读者分享您对本文的看法。在Java2平台发行之前,抽象窗口工具包(Abstract Window Toolkit,AWT)是Java平台的图形功能的范围。例如Swing等各种技术都是作为可选的扩展被引入的。在Java2平台上,这些扩展中的大部分都可以在平台的核心中找到它们的一席之地
47、,成为Java基础类(Java Foundation Classes,JFC)的一部分。JFC指的是包含在Java2平台内的一整套图形和用户界面技术,包括AWT和Swing等。在本文中,我们将讨论JFC的每个主要组件,并讨论一些可选的扩展。JFC的核心:SwingSwing是一个带有一套丰富组件的GUI工具包,它组成了JFC的用户界面功能的核心部分。它不仅是AWT所提供的组件的替代品,并且在这些组件的基础上有了很大进步。当集成有优先权时在JDK首次发行时,与本机平台的集成被认为具有优先权,于是AWT提供了一些组件,这些组件使用各平台的本机组件(在Java编程术语中,这些被称为重量级组件)来实现
48、。例如,在UNIX平台上,java.awt.Button类是用窗口小部件Motif PushButton实现的。相同的Java应用程序在每个平台上都有不同的外观,但本意是不同的实现在功能上是等同的。当然,这也是问题开始的地方。在简单的界面里,这种等同是真的。但随着复杂性的增加,情况就不一样了,这只是因为组件的不同,而且在某些情况下,不管修正了多少错误,并且AWT的部件被重写了多少次,它们总会表现得有一点不同。由于将优先权赋予集成而产生的另一个问题是功能性问题。AWT只提供了有限的一套组件,是因为最小公分母方法只有当一个特殊的组件或功能在每个平台上都可用的时候才能够被提供。一个典型的示例就是鼠标键。在以前的JDK1.0.2中,是无法区分鼠标键的点击的,因为Macintosh只有一个鼠标键,所以其它的每个平台都要表现得好像自己也只支持一个鼠标键一样。语言自身已经变得不只是一种平台了,GUI也正在朝着在所有平台上都有相同的外观和行为这种方向转变。为了实现这个目标,本机组件必须尽量地丢弃。但是,显然一些本机代码还是必需的。如果不包含X System Window 的调用,您就不能在UNIX上显示一个窗口。