[cairo-commit] CairoJava/src/org/cairographics/cairo CairoLinearPattern.java, NONE, 1.1 CairoPostscriptSurface.java, NONE, 1.1 CairoSWTSurface.java, NONE, 1.1 CairoImageBuffer.java, NONE, 1.1 CairoSurfacePattern.java, NONE, 1.1 FlatPathTracer.java, NONE, 1.1 PathTracer.java, NONE, 1.1 CairoRadialPattern.java, NONE, 1.1 CairoPattern.java, NONE, 1.1 CairoFreetypeFont.java, NONE, 1.1 CairoGlitzSurface.java, NONE, 1.1 CairoImageBufferSurface.java, NONE, 1.1

Soorya Kuloor commit at pdx.freedesktop.org
Fri Apr 30 10:49:26 PDT 2004


Committed by: skuloor

Update of /cvs/cairo/CairoJava/src/org/cairographics/cairo
In directory pdx:/tmp/cvs-serv14483/src/org/cairographics/cairo

Added Files:
	CairoLinearPattern.java CairoPostscriptSurface.java 
	CairoSWTSurface.java CairoImageBuffer.java 
	CairoSurfacePattern.java FlatPathTracer.java PathTracer.java 
	CairoRadialPattern.java CairoPattern.java 
	CairoFreetypeFont.java CairoGlitzSurface.java 
	CairoImageBufferSurface.java 
Log Message:
Split the libcarioJni.cpp files into individual modules.
Did the same for headers.

--- NEW FILE: CairoLinearPattern.java ---
/*
 * $Id: CairoLinearPattern.java,v 1.1 2004/04/30 17:49:24 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
package org.cairographics.cairo;

public class CairoLinearPattern extends CairoPattern {

    /**
     * Creates a linear pattern using the given co-ordinates.
     * 
     * @param x0
     *            The x co-ordinate of the starting point.
     * @param y0
     *            The y co-ordinate of the starting point.
     * @param x1
     *            The x co-ordinate of the end point.
     * @param y1
     *            The y co-ordinate of the end point.
     */
    public CairoLinearPattern(double x0, double y0, double x1, double y1) {
        this.handle = cairo_pattern_create_linear(x0, y0, x1, y1);
    }

    /*
     * Native methods.
     */
    native static long cairo_pattern_create_linear(double x0, double y0,
            double x1, double y1);
}
--- NEW FILE: CairoPostscriptSurface.java ---
/*
 * $Id: CairoPostscriptSurface.java,v 1.1 2004/04/30 17:49:24 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
package org.cairographics.cairo;

public class CairoPostscriptSurface extends CairoSurface {

}

--- NEW FILE: CairoSWTSurface.java ---
/*
 * $Id: CairoSWTSurface.java,v 1.1 2004/04/30 17:49:24 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
package org.cairographics.cairo;

import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Widget;

public class CairoSWTSurface extends CairoSurface {

    public CairoSWTSurface(Image img) {
        this.handle = cairo_swt_image_surface_create(img.pixmap);
    }
    
    public CairoSWTSurface(Widget w) {
        this.handle = cairo_swt_widget_surface_create(w.handle);
    }
    
    static {
        System.loadLibrary("cairoJni");
    }
    native static long cairo_swt_image_surface_create(long pixmap);
    native static long cairo_swt_widget_surface_create(long widget);
}

--- NEW FILE: CairoImageBuffer.java ---
/*
 * $Id: CairoImageBuffer.java,v 1.1 2004/04/30 17:49:24 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
package org.cairographics.cairo;

import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Widget;

/**
 * This class is a wrapper around a local image buffer. This buffer can be used
 * to render into using Cairo when the X server does not support Render
 * extension.
 */
public class CairoImageBuffer {

    /** Native handle */
    long handle = 0;

    /** Image width in number of pixels */
    int width;

    /** Image height in number of pixels */
    int height;

    /**
     * Default constructor. A image must be constructed with width and height
     * arguments. Due to this reason the default ctor is protecte.
     *  
     */
    protected CairoImageBuffer() {
        width = height = 0;
    }

    /**
     * Constructs an image with given format, width and height
     * 
     * @param format
     *            Image format (one of Cairo.FORMAT_xxx options).
     * @param width
     *            The image width in number of pixels
     * @param height
     *            The image height in number of pixels
     */
    public CairoImageBuffer(short format, int width, int height) {
        this.width = width;
        this.height = height;

        handle = image_buffer_create(format, width, height);
    }

