[cairo-commit] cairo-java/src/java/org/freedesktop/cairo Cairo.java, 1.14, 1.15 Pattern.java, 1.2, 1.3 PngSurface.java, 1.7, 1.8

Jeffrey Morgan commit at pdx.freedesktop.org
Sat Apr 23 09:48:30 PDT 2005


Committed by: kuzman

Update of /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo
In directory gabe:/tmp/cvs-serv27983/src/java/org/freedesktop/cairo

Modified Files:
	Cairo.java Pattern.java PngSurface.java 
Log Message:
updated methods to reflect upstream API changes.

Index: Cairo.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/Cairo.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Cairo.java	11 Apr 2005 00:47:21 -0000	1.14
+++ Cairo.java	23 Apr 2005 16:48:28 -0000	1.15
@@ -98,6 +98,16 @@
 	}
 	
 	/**
+	 *  Sets the source pattern within the Cairo object. This pattern
+	 *  will then be used for any subsequent drawing operation until 
+	 *  a new source pattern is set.
+	 * @param pattern
+	 */
+	public void setSource(Pattern pattern) {
+		cairo_set_source(getHandle(), pattern.getHandle());
+	}
+	
+	/**
 	 * Sets a constant color for filling and stroking.
 	 * The color components are floating point numbers in the
 	 * range 0 to 1. If the values passed in are outside that range,
@@ -106,8 +116,8 @@
 	 * @param green
 	 * @param blue
 	 */
