gnu.java.awt.peer.gtk

Class CairoSurface


public class CairoSurface
extends WritableRaster

CairoSurface - wraps a Cairo surface.

Field Summary

Fields inherited from class java.awt.image.Raster

dataBuffer, height, minX, minY, numBands, numDataElements, parent, sampleModel, sampleModelTranslateX, sampleModelTranslateY, width

Constructor Summary

CairoSurface(int width, int height)
Create a cairo_surface_t with specified width and height.
CairoSurface(int x, int y, int width, int height)
CairoSurface(SampleModel sm, CairoSurface parent, Rectangle bounds, Point origin)
Create a Cairo Surface that is a subimage of another Cairo Surface

Method Summary

void
copyAreaNative(int x, int y, int width, int height, int dx, int dy, int stride)
Copy a portion of this surface to another area on the surface.
protected static SampleModel
createCairoSampleModel(int w, int h)
Creates a SampleModel that matches Cairo's native format
Raster
createChild(int parentX, int parentY, int width, int height, int childMinX, int childMinY, int[] bandList)
WritableRaster
createCompatibleWritableRaster()
WritableRaster
createCompatibleWritableRaster(int x, int y, int w, int h)
Raster
createTranslatedChild(int childMinX, int childMinY)
WritableRaster
createWritableChild(int parentX, int parentY, int w, int h, int childMinX, int childMinY, int[] bandList)
WritableRaster
createWritableTranslatedChild(int x, int y)
void
dispose()
Dispose of the native data.
protected void
finalize()
Call dispose() to clean up any native resources allocated.
static BufferedImage
getBufferedImage(CairoSurface surface)
Returns a BufferedImage backed by a Cairo surface.
static BufferedImage
getBufferedImage(GtkImage image)
Returns a BufferedImage backed by a Cairo surface, created from a GtkImage.
static BufferedImage
getBufferedImage(int width, int height)
Returns a BufferedImage backed by a Cairo surface.
int[]
getData()
Convenience method to quickly grab the data array backing this Raster.
Graphics2D
getGraphics()
Return a Graphics2D drawing to the CairoSurface.
GtkImage
getGtkImage()
Return a GtkImage from this Cairo surface.
static boolean
isCompatibleColorModel(ColorModel cm)
Returns whether this ColorModel is compatible with Cairo's native types.
static boolean
isCompatibleSampleModel(SampleModel sm)
Returns whether this SampleModel is compatible with Cairo's native types.
void
nativeDrawSurface(long surfacePointer, long contextPointer, double[] i2u, double alpha, int interpolation)
Draws this image to a given CairoGraphics context, with an affine transform given by i2u.
long
newCairoContext()

Methods inherited from class java.awt.image.WritableRaster

createChild, createWritableChild, createWritableTranslatedChild, getWritableParent, setDataElements, setDataElements, setDataElements, setPixel, setPixel, setPixel, setPixels, setPixels, setPixels, setRect, setRect, setSample, setSample, setSample, setSamples, setSamples, setSamples

Methods inherited from class java.awt.image.Raster

createBandedRaster, createBandedRaster, createBandedRaster, createChild, createCompatibleWritableRaster, createCompatibleWritableRaster, createCompatibleWritableRaster, createCompatibleWritableRaster, createInterleavedRaster, createInterleavedRaster, createInterleavedRaster, createPackedRaster, createPackedRaster, createPackedRaster, createPackedRaster, createRaster, createTranslatedChild, createWritableRaster, createWritableRaster, getBounds, getDataBuffer, getDataElements, getDataElements, getHeight, getMinX, getMinY, getNumBands, getNumDataElements, getParent, getPixel, getPixel, getPixel, getPixels, getPixels, getPixels, getSample, getSampleDouble, getSampleFloat, getSampleModel, getSampleModelTranslateX, getSampleModelTranslateY, getSamples, getSamples, getSamples, getTransferType, getWidth, toString

Methods inherited from class java.lang.Object

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

Constructor Details

CairoSurface

public CairoSurface(int width,
                    int height)
