graphics2d.html
来自「API資料大全」· HTML 代码 · 共 1,145 行 · 第 1/5 页
HTML
1,145 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:32:38 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class Graphics2D</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Graphics2D.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../java/awt/Graphics.html"><B>PREV CLASS</B></A> <A HREF="../../java/awt/GraphicsConfigTemplate.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="Graphics2D.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.awt</FONT><BR>Class Graphics2D</H2><PRE><A HREF="../../java/lang/Object.html">java.lang.Object</A> | +--<A HREF="../../java/awt/Graphics.html">java.awt.Graphics</A> | +--<B>java.awt.Graphics2D</B></PRE><HR><DL><DT>public abstract class <B>Graphics2D</B><DT>extends <A HREF="../../java/awt/Graphics.html">Graphics</A></DL><P>This <code>Graphics2D</code> class extends the <A HREF="../../java/awt/Graphics.html"><CODE>Graphics</CODE></A> class to provide more sophisticated control over geometry, coordinate transformations, color management, and text layout. This is the fundamental class for rendering 2-dimensional shapes, text and images on the Java(tm) platform. <p> <h2>Coordinate Spaces</h2> All coordinates passed to a <code>Graphics2D</code> object are specified in a device-independent coordinate system called User Space, which is used by applications. The <code>Graphics2D</code> object contains an <A HREF="../../java/awt/geom/AffineTransform.html"><CODE>AffineTransform</CODE></A> object as part of its rendering state that defines how to convert coordinates from user space to device-dependent coordinates in Device Space. <p> Coordinates in device space usually refer to individual device pixels and are aligned on the infinitely thin gaps between these pixels. Some <code>Graphics2D</code> objects can be used to capture rendering operations for storage into a graphics metafile for playback on a concrete device of unknown physical resolution at a later time. Since the resolution might not be known when the rendering operations are captured, the <code>Graphics2D</code> <code>Transform</code> is set up to transform user coordinates to a virtual device space that approximates the expected resolution of the target device. Further transformations might need to be applied at playback time if the estimate is incorrect. <p> Some of the operations performed by the rendering attribute objects occur in the device space, but all <code>Graphics2D</code> methods take user space coordinates. <p> Every <code>Graphics2D</code> object is associated with a target that defines where rendering takes place. A <A HREF="../../java/awt/GraphicsConfiguration.html"><CODE>GraphicsConfiguration</CODE></A> object defines the characteristics of the rendering target, such as pixel format and resolution. The same rendering target is used throughout the life of a <code>Graphics2D</code> object. <p> When creating a <code>Graphics2D</code> object, the <code>GraphicsConfiguration</code> specifies the <a name="#deftransform">default transform</a> for the target of the <code>Graphics2D</code> (a <A HREF="../../java/awt/Component.html"><CODE>Component</CODE></A> or <A HREF="../../java/awt/Image.html"><CODE>Image</CODE></A>). This default transform maps the user space coordinate system to screen and printer device coordinates such that the origin maps to the upper left hand corner of the target region of the device with increasing X coordinates extending to the right and increasing Y coordinates extending downward. The scaling of the default transform is set to identity for those devices that are close to 72 dpi, such as screen devices. The scaling of the default transform is set to approximately 72 user space coordinates per square inch for high resolution devices, such as printers. For image buffers, the default transform is the <code>Identity</code> transform. <h2>Rendering Process</h2> The Rendering Process can be broken down into four phases that are controlled by the <code>Graphics2D</code> rendering attributes. The renderer can optimize many of these steps, either by caching the results for future calls, by collapsing multiple virtual steps into a single operation, or by recognizing various attributes as common simple cases that can be eliminated by modifying other parts of the operation. <p> The steps in the rendering process are: <ol> <li> Determine what to render. <li> Constrain the rendering operation to the current <code>Clip</code>. The <code>Clip</code> is specified by a <A HREF="../../java/awt/Shape.html"><CODE>Shape</CODE></A> in user space and is controlled by the program using the various clip manipulation methods of <code>Graphics</code> and <code>Graphics2D</code>. This <i>user clip</i> is transformed into device space by the current <code>Transform</code> and combined with the <i>device clip</i>, which is defined by the visibility of windows and device extents. The combination of the user clip and device clip defines the <i>composite clip</i>, which determines the final clipping region. The user clip is not modified by the rendering system to reflect the resulting composite clip. <li> Determine what colors to render. <li> Apply the colors to the destination drawing surface using the current <A HREF="../../java/awt/Composite.html"><CODE>Composite</CODE></A> attribute in the <code>Graphics2D</code> context. </ol> <br> The three types of rendering operations, along with details of each of their particular rendering processes are: <ol> <li> <b><a name="rendershape"><code>Shape</code> operations</a></b> <ol> <li> If the operation is a <code>draw(Shape)</code> operation, then the <A HREF="../../java/awt/Stroke.html#createStrokedShape(java.awt.Shape)"><CODE>createStrokedShape</CODE></A> method on the current <A HREF="../../java/awt/Stroke.html"><CODE>Stroke</CODE></A> attribute in the <code>Graphics2D</code> context is used to construct a new <code>Shape</code> object that contains the outline of the specified <code>Shape</code>. <li> The <code>Shape</code> is transformed from user space to device space using the current <code>Transform</code> in the <code>Graphics2D</code> context. <li> The outline of the <code>Shape</code> is extracted using the <A HREF="../../java/awt/Shape.html#getPathIterator(java.awt.geom.AffineTransform)"><CODE>getPathIterator</CODE></A> method of <code>Shape</code>, which returns a <A HREF="../../java/awt/geom/PathIterator.html"><CODE>PathIterator</CODE></A> object that iterates along the boundary of the <code>Shape</code>. <li> If the <code>Graphics2D</code> object cannot handle the curved segments that the <code>PathIterator</code> object returns then it can call the alternate <A HREF="../../java/awt/Shape.html#getPathIterator(java.awt.geom.AffineTransform, double)"><CODE>getPathIterator</CODE></A> method of <code>Shape</code>, which flattens the <code>Shape</code>. <li> The current <A HREF="../../java/awt/Paint.html"><CODE>Paint</CODE></A> in the <code>Graphics2D</code> context is queried for a <A HREF="../../java/awt/PaintContext.html"><CODE>PaintContext</CODE></A>, which specifies the colors to render in device space. </ol> <li> <b><a name=rendertext>Text operations</a></b> <ol> <li> The following steps are used to determine the set of glyphs required to render the indicated <code>String</code>: <ol> <li> If the argument is a <code>String</code>, then the current <code>Font</code> in the <code>Graphics2D</code> context is asked to convert the Unicode characters in the <code>String</code> into a set of glyphs for presentation with whatever basic layout and shaping algorithms the font implements. <li> If the argument is an <A HREF="../../java/text/AttributedCharacterIterator.html"><CODE>AttributedCharacterIterator</CODE></A>, the iterator is asked to convert itself to a <A HREF="../../java/awt/font/TextLayout.html"><CODE>TextLayout</CODE></A> using its embedded font attributes. The <code>TextLayout</code> implements more sophisticated glyph layout algorithms that perform Unicode bi-directional layout adjustments automatically for multiple fonts of differing writing directions. <li> If the argument is a <A HREF="../../java/awt/font/GlyphVector.html"><CODE>GlyphVector</CODE></A>, then the <code>GlyphVector</code> object already contains the appropriate font-specific glyph codes with explicit coordinates for the position of each glyph. </ol> <li> The current <code>Font</code> is queried to obtain outlines for the indicated glyphs. These outlines are treated as shapes in user space relative to the position of each glyph that was determined in step 1. <li> The character outlines are filled as indicated above under <a href="#rendershape"><code>Shape</code> operations</a>. <li>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?