[cairo-commit] cairo-java/src/java/org/freedesktop/cairo Matrix.java, 1.8, 1.9 ScaledFont.java, 1.1, 1.2 Pattern.java, 1.4, 1.5 Box.java, 1.1, NONE Context.java, 1.4, 1.5 Surface.java, 1.9, 1.10 ImageSurface.java, 1.9, 1.10 FontExtents.java, 1.2, 1.3 RGBColor.java, 1.1, NONE Distance.java, 1.2, NONE Rectangle.java, NONE, 1.1 FontFace.java, 1.2, 1.3 Glyph.java, 1.4, 1.5

Jeffrey Morgan commit at pdx.freedesktop.org
Mon May 9 07:47:10 PDT 2005


Committed by: kuzman

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

Modified Files:
	Matrix.java ScaledFont.java Pattern.java Context.java 
	Surface.java ImageSurface.java FontExtents.java FontFace.java 
	Glyph.java 
Added Files:
	Rectangle.java 
Removed Files:
	Box.java RGBColor.java Distance.java 
Log Message:
Continued API restructuring and cleanup

Index: Matrix.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/Matrix.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Matrix.java	7 May 2005 00:46:23 -0000	1.8
+++ Matrix.java	9 May 2005 14:47:03 -0000	1.9
@@ -79,11 +79,11 @@
 	/**
 	 * Transforms the given distance and returns transformed co-ordinates
 	 */