    /**
     * Creates an image in FORMAT_ARGB32 format, with given width and height.
     * 
     * @param width
     *            The image width in number of pixels
     * @param height
     *            The image height in number of pixels
     */
    public CairoImageBuffer(int width, int height) {
        this.width = width;
        this.height = height;

        handle = image_buffer_create(Cairo.FORMAT_ARGB32, width, height);
    }

    /**
     * Disposes the image by releasing its native memory and resources.
     *  
     */
    public void dispose() {
        image_buffer_destroy(handle);
        handle = 0;
    }

    /**
     * Draws the image on an SWT graphics context object. The image is drawn at
     * (0,0) location of the graphics context.
     * 
     * @param w
     *            The widget to draw on
     * @param gc
     *            The graphics context
     */
    public void drawOn(Widget w, GC gc) {
        image_buffer_draw(handle, w.handle, gc.handle, 0, 0, 0, 0, width,
                height);
    }

    /**
     * Draws the image on an SWT graphics context object at the given location
     * 
     * @param w
     *            The widget to draw on
     * @param gc
     *            The graphics context
     * @param dest_x
     *            The x co-ordinate of the location to draw the image
     * @param dest_y
     *            The y co-ordinate of the location to draw the image
     */
    public void drawOn(Widget w, GC gc, int dest_x, int dest_y) {
        image_buffer_draw(handle, w.handle, gc.handle, 0, 0, dest_x, dest_y,
                this.width, this.height);
    }

    /**
     * Draws a rectangular part of the the image on an SWT graphics context
     * object at the given location
     * 
     * @param w
     *            The widget to draw on
     * @param gc
     *            The graphics context
     * @param src_x
     *            the image x co-ordinate of the starting point
     * @param src_y
     *            the image y co-ordinate of the starting point
     * @param dest_x
     *            the x co-ordinate of the destination point
     * @param dest_y
     *            the y co-ordinate of the destination point
     * @param wdth
     *            The width of the section of the image to draw
     * @param ht
     *            The height of the section of the image to draw
     */
    public void drawOn(Widget w, GC gc, int src_x, int src_y, int dest_x,
            int dest_y, int wdth, int ht) {
        image_buffer_draw(handle, w.handle, gc.handle, src_x, src_y, dest_x,
                dest_y, wdth, ht);
    }

    /*
     * Native methods
     */
    static {
        System.loadLibrary("cairoJni");
    }
    
    native static long image_buffer_create(short format, int width, int height);

    native static void image_buffer_destroy(long handle);

    native static void image_buffer_draw(long handle, int widget, int gc,
            int src_x, int src_y, int dst_x, int dst_y, int width, int height);
}
--- NEW FILE: CairoSurfacePattern.java ---
/*
 * $Id: CairoSurfacePattern.java,v 1.1 2004/04/30 17:49:24 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
package org.cairographics.cairo;

public class CairoSurfacePattern extends CairoPattern {
    
    /**
     * Creates a new pattern using the given surface.
     * 
     * @param surface The cairo surface to use as pattern.
     */
    public CairoSurfacePattern(CairoSurface surface) {
        cairo_pattern_create_for_surface(surface.handle);
    }
    
    /*
     * Native methods.
     */
    native static long cairo_pattern_create_for_surface (long surface);
}

