PatchSet 4167 
Date: 2003/11/22 18:50:12
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Partially resynced with GNU Classpath CVS

Members: 
        ChangeLog:1.1759->1.1760 
        libraries/javalib/gnu/java/rmi/rmic/Compile_jikes.java:1.2->1.3 
        libraries/javalib/gnu/java/rmi/rmic/Compile_kjc.java:1.1->1.2 
        libraries/javalib/gnu/java/rmi/rmic/RMICException.java:1.1->1.2 
        libraries/javalib/java/awt/datatransfer/DataFlavor.java:1.10->1.11 
        libraries/javalib/java/awt/geom/FlatteningPathIterator.java:1.1->1.2 
        libraries/javalib/java/io/ByteArrayOutputStream.java:1.11->1.12 
        libraries/javalib/java/io/StreamTokenizer.java:1.22->1.23 
        libraries/javalib/java/net/Inet4Address.java:1.3->1.4 
        libraries/javalib/java/net/SocketPermission.java:1.2->1.3 
        libraries/javalib/java/net/URL.java:1.34->1.35 
        libraries/javalib/java/net/URLStreamHandler.java:1.12->1.13 
        libraries/javalib/java/nio/ByteBuffer.java:1.7->1.8 
        libraries/javalib/java/security/cert/CertStore.java:1.1->1.2 
        libraries/javalib/java/sql/Timestamp.java:1.6->1.7 
        libraries/javalib/java/text/CollationKey.java:1.13->1.14 
        libraries/javalib/java/text/FieldPosition.java:1.8->1.9 
        libraries/javalib/java/util/TreeMap.java:1.15->1.16 
        libraries/javalib/java/util/zip/Checksum.java:1.3->1.4 
        libraries/javalib/java/util/zip/InflaterInputStream.java:1.6->1.7 
        libraries/javalib/java/util/zip/ZipConstants.java:1.8->1.9 
        libraries/javalib/javax/naming/CompoundName.java:1.2->1.3 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1759 kaffe/ChangeLog:1.1760
--- kaffe/ChangeLog:1.1759      Sat Nov 22 05:57:28 2003
+++ kaffe/ChangeLog     Sat Nov 22 18:50:12 2003
@@ -1,3 +1,85 @@
+2002-11-22  Dalibor Topic <[EMAIL PROTECTED]>
+
+       Partially resynced with GNU Classpath. Detailed ChangeLog follows.
+
+       2003-08-29  Dalibor Topic  <[EMAIL PROTECTED]>
+
+       * gnu/java/rmi/rmic/Compile_kjc.java: New file.
+       * gnu/java/rmi/rmic/Compile_jikes.java: Likewise
+       * gnu/java/rmi/rmic/RMICException.java: Likewise.
+       
+       2003-11-15  Michael Koch  <[EMAIL PROTECTED]>
+
+       * java/awt/datatransfer/DataFlavor.java,
+       java/security/cert/CertStore.java,
+       java/sql/Timestamp.java,
+       javax/naming/CompoundName.java (equals):
+       Removed some redundant obj == null checks.
+
+       2003-11-11  Sascha Brawer  <[EMAIL PROTECTED]>
+
+       * java/awt/geom/FlatteningPathIterator.java: Entirely re-written.
+
+       2003-11-17  Jeff Sturm  <[EMAIL PROTECTED]>
+
+       * java/io/ByteArrayOutputStream.java (resize):
+       Fix off-by-one error.
+
+       2003-11-16  Tom Tromey  <[EMAIL PROTECTED]>
+
+       * java/io/StreamTokenizer.java (commentChar): Clear other
+       attributes for character.
+       (quoteChar): Likewise.
+
+       2003-11-09  Tom Tromey  <[EMAIL PROTECTED]>
+
+       * java/net/Inet4Address.java (serialVersionUID): Updated.
+
+       2003-11-04  Michael Koch  <[EMAIL PROTECTED]>
+
+       * java/net/SocketPermission.java
+       (equals): Removed unneeded obj == null check.
+       * java/net/URL.java
+       (equals): Removed unneeded obj == null check.
+
+       2003-11-13  Guilhem Lavaux  <[EMAIL PROTECTED]>
+           Mark Wielaard  <[EMAIL PROTECTED]>
+
+       * java/net/URLStreamHandler (parseUrl): Fixed URL parsing
+       ('@' should be checked to distinguish port from userinfo).
+       (toExternalForm): Add @ userInfo if necessary.
+
+       2003-11-04  Michael Koch  <[EMAIL PROTECTED]>
+
+       * java/nio/ByteBuffer.java
+       (equals): Removed unneeded obj != null check.
+
+       2003-10-21  Michael Koch  <[EMAIL PROTECTED]>
+
+       * java/text/CollationKey.java
+       (compareTo): Simplified implementation.
+       (equals): Reoved redundant obj == null check.
+
+       2003-11-19  Dalibor Topic <[EMAIL PROTECTED]>
+
+       * java/text/FieldPosition.java (equals): Adapted to handle
+       field_attribute. Added fast-circuit check for comparison to self.
+       Replaced use of instanceof by getClass to fix symmetry for derived
+       types.
+       (toString): Adapted to handle field_attribute. Improved readability.
+       (hashCode): New method.
+       
+       2003-10-26  Bryce McKinlay  <[EMAIL PROTECTED]> 
+       * java/util/TreeMap.java: Doc fixes. HashMap -> TreeMap.
+
+       2003-11-04  Michael Koch  <[EMAIL PROTECTED]>
+
+       * java/util/zip/Checksum.java,
+       java/util/zip/ZipConstants.java:
+       Removed redundant modifiers.
+       * java/util/zip/InflaterInputStream.java:
+       Merged copyright with libgcj's version.
+       
 2003-11-21  Guilhem Lavaux <[EMAIL PROTECTED]>
 
        * libraries/javalib/kjc.jar: Regenerated to include Ito's patch.
