Browse Source

GUI bug fix: graph plotting of infinite/NaN values.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@75 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 19 years ago
parent
commit
fa5ca30332
  1. 18
      prism/src/chart/GraphPoint.java
  2. 5
      prism/src/chart/MultiGraphModel.java
  3. 17
      prism/src/prism/DisplayableData.java

18
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. // This file is part of PRISM.
// //
@ -84,6 +84,22 @@ public class GraphPoint
//theModel.workOutAndSetYScales(); //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 /** Returns a string describing this point. This method is used to generate the
* tooltips. * tooltips.
*/ */

5
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. // 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 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); ((GraphList)graphs.get(graphIndex)).add(p);
if(sortAfter)((GraphList)graphs.get(graphIndex)).sortPoints(sortBy); if(sortAfter)((GraphList)graphs.get(graphIndex)).sortPoints(sortBy);

17
prism/src/prism/DisplayableData.java

@ -68,13 +68,11 @@ public class DisplayableData
public void notifyResult(Values v, Object result) public void notifyResult(Values v, Object result)
{ {
//System.out.println("**********************************************");
//System.out.println("notifying result "+v+" = "+result);
Object obj = shouldAddThis(v); Object obj = shouldAddThis(v);
if(obj != null) if(obj != null)
{ {
//System.out.println("this should be added");
double x,y; double x,y;
// Get x coordinate
if(obj instanceof Integer) if(obj instanceof Integer)
{ {
x = ((Integer)obj).intValue(); x = ((Integer)obj).intValue();
@ -83,7 +81,11 @@ public class DisplayableData
{ {
x = ((Double)obj).doubleValue(); x = ((Double)obj).doubleValue();
} }
// Cancel if non integer/double
else return; 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) if(result instanceof Integer)
{ {
y = ((Integer)result).intValue(); y = ((Integer)result).intValue();
@ -92,7 +94,11 @@ public class DisplayableData
{ {
y = ((Double)result).doubleValue(); y = ((Double)result).doubleValue();
} }
// Cancel if non integer/double
else return; else return;
// Cancel if +/- infinity or NaN
if (y == Double.POSITIVE_INFINITY || y == Double.NEGATIVE_INFINITY || y != y) return;
// Add point to graph
try try
{ {
GraphPoint existing = getExistingGraphPoint(v); GraphPoint existing = getExistingGraphPoint(v);
@ -115,10 +121,6 @@ public class DisplayableData
//do nothing //do nothing
} }
} }
else
{
//System.out.println("should not be added");
}
} }
public void clear() public void clear()
@ -154,7 +156,6 @@ public class DisplayableData
* the value of the rangeConstant. If not this returns null. */ * the value of the rangeConstant. If not this returns null. */
public Object shouldAddThis(Values v) public Object shouldAddThis(Values v)
{ {
boolean shouldAdd = true;
for(int i = 0; i < otherValues.getNumValues(); i++) for(int i = 0; i < otherValues.getNumValues(); i++)
{ {
String name = otherValues.getName(i); String name = otherValues.getName(i);

Loading…
Cancel
Save