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

📄 graphics.java

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    /**     * Sets the current clip to the rectangle specified by the     * given coordinates.     * Rendering operations have no effect outside of the clipping area.     * @param x the x coordinate of the new clip rectangle     * @param y the y coordinate of the new clip rectangle     * @param width the width of the new clip rectangle     * @param height the height of the new clip rectangle     * @see #clipRect(int, int, int, int)     */    public synchronized void setClip(int x, int y, int width, int height) {        int translatedX1, translatedY1;        int translatedX2, translatedY2;        // If width or height is zero or less then zero,        // we do not preserve the current clipping and        // set all clipping values to zero.        if ((width <= 0) || (height <= 0)) {            clipX1 = clipY1 = clipX2 = clipY2 = 0;            clipped = true;            gciImageRenderer.clipModified();            gciTextRenderer.clipModified();            gciShapeRenderer.clipModified();            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;            gciImageRenderer.clipModified();            gciTextRenderer.clipModified();            gciShapeRenderer.clipModified();            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          */        gciImageRenderer.clipModified();        gciTextRenderer.clipModified();        gciShapeRenderer.clipModified();    }    /**     * 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 void drawLine(int x1, int y1, int x2, int y2) {        gciShapeRenderer.drawLine(x1 + transX, y1 + transY,                                   x2 + transX, y2 + transY);    }    /**     * 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 void fillRect(int x, int y, int width, int height) {        gciShapeRenderer.fillRect(x + transX, y + transY, width, 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 void drawRect(int x, int y, int width, int height) {        gciShapeRenderer.drawRect(x + transX, y + transY, width, 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 void drawRoundRect(int x, int y, int width, int height,                              int arcWidth, int arcHeight) {        gciShapeRenderer.drawRoundRect(x + transX, y + transY, width, height,                                       arcWidth, 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 void fillRoundRect(int x, int y, int width, int height,                              int arcWidth, int arcHeight) {        gciShapeRenderer.fillRoundRect(x + transX, y + transY, width, height,                                       arcWidth, 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 void fillArc(int x, int y, int width, int height,                        int startAngle, int arcAngle) {        gciShapeRenderer.fillArc(x + transX, y + transY, width, height,                                  startAngle, 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 void drawArc(int x, int y, int width, int height,                       int startAngle, int arcAngle)  {        gciShapeRenderer.drawArc(x + transX, y + transY, width, height,                                  startAngle, 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 void drawString(java.lang.String str,                           int x, int y, int anchor) {        if (str == null) {            throw new NullPointerException();        }         if (anchor == 0) {	    anchor = TOP | LEFT;	} else if (!checkAnchor(anchor, VCENTER)) {            throw new IllegalArgumentException();        }        x += transX;        y += transY;        if ((anchor & LEFT) == 0) {

⌨️ 快捷键说明

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