The Java Tutorials have been written for JDK 8.Java教程是为JDK 8编写的。Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.本页中描述的示例和实践没有利用后续版本中引入的改进,并且可能使用不再可用的技术。See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.有关Java SE 9及其后续版本中更新的语言特性的摘要,请参阅Java语言更改。
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.有关所有JDK版本的新功能、增强功能以及已删除或不推荐的选项的信息,请参阅JDK发行说明。
The Java 2D API maintains two coordinate spaces:Java 2D API维护两个坐标空间:
User space is a device-independent logical coordinate system, the coordinate space that your program uses.用户空间是独立于设备的逻辑坐标系,即程序使用的坐标空间。All geometries passed into Java 2D rendering routines are specified in user-space coordinates.传递到Java 2D渲染例程中的所有几何体都在用户空间坐标中指定。
When the default transformation from user space to device space is used, the origin of user space is the upper-left corner of the component's drawing area.使用从用户空间到设备空间的默认转换时,用户空间的原点位于零部件绘图区域的左上角。The x coordinate increases to the right, and the y coordinate increases downward, as shown in the following figure.x坐标向右增加,y坐标向下增加,如下图所示。The top-left corner of a window is 0,0.窗口的左上角为(0,0)
。All coordinates are specified using integers, which is usually sufficient.所有坐标都是使用整数指定的,这通常就足够了。However, some cases require floating point or even double precision which are also supported.但是,在某些情况下,也支持浮点甚至双精度。
Device space is a device-dependent coordinate system that varies according to the target rendering device.设备空间是一个依赖于设备的坐标系,它随目标渲染设备的不同而变化。Although the coordinate system for a window or screen might be very different from the coordinate system of a printer, these differences are invisible to Java programs.尽管窗口或屏幕的坐标系可能与打印机的坐标系非常不同,但Java程序看不到这些差异。The necessary conversions between user space and device space are performed automatically during rendering.渲染过程中会自动执行用户空间和设备空间之间的必要转换。