j3d.org Code

org.j3d.geom.terrain
Class HeightImageCreator

java.lang.Object
  extended by org.j3d.geom.terrain.HeightImageCreator

public class HeightImageCreator
extends java.lang.Object

A converter utility for changing height map information to and from images.

Height maps are designed to use a single colour range - for example grey scale. They do not generate multiple colour values for different heights like the a colour ramp generator might produce. There is one colour for the minimum height and one colour for the maximum and the range blends between them.

When generating an image, the values works along the X part of image being equated to the X axis of the coordinates. The Y axis of the image is equivalent to the Z axis of the coordinates.

Version:
$Revision: 1.1 $
Author:
Justin Couch

Constructor Summary
HeightImageCreator()
          Create a default map converter.
HeightImageCreator(javax.vecmath.Color4b min, javax.vecmath.Color4b max)
          Create a new height map convertor that uses color range values when creating an image.If a parameter is null, it will set the color to either black or white depending on which is null.
 
Method Summary
 java.awt.image.BufferedImage createColorImage(float[][] data)
          Create a color model image from the set of terrain points.
 java.awt.image.BufferedImage createGreyScaleImage(float[][] data)
          Create a greyscale image from a set of terrain points.
 void setColorRange(javax.vecmath.Color4b min, javax.vecmath.Color4b max)
          Set the colours for the minimum and maximum height.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeightImageCreator

public HeightImageCreator()
Create a default map converter. If used to create an image, it will use a grayscale range.


HeightImageCreator

public HeightImageCreator(javax.vecmath.Color4b min,
                          javax.vecmath.Color4b max)
Create a new height map convertor that uses color range values when creating an image.If a parameter is null, it will set the color to either black or white depending on which is null.

Parameters:
min - The colour of the minimum height
max - The colour of the maximum height
Method Detail

setColorRange

public void setColorRange(javax.vecmath.Color4b min,
                          javax.vecmath.Color4b max)
Set the colours for the minimum and maximum height. If a parameter is null, it will set the color to either black or white depending on which is null.

Parameters:
min - The colour of the minimum height
max - The colour of the maximum height

createGreyScaleImage

public java.awt.image.BufferedImage createGreyScaleImage(float[][] data)
Create a greyscale image from a set of terrain points. White will indicate the highest point and black the lowest. The width and height of the image will be equivalent to the size of the terrain array presented.

Parameters:
data - The map of terrain coordinate values
Returns:
An image representation of the values
Throws:
java.lang.NullPointerException - The data reference is null
java.lang.IllegalArgumentException - Values in the data array are null

createColorImage

public java.awt.image.BufferedImage createColorImage(float[][] data)
Create a color model image from the set of terrain points. This will use the min and max colours that have been preset. Hints for width and height of the output image can be provided. If the value is -1 then it should be automatically calculated from the underlying data

Parameters:
data - The map of terrain coordinate values
Returns:
An image representing the heights
Throws:
java.lang.NullPointerException - The data reference is null
java.lang.IllegalArgumentException - Values in the data array are null

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org