javax.media.jai
Class RenderableGraphics

java.lang.Object
  |
  +--java.awt.Graphics
        |
        +--java.awt.Graphics2D
              |
              +--javax.media.jai.RenderableGraphics
All Implemented Interfaces:
RenderableImage

public class RenderableGraphics
extends Graphics2D
implements RenderableImage

An implementation of Graphics2D with RenderableImage semantics. In other words, content may be drawn into the image using the Graphics2D interface and later be turned into RenderedImages with different resolutions and characteristics.

A RenderableGraphics occupies a region of the plane specified at the time of construction.

The contents of RenderableImages that are drawn onto a RenderableGraphics are accessed only at the time of rendering, not the time of drawing.

Since the methods of this class all derive from Graphics2D and RenderableImage, they are not all commented individually.

See Also:
Graphics2D, RenderableImage

Fields inherited from interface java.awt.image.renderable.RenderableImage
HINTS_OBSERVED
 
Constructor Summary
RenderableGraphics(Rectangle2D dimensions)
          Constructs a RenderableGraphics given a bounding Rectangle2D.
 
Method Summary
 void addRenderingHints(Map hints)
           
 void clearRect(int x, int y, int width, int height)
           
 void clip(Shape s)
           
 void clipRect(int x, int y, int width, int height)
           
 void copyArea(int x, int y, int width, int height, int dx, int dy)
           
 Graphics create()
           
 RenderedImage createDefaultRendering()
           
 RenderedImage createRendering(RenderContext renderContext)
          Creates a RenderedImage that represents a rendering of this image using a given RenderContext.
 RenderedImage createScaledRendering(int w, int h, RenderingHints hints)
           
 void dispose()
           
 void draw(Shape s)
           
 void draw3DRect(int x, int y, int width, int height, boolean raised)
           
 void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
           
 void drawGlyphVector(GlyphVector v, float x, float y)
           
 void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
           
 boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
           
 boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
           
 boolean drawImage(Image img, int x, int y, ImageObserver observer)
           
 boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
           
 boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
           
 boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)
           
 boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
           
 void drawLine(int x1, int y1, int x2, int y2)
           
 void drawOval(int x, int y, int width, int height)
           
 void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
           
 void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
           
 void drawRenderableImage(RenderableImage img, AffineTransform xform)
           
 void drawRenderedImage(RenderedImage img, AffineTransform xform)
           
 void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
           
 void drawString(AttributedCharacterIterator iterator, float x, float y)
           
 void drawString(AttributedCharacterIterator iterator, int x, int y)
           
 void drawString(String s, float x, float y)
           
 void drawString(String str, int x, int y)
           
 void fill(Shape s)
           
 void fill3DRect(int x, int y, int width, int height, boolean raised)
           
 void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
           
 void fillOval(int x, int y, int width, int height)
           
 void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
           
 void fillRect(int x, int y, int width, int height)
           
 void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
           
 Color getBackground()
           
 Shape getClip()
           
 Rectangle getClipBounds()
           
 Color getColor()
           
 Composite getComposite()
           
 GraphicsConfiguration getDeviceConfiguration()
           
 Font getFont()
           
 FontMetrics getFontMetrics(Font f)
           
 FontRenderContext getFontRenderContext()
           
 float getHeight()
           
 float getMinX()
           
 float getMinY()
           
 Paint getPaint()
           
 Object getProperty(String name)
           
 String[] getPropertyNames()
           
 Object getRenderingHint(RenderingHints.Key hintKey)
           
 RenderingHints getRenderingHints()
           
 Vector getSources()
           
 Stroke getStroke()
           
 AffineTransform getTransform()
           
 float getWidth()
           
 boolean hit(Rectangle rect, Shape s, boolean onStroke)
           
 boolean isDynamic()
           
 void rotate(double theta)
           
 void rotate(double theta, double x, double y)
           
 void scale(double sx, double sy)
           
 void setBackground(Color color)
           
 void setClip(int x, int y, int width, int height)
           
 void setClip(Shape clip)
           
 void setColor(Color c)
           
 void setComposite(Composite comp)
           
 void setFont(Font font)
           
 void setPaint(Paint paint)
           
 void setPaintMode()
           
 void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
           
 void setRenderingHints(Map hints)
           
 void setStroke(Stroke s)
           
 void setTransform(AffineTransform Tx)
           
 void setXORMode(Color c1)
           
 void shear(double shx, double shy)
           
 void transform(AffineTransform Tx)
           
 void translate(double x, double y)
           
 void translate(int x, int y)
           
 
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
 

