You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by de...@apache.org on 2005/11/23 23:28:12 UTC

svn commit: r348585 - in /xmlgraphics/batik/branches/svg11: samples/tests/spec/scripting/ sources/org/apache/batik/ext/awt/image/spi/ sources/org/apache/batik/gvt/ sources/org/apache/batik/gvt/renderer/

Author: deweese
Date: Wed Nov 23 14:28:00 2005
New Revision: 348585

URL: http://svn.apache.org/viewcvs?rev=348585&view=rev
Log:
1) Fixed NPE when 'double' clicking now empty text.
2) Ensured that RegistryEntry classes fullfill DeferRable
   contract and provide filter, even when exceptions occur.
3) Fixed some minor issues with test cases.

Modified:
    xmlgraphics/batik/branches/svg11/samples/tests/spec/scripting/styling.svg
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/JDKRegistryEntry.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/JPEGRegistryEntry.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/PNGRegistryEntry.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/TIFFRegistryEntry.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/TextNode.java
    xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java

Modified: xmlgraphics/batik/branches/svg11/samples/tests/spec/scripting/styling.svg
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/samples/tests/spec/scripting/styling.svg?rev=348585&r1=348584&r2=348585&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/samples/tests/spec/scripting/styling.svg (original)
+++ xmlgraphics/batik/branches/svg11/samples/tests/spec/scripting/styling.svg Wed Nov 23 14:28:00 2005
@@ -114,10 +114,11 @@
       document.getElementById("test3").setAttribute("class", "xxx");
       document.getElementById("test4").setAttribute("class", "");
       document.getElementById("test5").setAttribute("id", "foo");
-      regardTestInstance.scriptDone();
       toggleSelected(document.getElementById("cb"));
 
       document.getElementById("a").setAttribute("class", "");
