net.quies.math.plot
Class LinearTimeIndexScheme

java.lang.Object
  extended by net.quies.math.plot.IndexScheme
      extended by net.quies.math.plot.LinearIndexScheme
          extended by net.quies.math.plot.LinearTimeIndexScheme

public class LinearTimeIndexScheme
extends LinearIndexScheme

Makes stepsizes of 1, 2, 4, 5, 10, 15, 20 or 30 for seconds and minutes. Fractions of a second and hours will make a decimal stepsize.

Since:
1.1
Author:
Pascal S. de Kloe

Constructor Summary
LinearTimeIndexScheme()
           
 
Method Summary
protected  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

LinearTimeIndexScheme

public LinearTimeIndexScheme()
Since:
1.1
Method Detail

getStepsize

protected BigDecimal getStepsize(BigDecimal preferredStepsize)
Description copied from class: LinearIndexScheme
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.

Specified by:
getStepsize in class LinearIndexScheme
Since:
1.1