uk.ac.leeds.ccg.andyt.grids.utilities
Class Utilities

java.lang.Object
  extended by uk.ac.leeds.ccg.andyt.grids.utilities.Utilities

public class Utilities
extends java.lang.Object

This class holds miscellaneous general utility methods


Constructor Summary
Utilities()
          Creates a new instance of Utilities
 
Method Summary
static double angle(double x1, double y1, double x2, double y2)
          Returns the clockwise angle in radians to the y axis of the line from x1, y1 to x2, y2
static java.lang.Object[] densityPlot(Grid2DSquareCellAbstract xGrid, Grid2DSquareCellAbstract yGrid, int divisions, Grid2DSquareCellDoubleFactory gridFactory)
          Returns a density plot of xGrid values against yGrid values.
static double distance(double x1, double y1, double x2, double y2)
          Returns the distance between a pair of coordinates
static void exportIntArray(int[] intArray, java.io.File file)
          Exports int[]
static java.awt.geom.Point2D.Double[] getSamplePoints(java.awt.geom.Point2D.Double point, double angle, double maxDistance, double samplingDistance, double samplingAngle, int numberOfSamples)
          TODO: documentation
static java.awt.geom.Point2D.Double[] getSamplePoints(java.awt.geom.Point2D.Double point, double angle, double maxDistance, int numberOfSamplingDistances, int numberOfSamplingAngles)
          TODO: documentation
static double getValueALittleBitLarger(double value)
          TODO: documentation
static double getValueALittleBitSmaller(double value)
          TODO: documentation
static int[] memoryAllocation(int bytes)
          Returns an int[] Used as a temporary means of allocating memory
static java.lang.String time(long time)
          Returns a string identifying the number of hours, minutes, seconds and milliseconds for the input time in milliseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utilities

public Utilities()
Creates a new instance of Utilities

Method Detail

memoryAllocation

public static int[] memoryAllocation(int bytes)
Returns an int[] Used as a temporary means of allocating memory

Parameters:
bytes - an approximate number of bytes to be allocated in array

exportIntArray

public static void exportIntArray(int[] intArray,
                                  java.io.File file)
Exports int[]


time

public static java.lang.String time(long time)
Returns a string identifying the number of hours, minutes, seconds and milliseconds for the input time in milliseconds.


getValueALittleBitLarger

public static double getValueALittleBitLarger(double value)
TODO: documentation


getValueALittleBitSmaller

public static double getValueALittleBitSmaller(double value)
TODO: documentation


getSamplePoints

public static java.awt.geom.Point2D.Double[] getSamplePoints(java.awt.geom.Point2D.Double point,
                                                             double angle,
                                                             double maxDistance,
                                                             int numberOfSamplingDistances,
                                                             int numberOfSamplingAngles)
TODO: documentation

Parameters:
point - point at centre of sampling
angle - angle in radians to the vertical (y axis) for first sampling
maxDistance - the maximum sampling distance
numberOfSamplingDistances - the number of sampling distances upto maxDistance
numberOfSamplingAngles - sets how many samplesPoints to take at each sample distance. Always the first sample is at angle from the vertical or y-axis. The angles at which samples are taken are all the same.

getSamplePoints

public static java.awt.geom.Point2D.Double[] getSamplePoints(java.awt.geom.Point2D.Double point,
                                                             double angle,
                                                             double maxDistance,
                                                             double samplingDistance,
                                                             double samplingAngle,
                                                             int numberOfSamples)
TODO: documentation


distance

public static final double distance(double x1,
                                    double y1,
                                    double x2,
                                    double y2)
Returns the distance between a pair of coordinates

Parameters:
x1 - - the x coordinte of one point
y1 - - the y coordinte of one point
x2 - - the x coordinte of another point
y2 - - the y coordinte of another point

angle

public static final double angle(double x1,
                                 double y1,
                                 double x2,
                                 double y2)
Returns the clockwise angle in radians to the y axis of the line from x1, y1 to x2, y2

Parameters:
x1 - - the x coordinte of one point
y1 - - the y coordinte of one point
x2 - - the x coordinte of another point
y2 - - the y coordinte of another point

densityPlot

public static java.lang.Object[] densityPlot(Grid2DSquareCellAbstract xGrid,
                                             Grid2DSquareCellAbstract yGrid,
                                             int divisions,
                                             Grid2DSquareCellDoubleFactory gridFactory)
Returns a density plot of xGrid values against yGrid values. A density plot is like a scatterplot, but rather than plotting individual point these are aggregated first to cells. The values of yGrid are scaled to be in the same range as the values of xGrid and the number of divisions for each axis is given by divisions. NB1 For this implementation xGrid and yGrid must have the same spatial frame. NB2 The result returned has a set cellsize of 1 and origin at ( 0, 0 ) (This enables easy comparison with other density plots)