com.davisor.graphics
Class AnnotatedGraphics2D

java.lang.Object
  extended byjava.awt.Graphics
      extended byjava.awt.Graphics2D
          extended bycom.davisor.graphics.AnnotatedGraphics2D

public class AnnotatedGraphics2D
extends java.awt.Graphics2D

AnnotatedGraphics2D adds selected rendering operation logging to abritary java.awt.Graphics2D instances. This is usefull when graphics needs to be rendered on several different targets simultaneously. A typical example would be an image map assosiated with an image: the image holds the actual rendering result, while the image map defines one or more hotspot areas on that image.

AnnotatedGraphics2D delegates rendering calls to an underlying member Graphics2D object which is expected to carry out the actual rendering. In addition to rendering call delegation, AnnotatedGraphics2D also records selected rendering shapes calls for later inspection. Recorded shapes can later be accessed with the getAnnotatedShapes() method.

The member Graphics2D object is typically expected to be an "ordinary" Graphics2D object that renders graphics to an image buffer or screen. It can however be also another special Graphics2D object, even another instance of AnnotatedGraphics2D.

The selection mechanism that chooses which method calls are recorder and which are not uses the current Paint value to make the call. In particular, all graphics rendering operations that would paint something with a paint instance that implement the AnnotatedPaint interface are recorded. The current paint is controlled with the standard setPaint(Paint) method.

The recorded shapes are made serializable so that the list returned by getAnnotatedShapes() can be serialized, too. Shape serialization is implemented by storing the shapes as IndirectAnnotatedSerializableShape objects.

For a thorough description of Graphics2D rendering methods, please refer to standard Java AWT documentation.

Since:
JDK1.2, JSP 1.1
See Also:
getAnnotatedShapes(), AnnotatedPaint, BetterPath

Field Summary
static int ANNOTATION
          Index for annotation (2).
protected  java.awt.Graphics2D M_g
          Graphics context for which all drawing operations are delegated.
protected  java.util.LinkedList M_log
          Shapes drawn with annotated data.
static int SHAPE
          Index for shapes (0).
static int SHAPEOBJECTS
          Number of elements in each object created with annotated paint (3).
static int TRANSFORM
          Index for transform (1).
 
Constructor Summary
AnnotatedGraphics2D(java.awt.Graphics2D g)
          Constructs a new AnnotatedGraphics2D object.
 
