【正文】
eometry, such as Arc2D, Line2D, Rectangle2D, Ellipse2D, and CubicCurve2D. Each of these is an abstract class, plete with two nonabstract inner classes called Double and Float (which are subclasses of the abstract outer class). These classes allow the various geometric shapes to be constructed with coordinates of either double or float precision. For example, (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 floatingpoint values. Also in this package is the AffineTransform class, which 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 bination of these. Each transformation can be represented 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 floatingpoint values, although they are more usually created by specifying one or more translation, rotation, scaling, or shearing operations. Mostly doubleprecision values are used, and angles are measured in radians (not degrees as used by the Arc2D class). Text rendering The text capabilities of the Java 2D API are impressive. They include: Antialiasing and hinting for improved output quality The ability to use all the systeminstalled fonts The ability to apply the same operations (rotation, scaling, painting, clipping, and so on) to text as to graphic objects Support for adding embedded attributes to strings (such as font, size, weight, and even images) Support for bidirectional text (to enable righttoleft character runs like you would encounter in Arabic and Hebrew) Primary and secondary cursors that can navigate through text containing both righttoleft and lefttoright character runs Advanced fontmeasurement capabilities, surpassing those of the old class Layout capabilities to wordwrap and justify multiline text Multimedia options: Java Media APIs The 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。例如 Swing 等各種技術(shù)都是作為可選的擴(kuò)展被引入的。 相同的 Java 應(yīng)用程序在每個(gè)平臺(tái)上都有不同的外觀,但本意是不同的實(shí)現(xiàn)在功能上是等同的。 語(yǔ)言自身已經(jīng)變得不只是一種平臺(tái)了, GUI 也正在朝著在所有平臺(tái)上都有相同的外觀和行為這種方向轉(zhuǎn)變。每一個(gè) Swing 組件都有一個(gè)自己的功能模型和一個(gè)獨(dú)立的外觀( lookandfeel),這可以預(yù)先設(shè)置或在運(yùn)行時(shí)更改。此包建立在數(shù)據(jù)傳輸?shù)臋C(jī)制上,提供了拖放功能,這些功能可以在一個(gè)單獨(dú)的 Java 應(yīng)用程序內(nèi)或兩個(gè) Java 應(yīng)用程序之間以一種平臺(tái)無(wú)關(guān)的方式執(zhí)行。 類 這個(gè)類是 (該類在 Java 2 發(fā)行前就提供圖形功能)的一個(gè)子類。 這些類允許各種幾何圖形建立在雙精度或浮點(diǎn)精度的坐標(biāo)系上。 文本著色 Java 2D API 的文本功能也相當(dāng)強(qiáng)大。 Advanced Imaging 這個(gè)規(guī)范所涵蓋的操作將提高用戶處理圖像的能力。這種 API 規(guī)定一個(gè)跨平臺(tái)的接口來(lái)支持命令 ―控制識(shí)別器、聽(tīng)寫系統(tǒng)和語(yǔ)音合成器。這種新的 API 正在由 Java Community Process 設(shè)計(jì)。其中,如 2D API和聲音 API 是核 心 J2SE 平臺(tái)的一部分;其余的是目前可選的擴(kuò)展,不過(guò)其中的一些技術(shù)在將來(lái)無(wú)疑會(huì)進(jìn)入核心。這種類型的轉(zhuǎn)換示例包括如下的操作:平移、旋轉(zhuǎn)、縮放、剪切或者這些操作的組合。這意味著,paint()方法可以將 Graphics 對(duì)象作為一個(gè) Graphics 對(duì)象使用(使用舊的畫圖方法),或者將其強(qiáng)制轉(zhuǎn)換成 Graphics2D 對(duì)象。 從簡(jiǎn)單到先進(jìn): Java 2D 在 Java2 平臺(tái)之前,語(yǔ)言中的圖形功能相當(dāng)簡(jiǎn)單,僅限于單像素厚度的實(shí)線;少數(shù)幾個(gè)幾何圖形(如橢圓、弧和多邊形);和基本的畫圖功能。這對(duì)于功能性來(lái)說(shuō)是好的,但在外觀上或行為上總有一些不同,所以復(fù)雜的界面永遠(yuǎn)不會(huì)和使用本機(jī)組件的界面完全相同。 現(xiàn)在來(lái)看一下 Swing,它使用 AWT 的一個(gè)子集來(lái)實(shí)現(xiàn)這個(gè)目標(biāo),這個(gè)子集包括基本畫圖操作和 包中的某些類(包括 Container、 Window、 Panel、Dialog 和 Frame)。 由于將優(yōu)先權(quán)賦予集成而產(chǎn)生的另一個(gè)問(wèn)題是功能性問(wèn)題。 JFC 的核心: Swing Swing 是一個(gè)帶有一套豐富組件的 GUI 工具包,它組成了 JFC 的用戶界面功能的核心部分。 Java2 平臺(tái)包含一個(gè)復(fù)雜的跨平臺(tái)的用戶界面體系結(jié)構(gòu),它的組成包括眾多的高級(jí)組件、一個(gè)先進(jìn)的,功能豐富的,獨(dú)立于設(shè)備的圖形系統(tǒng)和許多的多媒體擴(kuò)展。t make a window appear on UNIX without X System Window calls being involved. Enter Swing, which achieved this goal by making use of a subset of the AWT, in