⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graphics.html

📁 是MIDP 的API 查詢文件, 大家可以看一下裡面的index.html, 再用Package 或 Class 名字來查.
💻 HTML
📖 第 1 页 / 共 5 页
字号:
 do not modify the clip. The methods <A HREF="../../../javax/microedition/lcdui/Graphics.html#getClipX()"><CODE>getClipX()</CODE></A>, <A HREF="../../../javax/microedition/lcdui/Graphics.html#getClipY()"><CODE>getClipY()</CODE></A>, <A HREF="../../../javax/microedition/lcdui/Graphics.html#getClipWidth()"><CODE>getClipWidth()</CODE></A> and <A HREF="../../../javax/microedition/lcdui/Graphics.html#getClipHeight()"><CODE>getClipHeight()</CODE></A> must return a rectangle that, if passed to <code>setClip</code> without an intervening change to the <code>Graphics</code> object's coordinate system, must result in the identical set of pixels in the clip. The rectangle returned from the <code>getClip</code> family of methods may differ from the clip rectangle that was requested in <A HREF="../../../javax/microedition/lcdui/Graphics.html#setClip(int, int, int, int)"><CODE>setClip()</CODE></A>. This can occur if the coordinate system has been changed or if the implementation has chosen to intersect the clip rectangle with the bounds of the destination of the <code>Graphics</code> object. <p> If a graphics operation is affected by the clip, the pixels touched by that operation must be the same ones that would be touched as if the clip did not affect the operation. For example, consider a clip represented by the rectangle <code>(cx, cy, cw, ch)</code> and a point <code>(x1, y1)</code> that lies outside this rectangle and a point <code>(x2, y2)</code> that lies within this rectangle. In the following code fragment, </P> <TABLE BORDER="2"> <TR> <TD ROWSPAN="1" COLSPAN="1">    <pre><code>    g.setClip(0, 0, canvas.getWidth(),                    canvas.getHeight());    g.drawLine(x1, y1, x2, y2); // 3    g.setClip(cx, cy, cw, ch);    g.drawLine(x1, y1, x2, y2); // 4     </code></pre> </TD> </TR> </TABLE> <P> The pixels touched by statement (4) must be identical to the pixels within <code>(cx, cy, cw, ch)</code> touched by statement (3). </p> <p> <a name="anchor"></a> <h3>Anchor Points</h3> <p> The drawing of text is based on &quot;anchor points&quot;. Anchor points are used to minimize the amount of computation required when placing text. For example, in order to center a piece of text, an application needs to call <code>stringWidth()</code> or <code>charWidth()</code> to get the width and then perform a combination of subtraction and division to compute the proper location. The method to draw text is defined as follows: <pre><code> public void drawString(String text, int x, int y, int anchor); </code></pre> This method draws text in the current color, using the current font with its anchor point at <code>(x,y)</code>. The definition of the anchor point must be one of the horizontal constants <code>(LEFT, HCENTER, RIGHT)</code> combined with one of the vertical constants <code>(TOP, BASELINE, BOTTOM)</code> using the bit-wise <code>OR</code> operator. Zero may also be used as the value of an anchor point. Using zero for the anchor point value gives results identical to using <code>TOP | LEFT</code>.</p> <p> Vertical centering of the text is not specified since it is not considered useful, it is hard to specify, and it is burdensome to implement. Thus, the <code>VCENTER</code> value is not allowed in the anchor point parameter of text drawing calls. </p> <p> The actual position of the bounding box of the text relative to the <code>(x, y)</code> location is determined by the anchor point. These anchor points occur at named locations along the outer edge of the bounding box. Thus, if <code>f</code> is <code>g</code>'s current font (as returned by <code>g.getFont()</code>, the following calls will all have identical results: </P> <TABLE BORDER="2"> <TR> <TD ROWSPAN="1" COLSPAN="1">    <pre><code>    g.drawString(str, x, y, TOP|LEFT);    g.drawString(str, x + f.stringWidth(str)/2, y, TOP|HCENTER);    g.drawString(str, x + f.stringWidth(str), y, TOP|RIGHT);    g.drawString(str, x,        y + f.getBaselinePosition(), BASELINE|LEFT);    g.drawString(str, x + f.stringWidth(str)/2,        y + f.getBaselinePosition(), BASELINE|HCENTER);    g.drawString(str, x + f.stringWidth(str),        y + f.getBaselinePosition(), BASELINE|RIGHT);    drawString(str, x,        y + f.getHeight(), BOTTOM|LEFT);    drawString(str, x + f.stringWidth(str)/2,        y + f.getHeight(), BOTTOM|HCENTER);    drawString(str, x + f.stringWidth(str),        y + f.getHeight(), BOTTOM|RIGHT);      </code></pre> </TD> </TR> </TABLE> <p> For text drawing, the inter-character and inter-line spacing (leading) specified by the font designer are included as part of the values returned in the <A HREF="../../../javax/microedition/lcdui/Font.html#stringWidth(java.lang.String)"><CODE>stringWidth()</CODE></A> and <A HREF="../../../javax/microedition/lcdui/Font.html#getHeight()"><CODE>getHeight()</CODE></A> calls of class <A HREF="../../../javax/microedition/lcdui/Font.html"><CODE>Font</CODE></A>. For example, given the following code: </P> <TABLE BORDER="2"> <TR> <TD ROWSPAN="1" COLSPAN="1">    <pre><code>    // (5)    g.drawString(string1+string2, x, y, TOP|LEFT);    // (6)    g.drawString(string1, x, y, TOP|LEFT);    g.drawString(string2, x + f.stringWidth(string1), y, TOP|LEFT);     </code></pre> </TD> </TR> </TABLE> </P> <P> Code fragments (5) and (6) behave similarly if not identically. This occurs because <code>f.stringWidth()</code> includes the inter-character spacing.  The exact spacing of may differ between these calls if the system supports font kerning.</p> <p>Similarly, reasonable vertical spacing may be achieved simply by adding the font height to the Y-position of subsequent lines. For example: </P> <TABLE BORDER="2"> <TR> <TD ROWSPAN="1" COLSPAN="1">    <pre><code>    g.drawString(string1, x, y, TOP|LEFT);    g.drawString(string2, x, y + f.fontHeight(), TOP|LEFT);    </code></pre> </TD> </TR> </TABLE> <P> draws <code>string1</code> and <code>string2</code> on separate lines with an appropriate amount of inter-line spacing. </p> <p> The <code>stringWidth()</code> of the string and the <code>fontHeight()</code> of the font in which it is drawn define the size of the bounding box of a piece of text. As described above, this box includes inter-line and inter-character spacing. The implementation is required to put this space below and to right of the pixels actually belonging to the characters drawn. Applications that wish to position graphics closely with respect to text (for example, to paint a rectangle around a string of text) may assume that there is space below and to the right of a string and that there is <em>no</em> space above and to the left of the string. </p> <p> Anchor points are also used for positioning of images. Similar to text drawing, the anchor point for an image specifies the point on the bounding rectangle of the destination that is to positioned at the <code>(x,y)</code> location given in the graphics request. Unlike text, vertical centering of images is well-defined, and thus the <code>VCENTER</code> value may be used within the anchor point parameter of image drawing requests. Because images have no notion of a baseline, the <code>BASELINE</code> value may not be used within the anchor point parameter of image drawing requests. </p> <h3>Reference</h3> <dl> <dt>Porter-Duff <dd>Porter, T., and T. Duff.  &quot;Compositing Digital Images.&quot; <em>Computer Graphics V18 N3 (SIGGRAPH 1984)</em>, p. 253-259. </dl>
<P>
<DL>
<DT><B>Since: </B><DD>MIDP 1.0</DD>
</DL>
<HR>

<P>
<!-- ======== INNER CLASS SUMMARY ======== -->


<!-- =========== FIELD SUMMARY =========== -->

<A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Field Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/Graphics.html#BASELINE">BASELINE</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constant for positioning the anchor point at the baseline of text.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/Graphics.html#BOTTOM">BOTTOM</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constant for positioning the anchor point of text and images below the text or image.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/Graphics.html#DOTTED">DOTTED</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constant for the <code>DOTTED</code> stroke style.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/Graphics.html#HCENTER">HCENTER</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constant for centering text and images horizontally around the anchor point </TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/Graphics.html#LEFT">LEFT</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constant for positioning the anchor point of text and images to the left of the text or image.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/Graphics.html#RIGHT">RIGHT</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constant for positioning the anchor point of text and images to the right of the text or image.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/Graphics.html#SOLID">SOLID</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constant for the <code>SOLID</code> stroke style.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/Graphics.html#TOP">TOP</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constant for positioning the anchor point of text and images above the text or image.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/Graphics.html#VCENTER">VCENTER</A></B></CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constant for centering images vertically around the anchor point.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ======== CONSTRUCTOR SUMMARY ======== -->


<!-- ========== METHOD SUMMARY =========== -->

<A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/Graphics.html#clipRect(int, int, int, int)">clipRect</A></B>(int&nbsp;x,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -