Java java.awt Graphics2D fields, constructors, methods, implement or subclass

Example usage for Java java.awt Graphics2D fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for java.awt Graphics2D.

The text is from its open source code.

Subclass

java.awt.Graphics2D has subclasses.
Click this link to see all its subclasses.

Method

voidaddRenderingHints(Map hints)
Sets the values of an arbitrary number of preferences for the rendering algorithms.
voidclearRect(int x, int y, int width, int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface.
voidclip(Shape s)
Intersects the current Clip with the interior of the specified Shape and sets the Clip to the resulting intersection.
voidclipRect(int x, int y, int width, int height)
Intersects the current clip with the specified rectangle.
Graphicscreate()
Creates a new Graphics object that is a copy of this Graphics object.
Graphicscreate(int x, int y, int width, int height)
Creates a new Graphics object based on this Graphics object, but with a new translation and clip area.
voiddispose()
Disposes of this graphics context and releases any system resources that it is using.
voiddraw(Shape s)
Strokes the outline of a Shape using the settings of the current Graphics2D context.
voiddraw3DRect(int x, int y, int width, int height, boolean raised)
Draws a 3-D highlighted outline of the specified rectangle.
voiddrawArc(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.
voiddrawChars(char[] data, int offset, int length, int x, int y)
Draws the text given by the specified character array, using this graphics context's current font and color.
voiddrawGlyphVector(GlyphVector g, float x, float y)
Renders the text of the specified GlyphVector using the Graphics2D context's rendering attributes.
voiddrawImage(BufferedImage img, BufferedImageOp op, int x, int y)
Renders a BufferedImage that is filtered with a BufferedImageOp .
booleandrawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.
booleandrawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
Draws as much of the specified area of the specified image as is currently available, scaling it on the fly to fit inside the specified area of the destination drawable surface.
booleandrawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.
booleandrawImage(Image img, AffineTransform xform, ImageObserver obs)
Renders an image, applying a transform from image space into user space before drawing.
booleandrawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
Draws as much of the specified image as is currently available.
voiddrawLine(int x1, int y1, int x2, int y2)
Draws a line, using the current color, between the points (x1, y1) and (x2, y2) in this graphics context's coordinate system.
voiddrawOval(int x, int y, int width, int height)
Draws the outline of an oval.
voiddrawPolygon(Polygon p)
Draws the outline of a polygon defined by the specified Polygon object.
voiddrawPolygon(int[] xPoints, int[] yPoints, int nPoints)
Draws a closed polygon defined by arrays of x and y coordinates.
voiddrawPolyline(int[] xPoints, int[] yPoints, int nPoints)
Draws a sequence of connected lines defined by arrays of x and y coordinates.
voiddrawRect(int x, int y, int width, int height)
Draws the outline of the specified rectangle.
voiddrawRenderedImage(RenderedImage img, AffineTransform xform)
Renders a RenderedImage , applying a transform from image space into user space before drawing.
voiddrawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
Draws an outlined round-cornered rectangle using this graphics context's current color.
voiddrawString(String str, int x, int y)
Renders the text of the specified String , using the current text attribute state in the Graphics2D context.
voiddrawString(String str, float x, float y)
Renders the text specified by the specified String , using the current text attribute state in the Graphics2D context.
voiddrawString(AttributedCharacterIterator iterator, int x, int y)
Renders the text of the specified iterator applying its attributes in accordance with the specification of the TextAttribute class.
voiddrawString(AttributedCharacterIterator iterator, float x, float y)
Renders the text of the specified iterator applying its attributes in accordance with the specification of the TextAttribute class.
voidfill(Shape s)
Fills the interior of a Shape using the settings of the Graphics2D context.
voidfillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Fills a circular or elliptical arc covering the specified rectangle.
voidfillOval(int x, int y, int width, int height)
Fills an oval bounded by the specified rectangle with the current color.
voidfillPolygon(int[] xPoints, int[] yPoints, int nPoints)
Fills a closed polygon defined by arrays of x and y coordinates.
voidfillPolygon(Polygon p)
Fills the polygon defined by the specified Polygon object with the graphics context's current color.
voidfillRect(int x, int y, int width, int height)
Fills the specified rectangle.
voidfillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
Fills the specified rounded corner rectangle with the current color.
voidfinalize()
Disposes of this graphics context once it is no longer referenced.
ColorgetBackground()
Returns the background color used for clearing a region.
ClassgetClass()
Returns the runtime class of this Object .
ShapegetClip()
Gets the current clipping area.
RectanglegetClipBounds()
Returns the bounding rectangle of the current clipping area.
RectanglegetClipBounds(Rectangle r)
Returns the bounding rectangle of the current clipping area.
ColorgetColor()
Gets this graphics context's current color.
CompositegetComposite()
Returns the current Composite in the Graphics2D context.
GraphicsConfigurationgetDeviceConfiguration()
Returns the device configuration associated with this Graphics2D .
FontgetFont()
Gets the current font.
FontMetricsgetFontMetrics()
Gets the font metrics of the current font.
FontMetricsgetFontMetrics(Font f)
Gets the font metrics for the specified font.
FontRenderContextgetFontRenderContext()
Get the rendering context of the Font within this Graphics2D context.
PaintgetPaint()
Returns the current Paint of the Graphics2D context.
ObjectgetRenderingHint(Key hintKey)
Returns the value of a single preference for the rendering algorithms.
RenderingHintsgetRenderingHints()
Gets the preferences for the rendering algorithms.
StrokegetStroke()
Returns the current Stroke in the Graphics2D context.
AffineTransformgetTransform()
Returns a copy of the current Transform in the Graphics2D context.
voidrotate(double theta)
Concatenates the current Graphics2D Transform with a rotation transform.
voidrotate(double theta, double x, double y)
Concatenates the current Graphics2D Transform with a translated rotation transform.
voidscale(double sx, double sy)
Concatenates the current Graphics2D Transform with a scaling transformation Subsequent rendering is resized according to the specified scaling factors relative to the previous scaling.
voidsetBackground(Color color)
Sets the background color for the Graphics2D context.
voidsetClip(Shape clip)
Sets the current clipping area to an arbitrary clip shape.
voidsetClip(int x, int y, int width, int height)
Sets the current clip to the rectangle specified by the given coordinates.
voidsetColor(Color c)
Sets this graphics context's current color to the specified color.
voidsetComposite(Composite comp)
Sets the Composite for the Graphics2D context.
voidsetFont(Font font)
Sets this graphics context's font to the specified font.
voidsetPaint(Paint paint)
Sets the Paint attribute for the Graphics2D context.
voidsetPaintMode()
Sets the paint mode of this graphics context to overwrite the destination with this graphics context's current color.
voidsetRenderingHint(Key hintKey, Object hintValue)
Sets the value of a single preference for the rendering algorithms.
voidsetRenderingHints(Map hints)
Replaces the values of all preferences for the rendering algorithms with the specified hints .
voidsetStroke(Stroke s)
Sets the Stroke for the Graphics2D context.
voidsetTransform(AffineTransform Tx)
Overwrites the Transform in the Graphics2D context.
voidsetXORMode(Color c1)
Sets the paint mode of this graphics context to alternate between this graphics context's current color and the new specified color.
voidshear(double shx, double shy)
Concatenates the current Graphics2D Transform with a shearing transform.
StringtoString()
Returns a String object representing this Graphics object's value.
voidtransform(AffineTransform Tx)
Composes an AffineTransform object with the Transform in this Graphics2D according to the rule last-specified-first-applied.
voidtranslate(int x, int y)
Translates the origin of the Graphics2D context to the point (xy) in the current coordinate system.
voidtranslate(double tx, double ty)
Concatenates the current Graphics2D Transform with a translation transform.