GeoSoft API

no.geosoft.cc.util
Class NiceNumbers

Object
  |
  +--NiceNumbers
All Implemented Interfaces:
Iterator

public class NiceNumbers
extends Object
implements Iterator

Find "nice numbers" within an interval. The interval is given by a min and a max value:

 NiceNumbers numbers = new NiceNumbers (min, max, n, false);
 for (Iterator i = numbers.iterator(); i.hasNext(); ) {
   NiceNumber number = (NiceNumber) i.next();
   :
 }
 
This class is handy for producing quality annotation on graphic displays, for instance along an axis.

Author:
GeoSoft

Constructor Summary
NiceNumbers(double fromValue, double toValue, int nNumbersApprox)
          Create nice numbers in an unbound interval.
NiceNumbers(double fromValue, double toValue, int nNumbersApprox, boolean isBounded)
          Create nice numbers in an interval.
 
Method Summary
 double getFirstValue()
          Return the first nice number of the interval.
 double getLastValue()
          Return the last nice number of the interval.
 int getNValues()
          Return number of nice values in this interval.
 boolean hasNext()
          Retur true if there are more nice numbers, false otherwise.
 Iterator iterator()
          Initiate the iteration and return the iterator object
static void main(String[] args)
          Testing this class.
 Object next()
          Return the next nice number of the sequence.
 void remove()
          From Iterator.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NiceNumbers

public NiceNumbers(double fromValue,
                   double toValue,
                   int nNumbersApprox,
                   boolean isBounded)
Create nice numbers in an interval.

Parameters:
fromValue - From value.
toValue - To value.
nNumbersApprox - Approximate number of major nice numbers to produce.
isBounded - True if fromValue/toValue should be end points and hence reported as nice numbers.

NiceNumbers

public NiceNumbers(double fromValue,
                   double toValue,
                   int nNumbersApprox)
Create nice numbers in an unbound interval.

Parameters:
fromValue - From value.
toValue - To value.
nNumbersApprox - Approximate number of major nice numbers to produce.
Method Detail

iterator

public Iterator iterator()
Initiate the iteration and return the iterator object

Returns:
The iterator (which is this).

hasNext

public boolean hasNext()
Retur true if there are more nice numbers, false otherwise.

Specified by:
hasNext in interface Iterator
Returns:
True if there are more nice numbers, false otherwise.

getFirstValue

public double getFirstValue()
Return the first nice number of the interval.

Returns:
First nice number of the interval.

getLastValue

public double getLastValue()
Return the last nice number of the interval.

Returns:
Last nice number of the interval.

getNValues

public int getNValues()
Return number of nice values in this interval.

Returns:
Total number of nice numbers in the interval.

next

public Object next()
Return the next nice number of the sequence.

Specified by:
next in interface Iterator
Returns:
Next nice number.

remove

public void remove()
From Iterator. Removing nice numbers are not possible, so this method is left empty.

Specified by:
remove in interface Iterator

main

public static void main(String[] args)
Testing this class.

Parameters:
args - Not used.

GeoSoft API

Copyright © 2004 - Geotechnical Software Services     geosoft.no