+
+      regardTestInstance.scriptDone();
     }
   ]]></script>
 

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/JDKRegistryEntry.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/JDKRegistryEntry.java?rev=348585&r1=348584&r2=348585&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/JDKRegistryEntry.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/JDKRegistryEntry.java Wed Nov 23 14:28:00 2005
@@ -107,17 +107,22 @@
         Thread t = new Thread() {
                 public void run() {
                     Filter filt = null;
+                    try {
+                        Toolkit tk = Toolkit.getDefaultToolkit();
+                        Image img = tk.createImage(url);
 
-                    Toolkit tk = Toolkit.getDefaultToolkit();
-                    Image img = tk.createImage(url);
-
-                    if (img != null) {
-                        RenderedImage ri = loadImage(img, dr);
-                        if (ri != null) {
-                            filt = new RedRable(GraphicsUtil.wrap(ri));
+                        if (img != null) {
+                            RenderedImage ri = loadImage(img, dr);
+                            if (ri != null) {
+                                filt = new RedRable(GraphicsUtil.wrap(ri));
+                            }
                         }
-                    }
-
+                    } catch (ThreadDeath td) {
+                        filt = ImageTagRegistry.getBrokenLinkImage
+                            (this, errCode, errParam);
+                        dr.setSource(filt);
+                        throw td;
+                    } catch (Throwable t) { }
                     if (filt == null)
                         filt = ImageTagRegistry.getBrokenLinkImage
                             (this, errCode, errParam);

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/JPEGRegistryEntry.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/JPEGRegistryEntry.java?rev=348585&r1=348584&r2=348585&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/JPEGRegistryEntry.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/JPEGRegistryEntry.java Wed Nov 23 14:28:00 2005
@@ -111,6 +111,14 @@
                         // Something bad happened here...
                         filt = ImageTagRegistry.getBrokenLinkImage
                             (this, errCode, errParam);
+                    } catch (ThreadDeath td) {
+                        filt = ImageTagRegistry.getBrokenLinkImage
+                            (this, errCode, errParam);
+                        dr.setSource(filt);
+                        throw td;
+                    } catch (Throwable t) {
+                        filt = ImageTagRegistry.getBrokenLinkImage
+                            (this, errCode, errParam);
                     }
 
                     dr.setSource(filt);

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/PNGRegistryEntry.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/PNGRegistryEntry.java?rev=348585&r1=348584&r2=348585&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/PNGRegistryEntry.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/PNGRegistryEntry.java Wed Nov 23 14:28:00 2005
@@ -101,6 +101,9 @@
                         filt = ImageTagRegistry.getBrokenLinkImage
                             (this, errCode, errParam);
                     } catch (ThreadDeath td) {
+                        filt = ImageTagRegistry.getBrokenLinkImage
+                            (this, errCode, errParam);
+                        dr.setSource(filt);
                         throw td;
                     } catch (Throwable t) {
                         filt = ImageTagRegistry.getBrokenLinkImage

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/TIFFRegistryEntry.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/TIFFRegistryEntry.java?rev=348585&r1=348584&r2=348585&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/TIFFRegistryEntry.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/ext/awt/image/spi/TIFFRegistryEntry.java Wed Nov 23 14:28:00 2005
@@ -86,6 +86,9 @@
                         filt = ImageTagRegistry.getBrokenLinkImage
                             (this, errCode, errParam);
                     } catch (ThreadDeath td) {
+                        filt = ImageTagRegistry.getBrokenLinkImage
+                            (this, errCode, errParam);
+                        dr.setSource(filt);
                         throw td;
                     } catch (Throwable t) {
                         filt = ImageTagRegistry.getBrokenLinkImage

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/TextNode.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/TextNode.java?rev=348585&r1=348584&r2=348585&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/TextNode.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/TextNode.java Wed Nov 23 14:28:00 2005
@@ -337,8 +337,8 @@
      */
     public boolean selectAll(double x, double y) {
         beginMark = textPainter.selectFirst(this);
-        endMark = textPainter.selectLast(this);
-        return true;
+        endMark   = textPainter.selectLast(this);
+        return true; // assume this always changes selection, for now.
     }
 
     /**
@@ -347,10 +347,10 @@
      * @return an object containing the selected content.
      */
     public Object getSelection() {
-
-        int[] ranges = textPainter.getSelected(beginMark, endMark);
         Object o = null;
         if (aci == null) return o;
+
+        int[] ranges = textPainter.getSelected(beginMark, endMark);
 
         // TODO: later we can return more complex things like
         // noncontiguous selections

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java?rev=348585&r1=348584&r2=348585&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java Wed Nov 23 14:28:00 2005
@@ -162,6 +162,8 @@
     public void paint(TextNode node, Graphics2D g2d) {
         AttributedCharacterIterator aci;
         aci = node.getAttributedCharacterIterator();
+        if (aci == null)
+            return;
 
         List textRuns = getTextRuns(node, aci);
 
@@ -1029,7 +1031,10 @@
     public Shape getOutline(TextNode node) {
 
         GeneralPath outline = null;
-        AttributedCharacterIterator aci = node.getAttributedCharacterIterator();
+        AttributedCharacterIterator aci;
+        aci = node.getAttributedCharacterIterator();
+        if (aci == null)
+            return null;
 
         // get the list of text runs
         List textRuns = getTextRuns(node, aci);
@@ -1097,6 +1102,8 @@
      public Rectangle2D getBounds2D(TextNode node) {
         AttributedCharacterIterator aci;
         aci = node.getAttributedCharacterIterator();
+        if (aci == null)
+            return null;
 
         // get the list of text runs
         List textRuns = getTextRuns(node, aci);
@@ -1412,6 +1419,9 @@
     public Mark getMark(TextNode node, int index, boolean leadingEdge) {
         AttributedCharacterIterator aci;
         aci = node.getAttributedCharacterIterator();
+        if (aci == null)
+            return null;
+
         if ((index < aci.getBeginIndex()) ||
             (index > aci.getEndIndex()))
             return null;
@@ -1423,6 +1433,8 @@
     protected Mark hitTest(double x, double y, TextNode node) {
         AttributedCharacterIterator aci;
         aci = node.getAttributedCharacterIterator();
+        if (aci == null)
+            return null;
                            
         // get the list of text runs
         List textRuns = getTextRuns(node, aci);
@@ -1446,6 +1458,9 @@
     public Mark selectFirst(TextNode node) {
         AttributedCharacterIterator aci;
         aci = node.getAttributedCharacterIterator();
+        if (aci == null)
+            return null;
+
         TextHit textHit = new TextHit(aci.getBeginIndex(), false);
         return new BasicTextPainter.BasicMark(node, textHit);
     }
@@ -1456,6 +1471,9 @@
     public Mark selectLast(TextNode node) {
         AttributedCharacterIterator aci;
         aci = node.getAttributedCharacterIterator();
+        if (aci == null)
+            return null;
+
         TextHit textHit = new TextHit(aci.getEndIndex()-1, false);
         return  new BasicTextPainter.BasicMark(node, textHit);
     }
@@ -1484,11 +1502,15 @@
         }
 
         TextNode textNode = start.getTextNode();
+        if (textNode == null)
+            return null;
         if (textNode != finish.getTextNode()) 
             throw new Error("Markers are from different TextNodes!");
 
         AttributedCharacterIterator aci;
         aci = textNode.getAttributedCharacterIterator();
+        if (aci == null)
+            return null;
                              
         int[] result = new int[2];
         result[0] = start.getHit().getCharIndex();
@@ -1564,10 +1586,15 @@
                 ("This Mark was not instantiated by this TextPainter class!");
         }
 
-        TextNode textNode = begin.getTextNode();
+        TextNode textNode = begin.getTextNode(); 
+        if (textNode == null)
+            return null;
         if (textNode != end.getTextNode()) 
             throw new Error("Markers are from different TextNodes!");
-        if (textNode == null)
+
+        AttributedCharacterIterator aci;
+        aci = textNode.getAttributedCharacterIterator();
+        if (aci == null)
             return null;
 
         int beginIndex = begin.getHit().getCharIndex();
@@ -1582,8 +1609,7 @@
         }
 
         // get the list of text runs
-        List textRuns = getTextRuns
-            (textNode, textNode.getAttributedCharacterIterator());
+        List textRuns = getTextRuns(textNode, aci);
 
         GeneralPath highlightedShape = new GeneralPath();