[cairo-commit] cairo-java/src/java/org/freedesktop/cairo SubpixelOrder.java, NONE, 1.1 HintStyle.java, NONE, 1.1 Antialias.java, NONE, 1.1 ScaledFont.java, 1.2, 1.3 FontOptions.java, NONE, 1.1 Context.java, 1.7, 1.8 HintMetrics.java, NONE, 1.1 Status.java, 1.8, 1.9

Jeffrey Morgan commit at pdx.freedesktop.org
Sat Aug 13 15:11:24 PDT 2005


Committed by: kuzman

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

Modified Files:
	ScaledFont.java Context.java Status.java 
Added Files:
	SubpixelOrder.java HintStyle.java Antialias.java 
	FontOptions.java HintMetrics.java 
Log Message:
Updated API to match all cairo updates.

--- NEW FILE: SubpixelOrder.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.Enum;

/**
 * The subpixel order specifies the order of color elements within
 * each pixel on the display device when rendering with an
 * antialiasing mode of SUBPIXEL.
 */
public class SubpixelOrder extends Enum {

    static final private int _DEFAULT = 0;
    /**
     * Use the default subpixel order for
     * for the target device     
     */
    static final public SubpixelOrder DEFAULT = new SubpixelOrder (_DEFAULT);
    static final private int _RGB = 1;
    /**
     * Subpixel elements are arranged horizontally
     * with red at the left     
     */
    static final public SubpixelOrder RGB = new SubpixelOrder (_RGB);
    static final private int _BGR = 2;
    /**
     * Subpixel elements are arranged horizontally
     * with blue at the left
     */
    static final public SubpixelOrder BGR = new SubpixelOrder (_BGR);
    static final private int _VRGB = 3;
    /**
     * Subpixel elements are arranged vertically
     * with red at the top
     */
    static final public SubpixelOrder VRGB = new SubpixelOrder (_VRGB);
    static final private int _VBGR = 4;
    /**
     * Subpixel elements are arranged vertically
     * with blue at the top
     */
    static final public SubpixelOrder VBGR = new SubpixelOrder (_VBGR);
    static final private SubpixelOrder[] theInterned = new SubpixelOrder[] {
        DEFAULT, RGB, BGR, VRGB, VBGR
    };
    static private java.util.Hashtable theInternedExtras;
    static final private SubpixelOrder theSacrificialOne = new SubpixelOrder (0);
    static public SubpixelOrder intern (int value) {
        if (value < theInterned.length) {
            return theInterned[value];
        }
        theSacrificialOne.value_ = value;
        if (theInternedExtras == null) {
            theInternedExtras = new java.util.Hashtable();
        }
        SubpixelOrder already = (SubpixelOrder) theInternedExtras.get(theSacrificialOne);
        if (already == null) {
            already = new SubpixelOrder(value);
            theInternedExtras.put(already, already);
        }
        return already;
    }

    private SubpixelOrder(int value) {
        value_ = value;
    }

    public boolean test (SubpixelOrder other) {
        return (value_ & other.value_) == other.value_;
    }
}

--- NEW FILE: HintStyle.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.Enum;

/**
 * Specifies the type of hinting to do on font outlines. Hinting
 * is the process of fitting outlines to the pixel grid in order
 * to improve the appearance of the result. Since hinting outlines
 * involves distorting them, it also reduces the faithfulness
 * to the original outline shapes. Not all of the outline hinting
 * styles are supported by all font backends.
 */
public class HintStyle extends Enum {