--- NEW FILE: FlatPathTracer.java ---
/*
 * $Id: FlatPathTracer.java,v 1.1 2004/04/30 17:49:24 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
package org.cairographics.cairo;

public interface FlatPathTracer {
    public void moveTo(double x, double y);
    public void lineTo(double x, double y);
    public void closePath();
}

--- NEW FILE: PathTracer.java ---
/*
 * $Id: PathTracer.java,v 1.1 2004/04/30 17:49:24 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
package org.cairographics.cairo;

public interface PathTracer extends FlatPathTracer {
    public void curveTo(double x1, double y1, double x2, double y2, double x3, double y3);
}

--- NEW FILE: CairoRadialPattern.java ---
/*
 * $Id: CairoRadialPattern.java,v 1.1 2004/04/30 17:49:24 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
package org.cairographics.cairo;

public class CairoRadialPattern extends CairoPattern {

    /**
     * Creates a new cairo radial pattern using the given parameters.
     * 
     * @param cx0 X co-ordinate for the center of first circle.
     * @param cy0 Y co-ordinate for the center of first circle.
     * @param radius0 Radius of the first circle
     * @param cx1 X co-ordinate for the center of second circle.
     * @param cy1 Y co-ordinate for the center of second circle.
     * @param radius1 The radius of the second circle.
     */
    public CairoRadialPattern(double cx0, double cy0,
            double radius0, double cx1, double cy1, double radius1) {
        this.handle = cairo_pattern_create_radial(cx0, cy0, radius0, cx1, cy1, radius1);
    }
    
    /*
     * Native methods.
     */
    native static long cairo_pattern_create_radial(double cx0, double cy0,
            double radius0, double cx1, double cy1, double radius1);
}
--- NEW FILE: CairoPattern.java ---
/*
 * $Id: CairoPattern.java,v 1.1 2004/04/30 17:49:24 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
package org.cairographics.cairo;

public class CairoPattern {

    /* Pattern extend constants */
    public static final short EXTEND_NONE = 0;

    public static final short EXTEND_REPEAT = 1;

    public static final short EXTEND_REFLECT = 2;

    protected long handle = 0;

    /**
     * Default constructor is private. Must create one of specific patterns.
     *  
     */
    protected CairoPattern() {
    }

    /**
     * Create a pattern object, given its native handle.
     * 
     * @param handle The native handle of the pattern.
     */
    CairoPattern(long handle) {
        this.handle = handle;
    }

    /**
     * Increments the reference count on the font object. This is done so that the native pointer
     * does not get freed prematurely.
     */
    public void ref() {
        cairo_pattern_reference(handle);
    }

    /**
     * Decrements the reference count.
     */
    public void unref() {
        dispose();
    }

    /**
     * Disposes the font if no one in refering to the object, else decrements the reference count.
     *
     */
    public void dispose() {
        cairo_pattern_destroy(handle);
    }
    
    /**
     * Adds a new color stop to the pattern.
     * 
     * @param offset The offset length
     * @param red red component of the color
     * @param green green component of the color
     * @param blue blue component of the color
     * @param alpha alpha for the color
     */
    public void addColorStop(double offset, double red, double green, double blue, double alpha) {
        cairo_pattern_add_color_stop(handle, offset, red, blue, green, alpha);
    }
    
    /**
     * Sets the transformation matrix for this pattern.
     * 
     * @param matrix The transformation matrix.
     */
    public void setTransform(CairoMatrix matrix) {
        cairo_pattern_set_matrix(handle, matrix.handle);
    }
    
    /**
     * Returns the current transform matrix of this pattern. Note that this method returns a
     * new matrix object and you must dispose it.
     * 
     * @return The transformation matrix for the pattern.
     */
    public CairoMatrix getTransform() {
        CairoMatrix mat = new CairoMatrix();
        cairo_pattern_get_matrix(handle, mat.handle);
        return mat;
    }
    
    /**
     * Sets the extend option for the pattern.
     * 
     * @param extend One of the EXTEND_xxx options. 
     */
    public void setExtend(short extend) {
        cairo_pattern_set_extend(handle, extend);
    }
    
    /**
     * Returns the current extend option for the pattern.
     * 
     * @return The current extend option (One of the EXTEND_xxx options).
     */
    public short getExtend() {
        return cairo_pattern_get_extend(handle);
    }
    
    /**
     * Sets the filter option for the pattern.
     * 
     * @param filter One of the Cairo.FILTER_xxx options. 
     */
    public void setFilter(short filter) {
        cairo_pattern_set_filter(handle, filter);
    }
    
    /**
     * Returns the current filter option for the pattern.
     * 
     * @return The current filter option (One of the Cairo.FILTER_xxx options).
     */
    public short getFilter() {
        return cairo_pattern_get_filter(handle);
    }
    
    
    /*
     * Native method that correspond to cairo C functions.
     */
    native static void cairo_pattern_reference(long pattern);
    native static void cairo_pattern_destroy(long pattern);
    native static void cairo_pattern_add_color_stop(long pattern,
            double offset, double red, double green, double blue, double alpha);
    native static void cairo_pattern_set_matrix(long pattern, long matrix);
    native static void cairo_pattern_get_matrix(long pattern, long matrix);
    native static void cairo_pattern_set_extend(long pattern, short extend);
    native static short cairo_pattern_get_extend(long pattern);
    native static void cairo_pattern_set_filter(long pattern, short filter);
    native static short cairo_pattern_get_filter(long pattern);
}
--- NEW FILE: CairoFreetypeFont.java ---
/*
 * $Id: CairoFreetypeFont.java,v 1.1 2004/04/30 17:49:24 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
package org.cairographics.cairo;


public class CairoFreetypeFont extends CairoFont {

    /**
     * Creates a new freetype font using the given parameters.
     * 
     * @param family The font family
     * @param slant Font slant, one of CairoFont.SLANT_XXX constants.
     * @param weight Font weight, one of CairoFont.WEIGHT_XXX constants.
     */
    public CairoFreetypeFont(String family, short slant, short weight) {
        this.handle = cairo_ft_font_create(family, slant, weight);
    }
    
    /**
     * Creates a new freetype font using given font parameters. In this version of constructor, the
     * font slant and weight parameters are strings.
     * 
     * @param family The font family
     * @param slant Font slant, such as italic, normal, oblique.
     * @param weight Font weight, such as bold, normal, narrow.
     */
    public CairoFreetypeFont(String family, String slant, String weight) {
        this.handle = cairo_ft_font_create(family, slant, weight);
    }
       
    /*
     * Native methods
     */
    native static long cairo_ft_font_create (String family, short slant, short weight);

    native static long cairo_ft_font_create (String family, String slant, String weight);

    //native static void cairo_ft_font_destroy (long ft_font);
}