Constructor Detail

RenderableGraphics

public RenderableGraphics(Rectangle2D dimensions)
Constructs a RenderableGraphics given a bounding Rectangle2D.
Parameters:
dimensions - The bounding Rectangle2D.
Method Detail

create

public Graphics create()
Overrides:
create in class Graphics

getColor

public Color getColor()
Overrides:
getColor in class Graphics

setColor

public void setColor(Color c)
Overrides:
setColor in class Graphics

setPaintMode

public void setPaintMode()
Overrides:
setPaintMode in class Graphics

setXORMode

public void setXORMode(Color c1)
Overrides:
setXORMode in class Graphics

getFont

public Font getFont()
Overrides:
getFont in class Graphics

setFont

public void setFont(Font font)
Overrides:
setFont in class Graphics

getFontMetrics

public FontMetrics getFontMetrics(Font f)
Overrides:
getFontMetrics in class Graphics

getClipBounds

public Rectangle getClipBounds()
Overrides:
getClipBounds in class Graphics

clipRect

public void clipRect(int x,
                     int y,
                     int width,
                     int height)
Overrides:
clipRect in class Graphics

setClip

public void setClip(int x,
                    int y,
                    int width,
                    int height)
Overrides:
setClip in class Graphics

getClip

public Shape getClip()
Overrides:
getClip in class Graphics

setClip

public void setClip(Shape clip)
Overrides:
setClip in class Graphics

copyArea

public void copyArea(int x,
                     int y,
                     int width,
                     int height,
                     int dx,
                     int dy)
Overrides:
copyArea in class Graphics

drawLine

public void drawLine(int x1,
                     int y1,
                     int x2,
                     int y2)
Overrides:
drawLine in class Graphics

fillRect

public void fillRect(int x,
                     int y,
                     int width,
                     int height)
Overrides:
fillRect in class Graphics

clearRect

public void clearRect(int x,
                      int y,
                      int width,
                      int height)
Overrides:
clearRect in class Graphics

drawRoundRect

public void drawRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
Overrides:
drawRoundRect in class Graphics

fillRoundRect

public void fillRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
Overrides:
fillRoundRect in class Graphics

draw3DRect

public void draw3DRect(int x,
                       int y,
                       int width,
                       int height,
                       boolean raised)
Overrides:
draw3DRect in class Graphics2D

fill3DRect

public void fill3DRect(int x,
                       int y,
                       int width,
                       int height,
                       boolean raised)
Overrides:
fill3DRect in class Graphics2D

drawOval

public void drawOval(int x,
                     int y,
                     int width,
                     int height)
Overrides:
drawOval in class Graphics

fillOval

public void fillOval(int x,
                     int y,
                     int width,
                     int height)
Overrides:
fillOval in class Graphics

drawArc