Index: kaffe/libraries/javalib/gnu/java/rmi/rmic/Compile_jikes.java
diff -u kaffe/libraries/javalib/gnu/java/rmi/rmic/Compile_jikes.java:1.2 
kaffe/libraries/javalib/gnu/java/rmi/rmic/Compile_jikes.java:1.3
--- kaffe/libraries/javalib/gnu/java/rmi/rmic/Compile_jikes.java:1.2    Tue Sep 16 
12:35:53 2003
+++ kaffe/libraries/javalib/gnu/java/rmi/rmic/Compile_jikes.java        Sat Nov 22 
18:50:13 2003
@@ -1,56 +1,56 @@
-/*
-  Copyright (c) 2003 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
- 
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.java.rmi.rmic;
-
-/** Subclass of Compiler that can be used to invoke jikes.  */
-public class Compile_jikes extends CompilerProcess
-{
-  /** Compiler arguments to invoke jikes */
-  private static final String [] COMPILER_ARGS = 
-  {
-    "jikes"
-  };
-
-  /** Compute the command line for the process.  */
-  public String[] computeArguments (String filename)
-  {
-    return computeTypicalArguments(COMPILER_ARGS,
-                                  getDestination(),
-                                  filename);
-  }
-}
+/*
+  Copyright (c) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.rmi.rmic;
+
+/** Subclass of Compiler that can be used to invoke jikes.  */
+public class Compile_jikes extends CompilerProcess
+{
+  /** Compiler arguments to invoke jikes */
+  private static final String [] COMPILER_ARGS = 
+  {
+    "jikes"
+  };
+
+  /** Compute the command line for the process.  */
+  public String[] computeArguments (String filename)
+  {
+    return computeTypicalArguments(COMPILER_ARGS,
+                                  getDestination(),
+                                  filename);
+  }
+}
Index: kaffe/libraries/javalib/gnu/java/rmi/rmic/Compile_kjc.java
diff -u kaffe/libraries/javalib/gnu/java/rmi/rmic/Compile_kjc.java:1.1 
kaffe/libraries/javalib/gnu/java/rmi/rmic/Compile_kjc.java:1.2
--- kaffe/libraries/javalib/gnu/java/rmi/rmic/Compile_kjc.java:1.1      Mon Aug 18 
17:40:33 2003
+++ kaffe/libraries/javalib/gnu/java/rmi/rmic/Compile_kjc.java  Sat Nov 22 18:50:13 
2003
@@ -1,56 +1,56 @@
-/*
-  Copyright (c) 2003 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
- 
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.java.rmi.rmic;
-
-/** Subclass of Compiler that can be used to invoke kjc.  */
-public class Compile_kjc extends CompilerProcess
-{
-  /** Compiler arguments to invoke kjc */
-  private static final String [] COMPILER_ARGS = 
-  {
-    "kjc"
-  };
-
-  /** Compute the command line for the process.  */
-  public String[] computeArguments (String filename)
-  {
-    return computeTypicalArguments(COMPILER_ARGS,
-                                  getDestination(),
-                                  filename);
-  }
-}
+/*
+  Copyright (c) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.rmi.rmic;
+
+/** Subclass of Compiler that can be used to invoke kjc.  */
+public class Compile_kjc extends CompilerProcess
+{
+  /** Compiler arguments to invoke kjc */
+  private static final String [] COMPILER_ARGS = 
+  {
+    "kjc"
+  };
+
+  /** Compute the command line for the process.  */
+  public String[] computeArguments (String filename)
+  {
+    return computeTypicalArguments(COMPILER_ARGS,
+                                  getDestination(),
+                                  filename);
+  }
+}
Index: kaffe/libraries/javalib/gnu/java/rmi/rmic/RMICException.java
diff -u kaffe/libraries/javalib/gnu/java/rmi/rmic/RMICException.java:1.1 
kaffe/libraries/javalib/gnu/java/rmi/rmic/RMICException.java:1.2
--- kaffe/libraries/javalib/gnu/java/rmi/rmic/RMICException.java:1.1    Mon Aug 18 
17:40:33 2003
+++ kaffe/libraries/javalib/gnu/java/rmi/rmic/RMICException.java        Sat Nov 22 
18:50:13 2003
@@ -1,66 +1,66 @@
-/*
-  Copyright (c) 2003 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
- 
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.java.rmi.rmic;
-
-/**
- * Thrown by the underlying compiler used by RMIC when it fails to compile a file.
- *
- * @author Dalibor Topic <[EMAIL PROTECTED]>
- */
-
-public class RMICException extends Exception {
-       /**
-        * Create an exception with a message. The cause remains uninitialized.
-        *
-        * @param s the message string
-        * @see #initCause(Throwable)
-        */
-       public RMICException(String message) {
-               super(message);
-       }
-
-       /**
-        * Create an exception with a message and a cause.
-        *
-        * @param s the message string
-        * @param cause the cause of this exception
-        */
-       public RMICException(String message, Throwable cause) {
-               super(message, cause);
-       }
-}
+/*
+  Copyright (c) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.rmi.rmic;
+
+/**
+ * Thrown by the underlying compiler used by RMIC when it fails to compile a file.
+ *
+ * @author Dalibor Topic <[EMAIL PROTECTED]>
+ */
+
+public class RMICException extends Exception {
+       /**
+        * Create an exception with a message. The cause remains uninitialized.
+        *
+        * @param s the message string
+        * @see #initCause(Throwable)
+        */
+       public RMICException(String message) {
+               super(message);
+       }
+
+       /**
+        * Create an exception with a message and a cause.
+        *
+        * @param s the message string
+        * @param cause the cause of this exception
+        */
+       public RMICException(String message, Throwable cause) {
+               super(message, cause);
+       }
+}
Index: kaffe/libraries/javalib/java/awt/datatransfer/DataFlavor.java
diff -u kaffe/libraries/javalib/java/awt/datatransfer/DataFlavor.java:1.10 
kaffe/libraries/javalib/java/awt/datatransfer/DataFlavor.java:1.11
--- kaffe/libraries/javalib/java/awt/datatransfer/DataFlavor.java:1.10  Sun Aug 10 
18:47:48 2003
+++ kaffe/libraries/javalib/java/awt/datatransfer/DataFlavor.java       Sat Nov 22 
18:50:14 2003
@@ -723,9 +723,6 @@
 public boolean
 equals(Object obj)
 {
-  if (obj == null)
-    return(false);
-
   if (!(obj instanceof DataFlavor))
     return(false);
 
Index: kaffe/libraries/javalib/java/awt/geom/FlatteningPathIterator.java
diff -u kaffe/libraries/javalib/java/awt/geom/FlatteningPathIterator.java:1.1 
kaffe/libraries/javalib/java/awt/geom/FlatteningPathIterator.java:1.2
--- kaffe/libraries/javalib/java/awt/geom/FlatteningPathIterator.java:1.1       Wed 
Nov  6 11:52:24 2002
+++ kaffe/libraries/javalib/java/awt/geom/FlatteningPathIterator.java   Sat Nov 22 
18:50:15 2003
@@ -1,5 +1,5 @@
-/* FlatteningPathIterator.java -- performs interpolation of curved paths
-   Copyright (C) 2002 Free Software Foundation
+/* FlatteningPathIterator.java -- Approximates curves by straight lines
+   Copyright (C) 2003 Free Software Foundation
 
 This file is part of GNU Classpath.
 
@@ -38,68 +38,542 @@
 
 package java.awt.geom;
 
+import java.util.NoSuchElementException;
+
+
 /**
- * This class can be used to perform the flattening required by the Shape
- * interface. It interpolates a curved path segment into a sequence of flat
- * ones within a certain flatness, up to a recursion limit.
- *
- * @author Eric Blake <[EMAIL PROTECTED]>
- * @see Shape
- * @see RectangularShape#getPathIterator(AffineTransform, double)
+ * A PathIterator for approximating curved path segments by sequences
+ * of straight lines. Instances of this class will only return
+ * segments of type [EMAIL PROTECTED] PathIterator#SEG_MOVETO}, [EMAIL PROTECTED]
+ * PathIterator#SEG_LINETO}, and [EMAIL PROTECTED] PathIterator#SEG_CLOSE}.
+ *
+ * <p>The accuracy of the approximation is determined by two
+ * parameters:
+ *
+ * <ul><li>The <i>flatness</i> is a threshold value for deciding when
+ * a curved segment is consided flat enough for being approximated by
+ * a single straight line. Flatness is defined as the maximal distance
+ * of a curve control point to the straight line that connects the
+ * curve start and end. A lower flatness threshold means a closer
+ * approximation.  See [EMAIL PROTECTED] QuadCurve2D#getFlatness()} and [EMAIL 
PROTECTED]
+ * CubicCurve2D#getFlatness()} for drawings which illustrate the
+ * meaning of flatness.</li>
+ *
+ * <li>The <i>recursion limit</i> imposes an upper bound for how often
+ * a curved segment gets subdivided. A limit of <i>n</i> means that
+ * for each individual quadratic and cubic B&#xe9;zier spline
+ * segment, at most 2<sup><small><i>n</i></small></sup> [EMAIL PROTECTED]
+ * PathIterator#SEG_LINETO} segments will be created.</li></ul>
+ *
+ * <p><b>Memory Efficiency:</b> The memory consumption grows linearly
+ * with the recursion limit. Neither the <i>flatness</i> parameter nor
+ * the number of segments in the flattened path will affect the memory
+ * consumption.
+ *
+ * <p><b>Thread Safety:</b> Multiple threads can safely work on
+ * separate instances of this class. However, multiple threads should
+ * not concurrently access the same instance, as no synchronization is
+ * performed.
+ *
+ * @see <a href="doc-files/FlatteningPathIterator-1.html"
+ * >Implementation Note</a>
+ *
+ * @author Sascha Brawer ([EMAIL PROTECTED])
+ *
  * @since 1.2
- * @status STUBS ONLY
  */
-public class FlatteningPathIterator implements PathIterator
+public class FlatteningPathIterator
+  implements PathIterator
 {
-  // The iterator we are applied to.
-  private PathIterator subIterator;
-  private double flatness;
-  private int limit;
-
+  /**
+   * The PathIterator whose curved segments are being approximated.
+   */
+  private final PathIterator srcIter;
+
+
+  /**
+   * The square of the flatness threshold value, which determines when
+   * a curve segment is considered flat enough that no further
+   * subdivision is needed.
+   *
+   * <p>Calculating flatness actually produces the squared flatness
+   * value. To avoid the relatively expensive calculation of a square
+   * root for each curve segment, we perform all flatness comparisons
+   * on squared values.
+   *
+   * @see QuadCurve2D#getFlatnessSq()
+   * @see CubicCurve2D#getFlatnessSq()
+   */
+  private final double flatnessSq;
+
+
+  /**
+   * The maximal number of subdivions that are performed to
+   * approximate a quadratic or cubic curve segment.
+   */
+  private final int recursionLimit;
+
+
+  /**
+   * A stack for holding the coordinates of subdivided segments.
+   *
+   * @see <a href="doc-files/FlatteningPathIterator-1.html"
+   * >Implementation Note</a>
+   */
+  private double[] stack;
+
+
+  /**
+   * The current stack size.
+   *
+   * @see <a href="doc-files/FlatteningPathIterator-1.html"
+   * >Implementation Note</a>
+   */
+  private int stackSize;
+
+
+  /**
+   * The number of recursions that were performed to arrive at
+   * a segment on the stack.
+   *
+   * @see <a href="doc-files/FlatteningPathIterator-1.html"
+   * >Implementation Note</a>
+   */
+  private int[] recLevel;
+
+  
+  
+  private final double[] scratch = new double[6];
+
+
+  /**
+   * The segment type of the last segment that was returned by
+   * the source iterator.
+   */
+  private int srcSegType;
+
+
+  /**
+   * The current <i>x</i> position of the source iterator.
+   */
+  private double srcPosX;
+
+
+  /**
+   * The current <i>y</i> position of the source iterator.
+   */
+  private double srcPosY;
+
+
+  /**
+   * A flag that indicates when this path iterator has finished its
+   * iteration over path segments.
+   */
+  private boolean done;
+
+
+  /**
+   * Constructs a new PathIterator for approximating an input
+   * PathIterator with straight lines. The approximation works by
+   * recursive subdivisons, until the specified flatness threshold is
+   * not exceeded.
+   *
+   * <p>There will not be more than 10 nested recursion steps, which
+   * means that a single <code>SEG_QUADTO</code> or
+   * <code>SEG_CUBICTO</code> segment is approximated by at most
+   * 2<sup><small>10</small></sup> = 1024 straight lines.
+   */
   public FlatteningPathIterator(PathIterator src, double flatness)
   {
     this(src, flatness, 10);
   }
-  public FlatteningPathIterator(PathIterator src, double flatness, int limit)
+
+
+  /**
+   * Constructs a new PathIterator for approximating an input
+   * PathIterator with straight lines. The approximation works by
+   * recursive subdivisons, until the specified flatness threshold is
+   * not exceeded.  Additionally, the number of recursions is also
+   * bound by the specified recursion limit.
+   */
+  public FlatteningPathIterator(PathIterator src, double flatness,
+                                int limit)
   {
-    subIterator = src;
-    this.flatness = flatness;
-    this.limit = limit;
     if (flatness < 0 || limit < 0)
       throw new IllegalArgumentException();
+
+    srcIter = src;
+    flatnessSq = flatness * flatness;
+    recursionLimit = limit;
+    fetchSegment();
   }
 
+
+  /**
+   * Returns the maximally acceptable flatness.
+   *
+   * @see QuadCurve2D#getFlatness()
+   * @see CubicCurve2D#getFlatness()
+   */
   public double getFlatness()
   {
-    return flatness;
+    return Math.sqrt(flatnessSq);
   }
 
+
+  /**
+   * Returns the maximum number of recursive curve subdivisions.
+   */
   public int getRecursionLimit()
   {
-    return limit;
+    return recursionLimit;
   }
 
+
+  // Documentation will be copied from PathIterator.
   public int getWindingRule()
   {
-    return subIterator.getWindingRule();
+    return srcIter.getWindingRule();
   }
 
+
+  // Documentation will be copied from PathIterator.
   public boolean isDone()
   {
-    return subIterator.isDone();
+    return done;
   }
 
+
+  // Documentation will be copied from PathIterator.
   public void next()
   {
-    throw new Error("not implemented");
+    if (stackSize > 0)
+    {
+      --stackSize;
+      if (stackSize > 0)
+      {
+        switch (srcSegType)
+        {
+        case PathIterator.SEG_QUADTO:
+          subdivideQuadratic();
+          return;
+
+        case PathIterator.SEG_CUBICTO:
+          subdivideCubic();
+          return;
+
+        default:
+          throw new IllegalStateException();
+        }
+      }
+    }
+
+    srcIter.next();
+    fetchSegment();
   }
 
+
+  // Documentation will be copied from PathIterator.
   public int currentSegment(double[] coords)
   {
-    throw new Error("not implemented");
+    if (done)
+      throw new NoSuchElementException();
+
+    switch (srcSegType)
+    {
+    case PathIterator.SEG_CLOSE:
+      return srcSegType;
+
+    case PathIterator.SEG_MOVETO:
+    case PathIterator.SEG_LINETO:
+      coords[0] = srcPosX;
+      coords[1] = srcPosY;
+      return srcSegType;
+
+    case PathIterator.SEG_QUADTO:
+      if (stackSize == 0)
+      {
+        coords[0] = srcPosX;
+        coords[1] = srcPosY;
+      }
+      else
+      {
+        int sp = stack.length - 4 * stackSize;
+        coords[0] = stack[sp + 2];
+        coords[1] = stack[sp + 3];
+      }
+      return PathIterator.SEG_LINETO;
+
+    case PathIterator.SEG_CUBICTO:
+      if (stackSize == 0)
+      {
+        coords[0] = srcPosX;
+        coords[1] = srcPosY;
+      }
+      else
+      {
+        int sp = stack.length - 6 * stackSize;
+        coords[0] = stack[sp + 4];
+        coords[1] = stack[sp + 5];
+      }
+      return PathIterator.SEG_LINETO;
+    }
+
+    throw new IllegalStateException();
   }
+
+
+  // Documentation will be copied from PathIterator.
   public int currentSegment(float[] coords)
   {
-    throw new Error("not implemented");
+    if (done)
+      throw new NoSuchElementException();
+
+    switch (srcSegType)
+    {
+    case PathIterator.SEG_CLOSE:
+      return srcSegType;
+
+    case PathIterator.SEG_MOVETO:
+    case PathIterator.SEG_LINETO:
+      coords[0] = (float) srcPosX;
+      coords[1] = (float) srcPosY;
+      return srcSegType;
+
+    case PathIterator.SEG_QUADTO:
+      if (stackSize == 0)
+      {
+        coords[0] = (float) srcPosX;
+        coords[1] = (float) srcPosY;
+      }
+      else
+      {
+        int sp = stack.length - 4 * stackSize;
+        coords[0] = (float) stack[sp + 2];
+        coords[1] = (float) stack[sp + 3];
+      }
+      return PathIterator.SEG_LINETO;
+
+    case PathIterator.SEG_CUBICTO:
+      if (stackSize == 0)
+      {
+        coords[0] = (float) srcPosX;
+        coords[1] = (float) srcPosY;
+      }
+      else
+      {
+        int sp = stack.length - 6 * stackSize;
+        coords[0] = (float) stack[sp + 4];
+        coords[1] = (float) stack[sp + 5];
+      }
+      return PathIterator.SEG_LINETO;
+    }
+
+    throw new IllegalStateException();
+  }
+
+
+  /**
+   * Fetches the next segment from the source iterator.
+   */
+  private void fetchSegment()
+  {
+    int sp;
+
+    if (srcIter.isDone())
+    {
+      done = true;
+      return;
+    }
+
+    srcSegType = srcIter.currentSegment(scratch);
+    
+    switch (srcSegType)
+    {
+    case PathIterator.SEG_CLOSE:
+      return;
+
+    case PathIterator.SEG_MOVETO:
+    case PathIterator.SEG_LINETO:
+      srcPosX = scratch[0];
+      srcPosY = scratch[1];
+      return;
+
+    case PathIterator.SEG_QUADTO:
+      if (recursionLimit == 0)
+      {
+        srcPosX = scratch[2];
+        srcPosY = scratch[3];
+        stackSize = 0;
+        return;
+      }
+      sp = 4 * recursionLimit;
+      stackSize = 1;
+      if (stack == null)
+      {
+        stack = new double[sp + /* 4 + 2 */ 6];
+        recLevel = new int[recursionLimit + 1];
+      }
+      recLevel[0] = 0;
+      stack[sp] = srcPosX;                  // P1.x
+      stack[sp + 1] = srcPosY;              // P1.y
+      stack[sp + 2] = scratch[0];           // C.x
+      stack[sp + 3] = scratch[1];           // C.y
+      srcPosX = stack[sp + 4] = scratch[2]; // P2.x
+      srcPosY = stack[sp + 5] = scratch[3]; // P2.y
+      subdivideQuadratic();
+      break;
+
+    case PathIterator.SEG_CUBICTO:
+      if (recursionLimit == 0)
+      {
+        srcPosX = scratch[4];
+        srcPosY = scratch[5];
+        stackSize = 0;
+        return;
+      }
+      sp = 6 * recursionLimit;
+      stackSize = 1;
+      if ((stack == null) || (stack.length < sp + 8))
+      {
+        stack = new double[sp + /* 6 + 2 */ 8];
+        recLevel = new int[recursionLimit + 1];
+      }
+      recLevel[0] = 0;
+      stack[sp] = srcPosX;                  // P1.x
+      stack[sp + 1] = srcPosY;              // P1.y
+      stack[sp + 2] = scratch[0];           // C1.x
+      stack[sp + 3] = scratch[1];           // C1.y
+      stack[sp + 4] = scratch[2];           // C2.x
+      stack[sp + 5] = scratch[3];           // C2.y
+      srcPosX = stack[sp + 6] = scratch[4]; // P2.x
+      srcPosY = stack[sp + 7] = scratch[5]; // P2.y
+      subdivideCubic();
+      return;
+    }
+  }
+
+
+  /**
+   * Repeatedly subdivides the quadratic curve segment that is on top
+   * of the stack. The iteration terminates when the recursion limit
+   * has been reached, or when the resulting segment is flat enough.
+   */
+  private void subdivideQuadratic()
+  {
+    int sp;
+    int level;
+
+    sp = stack.length - 4 * stackSize - 2;
+    level = recLevel[stackSize - 1];
+    while ((level < recursionLimit)
+           && (QuadCurve2D.getFlatnessSq(stack, sp) >= flatnessSq))
+    {
+      recLevel[stackSize] = recLevel[stackSize - 1] = ++level;
+      QuadCurve2D.subdivide(stack, sp, stack, sp - 4, stack, sp);
+      ++stackSize;
+      sp -= 4;
+    }
   }
-} // class FlatteningPathIterator
+
+
+  /**
+   * Repeatedly subdivides the cubic curve segment that is on top
+   * of the stack. The iteration terminates when the recursion limit
+   * has been reached, or when the resulting segment is flat enough.
+   */
+  private void subdivideCubic()
+  {
+    int sp;
+    int level;
+
+    sp = stack.length - 6 * stackSize - 2;
+    level = recLevel[stackSize - 1];

*** Patch too long, truncated ***

_______________________________________________
kaffe mailing list
[EMAIL PROTECTED]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to