net.quies.math.plot
Class LinearIndexScheme

java.lang.Object
  extended by net.quies.math.plot.IndexScheme
      extended by net.quies.math.plot.LinearIndexScheme
Direct Known Subclasses:
LinearDecimalIndexScheme, LinearTimeIndexScheme

public abstract class LinearIndexScheme
extends IndexScheme

Subclasses of this class provide a linear axis index.

Since:
1.0
Author:
Pascal S. de Kloe

Constructor Summary
protected LinearIndexScheme()
           
 
Method Summary
protected abstract  BigDecimal getStepsize(BigDecimal preferredStepsize)
          Gets a suitable stepsize which will produce a number of steps as close as possible tho the ideal with preferredStepsize.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearIndexScheme

protected LinearIndexScheme()
Method Detail

getStepsize

protected abstract BigDecimal getStepsize(BigDecimal preferredStepsize)
Gets a suitable stepsize which will produce a number of steps as close as possible tho the ideal with preferredStepsize. The therm suitable is defined by the subclass of this class. If preferredStepsize is not a suitable stepsize this method must decide wheather to use a smaller or a larger one with the following algorithm.

Let a be the largest suitable stepsize less than preferredStepsize and let b be the smallest suitable stepsize greather than preferredStepsize.
Let r be the range of the dimension which is the diference between the highest and the lowest value.

The break point x lies where a is equally wrong than b so x is where the number of steps to many with a is equal to the number of steps short with b.

 r/a - r/x = r/x - r/b
 1/a + 1/b = 1/x + 1/x
 b/ab + a/ab = 2/x
 2/x = (a+b)/ab
 x = 2ab/(a+b)
 
For example the break point between stepsize 1 and stepsize 2 is 4/3.

Since:
1.0