    static final private int _DEFAULT = 0;
    /**
     * Use the default hint style for
     * for font backend and target device     
     */
    static final public HintStyle DEFAULT = new HintStyle (_DEFAULT);
    static final private int _NONE = 1;
    /**
     * Do not hint outlines     
     */
    static final public HintStyle NONE = new HintStyle (_NONE);
    static final private int _SLIGHT = 2;
    /**
     * Hint outlines slightly to improve
     * contrast while retaining good fidelity to the original
     * shapes.
     */
    static final public HintStyle SLIGHT = new HintStyle (_SLIGHT);
    static final private int _MEDIUM = 3;
    /**
     * Hint outlines with medium strength
     * giving a compromise between fidelity to the original shapes
     * and contrast
     */
    static final public HintStyle MEDIUM = new HintStyle (_MEDIUM);
    static final private int _FULL = 4;
    /**
     * Hint outlines to maximize contrast
     */
    static final public HintStyle FULL = new HintStyle (_FULL);
    static final private HintStyle[] theInterned = new HintStyle[] {
        DEFAULT, NONE, SLIGHT, MEDIUM, FULL
    };
    static private java.util.Hashtable theInternedExtras;
    static final private HintStyle theSacrificialOne = new HintStyle (0);
    static public HintStyle intern (int value) {
        if (value < theInterned.length) {
            return theInterned[value];
        }
        theSacrificialOne.value_ = value;
        if (theInternedExtras == null) {
            theInternedExtras = new java.util.Hashtable();
        }
        HintStyle already = (HintStyle) theInternedExtras.get(theSacrificialOne);
        if (already == null) {
            already = new HintStyle(value);
            theInternedExtras.put(already, already);
        }
        return already;
    }

    private HintStyle(int value) {
        value_ = value;
    }

    public boolean test (HintStyle other) {
        return (value_ & other.value_) == other.value_;
    }

}

--- NEW FILE: Antialias.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.Enum;

/**
 * Specifies the type of antialiasing to do when rendering text. 
 */
public class Antialias extends Enum {

    static final private int _DEFAULT = 0;
    /**
     * Use the default antialiasing for
     * the font subsystem and target device
     */
    static final public Antialias DEFAULT = new Antialias (_DEFAULT);
    static final private int _NONE = 1;
    /**
     * Do no antialiasing of fonts; use bilevel text.
     */
    static final public Antialias NONE = new Antialias (_NONE);
    static final private int _GRAY = 2;
    /**
     * Perform single-color antialiasing (using
     * shades of gray for black text on a white background, for example).
     */
    static final public Antialias GRAY = new Antialias (_GRAY);
    static final private int _SUBPIXEL = 3;
    /**
     * Perform antialiasing by taking
     * advantage of the order of subpixel elements on devices
     * such as LCD panels
     */
    static final public Antialias SUBPIXEL = new Antialias (_SUBPIXEL);
    static final private Antialias[] theInterned = new Antialias[] {
        DEFAULT, NONE, GRAY, SUBPIXEL
    };
    static private java.util.Hashtable theInternedExtras;
    static final private Antialias theSacrificialOne = new Antialias (0);
    static public Antialias intern (int value) {
        if (value < theInterned.length) {
            return theInterned[value];
        }
        theSacrificialOne.value_ = value;
        if (theInternedExtras == null) {
            theInternedExtras = new java.util.Hashtable();
        }
        Antialias already = (Antialias) theInternedExtras.get(theSacrificialOne);
        if (already == null) {
            already = new Antialias(value);
            theInternedExtras.put(already, already);
        }
        return already;
    }

    private Antialias(int value) {
        value_ = value;
    }

    public boolean test (Antialias other) {
        return (value_ & other.value_) == other.value_;
    }
}

Index: ScaledFont.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/ScaledFont.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ScaledFont.java	9 May 2005 14:47:03 -0000	1.2
+++ ScaledFont.java	13 Aug 2005 22:11:21 -0000	1.3
@@ -22,8 +22,8 @@
 	 * @param ctm user to device transformation matrix with which the font will
 	 * be used.
 	 */
-	public ScaledFont(FontFace fontFace, Matrix matrix, Matrix ctm) {
-		super(cairo_scaled_font_create(fontFace.getHandle(), matrix.getHandle(), ctm.getHandle()));
+	public ScaledFont(FontFace fontFace, Matrix matrix, Matrix ctm, FontOptions options) {
+		super(cairo_scaled_font_create(fontFace.getHandle(), matrix.getHandle(), ctm.getHandle(), options.getHandle()));
 	}
     
     protected void finalize() throws Throwable {
@@ -37,12 +37,12 @@
 	
 	public FontExtents getFontExtents() {
 		Handle hndl = getNullHandle();
-		int status = cairo_scaled_font_extents(getHandle(), hndl);
+		cairo_scaled_font_extents(getHandle(), hndl);
 		return new FontExtents(hndl);
 	}
 	
-	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);
+	native static final private Handle cairo_scaled_font_create(Handle face, Handle matrix, Handle ctm, Handle options);
+	native static final private void 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);

