gnu.java.awt.peer.gtk

Class CairoGraphics2D

Known Direct Subclasses:
BufferedImageGraphics, CairoSurfaceGraphics, ComponentGraphics

public abstract class CairoGraphics2D
extends Graphics2D

This is an abstract implementation of Graphics2D on Cairo. It should be subclassed for different Cairo contexts. Note for subclassers: Apart from the constructor (see comments below), The following abstract methods must be implemented: Graphics create() GraphicsConfiguration getDeviceConfiguration() copyArea(int x, int y, int width, int height, int dx, int dy) Also, dispose() must be overloaded to free any native datastructures used by subclass and in addition call super.dispose() to free the native cairographics2d structure and cairo_t.

Field Summary

static int
ALPHA_INTERPOLATION_DEFAULT
Native constants for interpolation methods.
static int
ALPHA_INTERPOLATION_QUALITY
Native constants for interpolation methods.
static int
ALPHA_INTERPOLATION_SPEED
Native constants for interpolation methods.
static int
INTERPOLATION_BICUBIC
Native constants for interpolation methods.
static int
INTERPOLATION_BILINEAR
Native constants for interpolation methods.
static int
INTERPOLATION_NEAREST
Native constants for interpolation methods.
protected boolean
shiftDrawCalls
Some operations (drawing rather than filling) require that their coords be shifted to land on 0.5-pixel boundaries, in order to land on "middle of pixel" coordinates and light up complete pixels.

Constructor Summary

CairoGraphics2D()
Constructor does nothing.

Method Summary

