Documentation

The Java™ Tutorials
Hide TOC
Coordinates坐标
Trail: 2D Graphics二维图形
Lesson: Overview of the Java 2D API Concepts课程:Java 2D API概念概述

Coordinates坐标

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.但是,在某些情况下,也支持浮点甚至双精度。

This figure represents the space in which

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.渲染过程中会自动执行用户空间和设备空间之间的必要转换。


Previous page: Overview of the Java 2D API Concepts
Next page: Java 2D Rendering