--- NEW FILE: FontOptions.java ---
package org.freedesktop.cairo;

import org.gnu.javagnome.Handle;


public class FontOptions extends CairoObject {
    
    public FontOptions() {
        super(cairo_font_options_create());
    }
    
    public void setAntialias(Antialias antialias) {
        cairo_font_options_set_antialias(getHandle(), antialias.getValue());
    }
    
    public Antialias getAntialias() {
        return Antialias.intern(cairo_font_options_get_antialias(getHandle()));
    }
    
    public void setSubpixelOrder(SubpixelOrder subpixelOrder) {
        cairo_font_options_set_subpixel_order(getHandle(), subpixelOrder.getValue());
    }
    
    public SubpixelOrder getSubpixelOrder() {
        return SubpixelOrder.intern(cairo_font_options_get_subpixel_order(getHandle()));
    }
    
    public void setHintStyle(HintStyle hintStyle) {
        cairo_font_options_set_hint_style(getHandle(), hintStyle.getValue());
    }
    
    public HintStyle getHintStyle() {
        return HintStyle.intern(cairo_font_options_get_hint_style(getHandle()));
    }
    
    public void setHintMetrics(HintMetrics hintMetrics) {
        cairo_font_options_set_hint_metrics(getHandle(), hintMetrics.getValue());
    }
    
    public HintMetrics getHintMetrics() {
        return HintMetrics.intern(cairo_font_options_get_hint_metrics(getHandle()));
    }
    
    public void merge(FontOptions other) {
        cairo_font_options_merge(getHandle(), other.getHandle());
    }
    
    public boolean equal(FontOptions other) {
        return cairo_font_options_equal(getHandle(), other.getHandle());
    }
    
    public long hash() {
        return cairo_font_options_hash(getHandle());
    }
    
    protected void finalize() throws Throwable {
        cairo_font_options_destroy(getHandle());
        super.finalize();
    }

    native static final private Handle cairo_font_options_create();
    native static final private void cairo_font_options_set_antialias(Handle obj, int antialias);
    native static final private int cairo_font_options_get_antialias(Handle obj);
    native static final private void cairo_font_options_set_subpixel_order(Handle obj, int order);
    native static final private int cairo_font_options_get_subpixel_order(Handle obj);
    native static final private void cairo_font_options_set_hint_style(Handle obj, int style);
    native static final private int cairo_font_options_get_hint_style(Handle obj);
    native static final private void cairo_font_options_set_hint_metrics(Handle obj, int metrics);
    native static final private int cairo_font_options_get_hint_metrics(Handle obj);
    native static final private void cairo_font_options_destroy(Handle obj);
    native static final private void cairo_font_options_merge(Handle obj, Handle other);
    native static final private boolean cairo_font_options_equal(Handle obj, Handle other);
    native static final private long cairo_font_options_hash(Handle obj);
}

Index: Context.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/Context.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Context.java	16 May 2005 16:19:38 -0000	1.7
+++ Context.java	13 Aug 2005 22:11:21 -0000	1.8
@@ -892,7 +892,13 @@
         return cairo_status_string(getHandle());
     }
     
-
+    public void setAntialias(Antialias antialias) {
+        cairo_set_antialias(getHandle(), antialias.getValue());        
+    }
+    
+    public Antialias getAntialias() {
+        return Antialias.intern(cairo_get_antialias(getHandle()));
+    }
     
     /** Constant use for drawing ellipse */
     private static final double SVG_ARC_MAGIC = 0.5522847498;
@@ -1008,6 +1014,8 @@
     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);
