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

📄 graphics.java

📁 用于移动设备上的java虚拟机源代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * parameters specify a rectangular region of the source image.  It is     * illegal for this region to extend beyond the bounds of the source     * image.  This requires that: </P>     * <TABLE BORDER="2">     * <TR>     * <TD ROWSPAN="1" COLSPAN="1">     *    <pre><code>     *   x_src &gt;= 0     *   y_src &gt;= 0     *   x_src + width &lt;= source width     *   y_src + height &lt;= source height    </code></pre>     * </TD>     * </TR>     * </TABLE>     * <P>     * The <code>(x_dest, y_dest)</code> coordinates are relative to     * the coordinate     * system of this Graphics object.  It is legal for the destination     * area to extend beyond the bounds of the <code>Graphics</code>     * object.  Pixels     * outside of the bounds of the <code>Graphics</code> object will     * not be drawn.</p>     *     * <p>The transform is applied to the image data from the region of the     * source image, and the result is rendered with its anchor point     * positioned at location <code>(x_dest, y_dest)</code> in the     * destination.</p>     *     * @param src the source image to copy from     * @param x_src the x coordinate of the upper left corner of the region     * within the source image to copy     * @param y_src the y coordinate of the upper left corner of the region     * within the source image to copy     * @param width the width of the region to copy     * @param height the height of the region to copy     * @param transform the desired transformation for the selected region     * being copied     * @param x_dest the x coordinate of the anchor point in the     * destination drawing area     * @param y_dest the y coordinate of the anchor point in the     * destination drawing area     * @param anchor the anchor point for positioning the region within     * the destination image     *     * @throws IllegalArgumentException if <code>src</code> is the     * same image as the     * destination of this <code>Graphics</code> object     * @throws NullPointerException if <code>src</code> is <code>null</code>     * @throws IllegalArgumentException if <code>transform</code> is invalid     * @throws IllegalArgumentException if <code>anchor</code> is invalid     * @throws IllegalArgumentException if the region to be copied exceeds     * the bounds of the source image     * @since MIDP 2.0     */    public native void drawRegion(Image src,                                   int x_src, int y_src,                                  int width, int height,                                   int transform,                                  int x_dest, int y_dest,                                   int anchor);    /**     * Copies the contents of a rectangular area     * <code>(x_src, y_src, width, height)</code> to a destination area,     * whose anchor point identified by anchor is located at     * <code>(x_dest, y_dest)</code>.  The effect must be that the     * destination area     * contains an exact copy of the contents of the source area     * immediately prior to the invocation of this method.  This result must     * occur even if the source and destination areas overlap.     *     * <p>The points <code>(x_src, y_src)</code> and <code>(x_dest,     * y_dest)</code> are both specified     * relative to the coordinate system of the <code>Graphics</code>     * object.  It is     * illegal for the source region to extend beyond the bounds of the     * graphic object.  This requires that: </P>     * <TABLE BORDER="2">     * <TR>     * <TD ROWSPAN="1" COLSPAN="1">     *    <pre><code>     *   x_src + tx &gt;= 0     *   y_src + ty &gt;= 0     *   x_src + tx + width &lt;= width of Graphics object's destination     *   y_src + ty + height &lt;= height of Graphics object's destination      </code></pre>     * </TD>     * </TR>     * </TABLE>     *      * <p>where <code>tx</code> and <code>ty</code> represent the X and Y      * coordinates of the translated origin of this graphics object, as      * returned by <code>getTranslateX()</code> and     * <code>getTranslateY()</code>, respectively.</p>     *      * <P>     * However, it is legal for the destination area to extend beyond     * the bounds of the <code>Graphics</code> object.  Pixels outside     * of the bounds of     * the <code>Graphics</code> object will not be drawn.</p>     *     * <p>The <code>copyArea</code> method is allowed on all     * <code>Graphics</code> objects except those     * whose destination is the actual display device.  This restriction is     * necessary because allowing a <code>copyArea</code> method on     * the display would     * adversely impact certain techniques for implementing     * double-buffering.</p>     *     * <p>Like other graphics operations, the <code>copyArea</code>     * method uses the Source     * Over Destination rule for combining pixels.  However, since it is     * defined only for mutable images, which can contain only fully opaque     * pixels, this is effectively the same as pixel replacement.</p>     *     * @param x_src  the x coordinate of upper left corner of source area     * @param y_src  the y coordinate of upper left corner of source area     * @param width  the width of the source area     * @param height the height of the source area     * @param x_dest the x coordinate of the destination anchor point     * @param y_dest the y coordinate of the destination anchor point     * @param anchor the anchor point for positioning the region within     *        the destination image     *     * @throws IllegalStateException if the destination of this     * <code>Graphics</code> object is the display device     * @throws IllegalArgumentException if the region to be copied exceeds     * the bounds of the source image     *     * @since MIDP 2.0     */    public void copyArea(int x_src, int y_src, int width, int height,			 int x_dest, int y_dest, int anchor) {	if (Display.isGraphicsDisplay(this)) {	    throw new IllegalStateException();	} else {	    doCopyArea(x_src, y_src, width, height, 		       x_dest, y_dest, anchor);	}    }    /**     * Fills the specified triangle will the current color.  The lines     * connecting each pair of points are included in the filled     * triangle.     *     * @param x1 the x coordinate of the first vertex of the triangle     * @param y1 the y coordinate of the first vertex of the triangle     * @param x2 the x coordinate of the second vertex of the triangle     * @param y2 the y coordinate of the second vertex of the triangle     * @param x3 the x coordinate of the third vertex of the triangle     * @param y3 the y coordinate of the third vertex of the triangle     *     * @since MIDP 2.0     */    public native void fillTriangle(int x1, int y1, 				    int x2, int y2,				    int x3, int y3);    /**     * Native implementation of CopyArea method.     *     * @param x_src  the x coordinate of upper left corner of source area     * @param y_src  the y coordinate of upper left corner of source area     * @param width  the width of the source area     * @param height the height of the source area     * @param x_dest the x coordinate of the destination anchor point     * @param y_dest the y coordinate of the destination anchor point     * @param anchor the anchor point for positioning the region within     *        the destination image     *     * @throws IllegalArgumentException if the region to be copied exceeds     * the bounds of the source image     */    private native void doCopyArea(int x_src, int y_src, 				   int width, int height, 				   int x_dest, int y_dest, int anchor);    /**     * Renders a series of device-independent RGB+transparency values in a     * specified region.  The values are stored in     * <code>rgbData</code> in a format     * with <code>24</code> bits of RGB and an eight-bit alpha value     * (<code>0xAARRGGBB</code>),     * with the first value stored at the specified offset.  The     * <code>scanlength</code>     * specifies the relative offset within the array between the     * corresponding pixels of consecutive rows.  Any value for     * <code>scanlength</code> is acceptable (even negative values)     * provided that all resulting references are within the     * bounds of the <code>rgbData</code> array. The ARGB data is     * rasterized horizontally from left to right within each row.     * The ARGB values are     * rendered in the region specified by <code>x</code>,     * <code>y</code>, <code>width</code> and <code>height</code>, and     * the operation is subject to the current clip region     * and translation for this <code>Graphics</code> object.     *     * <p>Consider <code>P(a,b)</code> to be the value of the pixel     * located at column <code>a</code> and row <code>b</code> of the     * Image, where rows and columns are numbered downward from the     * top starting at zero, and columns are numbered rightward from     * the left starting at zero. This operation can then be defined     * as:</p>     *     * <TABLE BORDER="2">     * <TR>     * <TD ROWSPAN="1" COLSPAN="1">     *    <pre><code>     *    P(a, b) = rgbData[offset + (a - x) + (b - y) * scanlength]       </code></pre>     * </TD>     * </TR>     * </TABLE>     *     * <p> for </p>     *     * <TABLE BORDER="2">     * <TR>     * <TD ROWSPAN="1" COLSPAN="1">     *    <pre><code>     *     x &lt;= a &lt; x + width     *     y &lt;= b &lt; y + height    </code></pre>     * </TD>     * </TR>     * </TABLE>     * <p> This capability is provided in the <code>Graphics</code>     * class so that it can be     * used to render both to the screen and to offscreen     * <code>Image</code> objects.  The     * ability to retrieve ARGB values is provided by the {@link Image#getRGB}     * method. </p>     *     * <p> If <code>processAlpha</code> is <code>true</code>, the     * high-order byte of the ARGB format     * specifies opacity; that is, <code>0x00RRGGBB</code> specifies a     * fully transparent     * pixel and <code>0xFFRRGGBB</code> specifies a fully opaque     * pixel.  Intermediate     * alpha values specify semitransparency.  If the implementation does not     * support alpha blending for image rendering operations, it must remove     * any semitransparency from the source data prior to performing any     * rendering.  (See <a href="Image.html#alpha">Alpha Processing</a> for     * further discussion.)     * If <code>processAlpha</code> is <code>false</code>, the alpha     * values are ignored and all pixels     * must be treated as completely opaque.</p>     *     * <p> The mapping from ARGB values to the device-dependent     * pixels is platform-specific and may require significant     * computation.</p>     *     * @param rgbData an array of ARGB values in the format     * <code>0xAARRGGBB</code>     * @param offset the array index of the first ARGB value     * @param scanlength the relative array offset between the     * corresponding pixels in consecutive rows in the     * <code>rgbData</code> array     * @param x the horizontal location of the region to be rendered     * @param y the vertical location of the region to be rendered     * @param width the width of the region to be rendered     * @param height the height of the region to be rendered     * @param processAlpha <code>true</code> if <code>rgbData</code>     * has an alpha channel,     * false if all pixels are fully opaque     *     * @throws ArrayIndexOutOfBoundsException if the requested operation     * will attempt to access an element of <code>rgbData</code>     * whose index is either negative or beyond its length     * @throws NullPointerException if <code>rgbData</code> is <code>null</code>     *     * @since MIDP 2.0     */    public native void drawRGB(int[] rgbData, int offset, int scanlength,			       int x, int y, int width, int height,			       boolean processAlpha);    /**     * Gets the color that will be displayed if the specified color     * is requested. This method enables the developer to check the     * manner in which RGB values are mapped to the set of distinct      * colors that the device can actually display. For example,      * with a monochrome device, this method will return either     * <code>0xFFFFFF</code> (white) or <code>0x000000</code> (black)      * depending on the brightness of the specified color.     *     * @param color the desired color (in <code>0x00RRGGBB</code>     * format, the high-order     * byte is ignored)     * @return the corresponding color that will be displayed on the device's     * screen (in <code>0x00RRGGBB</code> format)     *     * @since MIDP 2.0     */    public native int getDisplayColor(int color);    // private implementation //    /** Translated x,y coordinates */    private int transX, transY;    /** top/left clip bounds */    private short clipX1, clipY1;    /** right/bottom clip bounds */    private int clipX2, clipY2;    /**     * temporary variable for top/left clip bounds     * use a private data member instead of a new variable     * for every invocation of clipRect     */    private int translatedX1, translatedY1;    /**      * temporary variable for right/bottom clip bounds     * use a private data member instead of a new variable     * for every invocation of clipRect     */    private int translatedX2, translatedY2;    /** Array to hold the clip values */    private short clip[] = new short[4];     /* format is -- x y w h */    /** A flag indicating the clipping state */    private boolean clipped = false;    /** Pixel values */    private int rgbColor, gray, pixel;    /** Line stroke style */    private int style;          // line stroke style    /** The current Font

⌨️ 快捷键说明

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