-	public void setRGBColor(double red, double green, double blue) {
-		cairo_set_rgb_color(getHandle(), red, green, blue);
+	public void setSourceRGB(double red, double green, double blue) {
+		cairo_set_source_rgb(getHandle(), red, green, blue);
 	}
 	
 	/**
@@ -116,26 +126,36 @@
 	 * range 0 to 1. If the values passed in are outside that range,
 	 * they will be clamped.
 	 */
-	public void setRGBColor(RGBColor color) {
-		setRGBColor(color.getRed(), color.getGreen(), color.getBlue());
+	public void setSourceRGB(RGBColor color) {
+		setSourceRGB(color.getRed(), color.getGreen(), color.getBlue());
 	}
 	
 	/**
-	 * Sets the pattern for filling and stroking.
-	 * @param pattern
+	 * Sets the source pattern within this Cairo object to a 
+	 * translucent color. This color will then be used for any 
+	 * subsequent drawing operation until a new source pattern is set.
+	 * 
+	 * The color and alpha components are floating point numbers in the
+	 * range 0 to 1. If the values passed in are outside that range, they
+	 * will be clamped.
+	 * @param red
+	 * @param green
+	 * @param blue
+	 * @param alpha
 	 */
-	public void setPattern(Pattern pattern) {
-		cairo_set_pattern(getHandle(), pattern.getHandle());
+	public void setSourceRGBA(double red, double green, double blue, double alpha) {
+		cairo_set_source_rgba(getHandle(), red, green, blue, alpha);
 	}
 	
 	/**
-	 * Sets an overall alpha value used for stroking and filling.
-	 * This value is multiplied with any alpha value coming from
-	 * a gradient or image pattern.
+	 * Sets the source pattern within this Cairo object to a 
+	 * translucent color. This color will then be used for any 
+	 * subsequent drawing operation until a new source pattern is set.
+	 * @param color
 	 * @param alpha
 	 */
-	public void setAlpha(double alpha) {
-		cairo_set_alpha(getHandle(), alpha);
+	public void setSourceRGBA(RGBColor color, double alpha) {
+		setSourceRGBA(color.getRed(), color.getGreen(), color.getBlue(), alpha);
 	}
 	
 	/**
@@ -598,6 +618,14 @@
 		cairo_close_path(getHandle());
 	}
 	
+	/**
+	 * A drawing operator that paints the current source everywhere 
+	 * within the current clip region.
+	 */
+	public void paint() {
+		cairo_paint(getHandle());
+	}
+	
     /**
      * Strokes the current path.
      *  
@@ -799,8 +827,12 @@
 		return new RGBColor(red[0], green[0], blue[0]);
 	}
 
-	public Pattern getPattern() {
-		Handle hndl = cairo_get_pattern(getHandle());
+	/**
+	 * Gets the current source pattern for this object.
+	 * @return
+	 */
+	public Pattern getSource() {
+		Handle hndl = cairo_get_source(getHandle());
 		return new Pattern(hndl);
 	}
 	
@@ -1032,9 +1064,9 @@
 	native static final private void cairo_copy(Handle obj, Handle src);
 	native static final void cairo_set_target_surface(Handle obj, Handle surface);
 	native static final private void cairo_set_operator(Handle obj, int operator);
-	native static final private void cairo_set_rgb_color(Handle obj, double red, double green, double blue);
-	native static final private void cairo_set_pattern(Handle obj, Handle pattern);
-	native static final private void cairo_set_alpha(Handle obj, double alpha);
+	native static final private void cairo_set_source(Handle obj, Handle pattern);
+	native static final private void cairo_set_source_rgb(Handle obj, double red, double green, double blue);
+	native static final private void cairo_set_source_rgba(Handle object, double red, double green, double glue, double alpha);
 	native static final private void cairo_set_tolerance(Handle obj, double tolerance);
 	native static final private void cairo_set_fill_rule(Handle obj, int fillRule);
 	native static final private void cairo_set_line_width(Handle obj, double width);
@@ -1072,6 +1104,7 @@
 	native static final private void cairo_arc_negative(Handle obj, double xc, double yc, double radius, double angle1, double angle2);
 	native static final private void cairo_rectangle(Handle obj, double x, double y, double width, double height);
 	native static final private void cairo_close_path(Handle obj);
+	native static final private void cairo_paint(Handle obj);
 	native static final private void cairo_stroke(Handle obj);
 	native static final private void cairo_fill(Handle obj);
 	native static final private void cairo_copy_page(Handle obj);
@@ -1085,7 +1118,6 @@
 	native static final private void cairo_select_font_face(Handle obj, String family, int slant, int weight);
 	native static final private void cairo_set_font_size(Handle obj, double scale);
 	native static final private void cairo_set_font_matrix(Handle obj, Handle matrix);
-	//native static final private Handle cairo_get_font_matrix(Handle obj, Handle matrix);
 	native static final private void cairo_show_text(Handle obj, String utf8);
 	native static final private void cairo_show_glyphs(Handle obj, Handle[] glyphs);
 	native static final private Handle cairo_get_font_face(Handle obj);
@@ -1098,7 +1130,7 @@
 	native static final private void cairo_show_surface(Handle obj, Handle surface, int width, int height);
 	native static final private int cairo_get_operator(Handle obj);
 	native static final private void cairo_get_rgb_color(Handle obj, double[] red, double[] green, double[] blue);
-	native static final private Handle cairo_get_pattern(Handle obj);
+	native static final private Handle cairo_get_source(Handle obj);
 	native static final private double cairo_get_alpha(Handle obj);
 	native static final private double cairo_get_tolerance(Handle obj);
 	native static final private void cairo_get_current_point(Handle obj, double[] x, double[] y);

Index: Pattern.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/Pattern.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Pattern.java	24 Mar 2005 18:11:40 -0000	1.2
+++ Pattern.java	23 Apr 2005 16:48:28 -0000	1.3
@@ -41,10 +41,21 @@
      * 
      * @param offset The offset length
      * @param color The color to use
+     */
+	public void addColorStop(double offset, RGBColor color) {
+		int status = cairo_pattern_add_color_stop_rgb(getHandle(), offset, color.getRed(),
+					color.getGreen(), color.getBlue());
+	}
+	
+    /**
+     * Adds a new color stop to the pattern.
+     * 
+     * @param offset The offset length
+     * @param color The color to use
      * @param alpha alpha for the color
      */
 	public void addColorStop(double offset, RGBColor color, double alpha) {
-		int status = cairo_pattern_add_color_stop(getHandle(), offset, color.getRed(),
+		int status = cairo_pattern_add_color_stop_rgba(getHandle(), offset, color.getRed(),
 					color.getGreen(), color.getBlue(), alpha);
 	}
 	
@@ -113,8 +124,10 @@
 	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(Handle pat, double offset,
-				double red, double green, double blue, double alpha);
+	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);

Index: PngSurface.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/PngSurface.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- PngSurface.java	11 Apr 2005 00:47:21 -0000	1.7
+++ PngSurface.java	23 Apr 2005 16:48:28 -0000	1.8
@@ -18,8 +18,6 @@
 public class PngSurface extends ImageSurface {
 	
 	private String filename;
-//	private int width;
-//	private int height;
 
 	/**
 	 * Construct a new PngSurface initializing it with the contents
@@ -34,6 +32,11 @@
 		super(format, width, height);
 	}
 	
+	/**
+	 * Writes the image surface to the file identifyed by filename.
+	 * @param filename
+	 * @throws IOException
+	 */
 	public void write(String filename) throws IOException {
 		checkFile(filename);
 		this.filename = filename;
@@ -45,9 +48,7 @@
 
 		checkFile(filename);
 		
-		int[] w = new int[1];
-		int[] h = new int[1];
-		return cairo_image_surface_create_for_png(filename, w, h);
+		return cairo_image_surface_create_for_png(filename);
 	}
 	
 	private static void checkFile(String filename) throws IOException {
@@ -60,7 +61,6 @@
 	/*
 	 * Native calls
 	 */
-	native static final private Handle cairo_image_surface_create_for_png(String filename, 
-				int[] width, int[] height);
+	native static final private Handle cairo_image_surface_create_for_png(String filename); 
 	native static final private int cairo_surface_write_png(Handle surface, String filename);
 }




More information about the cairo-commit mailing list