+    native static final private void cairo_set_antialias(Handle obj, int antialias);
+    native static final private int cairo_get_antialias(Handle obj);
 
 // TODO: add the following	
 //	cairo_path_t *

--- NEW FILE: HintMetrics.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.Enum;

/**
 * Specifies whether to hint font metrics; hinting font metrics
 * means quantizing them so that they are integer values in
 * device space. Doing this improves the consistency of
 * letter and line spacing, however it also means that text
 * will be laid out differently at different zoom factors.
 */
public class HintMetrics extends Enum {

    static final private int _DEFAULT = 0;
    /**
     * Hint metrics in the default
     * manner for the font backend and target device     
     */
    static final public HintMetrics DEFAULT = new HintMetrics (_DEFAULT);
    static final private int _OFF = 1;
    /**
     * Do not hint font metrics     
     */
    static final public HintMetrics OFF = new HintMetrics (_OFF);
    static final private int _ON = 2;
    /**
     * Hint font metrics
     */
    static final public HintMetrics ON = new HintMetrics (_ON);

    static final private HintMetrics[] theInterned = new HintMetrics[] {
        DEFAULT, OFF, ON
    };
    static private java.util.Hashtable theInternedExtras;
    static final private HintMetrics theSacrificialOne = new HintMetrics (0);
    static public HintMetrics intern (int value) {
        if (value < theInterned.length) {
            return theInterned[value];
        }
        theSacrificialOne.value_ = value;
        if (theInternedExtras == null) {
            theInternedExtras = new java.util.Hashtable();
        }
        HintMetrics already = (HintMetrics) theInternedExtras.get(theSacrificialOne);
        if (already == null) {
            already = new HintMetrics(value);
            theInternedExtras.put(already, already);
        }
        return already;
    }

    private HintMetrics(int value) {
        value_ = value;
    }

    public boolean test (HintMetrics other) {
        return (value_ & other.value_) == other.value_;
    }

}

Index: Status.java
===================================================================
RCS file: /cvs/cairo/cairo-java/src/java/org/freedesktop/cairo/Status.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Status.java	17 Jul 2005 20:50:46 -0000	1.8
+++ Status.java	13 Aug 2005 22:11:21 -0000	1.9
@@ -42,11 +42,20 @@
     static final public Status SURFACE_TYPE_MISMATCH = new Status (_SURFACE_TYPE_MISMATCH);
     static final private int _PATTERN_TYPE_MISMATCH = 13;
     static final public Status PATTERN_TYPE_MISMATCH = new Status (_PATTERN_TYPE_MISMATCH);
+    static final private int _INVALID_CONTENT = 14;
+    static final public Status INVALID_CONTENT = new Status (_INVALID_CONTENT);
+    static final private int _INVALID_FORMAT = 13;
+    static final public Status INVALID_FORMAT = new Status (_INVALID_FORMAT);
+    static final private int _INVALID_VISUAL = 13;
+    static final public Status INVALID_VISUAL = new Status (_INVALID_VISUAL);
+    static final private int _FILE_NOT_FOUND= 13;
+    static final public Status FILE_NOT_FOUND = new Status (_FILE_NOT_FOUND);
 
     static final private Status[] theInterned = new Status[] {
         SUCCESS, NO_MEMORY, INVALID_RESTORE, INVALID_POP_GROUP, NO_CURRENT_POINT,
         INVALID_MATRIX, INVALID_STATUS, NULL_POINTER, INVALID_STRING, INVALID_PATH_DATA,
-        READ_ERROR, WRITE_ERROR, SURFACE_FINISHED, SURFACE_TYPE_MISMATCH, PATTERN_TYPE_MISMATCH
+        READ_ERROR, WRITE_ERROR, SURFACE_FINISHED, SURFACE_TYPE_MISMATCH, PATTERN_TYPE_MISMATCH,
+        INVALID_CONTENT, INVALID_FORMAT, INVALID_VISUAL, FILE_NOT_FOUND
     };
     static private java.util.Hashtable theInternedExtras;
     static final private Status theSacrificialOne = new Status (0);




More information about the cairo-commit mailing list