1234 lines · 54.6 KB · Java
RawDownload
        //drawLine(x + 1, y + height - 1, x + width - 1, y + height - 1);        fillRect(x + 1, y + height - 1, width - 1, 1);        //drawLine(x + width - 1, y, x + width - 1, y + height - 2);        fillRect(x + width - 1, y, 1, height - 1);        setPaint(p);    }     /**     * Strokes the outline of a <code>Shape</code> using the settings of the     * current <code>Graphics2D</code> context.  The rendering attributes     * applied include the <code>Clip</code>, <code>Transform</code>,     * <code>Paint</code>, <code>Composite</code> and     * <code>Stroke</code> attributes.     * @param s the <code>Shape</code> to be rendered     * @see #setStroke     * @see #setPaint     * @see java.awt.Graphics#setColor     * @see #transform     * @see #setTransform     * @see #clip     * @see #setClip     * @see #setComposite     */    public abstract void draw(Shape s);     /**     * Renders an image, applying a transform from image space into user space     * before drawing.     * The transformation from user space into device space is done with     * the current <code>Transform</code> in the <code>Graphics2D</code>.     * The specified transformation is applied to the image before the     * transform attribute in the <code>Graphics2D</code> context is applied.     * The rendering attributes applied include the <code>Clip</code>,     * <code>Transform</code>, and <code>Composite</code> attributes.     * Note that no rendering is done if the specified transform is     * noninvertible.     * @param img the specified image to be rendered.     *            This method does nothing if <code>img</code> is null.     * @param xform the transformation from image space into user space     * @param obs the {@link ImageObserver}     * to be notified as more of the <code>Image</code>     * is converted     * @return <code>true</code> if the <code>Image</code> is     * fully loaded and completely rendered, or if it's null;     * <code>false</code> if the <code>Image</code> is still being loaded.     * @see #transform     * @see #setTransform     * @see #setComposite     * @see #clip     * @see #setClip     */    public abstract boolean drawImage(Image img,                                      AffineTransform xform,                                      ImageObserver obs);     /**     * Renders a <code>BufferedImage</code> that is     * filtered with a     * {@link BufferedImageOp}.     * The rendering attributes applied include the <code>Clip</code>,     * <code>Transform</code>     * and <code>Composite</code> attributes.  This is equivalent to:     * <pre>     * img1 = op.filter(img, null);     * drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null);     * </pre>     * @param op the filter to be applied to the image before rendering     * @param img the specified <code>BufferedImage</code> to be rendered.     *            This method does nothing if <code>img</code> is null.     * @param x the x coordinate of the location in user space where     * the upper left corner of the image is rendered     * @param y the y coordinate of the location in user space where     * the upper left corner of the image is rendered     *     * @see #transform     * @see #setTransform     * @see #setComposite     * @see #clip     * @see #setClip     */    public abstract void drawImage(BufferedImage img,                                   BufferedImageOp op,                                   int x,                                   int y);     /**     * Renders a {@link RenderedImage},     * applying a transform from image     * space into user space before drawing.     * The transformation from user space into device space is done with     * the current <code>Transform</code> in the <code>Graphics2D</code>.     * The specified transformation is applied to the image before the     * transform attribute in the <code>Graphics2D</code> context is applied.     * The rendering attributes applied include the <code>Clip</code>,     * <code>Transform</code>, and <code>Composite</code> attributes. Note     * that no rendering is done if the specified transform is     * noninvertible.     * @param img the image to be rendered. This method does     *            nothing if <code>img</code> is null.     * @param xform the transformation from image space into user space     * @see #transform     * @see #setTransform     * @see #setComposite     * @see #clip     * @see #setClip     */    public abstract void drawRenderedImage(RenderedImage img,                                           AffineTransform xform);     /**     * Renders a     * {@link RenderableImage},     * applying a transform from image space into user space before drawing.     * The transformation from user space into device space is done with     * the current <code>Transform</code> in the <code>Graphics2D</code>.     * The specified transformation is applied to the image before the     * transform attribute in the <code>Graphics2D</code> context is applied.     * The rendering attributes applied include the <code>Clip</code>,     * <code>Transform</code>, and <code>Composite</code> attributes. Note     * that no rendering is done if the specified transform is     * noninvertible.     *<p>     * Rendering hints set on the <code>Graphics2D</code> object might     * be used in rendering the <code>RenderableImage</code>.     * If explicit control is required over specific hints recognized by a     * specific <code>RenderableImage</code>, or if knowledge of which hints     * are used is required, then a <code>RenderedImage</code> should be     * obtained directly from the <code>RenderableImage</code>     * and rendered using     *{@link #drawRenderedImage(RenderedImage, AffineTransform) drawRenderedImage}.     * @param img the image to be rendered. This method does     *            nothing if <code>img</code> is null.     * @param xform the transformation from image space into user space     * @see #transform     * @see #setTransform     * @see #setComposite     * @see #clip     * @see #setClip     * @see #drawRenderedImage     */    public abstract void drawRenderableImage(RenderableImage img,                                             AffineTransform xform);     /**     * Renders the text of the specified <code>String</code>, using the     * current text attribute state in the <code>Graphics2D</code> context.     * The baseline of the     * first character is at position (<i>x</i>,&nbsp;<i>y</i>) in     * the User Space.     * The rendering attributes applied include the <code>Clip</code>,     * <code>Transform</code>, <code>Paint</code>, <code>Font</code> and     * <code>Composite</code> attributes.  For characters in script     * systems such as Hebrew and Arabic, the glyphs can be rendered from     * right to left, in which case the coordinate supplied is the     * location of the leftmost character on the baseline.     * @param str the string to be rendered     * @param x the x coordinate of the location where the     * <code>String</code> should be rendered     * @param y the y coordinate of the location where the     * <code>String</code> should be rendered     * @throws NullPointerException if <code>str</code> is     *         <code>null</code>     * @see         java.awt.Graphics#drawBytes     * @see         java.awt.Graphics#drawChars     * @since       JDK1.0     */    public abstract void drawString(String str, int x, int y);     /**     * Renders the text specified by the specified <code>String</code>,     * using the current text attribute state in the <code>Graphics2D</code> context.     * The baseline of the first character is at position     * (<i>x</i>,&nbsp;<i>y</i>) in the User Space.     * The rendering attributes applied include the <code>Clip</code>,     * <code>Transform</code>, <code>Paint</code>, <code>Font</code> and     * <code>Composite</code> attributes. For characters in script systems     * such as Hebrew and Arabic, the glyphs can be rendered from right to     * left, in which case the coordinate supplied is the location of the     * leftmost character on the baseline.     * @param str the <code>String</code> to be rendered     * @param x the x coordinate of the location where the     * <code>String</code> should be rendered     * @param y the y coordinate of the location where the     * <code>String</code> should be rendered     * @throws NullPointerException if <code>str</code> is     *         <code>null</code>     * @see #setPaint     * @see java.awt.Graphics#setColor     * @see java.awt.Graphics#setFont     * @see #setTransform     * @see #setComposite     * @see #setClip     */    public abstract void drawString(String str, float x, float y);     /**     * Renders the text of the specified iterator applying its attributes     * in accordance with the specification of the {@link TextAttribute} class.     * <p>     * The baseline of the first character is at position     * (<i>x</i>,&nbsp;<i>y</i>) in User Space.     * For characters in script systems such as Hebrew and Arabic,     * the glyphs can be rendered from right to left, in which case the     * coordinate supplied is the location of the leftmost character     * on the baseline.     * @param iterator the iterator whose text is to be rendered     * @param x the x coordinate where the iterator's text is to be     * rendered     * @param y the y coordinate where the iterator's text is to be     * rendered     * @throws NullPointerException if <code>iterator</code> is     *         <code>null</code>     * @see #setPaint     * @see java.awt.Graphics#setColor     * @see #setTransform     * @see #setComposite     * @see #setClip     */    public abstract void drawString(AttributedCharacterIterator iterator,                                    int x, int y);     /**     * Renders the text of the specified iterator applying its attributes     * in accordance with the specification of the {@link TextAttribute} class.     * <p>     * The baseline of the first character is at position     * (<i>x</i>,&nbsp;<i>y</i>) in User Space.     * For characters in script systems such as Hebrew and Arabic,     * the glyphs can be rendered from right to left, in which case the     * coordinate supplied is the location of the leftmost character     * on the baseline.     * @param iterator the iterator whose text is to be rendered     * @param x the x coordinate where the iterator's text is to be     * rendered     * @param y the y coordinate where the iterator's text is to be     * rendered     * @throws NullPointerException if <code>iterator</code> is     *         <code>null</code>     * @see #setPaint     * @see java.awt.Graphics#setColor     * @see #setTransform     * @see #setComposite     * @see #setClip     */    public abstract void drawString(AttributedCharacterIterator iterator,                                    float x, float y);     /**     * Renders the text of the specified     * {@link GlyphVector} using     * the <code>Graphics2D</code> context's rendering attributes.     * The rendering attributes applied include the <code>Clip</code>,     * <code>Transform</code>, <code>Paint</code>, and     * <code>Composite</code> attributes.  The <code>GlyphVector</code>     * specifies individual glyphs from a {@link Font}.     * The <code>GlyphVector</code> can also contain the glyph positions.     * This is the fastest way to render a set of characters to the     * screen.     * @param g the <code>GlyphVector</code> to be rendered     * @param x the x position in User Space where the glyphs should     * be rendered     * @param y the y position in User Space where the glyphs should     * be rendered     * @throws NullPointerException if <code>g</code> is <code>null</code>.     *     * @see java.awt.Font#createGlyphVector     * @see java.awt.font.GlyphVector     * @see #setPaint     * @see java.awt.Graphics#setColor     * @see #setTransform     * @see #setComposite     * @see #setClip     */    public abstract void drawGlyphVector(GlyphVector g, float x, float y);     /**     * Fills the interior of a <code>Shape</code> using the settings of the     * <code>Graphics2D</code> context. The rendering attributes applied     * include the <code>Clip</code>, <code>Transform</code>,     * <code>Paint</code>, and <code>Composite</code>.     * @param s the <code>Shape</code> to be filled     * @see #setPaint     * @see java.awt.Graphics#setColor     * @see #transform     * @see #setTransform     * @see #setComposite     * @see #clip     * @see #setClip     */    public abstract void fill(Shape s);     /**     * Checks whether or not the specified <code>Shape</code> intersects     * the specified {@link Rectangle}, which is in device     * space. If <code>onStroke</code> is false, this method checks     * whether or not the interior of the specified <code>Shape</code>     * intersects the specified <code>Rectangle</code>.  If     * <code>onStroke</code> is <code>true</code>, this method checks     * whether or not the <code>Stroke</code> of the specified     * <code>Shape</code> outline intersects the specified     * <code>Rectangle</code>.     * The rendering attributes taken into account include the     * <code>Clip</code>, <code>Transform</code>, and <code>Stroke</code>     * attributes.     * @param rect the area in device space to check for a hit     * @param s the <code>Shape</code> to check for a hit     * @param onStroke flag used to choose between testing the     * stroked or the filled shape.  If the flag is <code>true</code>, the     * <code>Stroke</code> oultine is tested.  If the flag is     * <code>false</code>, the filled <code>Shape</code> is tested.     * @return <code>true</code> if there is a hit; <code>false</code>     * otherwise.     * @see #setStroke     * @see #fill     * @see #draw     * @see #transform     * @see #setTransform     * @see #clip     * @see #setClip     */    public abstract boolean hit(Rectangle rect,                                Shape s,                                boolean onStroke);     /**     * Returns the device configuration associated with this     * <code>Graphics2D</code>.     * @return the device configuration of this <code>Graphics2D</code>.     */    public abstract GraphicsConfiguration getDeviceConfiguration();     /**     * Sets the <code>Composite</code> for the <code>Graphics2D</code> context.     * The <code>Composite</code> is used in all drawing methods such as     * <code>drawImage</code>, <code>drawString</code>, <code>draw</code>,     * and <code>fill</code>.  It specifies how new pixels are to be combined     * with the existing pixels on the graphics device during the rendering     * process.     * <p>If this <code>Graphics2D</code> context is drawing to a     * <code>Component</code> on the display screen and the     * <code>Composite</code> is a custom object rather than an     * instance of the <code>AlphaComposite</code> class, and if     * there is a security manager, its <code>checkPermission</code>     * method is called with an <code>AWTPermission("readDisplayPixels")</code>     * permission.     * @throws SecurityException     *         if a custom <code>Composite</code> object is being     *         used to render to the screen and a security manager     *         is set and its <code>checkPermission</code> method     *         does not allow the operation.     * @param comp the <code>Composite</code> object to be used for rendering     * @see java.awt.Graphics#setXORMode     * @see java.awt.Graphics#setPaintMode     * @see #getComposite     * @see AlphaComposite     * @see SecurityManager#checkPermission     * @see java.awt.AWTPermission     */    public abstract void setComposite(Composite comp);     /**     * Sets the <code>Paint</code> attribute for the     * <code>Graphics2D</code> context.  Calling this method     * with a <code>null</code> <code>Paint</code> object does     * not have any effect on the current <code>Paint</code> attribute     * of this <code>Graphics2D</code>.     * @param paint the <code>Paint</code> object to be used to generate     * color during the rendering process, or <code>null</code>     * @see java.awt.Graphics#setColor     * @see #getPaint     * @see GradientPaint     * @see TexturePaint     */    public abstract void setPaint( Paint paint );     /**     * Sets the <code>Stroke</code> for the <code>Graphics2D</code> context.     * @param s the <code>Stroke</code> object to be used to stroke a     * <code>Shape</code> during the rendering process     * @see BasicStroke     * @see #getStroke     */    public abstract void setStroke(Stroke s);     /**     * Sets the value of a single preference for the rendering algorithms.     * Hint categories include controls for rendering quality and overall     * time/quality trade-off in the rendering process.  Refer to the     * <code>RenderingHints</code> class for definitions of some common     * keys and values.     * @param hintKey the key of the hint to be set.     * @param hintValue the value indicating preferences for the specified     * hint category.     * @see #getRenderingHint(RenderingHints.Key)     * @see RenderingHints     */    public abstract void setRenderingHint(Key hintKey, Object hintValue);     /**     * Returns the value of a single preference for the rendering algorithms.     * Hint categories include controls for rendering quality and overall     * time/quality trade-off in the rendering process.  Refer to the     * <code>RenderingHints</code> class for definitions of some common     * keys and values.     * @param hintKey the key corresponding to the hint to get.     * @return an object representing the value for the specified hint key.     * Some of the keys and their associated values are defined in the     * <code>RenderingHints</code> class.     * @see RenderingHints     * @see #setRenderingHint(RenderingHints.Key, Object)     */    public abstract Object getRenderingHint(Key hintKey);     /**     * Replaces the values of all preferences for the rendering     * algorithms with the specified <code>hints</code>.     * The existing values for all rendering hints are discarded and     * the new set of known hints and values are initialized from the     * specified {@link Map} object.     * Hint categories include controls for rendering quality and     * overall time/quality trade-off in the rendering process.     * Refer to the <code>RenderingHints</code> class for definitions of     * some common keys and values.     * @param hints the rendering hints to be set     * @see #getRenderingHints     * @see RenderingHints     */    public abstract void setRenderingHints(Map<?,?> hints);     /**     * Sets the values of an arbitrary number of preferences for the     * rendering algorithms.     * Only values for the rendering hints that are present in the     * specified <code>Map</code> object are modified.     * All other preferences not present in the specified     * object are left unmodified.     * Hint categories include controls for rendering quality and     * overall time/quality trade-off in the rendering process.     * Refer to the <code>RenderingHints</code> class for definitions of     * some common keys and values.     * @param hints the rendering hints to be set     * @see RenderingHints     */    public abstract void addRenderingHints(Map<?,?> hints);     /**     * Gets the preferences for the rendering algorithms.  Hint categories     * include controls for rendering quality and overall time/quality     * trade-off in the rendering process.     * Returns all of the hint key/value pairs that were ever specified in     * one operation.  Refer to the     * <code>RenderingHints</code> class for definitions of some common     * keys and values.     * @return a reference to an instance of <code>RenderingHints</code>     * that contains the current preferences.     * @see RenderingHints     * @see #setRenderingHints(Map)     */    public abstract RenderingHints getRenderingHints();     /**     * Translates the origin of the <code>Graphics2D</code> context to the     * point (<i>x</i>,&nbsp;<i>y</i>) in the current coordinate system.     * Modifies the <code>Graphics2D</code> context so that its new origin     * corresponds to the point (<i>x</i>,&nbsp;<i>y</i>) in the     * <code>Graphics2D</code> context's former coordinate system.  All     * coordinates used in subsequent rendering operations on this graphics     * context are relative to this new origin.     * @param  x the specified x coordinate     * @param  y the specified y coordinate     * @since   JDK1.0     */    public abstract void translate(int x, int y);     /**     * Concatenates the current     * <code>Graphics2D</code> <code>Transform</code>     * with a translation transform.     * Subsequent rendering is translated by the specified     * distance relative to the previous position.     * This is equivalent to calling transform(T), where T is an     * <code>AffineTransform</code> represented by the following matrix:     * <pre>     *          [   1    0    tx  ]     *          [   0    1    ty  ]     *          [   0    0    1   ]     * </pre>     * @param tx the distance to translate along the x-axis     * @param ty the distance to translate along the y-axis     */    public abstract void translate(double tx, double ty);     /**     * Concatenates the current <code>Graphics2D</code>     * <code>Transform</code> with a rotation transform.     * Subsequent rendering is rotated by the specified radians relative     * to the previous origin.     * This is equivalent to calling <code>transform(R)</code>, where R is an     * <code>AffineTransform</code> represented by the following matrix:     * <pre>

Lines 501–1000 of 1234. Previous lines