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

📄 graphics.java

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * range <code>[0..(data.length)]</code>, inclusive.     * The <code>length</code> parameter     * must be a non-negative integer such that     * <code>(offset + length) &lt;= data.length</code>.</p>     *     * @param data the array of characters to be drawn     * @param offset the start offset in the data     * @param length the number of characters to be drawn     * @param x the x coordinate of the anchor point     * @param y the y coordinate of the anchor point     * @param anchor the anchor point for positioning the text; see     * <a href="#anchor">anchor points</a>     *     * @throws ArrayIndexOutOfBoundsException if <code>offset</code>     * and <code>length</code>     * do not specify a valid range within the data array     * @throws IllegalArgumentException if anchor is not a legal value     * @throws NullPointerException if <code>data</code> is <code>null</code>     *     * @see #drawString(java.lang.String, int, int, int)     */    public native void drawChars(char[] data, int offset, int length,                                 int x, int y, int anchor);     /**     * Draws the specified image by using the anchor point.     * The image can be drawn in different positions relative to     * the anchor point by passing the appropriate position constants.     * See <a href="#anchor">anchor points</a>.     *     * <p>If the source image contains transparent pixels, the corresponding     * pixels in the destination image must be left untouched.  If the source     * image contains partially transparent pixels, a compositing operation      * must be performed with the destination pixels, leaving all pixels of      * the destination image fully opaque.</p>     *     * <p>If <code>img</code> is the same as the destination of this Graphics     * object, the result is undefined.  For copying areas within an     * <code>Image</code>, {@link #copyArea copyArea} should be used instead.     * </p>     *     * @param image the specified image to be drawn     * @param x the x coordinate of the anchor point     * @param y the y coordinate of the anchor point     * @param anchor the anchor point for positioning the image     * @throws IllegalArgumentException if <code>anchor</code>     * is not a legal value     * @throws NullPointerException if <code>img</code> is <code>null</code>     * @see Image     */    public void drawImage(Image image, int x, int y, int anchor) {        if (image == null) {            throw new NullPointerException();        }        if (!render(image, x, y, anchor)) {            throw new IllegalArgumentException("");        }    }    /**     * Copies a region of the specified source image to a location within     * the destination, possibly transforming (rotating and reflecting)     * the image data using the chosen transform function.     *     * <p>The destination, if it is an image, must not be the same image as     * the source image.  If it is, an exception is thrown.  This restriction     * is present in order to avoid ill-defined behaviors that might occur if     * overlapped, transformed copies were permitted.</p>     *     * <p>The transform function used must be one of the following, as defined     * in the {@link javax.microedition.lcdui.game.Sprite Sprite} class:<br>     *     * <code>Sprite.TRANS_NONE</code> - causes the specified image     * region to be copied unchanged<br>     * <code>Sprite.TRANS_ROT90</code> - causes the specified image     * region to be rotated clockwise by 90 degrees.<br>     * <code>Sprite.TRANS_ROT180</code> - causes the specified image     * region to be rotated clockwise by 180 degrees.<br>     * <code>Sprite.TRANS_ROT270</code> - causes the specified image     * region to be rotated clockwise by 270 degrees.<br>     * <code>Sprite.TRANS_MIRROR</code> - causes the specified image     * region to be reflected about its vertical center.<br>     * <code>Sprite.TRANS_MIRROR_ROT90</code> - causes the specified image     * region to be reflected about its vertical center and then rotated     * clockwise by 90 degrees.<br>     * <code>Sprite.TRANS_MIRROR_ROT180</code> - causes the specified image     * region to be reflected about its vertical center and then rotated     * clockwise by 180 degrees.<br>     * <code>Sprite.TRANS_MIRROR_ROT270</code> - causes the specified image     * region to be reflected about its vertical center and then rotated     * clockwise by 270 degrees.<br></p>     *     * <p>If the source region contains transparent pixels, the corresponding     * pixels in the destination region must be left untouched.  If the source     * region contains partially transparent pixels, a compositing operation     * must be performed with the destination pixels, leaving all pixels of     * the destination region fully opaque.</p>     *     * <p> The <code>(x_src, y_src)</code> coordinates are relative to     * the upper left     * corner of the source image.  The <code>x_src</code>,     * <code>y_src</code>, <code>width</code>, and <code>height</code>     * 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     */    public void drawRegion(Image src,                            int x_src, int y_src,                           int width, int height,                            int transform,                           int x_dest, int y_dest,                            int anchor) {        if (src == null) {            throw new NullPointerException();        }        if (!renderRegion(src, x_src, y_src, width, height,                          transform, x_dest, y_dest, anchor)) {            throw new IllegalArgumentException("");        }    }    /**     * 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     *     */    public synchronized void copyArea(int x_src, int y_src,                                       int width, int height,                                      int x_dest, int y_dest, int anchor) {        if (isScreenGraphics()) {            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     *     */    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>

⌨️ 快捷键说明

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