[Commit] CairoJava/src/org/cairographics/cairo/internal CairoAPI.java, NONE, 1.1

Soorya Kuloor commit at keithp.com
Wed Aug 6 12:54:06 PDT 2003


Committed by: skuloor

Update of /local/src/CVS/CairoJava/src/org/cairographics/cairo/internal
In directory home.keithp.com:/tmp/cvs-serv20525/src/org/cairographics/cairo/internal

Added Files:
	CairoAPI.java 
Log Message:
Initial checkin

--- NEW FILE: CairoAPI.java ---
/*
 * $Id: CairoAPI.java,v 1.1 2003/08/06 18:54:03 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 DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, 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.internal;

/**
 * This is a wrapper class that defines native methods to call Cairo functions.
 */
public final class CairoAPI {
    static {
        System.loadLibrary("cairoJni");
    }

    /**
     * Creates and returns handle to a new Cairo state object.
     * 
     * @return Handle to a new Cairo state object.
     */
    public static native long create();
    public static native void destroy(long xrs);
    public static native void save(long xrs);
    public static native void restore(long xrs);
    public static native void setTargetSurface(long xrs, long surface);
    public static native void setTargetDrawable(long xrs, long widget);
    public static native void setTargetImage(long xrs, long imageHandle);
    public static native void setOperator(long xrs, short operator);
    public static native void setRGBColor(
        long xrs,
        double red,
        double green,
        double blue);
    public static native void setPattern(long xrs, long surface);
    public static native void setTolerance(long xrs, double tolerance);
    public static native void setAlpha(long xrs, double alpha);

    public static native void setFillRule(long xrs, short fillRule);
    public static native void setLineWidth(long xrs, double width);
    public static native void setLineCap(long xrs, short linecap);
    public static native void setLineJoin(long xrs, short lineJoin);
    public static native void setDash(long xrs, double[] dashes, double offset);
    public static native void setMiterLimit(long xrs, double limit);

    /*
     * Transformation functions
     */
    public static native void translate(long xrs, double tx, double ty);
    public static native void scale(long xrs, double sx, double sy);
    public static native void rotate(long xrs, double angle);
    public static native void setMatrix(long xrs, long matrix);
    public static native void concatMatrix(long xrs, long matrix);
    public static native double[] transformPoint(long xrs, double x, double y);

    /*
     * Affine transform matrix functions
     */
    public static native void defaultMatrix(long xrs);
    public static native void identityMatrix(long xrs);

    public static native short surfaceSetMatrix(long surface, long matrix);

    public static native short surfaceGetMatrix(long surface, long matrix);

    /* Matrix functions */
    public static native long matrixCreate();
    public static native void matrixDestroy(long matrix);
    public static native short matrixCopy(long matrix, long otherMatrix);
    public static native short matrixSetIdentity(long matrix);
    public static native short matrixSetAffine(
        long matrix,
        double a,
        double b,
        double c,
        double d,
        double tx,
        double ty);
    public static native double[] matrixGetAffine(long matrix);
    public static native short matrixTranslate(
        long matrix,
        double tx,
        double ty);
    public static native short matrixScale(long matrix, double sx, double sy);
    public static native short matrixRotate(long matrix, double radians);
    public static native short matrixInvert(long matrix);
    public static native short matrixMultiply(long result, long a, long b);

    public static native double[] matrixTransformDistance(
        long matrix,
        double dx,
        double dy);
    public static native double[] matrixTransformPoint(
        long matrix,
        double x,
        double y);

    /*
     * Filter options
     */
    public final static short FILTER_FAST = 0;
    public final static short FILTER_GOOD = 1;
    public final static short FILTER_BEST = 2;
    public final static short FILTER_NEAREST = 3;
    public final static short FILTER_BILINEAR = 4;

    public static native short surfaceSetFilter(long surface, short filter);

    /*
     * Path creation functions
     */
    public static native void newPath(long xrs);
    public static native void moveTo(long xrs, double x, double y);
    public static native void relMoveTo(long xrs, double tx, double ty);
    public static native void lineTo(long xrs, double x, double y);
    public static native void relLineTo(long xrs, double tx, double ty);
    public static native void curveTo(
        long xrs,
        double x1,
        double y1,
        double x2,
        double y2,
        double x3,
        double y3);
    public static native void relCurveTo(
        long xrs,
        double dx1,
        double dy1,
        double dx2,
        double dy2,
        double dx3,
        double dy3);

    public static native void quadTo(
        long xrs,
        double x1,
        double y1,
        double x2,
        double y2);
    public static native void relQuadTo(
        long xrs,
        double dx1,
        double dy1,
        double dx2,
        double dy2);

    public static native void arcTo(
        long xrs,
        double rx,
        double ry,
        double x_axis_rotation,
        int large_arc_flag,
        int sweep_flag,
        double x,
        double y);

    public static native void relArcTo(
        long xrs,
        double rx,
        double ry,
        double x_axis_rotation,
        int large_arc_flag,
        int sweep_flag,
        double dx,
        double dy);

    public static native void hLineTo(long xrs, double x);
    public static native void relHLineTo(long xrs, double dx);

    public static native void vLineTo(long xrs, double y);
    public static native void relVLineTo(long xrs, double dy);

    public static native void closePath(long xrs);

    /*
     * Painting functions
     */
    public static native void stroke(long xrs);
    public static native void fill(long xrs);
    public static native void clip(long xrs);

    /*
     * Set rectangular clip on a region
     */
    public static native void clipSurface(
        long xrs,
        int x,
        int y,
        int width,
        int height);

    /*
     * Text functions.
     *
     */
    public static native void selectFont(long xrs, String key);
    public static native void scaleFont(long xrs, double scale);
    public static native void transformFont(
        long xrs,
        double a,
        double b,
        double c,
        double d);
    public static native double[] getTextExtents(long xrs, String str);
    public static native void showText(long xrs, String text);

    public static native void showSurface(
        long xrs,
        long surface,
        int width,
        int height);
    public static native long getTargetSurface(long xrs);

    /*
     * Functions to return error status
     *
     */
    public static native short getStatus(long xrs);
    public static native String getStatusString(long xrs);

    /*
     * Surface manipulation functions
     *
     */
    public static native long surfaceCreateForPixmap(long pixmap);
    public static native long surfaceCreateForDrawable(long drawable);
    public static native long surfaceCreateSimilar(
        long neighbor,
        short format,
        int width,
        int height);

    public static native long surfaceCreateSimilarSolid(
        long neighbor,
        short format,
        int width,
        int height,
        double red,
        double green,
        double blue,
        double alpha);
    public static native void surfaceDestroy(long surface);
    public static native short surfaceSetRepeat(long surface, int repeat);

    /*
     * Query functions
     */
    public static native short getOperator(long xrsp);
    public static native double getTolerance(long xrsp);
    public static native double[] getCurrentPoint(long xrsp);
    public static native double getLineWidth(long xrsp);
    public static native short getLineCap(long xrsp);
    public static native short getLineJoin(long xrsp);
    public static native double getMiterLimit(long xrsp);

    /*
     * Image buffer stuff
     */
    public static native long createImage(short format, int width, int height);
    public static native void destroyImage(long image);
    public static native void drawImage(
        long image,
        long widget,
        long gc,
        int src_x,
        int src_y,
        int dst_x,
        int dst_y,
        int width,
        int height);
    public static native long surfaceCreateForImage(long image);
}




More information about the Commit mailing list