This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi,
To get the JFreeChart demo program working as described on
http://classpath.wildebeest.org/dairy/index.php?p=31
I needed the following Fixlets/Workarounds:
2004-09-02 Mark Wielaard <mark@klomp.org>
* gnu/java/awt/peer/gtk/GdkGraphics.java (setColor): Use
Color.BLACK if c == null, don't create new Color object each time.
* gnu/java/awt/peer/gtk/GdkGraphics2D.java (comp): New private
field.
(setColor): Use Color.BLACK when argument null.
(setComposite): Set this.comp field.
(getComposite): Return this.comp, or AlphaComposite.SrcOver when null.
* java/awt/FontMetrics.java (gRC): New static final private field.
(getLineMetrics(String, Graphics)): New method.
(getLineMetrics(String, int, int, Graphics)): Likewise.
(getLineMetrics(char[], int, int, Graphics)): Likewise.
(getLineMetrics(CharacterIterator, int, int, Graphics)): Likewise.
* javax/swing/JMenu.java (JMenu(String, boolean)): Ignore tearoff
argument. PR SWING/17294.
* javax/swing/plaf/basic/BasicGraphicsUtils.java (): Always use
the fall-back code since none of the TextArea methods are really
implemented now. PR SWING/17296.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c
(GdkGlyphVector_setChars): Work around assert() when
pango_itemize() returns null. PR AWT/17295.
(GdkGlyphVector_allInkExtents): Likewise when vec->glyphitems is null.
I have added bugzilla reports for those issues that I work around but
that need a real fix.
OK to commit to the gui branch?
Cheers,
Mark
Index: gnu/java/awt/peer/gtk/GdkGraphics.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java,v
retrieving revision 1.4.16.6
diff -u -r1.4.16.6 GdkGraphics.java
--- gnu/java/awt/peer/gtk/GdkGraphics.java 9 Aug 2004 22:35:23 -0000 1.4.16.6
+++ gnu/java/awt/peer/gtk/GdkGraphics.java 2 Sep 2004 18:59:01 -0000
@@ -396,7 +396,7 @@
public void setColor (Color c)
{
if (c == null)
- color = new Color (0, 0, 0);
+ color = Color.BLACK;
else
color = c;
Index: gnu/java/awt/peer/gtk/GdkGraphics2D.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/awt/peer/gtk/GdkGraphics2D.java,v
retrieving revision 1.7.2.15
diff -u -r1.7.2.15 GdkGraphics2D.java
--- gnu/java/awt/peer/gtk/GdkGraphics2D.java 30 Jul 2004 19:29:40 -0000 1.7.2.15
+++ gnu/java/awt/peer/gtk/GdkGraphics2D.java 2 Sep 2004 18:59:01 -0000
@@ -85,6 +85,8 @@
private RenderingHints hints;
private BufferedImage bimage;
+ private Composite comp;
+
private Stack stateStack;
native private void initState (GtkComponentPeer component);
@@ -771,6 +773,9 @@
public void setColor (Color c)
{
+ if (c == null)
+ c = Color.BLACK;
+
fg = c;
paint = c;
cairoSetRGBColor (fg.getRed() / 255.0,
@@ -1259,6 +1264,8 @@
public void setComposite(Composite comp)
{
+ this.comp = comp;
+
if (comp instanceof AlphaComposite)
{
AlphaComposite a = (AlphaComposite) comp;
@@ -1345,7 +1352,10 @@
public Composite getComposite()
{
- throw new java.lang.UnsupportedOperationException ();
+ if (comp == null)
+ return AlphaComposite.SrcOver;
+ else
+ return comp;
}
public FontRenderContext getFontRenderContext ()
Index: java/awt/FontMetrics.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/FontMetrics.java,v
retrieving revision 1.5.2.1
diff -u -r1.5.2.1 FontMetrics.java
--- java/awt/FontMetrics.java 24 Jun 2004 05:30:16 -0000 1.5.2.1
+++ java/awt/FontMetrics.java 2 Sep 2004 18:59:01 -0000
@@ -38,6 +38,10 @@
package java.awt;
+import java.awt.font.FontRenderContext;
+import java.awt.font.LineMetrics;
+import java.text.CharacterIterator;
+
// FIXME: I leave many methods basically unimplemented. This
// should be reviewed.
@@ -349,6 +353,114 @@
+ ",descent=" + getDescent() + ",height=" + getHeight() + "]");
}
+
+// Generic FontRenderContext used when getLineMetrics is called with a
+// plain Graphics object.
+private static final FontRenderContext gRC = new FontRenderContext(null,
+ false,
+ false);
+
+/**
+ * Returns a {@link LineMetrics} object constructed with the
+ * specified text and the {@link FontRenderContext} of the Graphics
+ * object when it is an instance of Graphics2D or a generic
+ * FontRenderContext with a null transform, not anti-aliased and not
+ * using fractional metrics.
+ *
+ * @param text The string to calculate metrics from.
+ * @param g The Graphics object that will be used.
+ *
+ * @return A new {@link LineMetrics} object.
+ */
+public LineMetrics getLineMetrics(String text, Graphics g)
+{
+ return getLineMetrics(text, 0, text.length(), g);
+}
+
+/**
+ * Returns a {@link LineMetrics} object constructed with the
+ * specified text and the {@link FontRenderContext} of the Graphics
+ * object when it is an instance of Graphics2D or a generic
+ * FontRenderContext with a null transform, not anti-aliased and not
+ * using fractional metrics.
+ *
+ * @param text The string to calculate metrics from.
+ * @param begin Index of first character in <code>text</code> to measure.
+ * @param limit Index of last character in <code>text</code> to measure.
+ * @param g The Graphics object that will be used.
+ *
+ * @return A new {@link LineMetrics} object.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>text</code>.
+ */
+public LineMetrics getLineMetrics(String text, int begin,
+ int limit, Graphics g)
+{
+ FontRenderContext rc;
+ if (g instanceof Graphics2D)
+ rc = ((Graphics2D) g).getFontRenderContext();
+ else
+ rc = gRC;
+ return font.getLineMetrics(text, begin, limit, rc);
+}
+
+/**
+ * Returns a {@link LineMetrics} object constructed with the
+ * specified text and the {@link FontRenderContext} of the Graphics
+ * object when it is an instance of Graphics2D or a generic
+ * FontRenderContext with a null transform, not anti-aliased and not
+ * using fractional metrics.
+ *
+ * @param chars The string to calculate metrics from.
+ * @param begin Index of first character in <code>text</code> to measure.
+ * @param limit Index of last character in <code>text</code> to measure.
+ * @param g The Graphics object that will be used.
+ *
+ * @return A new {@link LineMetrics} object.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>text</code>.
+ */
+public LineMetrics getLineMetrics(char[] chars, int begin,
+ int limit, Graphics g)
+{
+ FontRenderContext rc;
+ if (g instanceof Graphics2D)
+ rc = ((Graphics2D) g).getFontRenderContext();
+ else
+ rc = gRC;
+ return font.getLineMetrics(chars, begin, limit, rc);
+}
+
+/**
+ * Returns a {@link LineMetrics} object constructed with the
+ * specified text and the {@link FontRenderContext} of the Graphics
+ * object when it is an instance of Graphics2D or a generic
+ * FontRenderContext with a null transform, not anti-aliased and not
+ * using fractional metrics.
+ *
+ * @param rc The string to calculate metrics from.
+ * @param begin Index of first character in <code>text</code> to measure.
+ * @param limit Index of last character in <code>text</code> to measure.
+ * @param g The Graphics object that will be used.
+ *
+ * @return A new {@link LineMetrics} object.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>text</code>.
+ */
+public LineMetrics getLineMetrics(CharacterIterator ci, int begin,
+ int limit, Graphics g)
+{
+ FontRenderContext rc;
+ if (g instanceof Graphics2D)
+ rc = ((Graphics2D) g).getFontRenderContext();
+ else
+ rc = gRC;
+ return font.getLineMetrics(ci, begin, limit, rc);
+}
+
} // class FontMetrics
Index: javax/swing/JMenu.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JMenu.java,v
retrieving revision 1.3.8.11
diff -u -r1.3.8.11 JMenu.java
--- javax/swing/JMenu.java 13 Jul 2004 15:45:35 -0000 1.3.8.11
+++ javax/swing/JMenu.java 2 Sep 2004 18:59:03 -0000
@@ -140,7 +140,8 @@
*/
public JMenu(String text, boolean tearoff)
{
- throw new Error("not implemented");
+ // FIXME: tearoff not implemented
+ this(text);
}
private void writeObject(ObjectOutputStream stream) throws IOException
Index: javax/swing/plaf/basic/BasicGraphicsUtils.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java,v
retrieving revision 1.7.2.2
diff -u -r1.7.2.2 BasicGraphicsUtils.java
--- javax/swing/plaf/basic/BasicGraphicsUtils.java 9 Jun 2004 08:40:08 -0000 1.7.2.2
+++ javax/swing/plaf/basic/BasicGraphicsUtils.java 2 Sep 2004 18:59:03 -0000
@@ -1,5 +1,5 @@
/* BasicGraphicsUtils.java
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -455,7 +455,9 @@
drawUnderline = (underlinedIndex >= 0) && (underlinedIndex < textLength);
- if (!(g instanceof Graphics2D))
+ // XXX - FIXME we now always use this fall-back since TextLayout is
+ // almost completely not implemented.
+ if (!(g instanceof Graphics2D) || true)
{
/* Fall-back. This is likely to produce garbage for any text
* containing right-to-left (Hebrew or Arabic) characters, even
Index: jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c,v
retrieving revision 1.2.12.2
diff -u -r1.2.12.2 gnu_java_awt_peer_gtk_GdkGlyphVector.c
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c 21 May 2004 23:34:16 -0000 1.2.12.2
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c 2 Sep 2004 18:59:03 -0000
@@ -274,6 +274,10 @@
pango_context_set_font_description (vec->ctx, vec->desc);
items = pango_itemize (vec->ctx, str, 0, len, attrs, NULL);
+ /* FIXME - work around assert(). */
+ if (items == NULL)
+ goto done;
+
g_assert (items != NULL);
/*
@@ -316,6 +320,7 @@
g_list_free (items);
pango_attr_list_unref (attrs);
+done:
(*env)->ReleaseStringUTFChars (env, chars, str);
gdk_threads_leave ();
}
@@ -435,6 +440,10 @@
gdk_threads_enter ();
g_assert (self != NULL);
vec = (struct glyphvec *)NSA_GET_GV_PTR (env, self);
+ /* FIXME - work around assert(). */
+ if (vec == NULL || vec->glyphitems == NULL)
+ goto done;
+
g_assert (vec != NULL);
g_assert (vec->glyphitems != NULL);
@@ -464,6 +473,7 @@
}
}
+done:
ret = rect_to_array (env, &rect);
gdk_threads_leave ();
return ret;
Attachment:
signature.asc
Description: This is a digitally signed message part
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |