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.
//
@ -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.
*/

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.
//
@ -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);

17
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);

Loading…
Cancel
Save