j3d.org Code

org.j3d.renderer.java3d.overlay
Class OverlayUtilities

java.lang.Object
  extended byorg.j3d.renderer.java3d.overlay.OverlayUtilities

public class OverlayUtilities
extends java.lang.Object

Utility functionality for creating parts of the overlay system.

Although designed mainly for internal use, this could be useful for end users too.

Version:
$Revision: 1.2 $
Author:
David Yazel

Constructor Summary
OverlayUtilities()
           
 
Method Summary
static java.util.List components(int value, int threshhold, int max)
          Breaks an integer into powers of 2.
static java.awt.image.BufferedImage createBufferedImage(java.awt.Dimension size, boolean hasAlpha)
          Create a buffered image that uses a 3 component colour model with the option of adding an alpha component.
static int optimalPower(int value, int threshhold, int max)
          Returns an optimal power of two for the value given.
static int smallestPower(int value)
          Return the smallest power of 2 greater than value
static java.util.List subdivide(java.awt.Dimension dimension, int threshhold, int max)
          Subdivides an area into a closest fit set of Rectangle with sides that are powers of 2.
static java.util.List subdivide(int width, int height, int threshhold, int max)
          Subdivides an area into a closest fit set of Rectangle with sides that are powers of 2.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OverlayUtilities

public OverlayUtilities()
Method Detail

createBufferedImage

public static java.awt.image.BufferedImage createBufferedImage(java.awt.Dimension size,
                                                               boolean hasAlpha)
Create a buffered image that uses a 3 component colour model with the option of adding an alpha component.

Parameters:
size - The overall size of the image in pixels
hasAlpha - true if the image should contain an alpha channel
Returns:
A matching image instance

subdivide

public static java.util.List subdivide(java.awt.Dimension dimension,
                                       int threshhold,
                                       int max)
Subdivides an area into a closest fit set of Rectangle with sides that are powers of 2. All elements will be less than max and greater than the minimum value by threshhold.

Parameters:
dimension - The required total size
max - The maximum required size
Returns:
A collection of the rectangles needed to construct the total size

subdivide

public static java.util.List subdivide(int width,
                                       int height,
                                       int threshhold,
                                       int max)
Subdivides an area into a closest fit set of Rectangle with sides that are powers of 2. All elements will be less than max and greater than the minimum value by threshhold.

Parameters:
max - The maximum required size
Returns:
A collection of the rectangles needed to construct the total size

components

public static java.util.List components(int value,
                                        int threshhold,
                                        int max)
Breaks an integer into powers of 2. The returned list contains a set of Integers that if summed would be a closest fit to to value. Each returned Integer is not greater than a power of 2 by more than threshhold and is not greater than max.

Parameters:
value - The target value to achieve
max - The maximum required size
Returns:
A list, in order of the component values

optimalPower

public static int optimalPower(int value,
                               int threshhold,
                               int max)
Returns an optimal power of two for the value given. return the largest power of 2 which is less than or equal to the value, OR it will return a larger power of two as long as the difference between that and the value is not greater than the threshhold.


smallestPower

public static int smallestPower(int value)
Return the smallest power of 2 greater than value


j3d.org Code

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