void
addRenderingHints(Map<K,V> hints)
protected void
cairoArc(long pointer, double x, double y, double radius, double angle1, double angle2)
Appends an arc to the current path
protected void
cairoClip(long pointer)
Clip current path
protected void
cairoClosePath(long pointer)
Close current path
protected void
cairoCurveTo(long pointer, double x1, double y1, double x2, double y2, double x3, double y3)
Cubic curve-to
protected void
cairoDrawGlyphVector(long pointer, GdkFontPeer font, float x, float y, int n, int[] codes, float[] positions, long[] fontset)
protected void
cairoFill(long pointer, double alpha)
Fill current path
protected void
cairoLineTo(long pointer, double x, double y)
lineTo
protected void
cairoMoveTo(long pointer, double x, double y)
moveTo
protected void
cairoNewPath(long pointer)
New current path
protected void
cairoRectangle(long pointer, double x, double y, double width, double height)
Appends a rectangle to the current path
protected void
cairoResetClip(long pointer)
Clear clip
protected void
cairoRestore(long pointer)
protected void
cairoSave(long pointer)
Save / restore a cairo path
protected void
cairoScale(long pointer, double x, double y)
Scaling method
protected void
cairoSetAntialias(long pointer, boolean aa)
Set antialias.
protected void
cairoSetDash(long pointer, double[] dashes, int ndash, double offset)
Set the dash style
protected void
cairoSetFillRule(long pointer, int cairoFillRule)
Sets the current winding rule in Cairo
protected void
cairoSetFont(long pointer, GdkFontPeer font)
Set the font in cairo.
protected void
cairoSetLine(long pointer, double width, int cap, int join, double miterLimit)
Set the line style, cap, join and miter limit.
protected void
cairoSetMatrix(long pointer, double[] m)
Set the current transform matrix
protected void
cairoSetOperator(long pointer, int cairoOperator)
Set the compositing operator
protected void
cairoSetRGBAColor(long pointer, double red, double green, double blue, double alpha)
Sets the current color in RGBA as a 0.0-1.0 double
protected void
cairoStroke(long pointer)
Stroke current path
void
clearRect(int x, int y, int width, int height)
Note that the rest of the drawing methods go via fill() or draw() for the drawing, although subclasses may with to overload these methods where context-specific optimizations are possible (e.g. bitmaps and fillRect(int, int, int, int)
void
clip(Shape s)
void
clipRect(int x, int y, int width, int height)
void
copy(CairoGraphics2D g, long cairo_t_pointer)
Same as above, but copies the state of another CairoGraphics2D.
void
copyArea(int ox, int oy, int owidth, int oheight, int odx, int ody)
CopyArea - performs clipping to the native surface as a convenience (requires getRealBounds).
protected abstract void
copyAreaImpl(int x, int y, int width, int height, int dx, int dy)
abstract Graphics
create()
These are declared abstract as there may be context-specific issues.
void
dispose()
Disposes the native cairographics2d structure, including the cairo_t and any gradient stuff, if allocated.
void
disposeNative(long pointer)
Dispose of allocate native resouces.
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)
protected void
drawCairoSurface(CairoSurface surface, AffineTransform tx, double alpha, int interpolation)
Optimized method for drawing a CairoSurface onto this graphics context.
void
drawGlyphVector(GlyphVector gv, float x, float y)
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)
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 x, int y, Color bgcolor, ImageObserver observer)
boolean
drawImage(Image img, int x, int y, ImageObserver observer)
protected boolean
drawImage(Image img, AffineTransform xform, Color bgcolor, ImageObserver obs)
boolean
drawImage(Image img, AffineTransform xform, ImageObserver obs)
void
drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
void
drawLine(int x1, int y1, int x2, int y2)
void
drawOval(int x, int y, int width, int height)
protected void
drawPixels(long pointer, int[] pixels, int w, int h, int stride, double[] i2u, double alpha, int interpolation)
Draw pixels as an RGBA int matrix
void
drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
void
drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
void
drawRect(int x, int y, int width, int height)
void
drawRenderableImage(RenderableImage image, AffineTransform xform)
void
drawRenderedImage(RenderedImage image, AffineTransform xform)
void
drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
void
drawString(String str, float x, float y)
void
drawString(String str, int x, int y)
void
drawString(AttributedCharacterIterator ci, float x, float y)
void
drawString(AttributedCharacterIterator ci, int x, int y)
void
fill(Shape s)
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)
void
finalize()
Generic destructor - call the native dispose() method.
static int[]
findSimpleIntegerArray(ColorModel cm, Raster raster)
Used by drawRaster and GdkPixbufDecoder
protected Rectangle
findStrokedBounds(Shape s)
Utility method to find the bounds of a shape, including the stroke width.
Color
getBackground()
protected ColorModel
getBufferCM()
Returns the Color Model describing the buffer that this peer uses for custom composites.
Shape
getClip()
Rectangle
getClipBounds()
protected Rectangle2D
getClipInDevSpace()
Color
getColor()
Composite
getComposite()
Return the current composite.
abstract GraphicsConfiguration
getDeviceConfiguration()
Font
getFont()
FontMetrics
getFontMetrics()
FontMetrics
getFontMetrics(Font f)
FontRenderContext
getFontRenderContext()
Should perhaps be contexct dependent, but this is left for now as an overloadable default implementation.
protected abstract ColorModel
getNativeCM()
Returns the Colour Model describing the native, raw image data for this specific peer.
Paint
getPaint()
protected abstract Rectangle2D
getRealBounds()
Find the bounds of this graphics context, in device space.
Object
getRenderingHint(RenderingHints.Key hintKey)
RenderingHints
getRenderingHints()
Stroke
getStroke()
AffineTransform
getTransform()
boolean
hit(Rectangle rect, Shape s, boolean onStroke)
protected long
init(long pointer)
Allocate the cairographics2d structure and set the cairo_t pointer in it.
void
rotate(double theta)
void
rotate(double theta, double x, double y)
void
scale(double sx, double sy)
void
setBackground(Color c)
void
setClip(int x, int y, int width, int height)
void
setClip(Shape s)
void
setColor(Color c)
void
setComposite(Composite comp)
Sets the current composite context.
protected void
setCustomPaint(Rectangle bounds)
Sets a custom paint
void
setFont(Font f)
protected void
setGradient(long pointer, double x1, double y1, double x2, double y2, int r1, int g1, int b1, int a1, int r2, int g2, int b2, int a2, boolean cyclic)
void
setPaint(Paint p)
void
setPaintMode()
protected void
setPaintPixels(long pointer, int[] pixels, int w, int h, int stride, boolean repeat, int x, int y)
void
setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
void
setRenderingHints(Map hints)
void
setStroke(Stroke st)
void
setTransform(AffineTransform tx)
Set the current transform
void
setXORMode(Color c)
void
setup(long cairo_t_pointer)
Sets up the default values and allocates the native cairographics2d structure
void
shear(double shearX, double shearY)
String
toString()
Convert this Object to a human-readable String.
void
transform(AffineTransform tx)
void
translate(double tx, double ty)
Translate the system of the co-ordinates.
void
translate(int x, int y)