public void drawArc(int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
Overrides:
drawArc in class Graphics

fillArc

public void fillArc(int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
Overrides:
fillArc in class Graphics

drawPolyline

public void drawPolyline(int[] xPoints,
                         int[] yPoints,
                         int nPoints)
Overrides:
drawPolyline in class Graphics

drawPolygon

public void drawPolygon(int[] xPoints,
                        int[] yPoints,
                        int nPoints)
Overrides:
drawPolygon in class Graphics

fillPolygon

public void fillPolygon(int[] xPoints,
                        int[] yPoints,
                        int nPoints)
Overrides:
fillPolygon in class Graphics

drawString

public void drawString(String str,
                       int x,
                       int y)
Overrides:
drawString in class Graphics2D

drawImage

public boolean drawImage(Image img,
                         int x,
                         int y,
                         ImageObserver observer)
Overrides:
drawImage in class Graphics

drawImage

public boolean drawImage(Image img,
                         int x,
                         int y,
                         int width,
                         int height,
                         ImageObserver observer)
Overrides:
drawImage in class Graphics

drawImage

public boolean drawImage(Image img,
                         int x,
                         int y,
                         Color bgcolor,
                         ImageObserver observer)
Overrides:
drawImage in class Graphics

drawImage

public boolean drawImage(Image img,
                         int x,
                         int y,
                         int width,
                         int height,
                         Color bgcolor,
                         ImageObserver observer)
Overrides:
drawImage in class Graphics

drawImage

public boolean drawImage(Image img,
                         int dx1,
                         int dy1,
                         int dx2,
                         int dy2,
                         int sx1,
                         int sy1,
                         int sx2,
                         int sy2,
                         ImageObserver observer)
Overrides:
drawImage in class Graphics

drawImage

public boolean drawImage(Image img,
                         int dx1,
                         int dy1,
                         int dx2,
                         int dy2,
                         int sx1,
                         int sy1,
                         int sx2,
                         int sy2,
                         Color bgcolor,
                         ImageObserver observer)
Overrides:
drawImage in class Graphics

dispose

public void dispose()
Overrides:
dispose in class Graphics

addRenderingHints

public void addRenderingHints(Map hints)
Overrides:
addRenderingHints in class Graphics2D

draw

public void draw(Shape s)
Overrides:
draw in class Graphics2D

drawImage

public boolean drawImage(Image img,
                         AffineTransform xform,
                         ImageObserver obs)
Overrides:
drawImage in class Graphics2D

drawRenderedImage

public void drawRenderedImage(RenderedImage img,
                              AffineTransform xform)
Overrides:
drawRenderedImage in class Graphics2D

drawRenderableImage

public void drawRenderableImage(RenderableImage img,
                                AffineTransform xform)
Overrides:
drawRenderableImage in class Graphics2D

drawImage

public void drawImage(BufferedImage img,
                      BufferedImageOp op,
                      int x,
                      int y)
Overrides:
drawImage in class Graphics2D

drawString

public void drawString(String s,
                       float x,
                       float y)
Overrides:
drawString in class Graphics2D

drawString

public void drawString(AttributedCharacterIterator iterator,
                       int x,
                       int y)
Overrides:
drawString in class Graphics2D

drawString

public void drawString(AttributedCharacterIterator iterator,
                       float x,
                       float y)
Overrides:
drawString in class Graphics2D

drawGlyphVector

public void drawGlyphVector(GlyphVector v,
                            float x,
                            float y)
Overrides:
drawGlyphVector in class Graphics2D

fill

public void fill(Shape s)
Overrides:
fill in class Graphics2D

hit

public boolean hit(Rectangle rect,
                   Shape s,
                   boolean onStroke)
Overrides:
hit in class Graphics2D

getDeviceConfiguration

public GraphicsConfiguration getDeviceConfiguration()
Overrides:
getDeviceConfiguration in class Graphics2D

getFontRenderContext

public FontRenderContext getFontRenderContext()
Overrides:
getFontRenderContext in class Graphics2D

setComposite

public void setComposite(Composite comp)
Overrides:
setComposite in class Graphics2D

setPaint

public void setPaint(Paint paint)
Overrides:
setPaint in class Graphics2D

setStroke

public void setStroke(Stroke s)
Overrides:
setStroke in class Graphics2D

setRenderingHint

public void setRenderingHint(RenderingHints.Key hintKey,
                             Object hintValue)
Overrides:
setRenderingHint in class Graphics2D

getRenderingHint

public Object getRenderingHint(RenderingHints.Key hintKey)
Overrides:
getRenderingHint in class Graphics2D

setRenderingHints

public void setRenderingHints(Map hints)
Overrides:
setRenderingHints in class Graphics2D

getRenderingHints

public RenderingHints getRenderingHints()
Overrides:
getRenderingHints in class Graphics2D

translate

public void translate(int x,
                      int y)
Overrides:
translate in class Graphics2D

translate

public void translate(double x,
                      double y)
Overrides:
translate in class Graphics2D

rotate

public void rotate(double theta)
Overrides:
rotate in class Graphics2D

rotate

public void rotate(double theta,
                   double x,
                   double y)
Overrides:
rotate in class Graphics2D

scale

public void scale(double sx,
                  double sy)
Overrides:
scale in class Graphics2D

shear

public void shear(double shx,
                  double shy)
Overrides:
shear in class Graphics2D

transform

public void transform(AffineTransform Tx)
Overrides:
transform in class Graphics2D

setTransform

public void setTransform(AffineTransform Tx)
Overrides:
setTransform in class Graphics2D

getTransform

public AffineTransform getTransform()
Overrides:
getTransform in class Graphics2D

getPaint

public Paint getPaint()
Overrides:
getPaint in class Graphics2D

getComposite

public Composite getComposite()
Overrides:
getComposite in class Graphics2D

setBackground

public void setBackground(Color color)
Overrides:
setBackground in class Graphics2D

getBackground

public Color getBackground()
Overrides:
getBackground in class Graphics2D

getStroke

public Stroke getStroke()
Overrides:
getStroke in class Graphics2D

clip

public void clip(Shape s)
Overrides:
clip in class Graphics2D

getSources

public Vector getSources()
Specified by:
getSources in interface RenderableImage

getProperty

public Object getProperty(String name)
Specified by:
getProperty in interface RenderableImage

getPropertyNames

public String[] getPropertyNames()
Specified by:
getPropertyNames in interface RenderableImage

isDynamic

public boolean isDynamic()
Specified by:
isDynamic in interface RenderableImage

getWidth

public float getWidth()
Specified by:
getWidth in interface RenderableImage

getHeight

public float getHeight()
Specified by:
getHeight in interface RenderableImage

getMinX

public float getMinX()
Specified by:
getMinX in interface RenderableImage

getMinY

public float getMinY()
Specified by:
getMinY in interface RenderableImage

createScaledRendering

public RenderedImage createScaledRendering(int w,
                                           int h,
                                           RenderingHints hints)
Specified by:
createScaledRendering in interface RenderableImage

createDefaultRendering

public RenderedImage createDefaultRendering()
Specified by:
createDefaultRendering in interface RenderableImage

createRendering

public RenderedImage createRendering(RenderContext renderContext)
Creates a RenderedImage that represents a rendering of this image using a given RenderContext. This is the most general way to obtain a rendering of a RenderableImage.

The created RenderedImage may have a property identified by the String HINTS_OBSERVED to indicate which RenderingHints (from the RenderContext) were used to create the image. In addition any RenderedImages that are obtained via the getSources() method on the created RenderedImage may have such a property.

The bounds of the RenderedImage are determined from the dimensions parameter passed to the RenderableGraphics constructor. These bounds will be transformed by any AffineTransform from the RenderContext. The RenderingHints from the RenderContext may be used to specify the tile width and height, SampleModel, and ColorModel by supplying an ImageLayout hint. The precedence for determining tile width and height is to use firstly values provided explicitly via the ImageLayout, secondly the width and height of the SampleModel in the hint, and thirdly the bounds of the RenderableGraphics object after transformation.

If either the SampleModel or ColorModel is null, an attempt will be made to derive a compatible value for the null object from the non-null object. If they are both null, a 3-band byte TiledImage with a null ColorModel and a PixelInterleavedSampleModel will be created.

Specified by:
createRendering in interface RenderableImage
Parameters:
renderContext - the RenderContext to use to produce the rendering.
Returns:
a RenderedImage containing the rendered data.