/** * Intersects the current clip with the specified rectangle. * The resulting clipping area is the intersection of the current * clipping area and the specified rectangle. If there is no * current clipping area, either because the clip has never been * set, or the clip has been cleared using <code>setClip(null)</code>, * the specified rectangle becomes the new clip. * This method sets the user clip, which is independent of the * clipping associated with device bounds and window visibility. * This method can only be used to make the current clip smaller. * To set the current clip larger, use any of the setClip methods. * Rendering operations have no effect outside of the clipping area. * @param x the x coordinate of the rectangle to intersect the clip with * @param y the y coordinate of the rectangle to intersect the clip with * @param width the width of the rectangle to intersect the clip with * @param height the height of the rectangle to intersect the clip with * @see #setClip(int, int, int, int) * @see #setClip(Shape) */ public void clipRect(int x, int y, int width, int height){ clip(new Rectangle(x, y, width, height)); }
/** * Draws a line, using the current color, between the points * <code>(x1, y1)</code> and <code>(x2, y2)</code> * in this graphics context's coordinate system. * @param x1 the first point's <i>x</i> coordinate. * @param y1 the first point's <i>y</i> coordinate. * @param x2 the second point's <i>x</i> coordinate. * @param y2 the second point's <i>y</i> coordinate. */ public void drawLine(int x1, int y1, int x2, int y2){ Line2D line = new Line2D.Double(x1, y1, x2, y2); draw(line); }
/** * 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 img the <code>BufferedImage</code> to be rendered * @param op the filter to be applied to the image before rendering * @param x the x coordinate in user space where the image is rendered * @param y the y coordinate in user space where the image is rendered * @see #_transform * @see #setTransform * @see #setComposite * @see #clip * @see #setClip(Shape) */ public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y){ img = op.filter(img, null); drawImage(img, x, y, null); }
/** * Clears the specified rectangle by filling it with the background * color of the current drawing surface. This operation does not * use the current paint mode. * <p> * Beginning with Java 1.1, the background color * of offscreen images may be system dependent. Applications should * use <code>setColor</code> followed by <code>fillRect</code> to * ensure that an offscreen image is cleared to a specific color. * @param x the <i>x</i> coordinate of the rectangle to clear. * @param y the <i>y</i> coordinate of the rectangle to clear. * @param width the width of the rectangle to clear. * @param height the height of the rectangle to clear. * @see java.awt.Graphics#fillRect(int, int, int, int) * @see java.awt.Graphics#drawRect * @see java.awt.Graphics#setColor(java.awt.Color) * @see java.awt.Graphics#setPaintMode * @see java.awt.Graphics#setXORMode(java.awt.Color) */ public void clearRect(int x, int y, int width, int height) { Paint paint = getPaint(); setColor(getBackground()); fillRect(x, y, width, height); setPaint(paint); }
/** * Fills an oval bounded by the specified rectangle with the * current color. * @param x the <i>x</i> coordinate of the upper left corner * of the oval to be filled. * @param y the <i>y</i> coordinate of the upper left corner * of the oval to be filled. * @param width the width of the oval to be filled. * @param height the height of the oval to be filled. * @see java.awt.Graphics#drawOval */ public void fillOval(int x, int y, int width, int height){ Ellipse2D oval = new Ellipse2D.Double(x, y, width, height); fill(oval); }
rt.setFontFamily(_font.getFamily()); if (getColor() != null) rt.setFontColor(DrawPaint.createSolidPaint(getColor())); if (_font.isBold()) rt.setBold(true); if (_font.isItalic()) rt.setItalic(true); TextLayout layout = new TextLayout(s, _font, getFontRenderContext()); float ascent = layout.getAscent();
/** * Draws the text given by the specified string, using this * graphics context's current font and color. The baseline of the * first character is at position (<i>x</i>, <i>y</i>) in this * graphics context's coordinate system. * @param str the string to be drawn. * @param x the <i>x</i> coordinate. * @param y the <i>y</i> coordinate. * @see java.awt.Graphics#drawBytes * @see java.awt.Graphics#drawChars */ public void drawString(String str, int x, int y){ drawString(str, (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 shape 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 void fill(Shape shape){ Path2D.Double path = new Path2D.Double(_transform.createTransformedShape(shape)); FreeformShape<?,?> p = _group.createFreeform(); p.setPath(path); applyPaint(p); p.setStrokeStyle(); //Fills must be "No Line" }
/** * 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 shape 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 void draw(Shape shape){ Path2D.Double path = new Path2D.Double(_transform.createTransformedShape(shape)); FreeformShape<?,?> p = _group.createFreeform(); p.setPath(path); p.setFillColor(null); applyStroke(p); if (_paint instanceof Color) { p.setStrokeStyle((Color)_paint); } }
/** * Clears the specified rectangle by filling it with the background * color of the current drawing surface. This operation does not * use the current paint mode. * <p> * Beginning with Java 1.1, the background color * of offscreen images may be system dependent. Applications should * use <code>setColor</code> followed by <code>fillRect</code> to * ensure that an offscreen image is cleared to a specific color. * @param x the <i>x</i> coordinate of the rectangle to clear. * @param y the <i>y</i> coordinate of the rectangle to clear. * @param width the width of the rectangle to clear. * @param height the height of the rectangle to clear. * @see java.awt.Graphics#fillRect(int, int, int, int) * @see java.awt.Graphics#drawRect * @see java.awt.Graphics#setColor(java.awt.Color) * @see java.awt.Graphics#setPaintMode * @see java.awt.Graphics#setXORMode(java.awt.Color) */ public void clearRect(int x, int y, int width, int height) { Paint paint = getPaint(); setColor(getBackground()); fillRect(x, y, width, height); setPaint(paint); }
/** * Fills the specified rectangle. * The left and right edges of the rectangle are at * <code>x</code> and <code>x + width - 1</code>. * The top and bottom edges are at * <code>y</code> and <code>y + height - 1</code>. * The resulting rectangle covers an area * <code>width</code> pixels wide by * <code>height</code> pixels tall. * The rectangle is filled using the graphics context's current color. * @param x the <i>x</i> coordinate * of the rectangle to be filled. * @param y the <i>y</i> 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 java.awt.Graphics#clearRect * @see java.awt.Graphics#drawRect */ public void fillRect(int x, int y, int width, int height){ Rectangle rect = new Rectangle(x, y, width, height); fill(rect); }
rt.setFontFamily(_font.getFamily()); if (getColor() != null) rt.setFontColor(DrawPaint.createSolidPaint(getColor())); if (_font.isBold()) rt.setBold(true); if (_font.isItalic()) rt.setItalic(true); TextLayout layout = new TextLayout(s, _font, getFontRenderContext()); float ascent = layout.getAscent();
/** * Draws the text given by the specified iterator, using this * graphics context's current color. The iterator has to specify a font * for each character. The baseline of the * first character is at position (<i>x</i>, <i>y</i>) in this * graphics context's coordinate system. * @param iterator the iterator whose text is to be drawn * @param x the <i>x</i> coordinate. * @param y the <i>y</i> coordinate. * @see java.awt.Graphics#drawBytes * @see java.awt.Graphics#drawChars */ public void drawString(AttributedCharacterIterator iterator, int x, int y){ drawString(iterator, (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 shape 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 void fill(Shape shape){ Path2D.Double path = new Path2D.Double(_transform.createTransformedShape(shape)); FreeformShape<?,?> p = _group.createFreeform(); p.setPath(path); applyPaint(p); p.setStrokeStyle(); //Fills must be "No Line" }
/** * 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 shape 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 void draw(Shape shape){ Path2D.Double path = new Path2D.Double(_transform.createTransformedShape(shape)); FreeformShape<?,?> p = _group.createFreeform(); p.setPath(path); p.setFillColor(null); applyStroke(p); if (_paint instanceof Color) { p.setStrokeStyle((Color)_paint); } }
/** * Draws the outline of the specified rectangle. * The left and right edges of the rectangle are at * <code>x</code> and <code>x + width</code>. * The top and bottom edges are at * <code>y</code> and <code>y + height</code>. * The rectangle is drawn using the graphics context's current color. * @param x the <i>x</i> coordinate * of the rectangle to be drawn. * @param y the <i>y</i> 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 java.awt.Graphics#fillRect * @see java.awt.Graphics#clearRect */ public void drawRect(int x, int y, int width, int height) { Rectangle rect = new Rectangle(x, y, width, height); draw(rect); }
/** * Fills a closed polygon defined by * arrays of <i>x</i> and <i>y</i> coordinates. * <p> * This method draws the polygon defined by <code>nPoint</code> line * segments, where the first <code>nPoint - 1</code> * line segments are line segments from * <code>(xPoints[i - 1], yPoints[i - 1])</code> * to <code>(xPoints[i], yPoints[i])</code>, for * 1 ≤ <i>i</i> ≤ <code>nPoints</code>. * The figure is automatically closed by drawing a line connecting * the final point to the first point, if those points are different. * <p> * The area inside the polygon is defined using an * even-odd fill rule, also known as the alternating rule. * @param xPoints a an array of <code>x</code> coordinates. * @param yPoints a an array of <code>y</code> coordinates. * @param nPoints a the total number of points. * @see java.awt.Graphics#drawPolygon(int[], int[], int) */ public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints){ java.awt.Polygon polygon = new java.awt.Polygon(xPoints, yPoints, nPoints); fill(polygon); }
/** * Draws the text given by the specified string, using this * graphics context's current font and color. The baseline of the * first character is at position (<i>x</i>, <i>y</i>) in this * graphics context's coordinate system. * @param str the string to be drawn. * @param x the <i>x</i> coordinate. * @param y the <i>y</i> coordinate. * @see java.awt.Graphics#drawBytes * @see java.awt.Graphics#drawChars */ public void drawString(String str, int x, int y){ drawString(str, (float)x, (float)y); }
/** * Intersects the current clip with the specified rectangle. * The resulting clipping area is the intersection of the current * clipping area and the specified rectangle. If there is no * current clipping area, either because the clip has never been * set, or the clip has been cleared using <code>setClip(null)</code>, * the specified rectangle becomes the new clip. * This method sets the user clip, which is independent of the * clipping associated with device bounds and window visibility. * This method can only be used to make the current clip smaller. * To set the current clip larger, use any of the setClip methods. * Rendering operations have no effect outside of the clipping area. * @param x the x coordinate of the rectangle to intersect the clip with * @param y the y coordinate of the rectangle to intersect the clip with * @param width the width of the rectangle to intersect the clip with * @param height the height of the rectangle to intersect the clip with * @see #setClip(int, int, int, int) * @see #setClip(Shape) */ public void clipRect(int x, int y, int width, int height){ clip(new Rectangle(x, y, width, height)); }
/** * 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 img the <code>BufferedImage</code> to be rendered * @param op the filter to be applied to the image before rendering * @param x the x coordinate in user space where the image is rendered * @param y the y coordinate in user space where the image is rendered * @see #_transform * @see #setTransform * @see #setComposite * @see #clip * @see #setClip(Shape) */ public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y){ img = op.filter(img, null); drawImage(img, x, y, null); }