Methods inherited from class java.awt.Graphics2D

addRenderingHints, clip, draw, draw3DRect, drawGlyphVector, drawImage, drawImage, drawRenderableImage, drawRenderedImage, drawString, drawString, drawString, drawString, fill, fill3DRect, getBackground, getComposite, getDeviceConfiguration, getFontRenderContext, getPaint, getRenderingHint, getRenderingHints, getStroke, getTransform, hit, rotate, rotate, scale, setBackground, setComposite, setPaint, setRenderingHint, setRenderingHints, setStroke, setTransform, shear, transform, translate, translate

Methods inherited from class java.awt.Graphics

clearRect, clipRect, copyArea, create, create, dispose, draw3DRect, drawArc, drawBytes, drawChars, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolygon, drawPolyline, drawRect, drawRoundRect, drawString, drawString, fill3DRect, fillArc, fillOval, fillPolygon, fillPolygon, fillRect, fillRoundRect, finalize, getClip, getClipBounds, getClipBounds, getClipRect, getColor, getFont, getFontMetrics, getFontMetrics, hitClip, setClip, setClip, setColor, setFont, setPaintMode, setXORMode, toString, translate

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

ALPHA_INTERPOLATION_DEFAULT

public static final int ALPHA_INTERPOLATION_DEFAULT
Native constants for interpolation methods. Note, this corresponds to an enum in native/jni/gtk-peer/cairographics2d.h
Field Value:
4

ALPHA_INTERPOLATION_QUALITY

public static final int ALPHA_INTERPOLATION_QUALITY
Native constants for interpolation methods. Note, this corresponds to an enum in native/jni/gtk-peer/cairographics2d.h
Field Value:
3

ALPHA_INTERPOLATION_SPEED

public static final int ALPHA_INTERPOLATION_SPEED
Native constants for interpolation methods. Note, this corresponds to an enum in native/jni/gtk-peer/cairographics2d.h
Field Value:
2

INTERPOLATION_BICUBIC

public static final int INTERPOLATION_BICUBIC
Native constants for interpolation methods. Note, this corresponds to an enum in native/jni/gtk-peer/cairographics2d.h
Field Value:
5

INTERPOLATION_BILINEAR

public static final int INTERPOLATION_BILINEAR
Native constants for interpolation methods. Note, this corresponds to an enum in native/jni/gtk-peer/cairographics2d.h
Field Value:
1

INTERPOLATION_NEAREST

public static final int INTERPOLATION_NEAREST
Native constants for interpolation methods. Note, this corresponds to an enum in native/jni/gtk-peer/cairographics2d.h
Field Value:
0

shiftDrawCalls

protected boolean shiftDrawCalls
Some operations (drawing rather than filling) require that their coords be shifted to land on 0.5-pixel boundaries, in order to land on "middle of pixel" coordinates and light up complete pixels.

Constructor Details

CairoGraphics2D

public CairoGraphics2D()
Constructor does nothing.

Method Details

addRenderingHints

public void addRenderingHints(Map<K,V> hints)

cairoArc

protected void cairoArc(long pointer,
                        double x,
                        double y,
                        double radius,
                        double angle1,
                        double angle2)
Appends an arc to the current path

