[cairo-commit] cairo-java/src/java/org/freedesktop/cairo
RadialGradient.java, NONE, 1.1 Pattern.java, 1.5,
1.6 Gradient.java, NONE, 1.1 SurfacePattern.java, NONE,
1.1 LinearGradient.java, NONE, 1.1
Jeffrey Morgan
commit at pdx.freedesktop.org
Mon May 9 08:38:26 PDT 2005
Committed by: kuzman
Update of /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo
In directory gabe:/tmp/cvs-serv8044a/src/java/org/freedesktop/cairo
Modified Files:
Pattern.java
Added Files:
RadialGradient.java Gradient.java SurfacePattern.java
LinearGradient.java
Log Message:
added pattern hierarchy
--- NEW FILE: RadialGradient.java ---
/*
* Java-Gnome Bindings Library
*
* Copyright 1998-2005 the Java-Gnome Team, all rights reserved.
*
* The Java-Gnome bindings library is free software distributed under
* the terms of the GNU Library General Public License version 2.
*/
package org.freedesktop.cairo;
public class RadialGradient extends Gradient {
public RadialGradient(double x1, double y1, double radius1, double x2, double y2, double radius2) {
super(cairo_pattern_create_radial(x1, y1, radius1, x1, y2, radius2));
}
}
Index: Pattern.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/Pattern.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Pattern.java 9 May 2005 14:47:03 -0000 1.5
+++ Pattern.java 9 May 2005 15:38:24 -0000 1.6
@@ -16,126 +16,58 @@
*/
public class Pattern extends CairoObject {
- public Pattern(Surface surface) {
- super(cairo_pattern_create_for_surface(surface.getHandle()));
- }
-
- public Pattern(double x1, double y1, double x2, double y2) {
- super(cairo_pattern_create_linear(x1, y1, x2, y2));
- }
-
- public Pattern(double x1, double y1, double radius1, double x2, double y2, double radius2) {
- super(cairo_pattern_create_radial(x1, y1, radius1, x1, y2, radius2));
- }
-
- Pattern(Handle hndl) {
- super(hndl);
- }
-
- public void dispose() {
- cairo_pattern_destroy(getHandle());
- }
-
- /**
- * Adds a new color stop to the pattern.
- *
- * @param offset The offset length
- * @param red The value to use for red
- * @param green The value to use for green
- * @param blue The value to use for blue
- */
- public void addColorStop(double offset, double red, double green, double blue) {
- int status = cairo_pattern_add_color_stop_rgb(getHandle(), offset, red,
- green, blue);
- }
-
- /**
- * Adds a new color stop to the pattern.
- *
- * @param offset The offset length
- * @param red The value to use for red
- * @param green The value to use for green
- * @param blue The value to use for blue
- * @param alpha alpha for the color
- */
- public void addColorStop(double offset, double red, double green, double blue, double alpha) {
- int status = cairo_pattern_add_color_stop_rgba(getHandle(), offset, red,
- green, blue, alpha);
- }
-
+ Pattern(Handle hndl) {
+ super(hndl);
+ }
+
+ protected void finalize() throws Throwable {
+ cairo_pattern_destroy(getHandle());
+ super.finalize();
+ }
+
+
/**
* Sets the transformation matrix for this pattern.
- *
* @param matrix The transformation matrix.
*/
- public void setMatrix(Matrix matrix) {
- int status = cairo_pattern_set_matrix(getHandle(), matrix.getHandle());
- }
-
+ public void setMatrix(Matrix matrix) {
+ int status = cairo_pattern_set_matrix(getHandle(), matrix.getHandle());
+ }
+
/**
* 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 Matrix getMatrix() {
- Handle hndl = Struct.getNullHandle();
- int status = cairo_pattern_get_matrix(getHandle(), hndl);
- return new Matrix(hndl);
- }
-
- /**
- * Sets the extend option for the pattern.
- *
- * @param extend The Extend to use.
- */
- public void setExtend(Extend extend) {
- int status = cairo_pattern_set_extend(getHandle(), extend.getValue());
- }
-
- /**
- * Returns the current extend option for the pattern.
- *
- * @return The current extend option
- */
- public Extend getExtend() {
- return Extend.intern(cairo_pattern_get_extend(getHandle()));
- }
-
- /**
- * Sets the filter option for the pattern.
- *
- * @param filter
- */
- public void setFilter(Filter filter) {
- int status = cairo_pattern_set_filter(getHandle(), filter.getValue());
- }
-
- /**
- * Returns the current filter option for the pattern.
- *
- * @return The current filter option (One of the Cairo.FILTER_xxx options).
- */
- public Filter getFilter() {
- return Filter.intern(cairo_pattern_get_filter(getHandle()));
- }
-
+ public Matrix getMatrix() {
+ Handle hndl = Struct.getNullHandle();
+ int status = cairo_pattern_get_matrix(getHandle(), hndl);
+ return new Matrix(hndl);
+ }
+
/*
* Native calls
*/
- native static final private Handle cairo_pattern_create_for_surface(Handle surface);
- native static final private Handle cairo_pattern_create_linear(double x0, double y0, double x1, double y1);
- native static final private Handle cairo_pattern_create_radial(double cx0, double yx0, double radius0, double cx1, double cy1, double radius1);
- native static final private void cairo_pattern_reference(Handle pat);
- native static final private void cairo_pattern_destroy(Handle pat);
- native static final private int cairo_pattern_add_color_stop_rgb(Handle pat, double offset,
- double red, double green, double blue);
- native static final private int cairo_pattern_add_color_stop_rgba(Handle pat, double offset,
- double red, double green, double blue, double alpha);
- native static final private int cairo_pattern_set_matrix(Handle pat, Handle matrix);
- native static final private int cairo_pattern_get_matrix(Handle pat, Handle matrix);
- native static final private int cairo_pattern_set_extend(Handle pat, int extend);
- native static final private int cairo_pattern_get_extend(Handle pat);
- native static final private int cairo_pattern_set_filter(Handle pat, int filter);
- native static final private int cairo_pattern_get_filter(Handle pat);
+ native static final private void cairo_pattern_destroy(Handle pat);
+ native static final private int cairo_pattern_set_matrix(Handle pat, Handle matrix);
+ native static final private int cairo_pattern_get_matrix(Handle pat, Handle matrix);
+
+ // Used by SurfacePattern
+ native static final protected Handle cairo_pattern_create_for_surface(Handle surface);
+ native static final protected int cairo_pattern_set_extend(Handle pat, int extend);
+ native static final protected int cairo_pattern_get_extend(Handle pat);
+ native static final protected int cairo_pattern_set_filter(Handle pat, int filter);
+ native static final protected int cairo_pattern_get_filter(Handle pat);
+
+ // Used by Gradient
+ native static final protected int cairo_pattern_add_color_stop_rgb(Handle pat, double offset,
+ double red, double green, double blue);
+ native static final protected int cairo_pattern_add_color_stop_rgba(Handle pat, double offset,
+ double red, double green, double blue, double alpha);
+
+ // Used by LinearGradient
+ native static final protected Handle cairo_pattern_create_linear(double x0, double y0, double x1, double y1);
+
+ // used by RadialGradient
+ native static final protected Handle cairo_pattern_create_radial(double cx0, double yx0, double radius0, double cx1, double cy1, double radius1);
}
--- NEW FILE: Gradient.java ---
/*
* Java-Gnome Bindings Library
*
* Copyright 1998-2005 the Java-Gnome Team, all rights reserved.
*
* The Java-Gnome bindings library is free software distributed under
* the terms of the GNU Library General Public License version 2.
*/
package org.freedesktop.cairo;
import org.gnu.javagnome.Handle;
public class Gradient extends Pattern {
Gradient(Handle hndl) {
super(hndl);
}
/**
* Adds a new color stop to the pattern.
* @param offset The offset length
* @param red The value to use for red
* @param green The value to use for green
* @param blue The value to use for blue
*/
public void addColorStop(double offset, double red, double green, double blue) {
int status = cairo_pattern_add_color_stop_rgb(getHandle(), offset, red,
green, blue);
}
/**
* Adds a new color stop to the pattern.
* @param offset The offset length
* @param red The value to use for red
* @param green The value to use for green
* @param blue The value to use for blue
* @param alpha alpha for the color
*/
public void addColorStop(double offset, double red, double green, double blue, double alpha) {
int status = cairo_pattern_add_color_stop_rgba(getHandle(), offset, red,
green, blue, alpha);
}
}
--- NEW FILE: SurfacePattern.java ---
/*
* Java-Gnome Bindings Library
*
* Copyright 1998-2005 the Java-Gnome Team, all rights reserved.
*
* The Java-Gnome bindings library is free software distributed under
* the terms of the GNU Library General Public License version 2.
*/
package org.freedesktop.cairo;
public class SurfacePattern extends Pattern {
public SurfacePattern(Surface surface) {
super(cairo_pattern_create_for_surface(surface.getHandle()));
}
/**
* Sets the extend option for the pattern.
* @param extend The Extend to use.
*/
public void setExtend(Extend extend) {
int status = cairo_pattern_set_extend(getHandle(), extend.getValue());
}
/**
* Returns the current extend option for the pattern.
* @return The current extend option
*/
public Extend getExtend() {
return Extend.intern(cairo_pattern_get_extend(getHandle()));
}
/**
* Sets the filter option for the pattern.
* @param filter
*/
public void setFilter(Filter filter) {
int status = cairo_pattern_set_filter(getHandle(), filter.getValue());
}
/**
* Returns the current filter option for the pattern.
* @return The current filter option (One of the Cairo.FILTER_xxx options).
*/
public Filter getFilter() {
return Filter.intern(cairo_pattern_get_filter(getHandle()));
}
}
--- NEW FILE: LinearGradient.java ---
/*
* Java-Gnome Bindings Library
*
* Copyright 1998-2005 the Java-Gnome Team, all rights reserved.
*
* The Java-Gnome bindings library is free software distributed under
* the terms of the GNU Library General Public License version 2.
*/
package org.freedesktop.cairo;
public class LinearGradient extends Gradient {
public LinearGradient(double x1, double y1, double x2, double y2) {
super(cairo_pattern_create_linear(x1, y1, x2, y2));
}
}
More information about the cairo-commit
mailing list