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 dv...@apache.org on 2006/11/09 13:44:47 UTC

svn commit: r472883 - /xmlgraphics/batik/trunk/sources/org/apache/batik/anim/timing/TimedElement.java

Author: dvholten
Date: Thu Nov  9 04:44:46 2006
New Revision: 472883

URL: http://svn.apache.org/viewvc?view=rev&rev=472883
Log:
fixed comparison with NaN

Modified:
    xmlgraphics/batik/trunk/sources/org/apache/batik/anim/timing/TimedElement.java

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/anim/timing/TimedElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/anim/timing/TimedElement.java?view=diff&rev=472883&r1=472882&r2=472883
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/anim/timing/TimedElement.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/anim/timing/TimedElement.java Thu Nov  9 04:44:46 2006
@@ -1,6 +1,6 @@
 /*
 
-   Copyright 2006  The Apache Software Foundation 
+   Copyright 2006  The Apache Software Foundation
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
 import java.util.Map;
 import java.util.MissingResourceException;
 import java.util.Vector;
+import java.util.Set;
 
 import org.apache.batik.anim.AnimationException;
 import org.apache.batik.i18n.LocalizableSupport;
@@ -282,8 +283,8 @@
         // Trace.enter(this, "removeInstanceTime", new Object[] { time, new Boolean(isBegin) } ); try {
         Vector instanceTimes = isBegin ? beginInstanceTimes : endInstanceTimes;
         int index = Collections.binarySearch(instanceTimes, time);
-        for (int i = index; index >= 0; index--) {
-            InstanceTime it = (InstanceTime) instanceTimes.get(i);
+        for (int i = index; index >= 0; index--) {                       // todo cam, please check this
+            InstanceTime it = (InstanceTime) instanceTimes.get(i);       // todo everything ok with i <-> index?? 
             if (it == time) {
                 instanceTimes.remove(i);
                 return;
@@ -293,7 +294,7 @@
             }
         }
         int len = instanceTimes.size();
-        for (int i = index + 1; index < len; i++) {
+        for (int i = index + 1; index < len; i++) {      // todo cam, please check this
             InstanceTime it = (InstanceTime) instanceTimes.get(i);
             if (it == time) {
                 instanceTimes.remove(i);
@@ -419,7 +420,7 @@
     }
 
     /**
-     * Subtracts one simple time from another.
+     * Multiplies one simple time by n.
      */
     protected float multiplyTime(float t, float n) {
         if (isUnresolved(t) || t == INDEFINITE) {
@@ -554,7 +555,7 @@
         while (i.hasNext()) {
             Map.Entry e = (Map.Entry) i.next();
             Event evt = (Event) e.getKey();
-            HashSet ts = (HashSet) e.getValue();
+            Set ts = (Set) e.getValue();
             Iterator j = ts.iterator();
             boolean hasBegin = false, hasEnd = false;
             while (j.hasNext() && !(hasBegin && hasEnd)) {
@@ -883,7 +884,7 @@
      */
     protected void reset(boolean clearCurrentBegin) {
         // System.err.println("reset");
-        Iterator i = beginInstanceTimes.iterator(); 
+        Iterator i = beginInstanceTimes.iterator();
         while (i.hasNext()) {
             InstanceTime it = (InstanceTime) i.next();
             if (it.getClearOnReset() &&
@@ -987,7 +988,8 @@
             public void clockValue(float newClockValue) {
                 v = newClockValue;
             }
-        };
+        }
+
         Handler h = new Handler();
         p.setClockHandler(h);
         p.parse(s);
@@ -1358,7 +1360,7 @@
     /**
      * The error messages bundle class name.
      */
-    protected final static String RESOURCES =
+    protected static final String RESOURCES =
         "org.apache.batik.anim.resources.Messages";
 
     /**
@@ -1394,9 +1396,9 @@
      * Returns a string representation of the given time value.
      */
     public static String toString(float time) {
-        if (time == Float.NaN) {
+        if (Float.isNaN( time )) {
             return "UNRESOLVED";
-        } else if (time == Float.POSITIVE_INFINITY) {
+        } else if (time == Float.POSITIVE_INFINITY) {  // should also test for NEGATIVE_INFINITY?
             return "INDEFINITE";
         } else {
             return Float.toString(time);



Re: svn commit: r472883 - /xmlgraphics/batik/trunk/sources/org/apache/batik/anim/timing/TimedElement.java

Posted by Cameron McCormack <ca...@mcc.id.au>.
dvholten@apache.org:
> -        for (int i = index; index >= 0; index--) {
> -            InstanceTime it = (InstanceTime) instanceTimes.get(i);
> +        for (int i = index; index >= 0; index--) {                       // todo cam, please check this
> +            InstanceTime it = (InstanceTime) instanceTimes.get(i);       // todo everything ok with i <-> index?? 
…
> -        for (int i = index + 1; index < len; i++) {
> +        for (int i = index + 1; index < len; i++) {      // todo cam, please check this

Yep these two are bugs.

> +        } else if (time == Float.POSITIVE_INFINITY) {  // should also test for NEGATIVE_INFINITY?

I never use Float.NEGATIVE_INFINITY for time values: POSITIVE_INFINITY
and NaN are the only two special values (for indefinite and unresolved
times).

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org