cairoClip

protected void cairoClip(long pointer)
Clip current path

cairoClosePath

protected void cairoClosePath(long pointer)
Close current path

cairoCurveTo

protected void cairoCurveTo(long pointer,
                            double x1,
                            double y1,
                            double x2,
                            double y2,
                            double x3,
                            double y3)
Cubic curve-to

cairoDrawGlyphVector

protected void cairoDrawGlyphVector(long pointer,
                                    GdkFontPeer font,
                                    float x,
                                    float y,
                                    int n,
                                    int[] codes,
                                    float[] positions,
                                    long[] fontset)

cairoFill

protected void cairoFill(long pointer,
                         double alpha)
Fill current path

cairoLineTo

protected void cairoLineTo(long pointer,
                           double x,
                           double y)
lineTo

cairoMoveTo

protected void cairoMoveTo(long pointer,
                           double x,
                           double y)
moveTo

cairoNewPath

protected void cairoNewPath(long pointer)
New current path

cairoRectangle

protected void cairoRectangle(long pointer,
                              double x,
                              double y,
                              double width,
                              double height)
Appends a rectangle to the current path

cairoResetClip

protected void cairoResetClip(long pointer)
Clear clip

cairoRestore

protected void cairoRestore(long pointer)

cairoSave

protected void cairoSave(long pointer)
Save / restore a cairo path

cairoScale

protected void cairoScale(long pointer,
                          double x,
                          double y)
Scaling method

cairoSetAntialias

protected void cairoSetAntialias(long pointer,
                                 boolean aa)
Set antialias.

cairoSetDash

protected void cairoSetDash(long pointer,
                            double[] dashes,
                            int ndash,
                            double offset)
Set the dash style

cairoSetFillRule

protected void cairoSetFillRule(long pointer,
                                int cairoFillRule)
Sets the current winding rule in Cairo

cairoSetFont

protected void cairoSetFont(long pointer,
                            GdkFontPeer font)
Set the font in cairo.

cairoSetLine

protected void cairoSetLine(long pointer,
                            double width,
                            int cap,
                            int join,
                            double miterLimit)
Set the line style, cap, join and miter limit. Cap and join parameters are in the BasicStroke enumerations.

cairoSetMatrix

protected void cairoSetMatrix(long pointer,
                              double[] m)
Set the current transform matrix

cairoSetOperator

protected void cairoSetOperator(long pointer,
                                int cairoOperator)
Set the compositing operator

cairoSetRGBAColor

protected void cairoSetRGBAColor(long pointer,
                                 double red,
                                 double green,
                                 double blue,
                                 double alpha)
Sets the current color in RGBA as a 0.0-1.0 double

cairoStroke

protected void cairoStroke(long pointer)
Stroke current path

clearRect

public void clearRect(int x,
                      int y,
                      int width,
                      int height)