-	public Distance transformDistance(Distance d) {
-		double[] dx = new double[] { d.getDX() };
-		double[] dy = new double[] { d.getDY() };
+	public Point transformDistance(Point distance) {
+		double[] dx = new double[] { distance.getX() };
+		double[] dy = new double[] { distance.getY() };
 		cairo_matrix_transform_distance(getHandle(), dx, dy);
-		return new Distance(dx[0], dy[0]);
+		return new Point(dx[0], dy[0]);
 	}
 
 	/**

Index: ScaledFont.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/ScaledFont.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ScaledFont.java	23 Apr 2005 19:25:56 -0000	1.1
+++ ScaledFont.java	9 May 2005 14:47:03 -0000	1.2
@@ -25,8 +25,13 @@
 	public ScaledFont(FontFace fontFace, Matrix matrix, Matrix ctm) {
 		super(cairo_scaled_font_create(fontFace.getHandle(), matrix.getHandle(), ctm.getHandle()));
 	}
-	
-	ScaledFont(Handle hndl) {
+    
+    protected void finalize() throws Throwable {
+        cairo_scaled_font_destroy(getHandle());
+        super.finalize();
+    }
+
+    ScaledFont(Handle hndl) {
 		super(hndl);
 	}
 	
@@ -38,5 +43,12 @@
 	
 	native static final private Handle cairo_scaled_font_create(Handle face, Handle matrix, Handle ctm);
 	native static final private int cairo_scaled_font_extents(Handle obj, Handle extents);
+    
+    // TODO:
+    native static final private void cairo_scaled_font_glyph_extents(Handle obj, Handle[] glyphs, Handle extents);
+    
+    // TODO: lifecycle
+    native static final private void cairo_scaled_font_reference(Handle obj);
+    native static final private void cairo_scaled_font_destroy(Handle obj);
 
 }

Index: Pattern.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/Pattern.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Pattern.java	7 May 2005 00:46:23 -0000	1.4
+++ Pattern.java	9 May 2005 14:47:03 -0000	1.5
@@ -40,23 +40,27 @@
      * Adds a new color stop to the pattern.
      * 
      * @param offset The offset length
-     * @param color The color to use
+     * @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, RGBColor color) {
-		int status = cairo_pattern_add_color_stop_rgb(getHandle(), offset, color.getRed(),
-					color.getGreen(), color.getBlue());
+	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 color The color to use
+     * @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, RGBColor color, double alpha) {
-		int status = cairo_pattern_add_color_stop_rgba(getHandle(), offset, color.getRed(),
-					color.getGreen(), color.getBlue(), alpha);
+	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);
 	}
 	
     /**

--- Box.java DELETED ---

Index: Context.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/Context.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Context.java	7 May 2005 00:27:02 -0000	1.4
+++ Context.java	9 May 2005 14:47:03 -0000	1.5
@@ -14,10 +14,15 @@
 public class Context extends CairoObject {
 	
 	/**
-	 * Create a new cairo target (cairo_t) 
+     * Creates a new Context with all graphics state parameters set to
+     * default values and with target as a target surface. The target
+     * surface should be constructed with a backend-specific function such
+     * as ImageSurface.create.
+     *  
+     *  @param target target surface for the context.
 	 */
-	public Context(Surface surface) {
-		super(cairo_create(surface.getHandle()));
+	public Context(Surface target) {
+		super(cairo_create(target.getHandle()));
 	}
 	
     Context(Handle hndl) {
@@ -26,13 +31,13 @@
 
     /**
      * Disposes all the native resources used by the object.
-     *  
      */
-    public void dispose() {
+    protected void finalize() throws Throwable {
         cairo_destroy(getHandle());
+        super.finalize();
     }
 
-	/**
+    /**
 	 * Makes a copy of the current state and saves it
 	 * on an internal stack of saved states.
 	 * When {@link #restore()} is called, the saved state will be restored.
@@ -53,7 +58,8 @@
 	}
     
 	/**
-	 * Sets the drawing operator. 
+     * Sets the compositing operator to be used for all drawing
+     * operations.  
 	 * @param op
 	 */
 	public void setOperator(Operator op) {
@@ -84,16 +90,6 @@
 	}
 	
 	/**
-	 * 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,
-	 * they will be clamped.
-	 */
-	public void setSourceRGB(RGBColor color) {
-		setSourceRGB(color.getRed(), color.getGreen(), color.getBlue());
-	}
-	
-	/**
 	 * 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.
@@ -109,20 +105,14 @@
 	public void setSourceRGBA(double red, double green, double blue, double alpha) {
 		cairo_set_source_rgba(getHandle(), red, green, blue, alpha);
 	}
-	
-	/**
-	 * 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 setSourceRGBA(RGBColor color, double alpha) {
-		setSourceRGBA(color.getRed(), color.getGreen(), color.getBlue(), alpha);
-	}
 
-	
-	public void setSourceSurface(Surface surface, double x, double y) {
+    /**
+     * 
+     * @param surface
+     * @param x
+     * @param y
+     */
+	public void setSource(Surface surface, double x, double y) {
 		cairo_set_source_surface(getHandle(), surface.getHandle(), x, y);
 	}
 	
@@ -143,7 +133,10 @@
 	}
 	
 	/**
-	 * Sets the fill rule.
+     * Set the current fill rule within the Context. The fill rule
+     * is used to determine which regions are inside or outside a complex
+     * (potentially self-intersecting) path. The current fill rule affects
+     * both <tt>fill</tt> and <tt>clip</tt>. 
 	 * @param fillrule
 	 */
 	public void setFillRule(FillRule fillrule) {
@@ -151,7 +144,14 @@
 	}
 	
 	/**
-	 * Sets the thickness of lines.
+     * Sets the current line width within the cairo context. The line
+     * width specifies the diameter of a pen that is circular in
+     * user-space.
+     *
+     * As with the other stroke parameters, the current line cap style is
+     * examined by <tt>stroke()</tt>, <tt>strokeExtents()</tt>, and
+     * <tt>strokeToPath(), but does not have any effect during path
+     * construction.
 	 * @param width
 	 */
 	public void setLineWidth(double width) {
@@ -159,7 +159,9 @@
 	}
 	
 	/**
-	 * Sets the line cap.
+     * Sets the current line cap style within the cairo context. See
+     * <tt>LineCap</tt> for details about how the available line cap
+     * styles are drawn.
 	 * @param linecap
 	 */
 	public void setLineCap(LineCap linecap) {
@@ -167,7 +169,9 @@
 	}
 	
 	/**
-	 * Sets the line join.
+     * Sets the current line join style within the cairo context. See
+     * <tt>LineJoin</tt> for details about how the available line join
+     * styles are drawn.
 	 * @param linejoin
 	 */
 	public void setLineJoin(LineJoin linejoin) {
@@ -192,7 +196,11 @@
 	}
 	
 	/**
-	 * Makes a translation.
+     * Modifies the current transformation matrix (CTM) by tanslating the
+     * user-space origin by (tx, ty). This offset is interpreted as a
+     * user-space coordinate according to the CTM in place before the new
+     * call to translate. In other words, the translation of the
+     * user-space origin takes place after any existing transformation.
 	 * @param tx
 	 * @param ty
 	 */
@@ -201,14 +209,23 @@
 	}
 	
 	/**
-	 * Scales.
+     * Modifies the current transformation matrix (CTM) by scaling the X
+     * and Y user-space axes by sx and sy respectively. The scaling of
+     * the axes takes place after any existing transformation of user
+     * space.
+     * @param sx
+     * @param sy
 	 */
 	public void scale(double sx, double sy) {
 		cairo_scale(getHandle(), sx, sy);
 	}
 	
 	/**
-	 * Rotates.
+     * Modifies the current transformation matrix (CTM) by rotating the
+     * user-space axes by angle radians. The rotation of the axes takes
+     * places after any existing transformation of user space. The
+     * rotation direction for positive angles is from the positive X axis
+     * toward the positive Y axis.
 	 * @param angle
 	 */
 	public void rotate(double angle) {
@@ -216,29 +233,29 @@
 	}
 	
     /**
-     * Appends the given transformation matrix to the current transformation of
-     * the state.
-     * 
-     * @param matrix
-     *            The transformation matrix to append
+     * Modifies the current transformation matrix (CTM) by applying
+     * matrix as an additional transformation. The new transformation of
+     * user space takes place after any existing transformation.
+     * @param matrix the transformation matrix to append
      */
 	public void transform(Matrix matrix) {
 		cairo_transform(getHandle(), matrix.getHandle());
 	}
 	
     /**
-     * Sets the transformation matrix for this state.
-     * 
-     * @param matrix
-     *            The transformation matrix
+     * Modifies the current transformation matrix (CTM) by setting it
+     * equal to matrix.
+     * @param matrix the transformation matrix
      */
 	public void setMatrix(Matrix matrix) {
 		cairo_set_matrix(getHandle(), matrix.getHandle());
 	}
 	
     /**
-     * Set the transformation matrix for the state to identity matrix.
-     *  
+     * Resets the current transformation matrix (CTM) by setting it equal
+     * to the identity matrix. That is, the user-space and device-space
+     * axes will be aligned and one user-space unit will transform to one
+     * device-space unit.
      */
 	public void identityMatrix() {
 		cairo_identity_matrix(getHandle());
@@ -249,49 +266,50 @@
      * multiplying the given point by the current transformation matrix
      * (CTM).
      */
-    public Point userToDevice(Point p) {
-        double[] px = new double[] { p.getX() };
-        double[] py = new double[] { p.getY() };
+    public Point userToDevice(Point point) {
+        double[] px = new double[] { point.getX() };
+        double[] py = new double[] { point.getY() };
         cairo_user_to_device(getHandle(), px, py);
 		return new Point(px[0], py[0]);
 	}
 	
     /**
+     * Transform a distance vector from user space to device space. This
+     * function is similar to userToDevice() except that the
+     * translation components of the CTM will be ignored when transforming
+     * the Point.
+     */
+    public Point userToDeviceDistance(Point distance) {
+        double[] dx = new double[] { distance.getX() };
+        double[] dy = new double[] { distance.getY() };
+        cairo_user_to_device_distance(getHandle(), dx, dy);
+        return new Point(dx[0], dy[0]);
+    }
+
+    /**
      * Transform a coordinate from device space to user space by
      * multiplying the given point by the inverse of the current
      * transformation matrix (CTM).
      */
-	public Point deviceToUser(Point p) {
-        double[] px = new double[] { p.getX() };
-        double[] py = new double[] { p.getY() };
+	public Point deviceToUser(Point point) {
+        double[] px = new double[] { point.getX() };
+        double[] py = new double[] { point.getY() };
         cairo_device_to_user(getHandle(), px, py);
 		return new Point(px[0], py[0]);
 	}
 	
-    /**
-     * Transform a distance vector from user space to device space. This
-     * function is similar to userToDevice() except that the
-     * translation components of the CTM will be ignored when transforming
-     * (dx,dy).
-     */
-    public Distance userToDeviceDistance(Distance d) {
-        double[] dx = new double[] { d.getDX() };
-        double[] dy = new double[] { d.getDY() };
-        cairo_user_to_device_distance(getHandle(), dx, dy);
-		return new Distance(dx[0], dy[0]);
-	}
 
     /**
      * Transform a distance vector from device space to user space. This
      * function is similar to deviceToUser() except that the
      * translation components of the inverse CTM will be ignored when
-     * transforming (dx,dy).
+     * transforming the Point.
      */
-	public Distance deviceToUserDistance(Distance d) {
-        double[] dx = new double[] { d.getDX() };
-        double[] dy = new double[] { d.getDY() };
+	public Point deviceToUserDistance(Point distance) {
+        double[] dx = new double[] { distance.getX() };
+        double[] dy = new double[] { distance.getY() };
         cairo_device_to_user_distance(getHandle(), dx, dy);
-		return new Distance(dx[0], dy[0]);
+		return new Point(dx[0], dy[0]);
 	}
 	
     /**
@@ -304,117 +322,145 @@
 	
     /**
      * Moves the current point in the path to the given co-ordinates.
-     * 
-     * @param x
-     *            The x co-ordinate of the point to move to
-     * @param y
-     *            The y co-ordinate of the point to move to
+     * @param p the point co-ordinate of the point to move to
      */
-	public void moveTo(double x, double y) {
-		cairo_move_to(getHandle(), x, y);
-	}
-	
 	public void moveTo(Point p) {
 		cairo_move_to(getHandle(), p.getX(), p.getY());
 	}
 	
-    /**
-     * Moves to the current path to a new point. The co-ordinates of the new
-     * point are given in relation to the current point of the state.
-     * 
-     * @param dx
-     *            Relative x distance between current point and the new point
-     * @param dy
-     *            Relative y distance between current point and the new point
-     */
-	public void relMoveTo(double dx, double dy) {
-		cairo_rel_move_to(getHandle(), dx, dy);
-	}
-	
+    public void moveTo(double x, double y) {
+        cairo_move_to(getHandle(), x, y);
+    }
+    
     /**
      * Draws a line segment as part of the current path. The line is drawn from
      * the current point of the path to the new co-ordinates.
-     * 
-     * @param x
-     *            The x coordinate for the end point for the line segment
-     * @param y
-     *            The y co-ordinate for the end point for the line segment
+     * @param p the point coordinate for the end point for the line segment
      */
-	public void lineTo(double x, double y) {
-		cairo_line_to(getHandle(), x, y);
-	}
-	
-	public void lineTo(Point p) {
-		cairo_line_to(getHandle(), p.getX(), p.getY());
+    public void lineTo(Point p) {
+        cairo_line_to(getHandle(), p.getX(), p.getY());
+    }
+    
+    public void lineTo(double x, double y) {
+        cairo_line_to(getHandle(), x, y);
+    }
+    
+    /**
+     * Draws a cubic bezier curve from the current point to (x3, y3) using 2
+     * control points (x1, y1) and (x2, y2).
+     * @param p1 x co-ordinate of the first control point
+     * @param p2 x co-ordinate of the second control point
+     * @param p3 x co-ordinate of the end point
+     */
+    public void curveTo(Point p1, Point p2, Point p3) {
+        cairo_curve_to(getHandle(), p1.getX(), p1.getY(), p2.getX(), p2.getY(), p3.getX(), p3.getY());
+    }
+
+    public void curveTo(double x1, double y1, double x2, double y2, double x3, double y3) {
+        cairo_curve_to(getHandle(), x1, y1, x2, y2, x3, y3);
+    }
+
+    /**
+     * Adds an arc from angle1 to angle2 to the current path. If there
+     * is a current point, that point is connected to the start of the arc
+     * by a straight line segment. Angles are measured in radians with an
+     * angle of 0 along the X axis and an angle of %M_PI radians (90
+     * degrees) along the Y axis, so with the default transformation
+     * matrix, positive angles are clockwise. (To convert from degrees to
+     * radians, use <literal>degrees * (M_PI / 180.)</literal>.)  This
+     * function gives the arc in the direction of increasing angle; see
+     * arcNegative() to get the arc in the direction of decreasing
+     * angle.
+     *
+     * A full arc is drawn as a circle. To make an oval arc, you can scale
+     * the current transformation matrix by different amounts in the X and
+     * Y directions.
+     * @param point
+     * @param radius
+     * @param angle1
+     * @param angle2
+     */
+    public void arc(Point point, double radius, double angle1, double angle2) {
+        cairo_arc(getHandle(), point.getX(), point.getY(), radius, angle1, angle2);
+    }
+
+    public void arc(double x, double y, double radius, double angle1, double angle2) {
+        cairo_arc(getHandle(), x, y, radius, angle1, angle2);
+    }
+
+    /**
+     * Adds an arc from angle1 to angle2 to the current path. The
+     * function behaves identically to <tt>arc()</tt> except that instead of
+     * giving the arc in the direction of increasing angle, it gives
+     * the arc in the direction of decreasing angle.
+     * @param point
+     * @param radius
+     * @param angle1
+     * @param angle2
+     */
+    public void arcNegative(Point point, double radius, double angle1, double angle2) {
+        cairo_arc_negative(getHandle(), point.getX(), point.getY(), radius, angle1, angle2);
+    }
+    
+    public void arcNegative(double x, double y, double radius, double angle1, double angle2) {
+        cairo_arc_negative(getHandle(), x, y, radius, angle1, angle2);
+    }
+
+    /**
+     * Moves to the current path to a new point. The co-ordinates of the new
+     * point are given in relation to the current point of the state.
+     * @param p relative distance between current point and the new point
+     */
+	public void relMoveTo(Point p) {
+		cairo_rel_move_to(getHandle(), p.getX(), p.getY());
 	}
 	
+    public void relMoveTo(double x, double y) {
+        cairo_rel_move_to(getHandle(), x, y);
+    }
+    
     /**
      * Draws a line segment as part of the current path. The line is drawn from
      * the current point of the path to the new co-ordinates. The new
      * co-ordinates are given relative to the current point.
-     * 
-     * @param dx
-     *            The relative x coordinate for the end point for the line
-     *            segment
-     * @param dy
-     *            The relative y co-ordinate for the end point for the line
-     *            segment
-     */
-	public void relLineTo(double dx, double dy) {
-		cairo_rel_line_to(getHandle(), dx, dy);
-	}
-	
-    /**
-     * Draws a cubic bezier curve from the current point to (x3, y3) using 2
-     * control points (x1, y1) and (x2, y2).
-     * 
-     * @param x1
-     *            x co-ordinate of the first control point
-     * @param y1
-     *            y co-ordinate of the first control point
-     * @param x2
-     *            x co-ordinate of the second control point
-     * @param y2
-     *            y co-ordinate of the second control point
-     * @param x3
-     *            x co-ordinate of the end point
-     * @param y3
-     *            y co-ordinate of the end point
+     * @param p The relative coordinate for the end point for the line segment
      */
-	public void curveTo(double x1, double y1, double x2, double y2, double x3, double y3) {
-		cairo_curve_to(getHandle(), x1, y1, x2, y2, x3, y3);
-	}
-	
-	public void curveTo(Point p1, Point p2, Point p3) {
-		cairo_curve_to(getHandle(), p1.getX(), p1.getY(), p2.getX(), p2.getY(), p3.getX(), p3.getY());
+	public void relLineTo(Point p) {
+		cairo_rel_line_to(getHandle(), p.getX(), p.getY());
 	}
 	
+    public void relLineTo(double x, double y) {
+        cairo_rel_line_to(getHandle(), x, y);
+    }
+    
     /**
-     * Draws a cubic bezier curve from the current point to (dx3, dy3) using 2
-     * control points (dx1, dy1) and (dx2, dy2). The co-ordinates are specified
+     * Draws a cubic bezier curve from the current point to p3 using 2
+     * control points p1 and p2. The co-ordinates are specified
      * relative to current point in the path.
-     * 
-     * @param dx1
-     *            relative x co-ordinate of the first control point
-     * @param dy1
-     *            relative y co-ordinate of the first control point
-     * @param dx2
-     *            relative x co-ordinate of the second control point
-     * @param dy2
-     *            relative y co-ordinate of the second control point
-     * @param dx3
-     *            relative x co-ordinate of the end point
-     * @param dy3
-     *            relative y co-ordinate of the end point
+     * @param dx1 relative co-ordinate of the first control point
+     * @param dx2 relative co-ordinate of the second control point
+     * @param dx3 relative co-ordinate of the end point
      */
-	public void relCurveTo(double dx1, double dy1, double dx2, double dy2, double dx3, double dy3) {
-		cairo_rel_curve_to(getHandle(), dx1, dy1, dx2, dy2, dx3, dy3);
+	public void relCurveTo(Point p1, Point p2, Point p3) {
+		cairo_rel_curve_to(getHandle(), p1.getX(), p1.getY(), 
+                p2.getX(), p2.getY(), p3.getX(), p3.getY());
 	}
 	
+    public void relCurveTo(double x1, double y1, double x2, double y2, double x3, double y3) {
+        cairo_rel_curve_to(getHandle(), x1, y1, x2, y2, x3, y3); 
+    }
+    
+    public void rectangle(Point p1, Point p2) {
+        cairo_rectangle(getHandle(), p1.getX(), p1.getY(), p2.getX(), p2.getY());
+    }
+    
+    public void rectangle(Rectangle rect) {
+        cairo_rectangle(getHandle(), rect.getX1(), rect.getY1(), rect.getX2(), rect.getY2());
+    }
+    
     /**
      * Closes the current path by connecting current point to the starting point
      * with a line segment.
-     *  
      */
 	public void closePath() {
 		cairo_close_path(getHandle());
@@ -427,9 +473,20 @@
 	public void paint() {
 		cairo_paint(getHandle());
 	}
+    
+    /**
+     * A drawing operator that paints the current source everywhere within
+     * the current clip region using a mask of constant alpha value
+     * alpha. The effect is similar to <tt>paint()</tt>, but the drawing
+     * is faded out using the alpha value.
+     * @param alpha
+     */
+    public void paintWithAlpha(double alpha) {
+        cairo_paint_with_alpha(getHandle(), alpha);
+    }
 
 	/**
-	 *  A drawing operator that paints the current source
+	 * A drawing operator that paints the current source
 	 * using the alpha channel of pattern as a mask. (Opaque
 	 * areas of mask are painted with the source, transparent
 	 * areas are not painted.)
@@ -448,7 +505,7 @@
 	 * @param sx
 	 * @param sy
 	 */
-	public void maskSurface(Surface surface, double sx, double sy) {
+	public void mask(Surface surface, double sx, double sy) {
 		cairo_mask_surface(getHandle(), surface.getHandle(), sx, sy);
 	}
 
@@ -506,25 +563,38 @@
 		return cairo_in_fill(getHandle(), x, y);
 	}
 	
-	public Box getStrokeExtents() {
+	public Rectangle strokeExtents() {
 		double[] x1 = new double[1];
 		double[] y1 = new double[1];
 		double[] x2 = new double[1];
 		double[] y2 = new double[1];
 		cairo_stroke_extents(getHandle(), x1, y1, x2, y2);
-		return new Box(x1[0], y1[0], x2[0], y2[0]);
+		return new Rectangle(x1[0], y1[0], x2[0], y2[0]);
 	}
 	
-	public Box getFillExtents() {
+	public Rectangle fillExtents() {
 		double[] x1 = new double[1];
 		double[] y1 = new double[1];
 		double[] x2 = new double[1];
 		double[] y2 = new double[1];
 		cairo_fill_extents(getHandle(), x1, y1, x2, y2);
-		return new Box(x1[0], y1[0], x2[0], y2[0]);
+		return new Rectangle(x1[0], y1[0], x2[0], y2[0]);
 	}
 	
-	public void resetClip() {
+    /**
+     * Reset the current clip region to its original, unrestricted
+     * state. That is, set the clip region to an infinitely large shape
+     * containing the target surface. Equivalently, if infinity is too
+     * hard to grasp, one can imagine the clip region being reset to the
+     * exact bounds of the target surface.
+     *
+     * Note that code meant to be reusable should not call
+     * resetClip() as it will cause results unexpected by
+     * higher-level code which calls clip(). Consider using
+     * save() and restore() around clip() as a more
+     * robust means of temporarily restricting the clip region.
+     */
+    public void resetClip() {
 		cairo_reset_clip(getHandle());
 	}
 
@@ -573,25 +643,28 @@
 	}
 	
     /**
-     * Sets the font for drawing text.
-     * 
-     * @param family
-     *            Font family name
-     * @param slant
-     *            Font slant
-     * @param weight
-     *            Font weight
+     * Selects a family and style of font from a simplified description as
+     * a family name, slant and weight. This method is meant to be used
+     * only for applications with simple font needs: Cairo doesn't provide
+     * for operations such as listing all available fonts on the system,
+     * and it is expected that most applications will need to use a more
+     * comprehensive font handling and text layout library in addition to
+     * Cairo.
+     * @param family font family name
+     * @param slant font slant
+     * @param weight font weight
      */
 	public void selectFontFace(String family, FontSlant slant, FontWeight weight) {
 		cairo_select_font_face(getHandle(), family, slant.getValue(), weight.getValue());
 	}
 	
     /**
-     * Uniformly scale the current font by the given amount. You can set font
-     * size using this method.
-     * 
-     * @param scale
-     *            The scaling factor.
+     * Sets the current font matrix to a scale by a factor of size, replacing
+     * any font matrix previously set with cairo_setFontSize() or
+     * setFontMatrix(). This results in a font size of size user space
+     * units. (More precisely, this matrix will result in the font's
+     * em-square being a size by size square in user space.)
+     * @param scale the scaling factor.
      */
 	public void setFontSize(double scale) {
 		cairo_set_font_size(getHandle(), scale);
@@ -621,9 +694,7 @@
 	
     /**
      * Draws the given text on the screen.
-     * 
-     * @param text
-     *            String to draw on the screen.
+     * @param text String to draw on the screen.
      */
 	public void showText(String text) {
 		cairo_show_text(getHandle(), text);
@@ -645,20 +716,25 @@
 		return new FontFace(cairo_get_font_face(getHandle()));
 	}
 
+    /**
+     * Gets the font extents for the currently selected font.
+     */
+    public FontExtents fontExtents() {
+        Handle hndl = Struct.getNullHandle();
+        cairo_font_extents(getHandle(), hndl);
+        return new FontExtents(hndl);
+    }
+    
 	/**
-	 * Sets the current font face.
+     * Replaces the current FontFace object in the context with
+     * fontFace. The replaced font face in the context will be
+     * destroyed if there are no other references to it.
 	 * @param font
 	 */
-	public void setFontFace(FontFace font) {
-		cairo_set_font_face(getHandle(), font.getHandle());
+	public void setFontFace(FontFace fontFace) {
+		cairo_set_font_face(getHandle(), fontFace.getHandle());
 	}
 
-	public FontExtents getFontExtents() {
-		Handle hndl = Struct.getNullHandle();
-		cairo_font_extents(getHandle(), hndl);
-		return new FontExtents(hndl);
-	}
-	
     /**
      * Gets the extents for a string of text. The extents describe a
      * user-space rectangle that encloses the "inked" portion of the text,
@@ -712,124 +788,112 @@
 
     /**
      * Returns the current surface operator
-     * 
      * @return The surface operator.
      */
 	public Operator getOperator() {
 		return Operator.intern(cairo_get_operator(getHandle()));
 	}
 	
-	public RGBColor getRGBColor() {
-		double[] red = new double[1];
-		double[] green = new double[1];
-		double[] blue = new double[1];
-		cairo_get_rgb_color(getHandle(), red, green, blue);
-		return new RGBColor(red[0], green[0], blue[0]);
-	}
-
-	/**
-	 * Gets the current source pattern for this object.
-	 */
-	public Pattern getSource() {
-		Handle hndl = cairo_get_source(getHandle());
-		return new Pattern(hndl);
-	}
-	
+    /**
+     * Gets the current source pattern for this object.
+     */
+    public Pattern getSource() {
+        Handle hndl = cairo_get_source(getHandle());
+        return new Pattern(hndl);
+    }
+    
     /**
      * Returns the tesselation tolerance of the current state.
-     * 
      * @return tesselation tolerance
      */
-	public double getTolerance() {
-		return cairo_get_tolerance(getHandle());
-	}
-	
+    public double getTolerance() {
+        return cairo_get_tolerance(getHandle());
+    }
+    
     /**
      * Returns the current point of the surface.
      * 
+     * The current point is returned in the user-space coordinate
+     * system. If there is no defined current point then Point will
+     * be set to (0,0)
+     *
      * @return Current point for drawing
      */
-	public Point getCurrentPoint() {
-		double[] x = new double[1];
-		double[] y = new double[1];
-		cairo_get_current_point(getHandle(), x, y);
-		return new Point(x[0], y[0]);
-	}
+    public Point getCurrentPoint() {
+        double[] x = new double[1];
+        double[] y = new double[1];
+        cairo_get_current_point(getHandle(), x, y);
+        return new Point(x[0], y[0]);
+    }
 
-	public FillRule getFillRule() {
-		return FillRule.intern(cairo_get_fill_rule(getHandle()));
-	}
-	
+    /**
+     * Gets the current fill rule, as set by setFillRule().
+     */
+    public FillRule getFillRule() {
+        return FillRule.intern(cairo_get_fill_rule(getHandle()));
+    }
+    
     /**
      * Returns the stroke line width.
-     * 
      * @return The stroke line width
      */
-	public double getLineWidth() {
-		return cairo_get_line_width(getHandle());
-	}
+    public double getLineWidth() {
+        return cairo_get_line_width(getHandle());
+    }
 
     /**
      * Returns current linecap style.
-     * 
      * @return The line cap style
      */
-	public LineCap getLineCap() {
-		return LineCap.intern(cairo_get_line_cap(getHandle()));
-	}
+    public LineCap getLineCap() {
+        return LineCap.intern(cairo_get_line_cap(getHandle()));
+    }
 
     /**
      * Return current line join style.
-     * 
      * @return Line join style
      */
-	public LineJoin getLineJoin() {
-		return LineJoin.intern(cairo_get_line_join(getHandle()));
-	}
+    public LineJoin getLineJoin() {
+        return LineJoin.intern(cairo_get_line_join(getHandle()));
+    }
 
     /**
      * Returns the miter limit for miter style line joins
-     * 
      * @return The miter limit
      */
-	public double getMiterLimit() {
-		return cairo_get_miter_limit(getHandle());
-	}
+    public double getMiterLimit() {
+        return cairo_get_miter_limit(getHandle());
+    }
 
-	public Matrix getMatrix() {
-		Handle hndl = Struct.getNullHandle();
-		cairo_get_matrix(getHandle(), hndl);
-		return new Matrix(hndl);
-	}
+    /**
+     * Returns the current transformation matrix
+     * @return the current transformation matrix
+     */
+    public Matrix getMatrix() {
+        Handle hndl = Struct.getNullHandle();
+        cairo_get_matrix(getHandle(), hndl);
+        return new Matrix(hndl);
+    }
 
-	public void arc(double xc, double yc, double radius, double angle1, double angle2) {
-		cairo_arc(getHandle(), xc, yc, radius, angle1, angle2);
-	}
-    
-    public void arc(Point p, double radius, double angle1, double angle2) {
-        arc(p.getX(), p.getY(), radius, angle1, angle2);
+    /**
+     * Gets the target surface for the cairo context as passed to
+     * the constructor.
+     * @return the target surface
+     */
+    public Surface getTarget() {
+        return new Surface(cairo_get_target(getHandle()));
     }
 
-	public void arcNegative(double xc, double yc, double radius, double angle1, double angle2) {
-		cairo_arc_negative(getHandle(), xc, yc, radius, angle1, angle2);
-	}
-    
-    public void arcNegative(Point p, double radius, double angle1, double angle2) {
-        arcNegative(p.getX(), p.getY(), radius, angle1, angle2);
+    public Status status() {
+        return Status.intern(cairo_status(getHandle()));
     }
-	
-    public void rectangle(double x, double y, double width, double height) {
-		cairo_rectangle(getHandle(), x, y, width, height);
-	}
-	
-	public void rectangle(Point p1, Point p2) {
-		cairo_rectangle(getHandle(), p1.getX(), p1.getY(), p2.getX(), p2.getY());
-	}
-	
-    public void rectangle(Box box) {
-        cairo_rectangle(getHandle(), box.getX1(), box.getY1(), box.getX2(), box.getY2());
+    
+    public String statusString() {
+        return cairo_status_string(getHandle());
     }
     
+
+    
     /** Constant use for drawing ellipse */
     private static final double SVG_ARC_MAGIC = 0.5522847498;
 
@@ -861,20 +925,10 @@
         cairo_close_path(getHandle());
     }
 
-	public Status getStatus() {
-        return Status.intern(cairo_status(getHandle()));
-    }
-    
-    public String getStatusString() {
-        return cairo_status_string(getHandle());
-    }
-    
     /*
      * Native calls
      */
 	native static final private Handle cairo_create(Handle surface);
-	// TODO: API
-	native static final private void cairo_reference(Handle obj);
 	native static final private void cairo_destroy(Handle obj);
 	native static final private void cairo_save(Handle obj);
 	native static final private void cairo_restore(Handle obj);
@@ -912,6 +966,7 @@
 	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_paint_with_alpha(Handle obj, double alpha);
 	native static final private void cairo_mask(Handle obj, Handle pattern);
 	native static final private void cairo_mask_surface(Handle obj, Handle surface, double sx, double sy);
 	native static final private void cairo_stroke(Handle obj);
@@ -941,21 +996,20 @@
 	native static final private void cairo_text_path(Handle obj, String utf8);
 	native static final private void cairo_glyph_path(Handle obj, Handle[] glyphs);
 	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_source(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);
-	native static final private int cairo_get_fill_rule(Handle obj);
-	native static final private double cairo_get_line_width(Handle obj);
-	native static final private int cairo_get_line_cap(Handle obj);
-	native static final private int cairo_get_line_join(Handle obj);
-	native static final private double cairo_get_miter_limit(Handle obj);
-	native static final private void cairo_get_matrix(Handle obj, Handle matrix);
-	// TODO: API JNI
-	native static final Handle cairo_get_target(Handle obj);
-	native static final private int cairo_status(Handle obj);
-	native static final private String cairo_status_string(Handle obj);
-	
+    native static final private Handle cairo_get_source(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);
+    native static final private int cairo_get_fill_rule(Handle obj);
+    native static final private double cairo_get_line_width(Handle obj);
+    native static final private int cairo_get_line_cap(Handle obj);
+    native static final private int cairo_get_line_join(Handle obj);
+    native static final private double cairo_get_miter_limit(Handle obj);
+    native static final private void cairo_get_matrix(Handle obj, Handle matrix);
+    // TODO: JNI
+    native static final private Handle cairo_get_target(Handle obj);
+    native static final private int cairo_status(Handle obj);
+    native static final private String cairo_status_string(Handle obj);
+
 // TODO: add the following	
 //	cairo_path_t *
 //	cairo_copy_path (cairo_t *cr);

Index: Surface.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/Surface.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Surface.java	7 May 2005 00:46:23 -0000	1.9
+++ Surface.java	9 May 2005 14:47:03 -0000	1.10
@@ -48,10 +48,15 @@
     	cairo_surface_set_device_offset(getHandle(), xOffset, yOffset);
     }
     
+    public void writeToPNG(String filename) {
+        cairo_surface_write_to_png(getHandle(), filename);
+    }
+    
     /*
      * Native calls
      */
     native static final private Handle cairo_surface_create_similar(Handle other, int format, int width, int height);
+    // TODO: JNI is wrong here - should use alloc and remove ref
     native static final private void cairo_surface_reference(Handle obj);
     native static final private void cairo_surface_destroy(Handle obj);
     native static final private int cairo_surface_finish(Handle obj);

Index: ImageSurface.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/ImageSurface.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- ImageSurface.java	7 May 2005 00:46:23 -0000	1.9
+++ ImageSurface.java	9 May 2005 14:47:03 -0000	1.10
@@ -15,48 +15,46 @@
  */
 public class ImageSurface extends Surface {
 	
-	private Format format;
-	private int width;
-	private int height;
-	private int stride;
-	private char[] data = null;
 	
 	public ImageSurface(Format format, int width, int height) {
 		super(cairo_image_surface_create(format.getValue(), width, height));
-		this.format = format;
-		this.width = width;
-		this.height = height;
 	}
 	
 	public ImageSurface(char[] data, Format format, int width, int height, int stride) {
 		super(cairo_image_surface_create_for_data(data, format.getValue(), width, height, stride));
-		this.format = format;
-		this.width = width;
-		this.height = height;
-		this.stride = stride;
-		this.data = data;
 	}
 	
 	ImageSurface(Handle hndl) {
 		super(hndl);
 	}
-	
+    
+    public int getWidth() {
+        return cairo_image_surface_get_width(getHandle());
+    }
+    
+    public int getHeight() {
+        return cairo_image_surface_get_height(getHandle());
+    }
+    
+    static public ImageSurface createFromPNG(String filename) {
+        return new ImageSurface(cairo_image_surface_create_from_png(filename));
+    }
+    
 	/*
 	 * Native calls
 	 */
 	native static final private Handle cairo_image_surface_create(int format, int width, int height);
 	native static final private Handle cairo_image_surface_create_for_data(char[] data, int format, int width, int height, int stride);
-	// TODO: API JNI
+	// TODO: JNI
 	native static final private int cairo_image_surface_get_width(Handle obj);
-	// TODO: API JNI
+	// TODO: JNI
 	native static final private int cairo_image_surface_get_height(Handle obj);
-	// TODO: API JNI
+	// TODO: JNI and exception handling
 	native static final private Handle cairo_image_surface_create_from_png(String filename);
 	// TODO:
 //	native static final private Handle cairo_image_surface_create_from_png_stream(String func);
 //	cairo_surface_t *
 //	cairo_image_surface_create_from_png_stream (cairo_read_func_t	read_func,
 //						    void		*closure);
-
 	
 }

Index: FontExtents.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/FontExtents.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- FontExtents.java	24 Mar 2005 18:11:40 -0000	1.2
+++ FontExtents.java	9 May 2005 14:47:03 -0000	1.3
@@ -39,6 +39,9 @@
 	/*
 	 * Native calls
 	 */
+    // TODO: free resources
+    native static final private void free(Handle obj);
+    
 	native static final private double get_ascent(Handle obj);
 	native static final private double get_descent(Handle obj);
 	native static final private double get_height(Handle obj);

--- RGBColor.java DELETED ---

--- Distance.java DELETED ---

--- NEW FILE: Rectangle.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 Rectangle {
    
    double x1;
    double y1;
    double x2;
    double y2;
    
    public Rectangle(double x1, double y1, double x2, double y2) {
        this.x1 = x1;
        this.y1 = y1;
        this.x2 = x2;
        this.y2 = y2;
    }
    
    public Rectangle(Point upperLeft, Point lowerRight) {
        this.x1 = upperLeft.getX();
        this.y1 = upperLeft.getY();
        this.x2 = lowerRight.getX();
        this.y2 = lowerRight.getY();
    }
    
    public double getX1() {
        return x1;
    }
    public void setX1(double x1) {
        this.x1 = x1;
    }
    public double getX2() {
        return x2;
    }
    public void setX2(double x2) {
        this.x2 = x2;
    }
    public double getY1() {
        return y1;
    }
    public void setY1(double y1) {
        this.y1 = y1;
    }
    public double getY2() {
        return y2;
    }
    public void setY2(double y2) {
        this.y2 = y2;
    }
}

Index: FontFace.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/FontFace.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- FontFace.java	23 Apr 2005 19:25:56 -0000	1.2
+++ FontFace.java	9 May 2005 14:47:03 -0000	1.3
@@ -16,20 +16,25 @@
  * sheering it or scaling it unequally in the two directions). 
  */
 public class FontFace extends CairoObject {
-	
+
+    public FontFace() {
+        super(alloc());
+    }
+    
 	FontFace(Handle hndl) {
 		super(hndl);
 	}
 	
-	public void dispose() {
-		cairo_font_face_destroy(getHandle());
-	}
-	
+    protected void finalize() throws Throwable {
+        cairo_font_face_destroy(getHandle());
+        super.finalize();
+    }
 
     /*
      * Native calls
      */
-	native static final private void cairo_font_face_reference(Handle obj);
+    // TODO: alloc
+    native static final private Handle alloc();
 	native static final private void cairo_font_face_destroy(Handle obj);
 
 }

Index: Glyph.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/Glyph.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Glyph.java	23 Apr 2005 19:25:56 -0000	1.4
+++ Glyph.java	9 May 2005 14:47:03 -0000	1.5
@@ -47,7 +47,17 @@
     /*
      * native calls
      */
+    // TODO: lifecycle methods
+    native static final private Handle alloc();
+    native static final private Handle alloc(long index, double x, double y);
+    native static final private void free(Handle obj);
+    
     native static final private long get_index(Handle obj);
     native static final private double get_x(Handle obj);
     native static final private double get_y(Handle obj);
+
+    // TODO: setters
+    native static final private void set_index(Handle obj, long index);
+    native static final private void set_x(Handle obj, double x);
+    native static final private void set_y(Handle obj, double y);
 }
\ No newline at end of file




More information about the cairo-commit mailing list