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发行说明。
This lesson shows you how to use 本课程介绍如何使用Graphics2D
to display graphics with fancy outline and fill styles, transform graphics when they are rendered, constrain rendering to a particular area, and generally control the way graphics look when they are rendered.Graphics2D
显示具有奇特轮廓和填充样式的图形,在渲染时变换图形,将渲染约束到特定区域,以及通常控制渲染时图形的外观。You'll also learn how to create complex 您还将学习如何通过组合简单图形对象来创建复杂Shape
objects by combining simple ones and how to detect when the user clicks on a displayed graphics primitive.Shape
对象,以及如何检测用户何时单击显示的图形图元。These topics are discussed in the following sections:以下章节将讨论这些主题:
This section shows you how to modify the default transformation so that objects are translated, rotated, scaled, or sheared when they are rendered.本节介绍如何修改默认变换,以便在渲染对象时平移、旋转、缩放或剪切对象。
You can use any shape as a clipping path—the area within which rendering takes place.您可以使用任何形状作为剪裁路径—进行渲染的区域。
This section illustrates the various compositing styles supported by 本节说明AlphaComposite
and shows you how to set the compositing style in the Graphics2D
rendering context.AlphaComposite
支持的各种合成样式,并说明如何在Graphics2D
渲染上下文中设置合成样式。
This section describes the rendering hints that 本节介绍Graphics2D
supports and shows you how to specify your preference in the trade-off between rendering quality and speed.Graphics2D
支持的渲染提示,并向您展示如何在渲染质量和速度之间进行权衡时指定首选项。
This section shows you how to perform boolean operations on 本节介绍如何使用Shape
objects using the Area
class.Area
类对Shape
对象执行布尔操作。
This section shows you how to perform hit detection on graphics primitives.本节介绍如何对图形原语执行命中检测。