diff --git a/prism/src/chart/GraphPoint.java b/prism/src/chart/GraphPoint.java index 33c165e0..1525293e 100644 --- a/prism/src/chart/GraphPoint.java +++ b/prism/src/chart/GraphPoint.java @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2002-2004, Andrew Hinton +// Copyright (c) 2002-2006 Andrew Hinton, Dave Parker // // This file is part of PRISM. // @@ -84,6 +84,22 @@ public class GraphPoint //theModel.workOutAndSetYScales(); } + // Check that point is valid (x/y not +/- infnity or NaN) + + public boolean isValid() + { + // x = +/- infinity + if (xCoord == Double.POSITIVE_INFINITY || xCoord == Double.NEGATIVE_INFINITY) return false; + // x = NaN + if (xCoord != xCoord) return false; + // y = +/- infinity + if (yCoord == Double.POSITIVE_INFINITY || yCoord == Double.NEGATIVE_INFINITY) return false; + // y = NaN + if (yCoord != yCoord) return false; + // valid + return true; + } + /** Returns a string describing this point. This method is used to generate the * tooltips. */ diff --git a/prism/src/chart/MultiGraphModel.java b/prism/src/chart/MultiGraphModel.java index 441bcb2e..67c645a5 100644 --- a/prism/src/chart/MultiGraphModel.java +++ b/prism/src/chart/MultiGraphModel.java @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2002-2005, Andrew Hinton +// Copyright (c) 2002-2006, Andrew Hinton, Dave Parker // // This file is part of PRISM. // @@ -1028,6 +1028,9 @@ public class MultiGraphModel extends Observable implements SettingOwner, ListMod */ public synchronized void addPoint(int graphIndex, GraphPoint p, boolean sortAfter, boolean autoX, boolean autoY) throws SettingException { + // Check point valid (no infinity/NaN) + if (!p.isValid()) return; + ((GraphList)graphs.get(graphIndex)).add(p); if(sortAfter)((GraphList)graphs.get(graphIndex)).sortPoints(sortBy); diff --git a/prism/src/prism/DisplayableData.java b/prism/src/prism/DisplayableData.java index e01e2d11..1ac6a26b 100644 --- a/prism/src/prism/DisplayableData.java +++ b/prism/src/prism/DisplayableData.java @@ -68,13 +68,11 @@ public class DisplayableData public void notifyResult(Values v, Object result) { - //System.out.println("**********************************************"); - //System.out.println("notifying result "+v+" = "+result); Object obj = shouldAddThis(v); if(obj != null) { - //System.out.println("this should be added"); double x,y; + // Get x coordinate if(obj instanceof Integer) { x = ((Integer)obj).intValue(); @@ -83,7 +81,11 @@ public class DisplayableData { x = ((Double)obj).doubleValue(); } + // Cancel if non integer/double else return; + // Cancel if +/- infinity or NaN + if (x == Double.POSITIVE_INFINITY || x == Double.NEGATIVE_INFINITY || x != x) return; + // Get y coordinate if(result instanceof Integer) { y = ((Integer)result).intValue(); @@ -92,7 +94,11 @@ public class DisplayableData { y = ((Double)result).doubleValue(); } + // Cancel if non integer/double else return; + // Cancel if +/- infinity or NaN + if (y == Double.POSITIVE_INFINITY || y == Double.NEGATIVE_INFINITY || y != y) return; + // Add point to graph try { GraphPoint existing = getExistingGraphPoint(v); @@ -115,10 +121,6 @@ public class DisplayableData //do nothing } } - else - { - //System.out.println("should not be added"); - } } public void clear() @@ -154,7 +156,6 @@ public class DisplayableData * the value of the rangeConstant. If not this returns null. */ public Object shouldAddThis(Values v) { - boolean shouldAdd = true; for(int i = 0; i < otherValues.getNumValues(); i++) { String name = otherValues.getName(i);