Create a cairo_surface_t with specified width and height. The format will be ARGB32 with premultiplied alpha and native bit and word ordering.

CairoSurface

public CairoSurface(int x,
                    int y,
                    int width,
                    int height)

CairoSurface

public CairoSurface(SampleModel sm,
                    CairoSurface parent,
                    Rectangle bounds,
                    Point origin)
Create a Cairo Surface that is a subimage of another Cairo Surface

Method Details

copyAreaNative

public void copyAreaNative(int x,
                           int y,
                           int width,
                           int height,
                           int dx,
                           int dy,
                           int stride)
Copy a portion of this surface to another area on the surface. The given parameters must be within bounds - count on a segfault otherwise.
Parameters:
x - The x coordinate of the area to be copied from.
y - The y coordinate of the area to be copied from.
width - The width of the area to be copied.
height - The height of the area to be copied.
dx - The destination x coordinate.
dy - The destination y coordinate.
stride - The scanline stride.

createCairoSampleModel

protected static SampleModel createCairoSampleModel(int w,
                                                    int h)
Creates a SampleModel that matches Cairo's native format

createChild

public Raster createChild(int parentX,
                          int parentY,
                          int width,
                          int height,
                          int childMinX,
                          int childMinY,
                          int[] bandList)
Overrides:
createChild in interface WritableRaster

createCompatibleWritableRaster

public WritableRaster createCompatibleWritableRaster()
Overrides:
createCompatibleWritableRaster in interface Raster

createCompatibleWritableRaster

public WritableRaster createCompatibleWritableRaster(int x,
                                                     int y,
                                                     int w,
                                                     int h)
Overrides:
createCompatibleWritableRaster in interface Raster

createTranslatedChild

public Raster createTranslatedChild(int childMinX,
                                    int childMinY)
Overrides:
createTranslatedChild in interface Raster

createWritableChild

public WritableRaster createWritableChild(int parentX,
                                          int parentY,
                                          int w,
                                          int h,
                                          int childMinX,
                                          int childMinY,
                                          int[] bandList)
Overrides:
createWritableChild in interface WritableRaster

createWritableTranslatedChild

public WritableRaster createWritableTranslatedChild(int x,
                                                    int y)
Overrides:
createWritableTranslatedChild in interface WritableRaster

dispose

public void dispose()
Dispose of the native data.

finalize

protected void finalize()
Call dispose() to clean up any native resources allocated.
Overrides:
finalize in interface Object

getBufferedImage

public static BufferedImage getBufferedImage(CairoSurface surface)
Returns a BufferedImage backed by a Cairo surface.

getBufferedImage

public static BufferedImage getBufferedImage(GtkImage image)
Returns a BufferedImage backed by a Cairo surface, created from a GtkImage.

getBufferedImage

public static BufferedImage getBufferedImage(int width,
                                             int height)
Returns a BufferedImage backed by a Cairo surface.

getData

public int[] getData()
Convenience method to quickly grab the data array backing this Raster.
Returns:
The array behind the databuffer.

getGraphics

public Graphics2D getGraphics()
Return a Graphics2D drawing to the CairoSurface.

getGtkImage

public GtkImage getGtkImage()
Return a GtkImage from this Cairo surface.

isCompatibleColorModel

public static boolean isCompatibleColorModel(ColorModel cm)
Returns whether this ColorModel is compatible with Cairo's native types.
Parameters:
cm - The color model to check.
Returns:
Whether it is compatible.

isCompatibleSampleModel

public static boolean isCompatibleSampleModel(SampleModel sm)
Returns whether this SampleModel is compatible with Cairo's native types.
Parameters:
sm - The sample model to check.
Returns:
Whether it is compatible.

nativeDrawSurface

public void nativeDrawSurface(long surfacePointer,
                              long contextPointer,
                              double[] i2u,
                              double alpha,
                              int interpolation)
Draws this image to a given CairoGraphics context, with an affine transform given by i2u.

newCairoContext

public long newCairoContext()

CairoSurface.java Copyright (C) 2006, 2007 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.