visad.bio
Class BioUtil

java.lang.Object
  extended by visad.bio.BioUtil

public class BioUtil
extends java.lang.Object

BioUtil provides a collection of general utilities used by VisBio.


Constructor Summary
BioUtil()
           
 
Method Summary
static float[][] adjustColorTable(float[][] table, float[] alpha, boolean doAlpha)
          Ensures the color table is of the proper type (RGB or RGBA).
static boolean contains(double x1, double y1, double x2, double y2, double vx, double vy)
          Determines whether the specified endpoint lies within the given rectangle.
static RealTuple[] copy(RealTuple[] tuples)
          Makes a deep copy of the given RealTuple array.
static RealTuple[] copy(RealTuple[] tuples, int slice)
          Makes a deep copy of the given RealTuple array, altering the last dimension to match the specified Z-slice value.
static float[] corner(float[] c1, float[] c2, float[] c3)
          Computes the fourth corner of a rectangle, given the first three.
static double[] cursorToDomain(DisplayImpl d, double[] cursor)
          Converts the given cursor coordinates to domain coordinates.
static void dump(RealTuple tuple)
          Dumps information about the given RealTuple to the screen.
static double getDistance(double[] p, double[] q, double[] m)
          Gets the distance between the endpoints p and q, using the given conversion values between pixels and microns.
static double getDistance(double[] a, double[] b, double[] v, boolean segment)
          Computes the minimum distance between the point v and the line a-b.
static boolean intersects(double x1, double y1, double x2, double y2, double ax, double ay, double bx, double by)
          Determines whether the specified line segment intersects the given rectangle.
static FieldImpl loadData(java.io.File file, boolean makeStack)
          Loads the data from the given file, and ensures that the resulting data object is of the proper form, converting image data into single-slice stack data if specified.
static FieldImpl makeStack(FlatField[] f)
          Converts an array of images to an image stack.
static double[] pixelToCursor(DisplayImpl d, int x, int y)
          Converts the given pixel coordinates to cursor coordinates.
static double[] pixelToDomain(DisplayImpl d, int x, int y)
          Converts the given pixel coordinates to domain coordinates.
static void project(float[] x, float[] y, float[] z, float p1x, float p1y, float p1z, float p2x, float p2y, float p2z, int p, float[] min, float[] max, float[] proj)
          Projects all the points in (x, y, z) onto the line defined by (p1, p2).
static boolean tablesEqual(float[][] t1, float[][] t2)
          Tests whether two color tables are identical in content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BioUtil

public BioUtil()
Method Detail

pixelToDomain

public static double[] pixelToDomain(DisplayImpl d,
                                     int x,
                                     int y)
Converts the given pixel coordinates to domain coordinates.


pixelToCursor

public static double[] pixelToCursor(DisplayImpl d,
                                     int x,
                                     int y)
Converts the given pixel coordinates to cursor coordinates.


cursorToDomain

public static double[] cursorToDomain(DisplayImpl d,
                                      double[] cursor)
Converts the given cursor coordinates to domain coordinates.


getDistance

public static double getDistance(double[] a,
                                 double[] b,
                                 double[] v,
                                 boolean segment)
Computes the minimum distance between the point v and the line a-b.

Parameters:
a - Coordinates of the line's first endpoint
b - Coordinates of the line's second endpoint
v - Coordinates of the standalone endpoint
segment - Whether distance computation should be constrained to the given line segment

getDistance

public static double getDistance(double[] p,
                                 double[] q,
                                 double[] m)
Gets the distance between the endpoints p and q, using the given conversion values between pixels and microns.

Parameters:
p - Coordinates of the first endpoint
q - Coordinates of the second endpoint
m - Conversion values between microns and pixels

intersects

public static boolean intersects(double x1,
                                 double y1,
                                 double x2,
                                 double y2,
                                 double ax,
                                 double ay,
                                 double bx,
                                 double by)
Determines whether the specified line segment intersects the given rectangle.

Parameters:
x1 - X-coordinate of the top-left corner of the rectangle
y1 - Y-coordinate of the top-left corner of the rectangle
x2 - X-coordinate of the bottom-right corner of the rectangle
y2 - Y-coordinate of the bottom-right corner of the rectangle
ax - X-coordinate of the line's first endpoint
ay - Y-coordinate of the line's first endpoint
bx - X-coordinate of the line's second endpoint
by - Y-coordinate of the line's second endpoint

contains

public static boolean contains(double x1,
                               double y1,
                               double x2,
                               double y2,
                               double vx,
                               double vy)
Determines whether the specified endpoint lies within the given rectangle.

Parameters:
x1 - X-coordinate of the top-left corner of the rectangle
y1 - Y-coordinate of the top-left corner of the rectangle
x2 - X-coordinate of the bottom-right corner of the rectangle
y2 - Y-coordinate of the bottom-right corner of the rectangle
vx - X-coordinate of the standalone endpoint
vy - Y-coordinate of the standalone endpoint

loadData

public static FieldImpl loadData(java.io.File file,
                                 boolean makeStack)
                          throws VisADException,
                                 java.rmi.RemoteException
Loads the data from the given file, and ensures that the resulting data object is of the proper form, converting image data into single-slice stack data if specified.

Throws:
VisADException
java.rmi.RemoteException

makeStack

public static FieldImpl makeStack(FlatField[] f)
                           throws VisADException,
                                  java.rmi.RemoteException
Converts an array of images to an image stack.

Throws:
VisADException
java.rmi.RemoteException

copy

public static RealTuple[] copy(RealTuple[] tuples)
Makes a deep copy of the given RealTuple array.


copy

public static RealTuple[] copy(RealTuple[] tuples,
                               int slice)
Makes a deep copy of the given RealTuple array, altering the last dimension to match the specified Z-slice value.


dump

public static void dump(RealTuple tuple)
Dumps information about the given RealTuple to the screen.


adjustColorTable

public static float[][] adjustColorTable(float[][] table,
                                         float[] alpha,
                                         boolean doAlpha)
Ensures the color table is of the proper type (RGB or RGBA). If the alpha is not required but the table has an alpha channel, a new table is returned with the alpha channel stripped out. If alpha is required but the table does not have an alpha channel, a new table is returned with an alpha channel matching the provided one (or all 1s if the provided alpha channel is null or invalid).


tablesEqual

public static boolean tablesEqual(float[][] t1,
                                  float[][] t2)
Tests whether two color tables are identical in content.


project

public static void project(float[] x,
                           float[] y,
                           float[] z,
                           float p1x,
                           float p1y,
                           float p1z,
                           float p2x,
                           float p2y,
                           float p2z,
                           int p,
                           float[] min,
                           float[] max,
                           float[] proj)
Projects all the points in (x, y, z) onto the line defined by (p1, p2). The points that bound the line segment are stored in (min, max). The projection of the pth point is stored in proj.


corner

public static float[] corner(float[] c1,
                             float[] c2,
                             float[] c3)
Computes the fourth corner of a rectangle, given the first three.