Method Summary
 void addRenderingHints(java.util.Map hints)
          Sets the values of an arbitrary number of preferences for the rendering algorithms.
 void clearRect(int x, int y, int width, int height)
          Clears the specified rectangle by filling it with the background color of the current drawing surface.
 void clip(java.awt.Shape s)
          Intersects the current Clip with the interior of the specified Shape and sets the Clip to the resulting intersection.
 void clipRect(int x, int y, int width, int height)
          Intersects the current clip with the specified rectangle.
 void copyArea(int x, int y, int width, int height, int dx, int dy)
          Copies an area of the component by a distance specified by dx and dy.
 java.awt.Graphics create()
          Creates a new Graphics object based on this Graphics object, but with a new translation and clip area.
 void dispose()
          Disposes of this graphic's context and releases any system resources that it is using.
 void draw(java.awt.Shape s)
          Strokes the outline of a Shape using the settings of the current Graphics2D context.
 void drawArc(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.
 void drawGlyphVector(java.awt.font.GlyphVector g, float x, float y)
          Renders the text of the specified GlyphVector using the Graphics2D context's rendering attributes.
 void drawImage(java.awt.image.BufferedImage img, java.awt.image.BufferedImageOp op, int x, int y)
          Renders a BufferedImage that is filtered with a BufferedImageOp.
 boolean drawImage(java.awt.Image img, java.awt.geom.AffineTransform xform, java.awt.image.ImageObserver obs)
          Renders an image, applying a transform from image space to user space before drawing.
 boolean drawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
          Draws as much of the specified image as is currently available.
 boolean drawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)
          Draws as much of the specified image as is currently available.
 boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
          Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.
 boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)
          Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.
 boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.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's drawable surface.
 boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.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's drawable surface.
 void drawLine(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 graphic's context's coordinate system.
 void drawOval(int x, int y, int width, int height)
          Draws the outline of an oval.
 void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
          Draws a closed polygon defined by arrays of x and y coordinates.
 void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
          Draws a sequence of connected lines defined by arrays of x and y coordinates.
 void drawRenderableImage(java.awt.image.renderable.RenderableImage img, java.awt.geom.AffineTransform xform)
          Renders a RenderableImage, applying a transform from image space to user space before drawing.
 void drawRenderedImage(java.awt.image.RenderedImage img, java.awt.geom.AffineTransform xform)
          Renders a RenderedImage, applying a transform from image space to user space before drawing.
 void drawRoundRect(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.
 void drawString(java.text.AttributedCharacterIterator iterator, float x, float y)
          Renders the text of the specified iterator, using the Graphics2D context's current Paint.
 void drawString(java.text.AttributedCharacterIterator iterator, int x, int y)
          Renders the text of the specified iterator, using the Graphics2D context's current Paint.
 void drawString(java.lang.String str, float x, float y)
          Renders the text specified by the specified String, using the current Font and Paint attributes in the Graphics2D context.
 void drawString(java.lang.String str, int x, int y)
          Renders the text of the specified String, using the current Font and Paint attributes in the Graphics2D context.
 void fill(java.awt.Shape s)
          Fills the interior of a Shape using the settings of the Graphics2D context.
 void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
          Fills a circular or elliptical arc covering the specified rectangle.
 void fillOval(int x, int y, int width, int height)
          Fills an oval bounded by the specified rectangle with the current color.
 void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
          Fills a closed polygon defined by arrays of x and y coordinates.
 void fillRect(int x, int y, int width, int height)
          Fills the specified rectangle.
 void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
          Fills the specified rounded corner rectangle with the current color.
 java.util.List getAnnotatedShapes()
          Gets the current list of recorded annotated shapes.
 java.awt.Color getBackground()
          Returns the background color used for clearing a region.
 java.awt.Shape getClip()
          Gets the current clipping area.
 java.awt.Rectangle getClipBounds()
          Returns the bounding rectangle of the current clipping area.
 java.awt.Color getColor()
          Gets this graphic's context's current color.
 java.awt.Composite getComposite()
          Returns the current Composite in the Graphics2D context.
 java.awt.GraphicsConfiguration getDeviceConfiguration()
          Returns the device configuration associated with this Graphics2D.
 java.awt.Font getFont()
          Gets the current font.
 java.awt.FontMetrics getFontMetrics(java.awt.Font font)
          Gets the font metrics for the specified font.
 java.awt.font.FontRenderContext getFontRenderContext()
          Get the rendering context of the Font within this Graphics2D context.
 java.awt.Paint getPaint()
          Returns the current Paint of the Graphics2D context.
 java.lang.Object getRenderingHint(java.awt.RenderingHints.Key hintKey)
          Returns the value of a single preference for the rendering algorithms.
 java.awt.RenderingHints getRenderingHints()
          Gets the preferences for the rendering algorithms.
 java.awt.Stroke getStroke()
          Returns the current Stroke in the Graphics2D context.
 java.awt.geom.AffineTransform getTransform()
          Returns a copy of the current Transform in the Graphics2D context.
 boolean hit(java.awt.Rectangle rect, java.awt.Shape s, boolean onStroke)
          Checks whether or not the specified Shape intersects with the specified Rectangle, which is in the device space.
protected  void record(java.awt.Shape s, com.davisor.core.Annotated a)
          Records given shape with given annotation information.
protected  void record(java.awt.Shape s, com.davisor.core.Annotated a, float x, float y)
          Translates and records given shape.
protected  void record(java.awt.Shape s, com.davisor.core.Annotated a, java.awt.Stroke stroke)
          Strokes and records given shape.
protected  void record(java.lang.String str, com.davisor.core.Annotated a, float x, float y)
          Translates and records the bounding box of given string.
 void rotate(double theta)
          Concatenates the current Graphics2D Transform with a rotation transform.
 void rotate(double theta, double x, double y)
          Concatenates the current Graphics2D Transform with a translated rotation transform.
 void scale(double sx, double sy)
          Concatenates the current Graphics2D Transform with a scaling transformation.
 void setBackground(java.awt.Color color)
          Sets the background color for the Graphics2D context.
 void setClip(int x, int y, int width, int height)
          Sets the current clip to the rectangle specified by the given coordinates.
 void setClip(java.awt.Shape clip)
          Sets the current clipping area to an arbitrary clip shape.
 void setColor(java.awt.Color color)
          Sets this graphic's context's current color to the specified color.
 void setComposite(java.awt.Composite comp)
          Sets the Composite for the Graphics2D context.
 void setFont(java.awt.Font font)
          Sets this graphic's context's font to the specified font.
 void setPaint(java.awt.Paint paint)
          Sets the Paint attribute for the Graphics2D context.
 void setPaintMode()
          Sets the paint mode of this graphic's context to overwrite the destination with this graphic's context's current color.
 void setRenderingHint(java.awt.RenderingHints.Key hintKey, java.lang.Object hintValue)
          Sets the value of a single preference for the rendering algorithms.
 void setRenderingHints(java.util.Map hints)
          Replaces the values of all preferences for the rendering algorithms with the specified hints.
 void setStroke(java.awt.Stroke s)
          Sets the Stroke for the Graphics2D context.
 void setTransform(java.awt.geom.AffineTransform Tx)
          Sets the Transform in the Graphics2D context.
 void setXORMode(java.awt.Color c1)
          Sets the paint mode of this graphic's context to alternate between this graphic's context's current color and the new specified color.
 void shear(double shx, double shy)
          Concatenates the current Graphics2D Transform with a shearing transform.
 void transform(java.awt.geom.AffineTransform Tx)
          Composes an AffineTransform object with the Transform in this Graphics2D according to the rule last-specified-first-applied.
 void translate(double tx, double ty)
          Concatenates the current Graphics2D Transform with a translation transform.
 void translate(int x, int y)
          Translates the origin of the Graphics2D context to the point (xy) in the current coordinate system.
 
Methods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRect
 
Methods inherited from class java.awt.Graphics
create, drawBytes, drawChars, drawPolygon, drawRect, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SHAPE

public static final int SHAPE
Index for shapes (0).

See Also:
Constant Field Values

TRANSFORM

public static final int TRANSFORM
Index for transform (1).

See Also:
Constant Field Values

ANNOTATION

public static final int ANNOTATION
Index for annotation (2).

See Also:
Constant Field Values

SHAPEOBJECTS

public static final int SHAPEOBJECTS
Number of elements in each object created with annotated paint (3).

See Also:
Constant Field Values

M_g

protected java.awt.Graphics2D M_g
Graphics context for which all drawing operations are delegated.


M_log

protected java.util.LinkedList M_log
Shapes drawn with annotated data.

Constructor Detail

AnnotatedGraphics2D

public AnnotatedGraphics2D(java.awt.Graphics2D g)
Constructs a new AnnotatedGraphics2D object.

Method Detail

clearRect

public void clearRect(int x,
                      int y,
                      int width,
                      int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface.

The cleared rectangle is not recorded, even if the current backgroud paint would implement AnnotatedPaint interface.


clipRect

public void clipRect(int x,
                     int y,
                     int width,
                     int height)
Intersects the current clip with the specified rectangle.


copyArea

public void copyArea(int x,
                     int y,
                     int width,
                     int height,
                     int dx,
                     int dy)
Copies an area of the component by a distance specified by dx and dy.

The copied area is not recorded, even if it would contain material painted with a paint that implemented AnnotatedPaint interface.


create

public java.awt.Graphics create()
Creates a new Graphics object based on this Graphics object, but with a new translation and clip area.

This method call is delegated directly to the underlying Graphics2D object. In particular, the returned new Graphics object will NOT be annotated, at least by this AnnotatedGraphics2D instance.


dispose

public void dispose()
Disposes of this graphic's context and releases any system resources that it is using.


drawArc

public void drawArc(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.

The arc is never recorded, since it uses the current Color, not Paint. To record an arc, create an arc shape, and draw or fill it.

See Also:
draw(java.awt.Shape), fill(java.awt.Shape)

drawImage

public boolean drawImage(java.awt.Image img,
                         int x,
                         int y,
                         java.awt.Color bgcolor,
                         java.awt.image.ImageObserver observer)
Draws as much of the specified image as is currently available.

The image area is not recorded, even if it would contain material painted with a paint that implemented AnnotatedPaint interface.


drawImage

public boolean drawImage(java.awt.Image img,
                         int x,
                         int y,
                         java.awt.image.ImageObserver observer)
Draws as much of the specified image as is currently available.

The image area is not recorded, even if it would contain material painted with a paint that implemented AnnotatedPaint interface.


drawImage

public boolean drawImage(java.awt.Image img,
                         int x,
                         int y,
                         int width,
                         int height,
                         java.awt.Color bgcolor,
                         java.awt.image.ImageObserver observer)
Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.

The image area is not recorded, even if it would contain material painted with a paint that implemented AnnotatedPaint interface.


drawImage

public boolean drawImage(java.awt.Image img,
                         int x,
                         int y,
                         int width,
                         int height,
                         java.awt.image.ImageObserver observer)
Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.

The image area is not recorded, even if it would contain material painted with a paint that implemented AnnotatedPaint interface.


drawImage

public boolean drawImage(java.awt.Image img,
                         int dx1,
                         int dy1,
                         int dx2,
                         int dy2,
                         int sx1,
                         int sy1,
                         int sx2,
                         int sy2,
                         java.awt.Color bgcolor,
                         java.awt.image.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's drawable surface.

The image area is not recorded, even if it would contain material painted with a paint that implemented AnnotatedPaint interface.


drawImage

public boolean drawImage(java.awt.Image img,
                         int dx1,
                         int dy1,
                         int dx2,
                         int dy2,
                         int sx1,
                         int sy1,
                         int sx2,
                         int sy2,
                         java.awt.image.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's drawable surface.

The image area is not recorded, even if it would contain material painted with a paint that implemented AnnotatedPaint interface.


drawLine

public void drawLine(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 graphic's context's coordinate system.

The line is never recorded, since it uses the current Color, not Paint. To record a line, create a line shape, and draw or fill it.

See Also:
draw(java.awt.Shape), fill(java.awt.Shape)

drawOval

public void drawOval(int x,
                     int y,
                     int width,
                     int height)
Draws the outline of an oval.

The oval is never recorded, since it uses the current Color, not Paint. To record an oval, create an oval shape, and draw or fill it.

See Also:
draw(java.awt.Shape), fill(java.awt.Shape)

drawPolygon

public void drawPolygon(int[] xPoints,
                        int[] yPoints,
                        int nPoints)
Draws a closed polygon defined by arrays of x and y coordinates.

The polygon is never recorded, since it uses the current Color, not Paint. To record a polygon, create a polygon shape, and draw or fill it.

See Also:
draw(java.awt.Shape), fill(java.awt.Shape)

drawPolyline

public void drawPolyline(int[] xPoints,
                         int[] yPoints,
                         int nPoints)
Draws a sequence of connected lines defined by arrays of x and y coordinates.

The polyline is never recorded, since it uses the current Color, not Paint. To record a polyline, create a polyline shape, and draw or fill it.

See Also:
draw(java.awt.Shape), fill(java.awt.Shape)

drawRoundRect

public void drawRoundRect(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.

The rounded rectangle is never recorded, since it uses the current Color, not Paint. To record a rounded rectangle, create a rounded rectangle shape, and draw or fill it.

See Also:
draw(java.awt.Shape), fill(java.awt.Shape)

fillArc

public void fillArc(int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
Fills a circular or elliptical arc covering the specified rectangle.

The arc is never recorded, since it uses the current Color, not Paint. To record an arc, create an arc shape, and draw or fill it.

See Also:
draw(java.awt.Shape), fill(java.awt.Shape)

fillOval

public void fillOval(int x,
                     int y,
                     int width,
                     int height)
Fills an oval bounded by the specified rectangle with the current color.

The oval is never recorded, since it uses the current Color, not Paint. To record an oval, create an oval shape, and draw or fill it.

See Also:
draw(java.awt.Shape), fill(java.awt.Shape)

fillPolygon

public void fillPolygon(int[] xPoints,
                        int[] yPoints,
                        int nPoints)
Fills a closed polygon defined by arrays of x and y coordinates.

The polygon is never recorded, since it uses the current Color, not Paint. To record a polygon, create a polygon shape, and draw or fill it.

See Also:
draw(java.awt.Shape), fill(java.awt.Shape)

fillRect

public void fillRect(int x,
                     int y,
                     int width,
                     int height)
Fills the specified rectangle.

The rectangle is never recorded, since it uses the current Color, not Paint. To record a rectangle, create a rectangle shape, and draw or fill it.

See Also:
draw(java.awt.Shape), fill(java.awt.Shape)

fillRoundRect

public void fillRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
Fills the specified rounded corner rectangle with the current color.

The rounded rectangle is never recorded, since it uses the current Color, not Paint. To record a rounded rectangle, create a rounded rectangle shape, and draw or fill it.

See Also:
draw(java.awt.Shape), fill(java.awt.Shape)

getClip

public java.awt.Shape getClip()
Gets the current clipping area.


getClipBounds

public java.awt.Rectangle getClipBounds()
Returns the bounding rectangle of the current clipping area.


getColor

public java.awt.Color getColor()
Gets this graphic's context's current color.


getFont

public java.awt.Font getFont()
Gets the current font.


getFontMetrics

public java.awt.FontMetrics getFontMetrics(java.awt.Font font)
Gets the font metrics for the specified font.


setClip

public void setClip(int x,
                    int y,
                    int width,
                    int height)
Sets the current clip to the rectangle specified by the given coordinates.


setClip

public void setClip(java.awt.Shape clip)
Sets the current clipping area to an arbitrary clip shape.


setColor

public void setColor(java.awt.Color color)
Sets this graphic's context's current color to the specified color.

Setting the color has no effect whatsoever to the annotation mechanism. To control annotation, apply paints that do or do not implement AnnotatedPaint interface to the setPaint method.

See Also:
setPaint(java.awt.Paint)

setFont

public void setFont(java.awt.Font font)
Sets this graphic's context's font to the specified font.


setPaintMode

public void setPaintMode()
Sets the paint mode of this graphic's context to overwrite the destination with this graphic's context's current color.


setXORMode

public void setXORMode(java.awt.Color c1)
Sets the paint mode of this graphic's context to alternate between this graphic's context's current color and the new specified color.


addRenderingHints

public void addRenderingHints(java.util.Map hints)
Sets the values of an arbitrary number of preferences for the rendering algorithms.

Parameters:
hints - the rendering hints to be set

clip

public void clip(java.awt.Shape s)
Intersects the current Clip with the interior of the specified Shape and sets the Clip to the resulting intersection.

Parameters:
s - the Shape to be intersected with the current Clip. If s is null, this method clears the current Clip.

draw

public void draw(java.awt.Shape s)
Strokes the outline of a Shape using the settings of the current Graphics2D context.

If drawing is successfull, and current paint or given shape is annotated, the drawn shape is stroked and recorded. If both the paint and shape are annotated, paint annotation takes preferences.

Parameters:
s - the Shape to be rendered
See Also:
clip(java.awt.Shape), getStroke(), record(Shape,Annotated,Stroke), setClip(int, int, int, int), setComposite(java.awt.Composite), setPaint(java.awt.Paint), setStroke(java.awt.Stroke), setTransform(java.awt.geom.AffineTransform), transform(java.awt.geom.AffineTransform), AnnotatedPaint, AnnotatedShape

drawGlyphVector

public void drawGlyphVector(java.awt.font.GlyphVector g,
                            float x,
                            float y)
Renders the text of the specified GlyphVector using the Graphics2D context's rendering attributes.

If drawing is successfull, and current paint is annotated, the glyph vector visual bounds are recorded.

Parameters:
g - the GlyphVector to be rendered
x - glypth X -coordinate
y - glypth Y -coordinate
See Also:
record(Shape,Annotated,float,float), setClip(int, int, int, int), setComposite(java.awt.Composite), setPaint(java.awt.Paint), setTransform(java.awt.geom.AffineTransform), AnnotatedPaint, GlyphVector, Graphics.setColor(java.awt.Color)

drawImage

public void drawImage(java.awt.image.BufferedImage img,
                      java.awt.image.BufferedImageOp op,
                      int x,
                      int y)
Renders a BufferedImage that is filtered with a BufferedImageOp.

The image area is not recorded, even if it would contain material painted with a paint that implemented AnnotatedPaint interface.

Parameters:
op - the filter to be applied to the image before rendering
img - the BufferedImage to be rendered
x - image upper left corner X -coordinate
y - image upper left corner Y -coordinate
See Also:
clip(java.awt.Shape), setClip(int, int, int, int), setComposite(java.awt.Composite), setTransform(java.awt.geom.AffineTransform), transform(java.awt.geom.AffineTransform)

drawImage

public boolean drawImage(java.awt.Image img,
                         java.awt.geom.AffineTransform xform,
                         java.awt.image.ImageObserver obs)
Renders an image, applying a transform from image space to user space before drawing.

The image area is not recorded, even if it would contain material painted with a paint that implemented AnnotatedPaint interface.

Parameters:
img - the Image to be rendered
xform - the transformation from image space to user space
obs - the ImageObserver to be notified as more of the Image is converted
Returns:
true if the Image is fully loaded and completely rendered; false if the Image is still being loaded.
See Also:
clip(java.awt.Shape), setClip(int, int, int, int), setComposite(java.awt.Composite), setTransform(java.awt.geom.AffineTransform), transform(java.awt.geom.AffineTransform)

drawRenderableImage

public void drawRenderableImage(java.awt.image.renderable.RenderableImage img,
                                java.awt.geom.AffineTransform xform)
Renders a RenderableImage, applying a transform from image space to user space before drawing.

The image area is not recorded, even if it would contain material painted with a paint that implemented AnnotatedPaint interface.

Parameters:
img - the image to be rendered
xform - the transformation from image space to user space
See Also:
clip(java.awt.Shape), drawRenderedImage(java.awt.image.RenderedImage, java.awt.geom.AffineTransform), setClip(int, int, int, int), setComposite(java.awt.Composite), setTransform(java.awt.geom.AffineTransform), transform(java.awt.geom.AffineTransform)

drawRenderedImage

public void drawRenderedImage(java.awt.image.RenderedImage img,
                              java.awt.geom.AffineTransform xform)
Renders a RenderedImage, applying a transform from image space to user space before drawing.

The image area is not recorded, even if it would contain material painted with a paint that implemented AnnotatedPaint interface.

Parameters:
img - the image to be rendered
xform - the transformation from image space to user space
See Also:
clip(java.awt.Shape), setClip(int, int, int, int), setComposite(java.awt.Composite), setTransform(java.awt.geom.AffineTransform), transform(java.awt.geom.AffineTransform)

drawString

public void drawString(java.text.AttributedCharacterIterator iterator,
                       float x,
                       float y)
Renders the text of the specified iterator, using the Graphics2D context's current Paint.

The text area is not recorded, even if it would contain material painted with a paint that implemented AnnotatedPaint interface.

Parameters:
iterator - the iterator whose text is to be rendered
x - string X -coordinate
y - string Y -coordinate
See Also:
setClip(int, int, int, int), setComposite(java.awt.Composite), setPaint(java.awt.Paint), setTransform(java.awt.geom.AffineTransform), Graphics.setColor(java.awt.Color)

drawString

public void drawString(java.text.AttributedCharacterIterator iterator,
                       int x,
                       int y)
Renders the text of the specified iterator, using the Graphics2D context's current Paint.

The text area is not recorded, even if it would contain material painted with a paint that implemented AnnotatedPaint interface.

Parameters:
iterator - the iterator whose text is to be rendered
x - string X -coordinate
y - string Y -coordinate
See Also:
setClip(int, int, int, int), setComposite(java.awt.Composite), setPaint(java.awt.Paint), setTransform(java.awt.geom.AffineTransform), Graphics.setColor(java.awt.Color)

drawString

public void drawString(java.lang.String str,
                       float x,
                       float y)
Renders the text specified by the specified String, using the current Font and Paint attributes in the Graphics2D context.

If drawing is successfull, and current paint is annotated, the visual bounds of the string are recorded.

Parameters:
str - the string to be rendered
x - string X -coordinate
y - string Y -coordinate
See Also:
record(String,Annotated,float,float), setClip(int, int, int, int), setComposite(java.awt.Composite), setPaint(java.awt.Paint), setTransform(java.awt.geom.AffineTransform), AnnotatedPaint, Graphics.setColor(java.awt.Color), Graphics.setFont(java.awt.Font)

drawString

public void drawString(java.lang.String str,
                       int x,
                       int y)
Renders the text of the specified String, using the current Font and Paint attributes in the Graphics2D context.

If drawing is successfull, and current paint is annotated, the visual bounds of the string are recorded.

Parameters:
str - the string to be rendered
x - string X -coordinate
y - string Y -coordinate
Throws:
java.lang.NullPointerException - if str is null
Since:
JDK1.0
See Also:
record(String,Annotated,float,float), AnnotatedPaint, Graphics.drawBytes(byte[], int, int, int, int), Graphics.drawChars(char[], int, int, int, int)

fill

public void fill(java.awt.Shape s)
Fills the interior of a Shape using the settings of the Graphics2D context.

If drawing is successfull, and current paint or given shape is annotated, the shape interior is recorded. If both the paint and shape are annotated, paint annotation takes preferences.

Parameters:
s - the Shape to be filled
See Also:
clip(java.awt.Shape), record(Shape,Annotated), setClip(int, int, int, int), setComposite(java.awt.Composite), setPaint(java.awt.Paint), setTransform(java.awt.geom.AffineTransform), transform(java.awt.geom.AffineTransform), AnnotatedPaint, AnnotatedShape

getBackground

public java.awt.Color getBackground()
Returns the background color used for clearing a region.

Returns:
the current Graphics2D Color, which defines the background color.
See Also:
setBackground(java.awt.Color)

getComposite

public java.awt.Composite getComposite()
Returns the current Composite in the Graphics2D context.

Returns:
the current Graphics2D Composite, which defines a compositing style.
See Also:
setComposite(java.awt.Composite)

getDeviceConfiguration

public java.awt.GraphicsConfiguration getDeviceConfiguration()
Returns the device configuration associated with this Graphics2D.


getFontRenderContext

public java.awt.font.FontRenderContext getFontRenderContext()
Get the rendering context of the Font within this Graphics2D context.

Returns:
a reference to an instance of FontRenderContext.
Since:
1.2
See Also:
FontRenderContext, Font.createGlyphVector(java.awt.font.FontRenderContext, char[])

getPaint

public java.awt.Paint getPaint()
Returns the current Paint of the Graphics2D context.

Returns:
the current Graphics2D Paint, which defines a color or a pattern.
See Also:
setPaint(java.awt.Paint), Graphics.setColor(java.awt.Color)

getRenderingHint

public java.lang.Object getRenderingHint(java.awt.RenderingHints.Key hintKey)
Returns the value of a single preference for the rendering algorithms.

Parameters:
hintKey - the key corresponding to the hint to get.
Returns:
an object representing the value for the specified hint key. Some of the keys and their associated values are defined in the RenderingHints class.
See Also:
RenderingHints

getRenderingHints

public java.awt.RenderingHints getRenderingHints()
Gets the preferences for the rendering algorithms.

Returns:
a reference to an instance of RenderingHints that contains the current preferences.
See Also:
RenderingHints

getStroke

public java.awt.Stroke getStroke()
Returns the current Stroke in the Graphics2D context.

Returns:
the current Graphics2D Stroke, which defines the line style.
See Also:
setStroke(java.awt.Stroke)

getTransform

public java.awt.geom.AffineTransform getTransform()
Returns a copy of the current Transform in the Graphics2D context.

Returns:
the current AffineTransform in the Graphics2D context.
See Also:
setTransform(java.awt.geom.AffineTransform), transform(java.awt.geom.AffineTransform)

hit

public boolean hit(java.awt.Rectangle rect,
                   java.awt.Shape s,
                   boolean onStroke)
Checks whether or not the specified Shape intersects with the specified Rectangle, which is in the device space.

Parameters:
rect - the area in the device space to check for a hit
s - the Shape to check for a hit
onStroke - flag used to choose between testing the stroked or the filled shape. If the flag is true, the Stroke outline is tested. If the flag is false, the filled Shape is tested.
Returns:
true if there is a hit; false otherwise.
See Also:
clip(java.awt.Shape), draw(java.awt.Shape), fill(java.awt.Shape), setClip(int, int, int, int), setStroke(java.awt.Stroke), setTransform(java.awt.geom.AffineTransform), transform(java.awt.geom.AffineTransform)

rotate

public void rotate(double theta)
Concatenates the current Graphics2D Transform with a rotation transform.

Parameters:
theta - the angle of rotation in radians

rotate

public void rotate(double theta,
                   double x,
                   double y)
Concatenates the current Graphics2D Transform with a translated rotation transform.

Parameters:
theta - the angle of rotation in radians
x - string X -coordinate
y - string Y -coordinate

scale

public void scale(double sx,
                  double sy)
Concatenates the current Graphics2D Transform with a scaling transformation.

Parameters:
sx - the amount by which X coordinates in subsequent rendering operations are multiplied relative to previous rendering operations.
sy - the amount by which Y coordinates in subsequent rendering operations are multiplied relative to previous rendering operations.

setBackground

public void setBackground(java.awt.Color color)
Sets the background color for the Graphics2D context.

Parameters:
color - the background color that is used in subsequent calls to clearRect
See Also:
getBackground(), Graphics.clearRect(int, int, int, int)

setComposite

public void setComposite(java.awt.Composite comp)
Sets the Composite for the Graphics2D context.

Parameters:
comp - the Composite object to be used for rendering
Throws:
java.lang.SecurityException - if a custom Composite object is being used to render the screen, and a security manager is set and its checkPermission method does not allow the operation.
See Also:
Graphics.setXORMode(java.awt.Color), Graphics.setPaintMode()

setPaint

public void setPaint(java.awt.Paint paint)
Sets the Paint attribute for the Graphics2D context.

Parameters:
paint - the Paint object to be used to generate color during the rendering process, or null
See Also:
Graphics.setColor(java.awt.Color), GradientPaint

setRenderingHint

public void setRenderingHint(java.awt.RenderingHints.Key hintKey,
                             java.lang.Object hintValue)
Sets the value of a single preference for the rendering algorithms.

Parameters:
hintKey - the key of the hint to be set.
hintValue - the value indicating preferences for the specified hint category.
See Also:
RenderingHints

setRenderingHints

public void setRenderingHints(java.util.Map hints)
Replaces the values of all preferences for the rendering algorithms with the specified hints.

Parameters:
hints - the rendering hints to be set
See Also:
RenderingHints

setStroke

public void setStroke(java.awt.Stroke s)
Sets the Stroke for the Graphics2D context.

Parameters:
s - the Stroke object to be used to stroke a Shape during the rendering process
See Also:
BasicStroke

setTransform

public void setTransform(java.awt.geom.AffineTransform Tx)
Sets the Transform in the Graphics2D context.

Parameters:
Tx - the AffineTransform object to be used in the rendering process
See Also:
transform(java.awt.geom.AffineTransform), AffineTransform

shear

public void shear(double shx,
                  double shy)
Concatenates the current Graphics2D Transform with a shearing transform.

Parameters:
shx - the multiplier by which coordinates are shifted in the positive X axis direction as a function of their Y coordinate
shy - the multiplier by which coordinates are shifted in the positive Y axis direction as a function of their X coordinate

transform

public void transform(java.awt.geom.AffineTransform Tx)
Composes an AffineTransform object with the Transform in this Graphics2D according to the rule last-specified-first-applied.

Parameters:
Tx - the AffineTransform object to be composed with the current Transform
See Also:
setTransform(java.awt.geom.AffineTransform), AffineTransform

translate

public void translate(int x,
                      int y)
Translates the origin of the Graphics2D context to the point (xy) in the current coordinate system.

Parameters:
x - X offset
y - Y offset

translate

public void translate(double tx,
                      double ty)
Concatenates the current Graphics2D Transform with a translation transform.

Parameters:
tx - the distance to translate along the x-axis
ty - the distance to translate along the y-axis

getAnnotatedShapes

public java.util.List getAnnotatedShapes()
Gets the current list of recorded annotated shapes. The annotated shapes are represented with AnnotatedShape objects, with the annotation information as label, and the corresponding shape as assosiated object.

The list elements are arranged in last-in-first-out (LIFO) order, so that shapes drawn last are encountered first when traversing the list from beginning to end.

The returned list object refers directly to the list object this AnnotatedGraphics2D uses to store the recorded shapes. Any modifications to the list will therefore affect the this AnnotatedGraphics2D instance, too. Likewise, drawing and recording shapes through this context while inspecting the returned list will instantly modify the content of the list.

The returned list of shapes is guaranteed to be serializable.

See Also:
record(Shape,Annotated)

record

protected void record(java.awt.Shape s,
                      com.davisor.core.Annotated a)
Records given shape with given annotation information. Shape list serialization is enforced.

Parameters:
s - shape to be annotated
a - annotation the shape is to be annotated with
See Also:
getAnnotatedShapes(), IndirectAnnotatedSerializableShape

record

protected void record(java.awt.Shape s,
                      com.davisor.core.Annotated a,
                      java.awt.Stroke stroke)
Strokes and records given shape.

Parameters:
s - shape to be annotated
a - annotation the shape is to be annotated with
stroke - the stroke the shape is to be stroked with
See Also:
record(Shape,Annotated)

record

protected void record(java.awt.Shape s,
                      com.davisor.core.Annotated a,
                      float x,
                      float y)
Translates and records given shape.

Parameters:
s - shape to be annotated
a - annotation the shape is to be annotated with
x - translation x -amount
y - translation y -amount
See Also:
record(Shape,Annotated)

record

protected void record(java.lang.String str,
                      com.davisor.core.Annotated a,
                      float x,
                      float y)
Translates and records the bounding box of given string.

Parameters:
str - string content of the bounding box to be annotated
a - annotation the bounding box is to be annotated with
x - translation x -amount
y - translation y -amount
See Also:
record(Shape,Annotated,float,float)


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.