--- NEW FILE: CairoGlitzSurface.java ---
/*
 * $Id: CairoGlitzSurface.java,v 1.1 2004/04/30 17:49:24 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
package org.cairographics.cairo;

import org.eclipse.swt.widgets.Widget;

public class CairoGlitzSurface extends CairoSurface {

    public CairoGlitzSurface(Widget w) {
        this.handle = glitz_glx_surface_create_for_window(w.handle);
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.cairographics.cairo.CairoSurface#makeTarget(org.cairographics.cairo.Cairo)
     */
    void makeTarget(Cairo cairo) {
        cairo_set_target_gl(cairo.handle, handle);
    }

    public void flush(int x, int y, int width, int height) {
        glitz_glx_surface_flush(handle, x, y, width, height);
    }
    
    /*
     * Native methods
     */
    static {
        System.loadLibrary("cairoJni");
    }

    native static void cairo_set_target_gl(long cr, long surface);

    /*
     * native static long glitz_glx_surface_create(long display, int screen,
     * short[] format, int width, int height);
     */

    native static long glitz_glx_surface_create_for_window(long window);

    native static void glitz_glx_surface_flush(long surface, int x, int y,
            int width, int height);
}
--- NEW FILE: CairoImageBufferSurface.java ---
/*
 * $Id: CairoImageBufferSurface.java,v 1.1 2004/04/30 17:49:24 skuloor Exp $
 * 
 * Copyright (C) 2003 Verano
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Verano not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Verano makes no representations about the suitability of this software for
 * any purpose. It is provided "as is" without express or implied warranty.
 * 
 * VERANO MAKES NO REPRESENTATIONS OR WARRANTIES OR COVENANTS, EITHER EXPRESS OR
 * IMPLIED, WITH RESPECT TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * STATUTORY OR IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR ARISING FROM CUSTOM, COURSE
 * OF DEALING, USAGE OF TRADE OR COURSE OF PERFORMANCE, ALL OF WHICH ARE
 * EXPRESSLY DISCLAIMED TO THE FULLEST EXTENT ALLOWABLE BY APPLICABLE LAW. IN NO
 * EVENT SHALL VERANO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
package org.cairographics.cairo;

public class CairoImageBufferSurface extends CairoSurface {
    
    /**
     * Creates a new surface for the given image buffer.
     * 
     * @param buff The image buffer for which the drawing surface is to be created.
     */
    public CairoImageBufferSurface(CairoImageBuffer buff) {
        this.handle = cairo_image_buffer_surface_create(buff.handle);
    }
    
    /*
     * Native methods.
     */
    native static long cairo_image_buffer_surface_create(long buffHandle);
}





More information about the cairo-commit mailing list