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

📄 graphics.java

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            return;        }        // Translate the given coordinates        translatedX1 = x + transX;        translatedY1 = y + transY;        // Detect Overflow        if (translatedX1 < 0) {            translatedX1 = (x < 0 || transX < 0) ? 0 : maxWidth;        }        if (translatedY1 < 0) {            translatedY1 = (y < 0 || transY < 0) ? 0 : maxHeight;        }        clipX1 = (short)(translatedX1 & 0x7fff);        clipY1 = (short)(translatedY1 & 0x7fff);        if ((translatedX1 >= maxWidth)             || (translatedY1 >= maxHeight)) {            clipX1 = clipY1 = clipX2 = clipY2 = 0;            clipped = true;            return;        }        // Check against the runtime library clip values        if (runtimeClipEnforce) {          if (clipX1 < systemClipX1)                  clipX1 = systemClipX1;          if (clipY1 < systemClipY1) {                  clipY1 = systemClipY1;          }        }        // Translate the given width, height to abs. coordinates        translatedX2 = x + transX + width;        translatedY2 = y + transY + height;        // Detect overflow        if (translatedX2 < 0) {            translatedX2 = (x < 0 || transX < 0) ? translatedX1 : maxWidth;        } else {          if (translatedX2 > maxWidth)            translatedX2 = maxWidth;        }        if (translatedY2 < 0) {            translatedY2 = (y < 0 || transY < 0) ? translatedY1 : maxHeight;        } else {          if (translatedY2 > maxHeight)            translatedY2 = maxHeight;        }        clipX2 = (short) (translatedX2 & 0x7FFF);        clipY2 = (short) (translatedY2 & 0x7FFF);        // Check against the runtime library clip values        if (runtimeClipEnforce) {          if (clipX2 > systemClipX2)                  clipX2 = systemClipX2;          if (clipY2 > systemClipY2)                  clipY2 = systemClipY2;        }        if ((clipX1 != 0) || (clipY1 != 0)                || (clipX2 != maxWidth) || (clipY2 != maxHeight)) {            clipped = true;        }        /**         *  sanity check        if (clipX1 < 0 || clipY1 < 0 ||            clipX2 > maxWidth || clipY2 > maxHeight ||            clipX1 > clipX2 || clipY1 > clipY2)          System.out.println("Graphics:setClip error: clipX1 = "+clipX1+              " clipY1 = "+clipY1+" clipX2 = "+clipX2+" clipY2 = "+clipY2+              " maxWidth = "+maxWidth+" maxHeight = "+maxHeight);        if (runtimeClipEnforce)          System.out.println("Graphics:setClip runtimeClipEnforce:"+              " systemClipX1 = "+systemClipX1+" systemClipY1 = "+systemClipY1+              " systemClipX2 = "+systemClipX2+" systemClipY2 = "+systemClipY2);         * end sanity check          */    }    /**     * Draws a line between the coordinates <code>(x1,y1)</code> and     * <code>(x2,y2)</code> using     * the current color and stroke style.     * @param x1 the x coordinate of the start of the line     * @param y1 the y coordinate of the start of the line     * @param x2 the x coordinate of the end of the line     * @param y2 the y coordinate of the end of the line     */    public native void drawLine(int x1, int y1, int x2, int y2);    /**     * Fills the specified rectangle with the current color.     * If either width or height is zero or less,     * nothing is drawn.     * @param x the x coordinate of the rectangle to be filled     * @param y the y coordinate of the rectangle to be filled     * @param width the width of the rectangle to be filled     * @param height the height of the rectangle to be filled     * @see #drawRect(int, int, int, int)     */    public native void fillRect(int x, int y, int width, int height);     /**     * Draws the outline of the specified rectangle using the current     * color and stroke style.     * The resulting rectangle will cover an area <code>(width + 1)</code>     * pixels wide by <code>(height + 1)</code> pixels tall.     * If either width or height is less than     * zero, nothing is drawn.     * @param x the x coordinate of the rectangle to be drawn     * @param y the y coordinate of the rectangle to be drawn     * @param width the width of the rectangle to be drawn     * @param height the height of the rectangle to be drawn     * @see #fillRect(int, int, int, int)     */    public native void drawRect(int x, int y, int width, int height);    /**     * Draws the outline of the specified rounded corner rectangle     * using the current color and stroke style.     * The resulting rectangle will cover an area <code>(width +     * 1)</code> pixels wide     * by <code>(height + 1)</code> pixels tall.     * If either <code>width</code> or <code>height</code> is less than     * zero, nothing is drawn.     * @param x the x coordinate of the rectangle to be drawn     * @param y the y coordinate of the rectangle to be drawn     * @param width the width of the rectangle to be drawn     * @param height the height of the rectangle to be drawn     * @param arcWidth the horizontal diameter of the arc at the four corners     * @param arcHeight the vertical diameter of the arc at the four corners     * @see #fillRoundRect(int, int, int, int, int, int)     */    public native void drawRoundRect(int x, int y, int width, int height,                                     int arcWidth, int arcHeight);     /**     * Fills the specified rounded corner rectangle with the current color.     * If either <code>width</code> or <code>height</code> is zero or less,     * nothing is drawn.     * @param x the x coordinate of the rectangle to be filled     * @param y the y coordinate of the rectangle to be filled     * @param width the width of the rectangle to be filled     * @param height the height of the rectangle to be filled     * @param arcWidth the horizontal diameter of the arc at the four     * corners     * @param arcHeight the vertical diameter of the arc at the four corners     * @see #drawRoundRect(int, int, int, int, int, int)     */    public native void fillRoundRect(int x, int y, int width, int height,                                     int arcWidth, int arcHeight);                              /**     * Fills a circular or elliptical arc covering the specified rectangle.     * <p>     * The resulting arc begins at <code>startAngle</code> and extends     * for <code>arcAngle</code> degrees.     * Angles are interpreted such that <code>0</code> degrees     * is at the <code>3</code> o'clock position.     * A positive value indicates a counter-clockwise rotation     * while a negative value indicates a clockwise rotation.     * <p>     * The center of the arc is the center of the rectangle whose origin     * is (<em>x</em>,&nbsp;<em>y</em>) and whose size is specified by the     * <code>width</code> and <code>height</code> arguments.     * <p>     * If either <code>width</code> or <code>height</code> is zero or less,     * nothing is drawn.     *     * <p> The filled region consists of the &quot;pie wedge&quot;     * region bounded     * by the arc     * segment as if drawn by <code>drawArc()</code>, the radius extending from     * the center to     * this arc at <code>startAngle</code> degrees, and radius extending     * from the     * center to this arc at <code>startAngle + arcAngle</code> degrees. </p>     *     * <p> The angles are specified relative to the non-square extents of     * the bounding rectangle such that <code>45</code> degrees always     * falls on the     * line from the center of the ellipse to the upper right corner of     * the bounding rectangle. As a result, if the bounding rectangle is     * noticeably longer in one axis than the other, the angles to the     * start and end of the arc segment will be skewed farther along the     * longer axis of the bounds. </p>     *     * @param x the <em>x</em> coordinate of the upper-left corner of     * the arc to be filled.     * @param y the <em>y</em> coordinate of the upper-left corner of the     * arc to be filled.     * @param width the width of the arc to be filled     * @param height the height of the arc to be filled     * @param startAngle the beginning angle.     * @param arcAngle the angular extent of the arc,     * relative to the start angle.     * @see #drawArc(int, int, int, int, int, int)     */    public native void fillArc(int x, int y, int width, int height,                               int startAngle, int arcAngle);    /**     * Draws the outline of a circular or elliptical arc     * covering the specified rectangle,     * using the current color and stroke style.     * <p>     * The resulting arc begins at <code>startAngle</code> and extends     * for <code>arcAngle</code> degrees, using the current color.     * Angles are interpreted such that <code>0</code>&nbsp;degrees     * is at the <code>3</code>&nbsp;o'clock position.     * A positive value indicates a counter-clockwise rotation     * while a negative value indicates a clockwise rotation.     * <p>     * The center of the arc is the center of the rectangle whose origin     * is (<em>x</em>,&nbsp;<em>y</em>) and whose size is specified by the     * <code>width</code> and <code>height</code> arguments.     * <p>     * The resulting arc covers an area     * <code>width&nbsp;+&nbsp;1</code> pixels wide     * by <code>height&nbsp;+&nbsp;1</code> pixels tall.     * If either <code>width</code> or <code>height</code> is less than zero,     * nothing is drawn.     *     * <p> The angles are specified relative to the non-square extents of     * the bounding rectangle such that <code>45</code> degrees always     * falls on the     * line from the center of the ellipse to the upper right corner of     * the bounding rectangle. As a result, if the bounding rectangle is     * noticeably longer in one axis than the other, the angles to the     * start and end of the arc segment will be skewed farther along the     * longer axis of the bounds. </p>     *     * @param x the <em>x</em> coordinate of the upper-left corner     * of the arc to be drawn     * @param y the <em>y</em> coordinate of the upper-left corner     * of the arc to be drawn     * @param width the width of the arc to be drawn     * @param height the height of the arc to be drawn     * @param startAngle the beginning angle     * @param arcAngle the angular extent of the arc, relative to     * the start angle     * @see #fillArc(int, int, int, int, int, int)     */    public native void drawArc(int x, int y, int width, int height,                               int startAngle, int arcAngle);    /**     * Draws the specified <code>String</code> using the current font and color.     * The <code>x,y</code> position is the position of the anchor point.     * See <a href="#anchor">anchor points</a>.     * @param str the <code>String</code> 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     * @throws NullPointerException if <code>str</code> is <code>null</code>     * @throws IllegalArgumentException if anchor is not a legal value     * @see #drawChars(char[], int, int, int, int, int)     */    public native void drawString(java.lang.String str,                                  int x, int y, int anchor);    /**     * Draws the specified <code>String</code> using the current font and color.     * The <code>x,y</code> position is the position of the anchor point.     * See <a href="#anchor">anchor points</a>.     *     * <p>The <code>offset</code> and <code>len</code> parameters must     * specify a valid range of characters within     * the string <code>str</code>.     * The <code>offset</code> parameter must be within the     * range <code>[0..(str.length())]</code>, inclusive.     * The <code>len</code> parameter     * must be a non-negative integer such that     * <code>(offset + len) &lt;= str.length()</code>.</p>     *     * @param str the <code>String</code> to be drawn     * @param offset zero-based index of first character in the substring     * @param len length of the substring     * @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 #drawString(String, int, int, int).     * @throws StringIndexOutOfBoundsException if <code>offset</code>     * and <code>length</code> do not specify     * a valid range within the <code>String</code> <code>str</code>     * @throws IllegalArgumentException if <code>anchor</code>     * is not a legal value     * @throws NullPointerException if <code>str</code> is <code>null</code>     */    public native void drawSubstring(String str, int offset, int len,                                     int x, int y, int anchor);    /**     * Draws the specified character using the current font and color.     * @param character the character 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 IllegalArgumentException if <code>anchor</code>     * is not a legal value     *     * @see #drawString(java.lang.String, int, int, int)     * @see #drawChars(char[], int, int, int, int, int)     */    public native void drawChar(char character, int x, int y, int anchor);    /**     * Draws the specified characters using the current font and color.     *     * <p>The <code>offset</code> and <code>length</code> parameters must     * specify a valid range of characters within     * the character array <code>data</code>.     * The <code>offset</code> parameter must be within the

⌨️ 快捷键说明

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