Note that the rest of the drawing methods go via fill() or draw() for the drawing, although subclasses may with to overload these methods where context-specific optimizations are possible (e.g. bitmaps and fillRect(int, int, int, int)
Overrides:
clearRect in interface Graphics

clip

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

clipRect

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

copy

public void copy(CairoGraphics2D g,
                 long cairo_t_pointer)
Same as above, but copies the state of another CairoGraphics2D.

copyArea

public void copyArea(int ox,
                     int oy,
                     int owidth,
                     int oheight,
                     int odx,
                     int ody)
CopyArea - performs clipping to the native surface as a convenience (requires getRealBounds). Then calls copyAreaImpl.
Overrides:
copyArea in interface Graphics

copyAreaImpl

protected abstract void copyAreaImpl(int x,
                                     int y,
                                     int width,
                                     int height,
                                     int dx,
                                     int dy)

create

public abstract Graphics create()
These are declared abstract as there may be context-specific issues.
Overrides:
create in interface Graphics

dispose

public void dispose()
Disposes the native cairographics2d structure, including the cairo_t and any gradient stuff, if allocated. Subclasses should of course overload and call this if they have additional native structures.
Overrides:
dispose in interface Graphics

disposeNative

public void disposeNative(long pointer)
Dispose of allocate native resouces.

draw

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

draw3DRect

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

drawArc

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

drawCairoSurface

protected void drawCairoSurface(CairoSurface surface,
                                AffineTransform tx,
                                double alpha,
                                int interpolation)
Optimized method for drawing a CairoSurface onto this graphics context.
Parameters:
surface - The surface to draw.
tx - The transformation matrix (cannot be null).
alpha - The alpha value to paint with ( 0 <= alpha <= 1).
interpolation - The interpolation type.

drawGlyphVector

public void drawGlyphVector(GlyphVector gv,
                            float x,
                            float y)
Overrides:
drawGlyphVector in interface Graphics2D

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 interface 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 interface Graphics

drawImage

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

drawImage

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

drawImage

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

drawImage

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

drawImage

protected boolean drawImage(Image img,
                            AffineTransform xform,
                            Color bgcolor,
                            ImageObserver obs)

drawImage

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

drawImage

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

drawLine

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

drawOval

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

drawPixels

protected void drawPixels(long pointer,
                          int[] pixels,
                          int w,
                          int h,
                          int stride,
                          double[] i2u,
                          double alpha,
                          int interpolation)
Draw pixels as an RGBA int matrix
Parameters:
w - - width
h - - height
stride - - stride of the array width
i2u - - affine transform array

drawPolygon

public void drawPolygon(int[] xPoints,
                        int[] yPoints,
                        int nPoints)

drawPolyline

public void drawPolyline(int[] xPoints,
                         int[] yPoints,
                         int nPoints)

drawRect

public void drawRect(int x,
                     int y,
                     int width,
                     int height)
Overrides:
drawRect in interface Graphics

drawRenderableImage

public void drawRenderableImage(RenderableImage image,
                                AffineTransform xform)
Overrides:
drawRenderableImage in interface Graphics2D

drawRenderedImage

public void drawRenderedImage(RenderedImage image,
                              AffineTransform xform)
Overrides:
drawRenderedImage in interface Graphics2D

drawRoundRect

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

drawString

public void drawString(String str,
                       float x,
                       float y)
Overrides:
drawString in interface Graphics2D

drawString

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

drawString

public void drawString(AttributedCharacterIterator ci,
                       float x,
                       float y)
Overrides:
drawString in interface Graphics2D

drawString

public void drawString(AttributedCharacterIterator ci,
                       int x,
                       int y)
Overrides:
drawString in interface Graphics2D

fill

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

fillArc

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

fillOval

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

fillPolygon

public void fillPolygon(int[] xPoints,
                        int[] yPoints,
                        int nPoints)

fillRect

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

fillRoundRect

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

finalize

public void finalize()
Generic destructor - call the native dispose() method.
Overrides:
finalize in interface Graphics

findSimpleIntegerArray

public static int[] findSimpleIntegerArray(ColorModel cm,
                                           Raster raster)
Used by drawRaster and GdkPixbufDecoder

findStrokedBounds

protected Rectangle findStrokedBounds(Shape s)
Utility method to find the bounds of a shape, including the stroke width.
Parameters:
s - the shape
Returns:
the bounds of the shape, including stroke width

getBackground

public Color getBackground()
Overrides:
getBackground in interface Graphics2D

getBufferCM

protected ColorModel getBufferCM()
Returns the Color Model describing the buffer that this peer uses for custom composites.
Returns:
ColorModel the ColorModel of the composite buffer in this peer.

getClip

public Shape getClip()
Overrides:
getClip in interface Graphics

getClipBounds

public Rectangle getClipBounds()
Overrides:
getClipBounds in interface Graphics

getClipInDevSpace

protected Rectangle2D getClipInDevSpace()

getColor

public Color getColor()
Overrides:
getColor in interface Graphics

getComposite

public Composite getComposite()
Return the current composite.
Overrides:
getComposite in interface Graphics2D

getDeviceConfiguration

public abstract GraphicsConfiguration getDeviceConfiguration()
Overrides:
getDeviceConfiguration in interface Graphics2D

getFont

public Font getFont()
Overrides:
getFont in interface Graphics

getFontMetrics

public FontMetrics getFontMetrics()
Overrides:
getFontMetrics in interface Graphics

getFontMetrics

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

getFontRenderContext

public FontRenderContext getFontRenderContext()
Should perhaps be contexct dependent, but this is left for now as an overloadable default implementation.
Overrides:
getFontRenderContext in interface Graphics2D

getNativeCM

protected abstract ColorModel getNativeCM()
Returns the Colour Model describing the native, raw image data for this specific peer.
Returns:
ColorModel the ColorModel of native data in this peer

getPaint

public Paint getPaint()
Overrides:
getPaint in interface Graphics2D

getRealBounds

protected abstract Rectangle2D getRealBounds()
Find the bounds of this graphics context, in device space.
Returns:
the bounds in device-space

getRenderingHint

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

getRenderingHints

public RenderingHints getRenderingHints()
Overrides:
getRenderingHints in interface Graphics2D

getStroke

public Stroke getStroke()
Overrides:
getStroke in interface Graphics2D

getTransform

public AffineTransform getTransform()
Overrides:
getTransform in interface Graphics2D

hit

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

init

protected long init(long pointer)
Allocate the cairographics2d structure and set the cairo_t pointer in it.
Parameters:
pointer - - a cairo_t pointer, casted to a long.

rotate

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

rotate

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

scale

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

setBackground

public void setBackground(Color c)
Overrides:
setBackground in interface Graphics2D

setClip

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

setClip

public void setClip(Shape s)
Overrides:
setClip in interface Graphics

setColor

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

setComposite

public void setComposite(Composite comp)
Sets the current composite context.
Overrides:
setComposite in interface Graphics2D

setCustomPaint

protected void setCustomPaint(Rectangle bounds)
Sets a custom paint
Parameters:
bounds - the bounding box, in user space

setFont

public void setFont(Font f)
Overrides:
setFont in interface Graphics

setGradient

protected void setGradient(long pointer,
                           double x1,
                           double y1,
                           double x2,
                           double y2,
                           int r1,
                           int g1,
                           int b1,
                           int a1,
                           int r2,
                           int g2,
                           int b2,
                           int a2,
                           boolean cyclic)

setPaint

public void setPaint(Paint p)
Overrides:
setPaint in interface Graphics2D

setPaintMode

public void setPaintMode()
Overrides:
setPaintMode in interface Graphics

setPaintPixels

protected void setPaintPixels(long pointer,
                              int[] pixels,
                              int w,
                              int h,
                              int stride,
                              boolean repeat,
                              int x,
                              int y)

setRenderingHint

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

setRenderingHints

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

setStroke

public void setStroke(Stroke st)
Overrides:
setStroke in interface Graphics2D

setTransform

public void setTransform(AffineTransform tx)
Set the current transform
Overrides:
setTransform in interface Graphics2D

setXORMode

public void setXORMode(Color c)
Overrides:
setXORMode in interface Graphics

setup

public void setup(long cairo_t_pointer)
Sets up the default values and allocates the native cairographics2d structure
Parameters:
cairo_t_pointer - a native pointer to a cairo_t of the context.

shear

public void shear(double shearX,
                  double shearY)
Overrides:
shear in interface Graphics2D

toString

public String toString()
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() and such.

It is typical, but not required, to ensure that this method never completes abruptly with a RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).

Overrides:
toString in interface Graphics
Returns:
the String representing this Object, which may be null

transform

public void transform(AffineTransform tx)
Overrides:
transform in interface Graphics2D

translate

public void translate(double tx,
                      double ty)
Translate the system of the co-ordinates. As translation is a frequent operation, it is done in an optimised way, unlike scaling and rotating.
Overrides:
translate in interface Graphics2D

translate

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

CairoGraphics2D.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.