com.xith.java3d.overlay
Class OverlayUtilities

java.lang.Object
  |
  +--com.xith.java3d.overlay.OverlayUtilities

public class OverlayUtilities
extends java.lang.Object

Copyright: Copyright (c) 2000,2001 Company: Teseract Software, LLP

Author:
David Yazel

Constructor Summary
OverlayUtilities()
           
 
Method Summary
static javax.media.j3d.Shape3D buildShape(javax.media.j3d.Appearance appearance, java.awt.Rectangle bounds)
          Builds a Shape3D with the specified appearanace covering the specified rectangle.
static java.util.Vector 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)
          Return an appropriate buffered image for the size and format.
static java.awt.image.BufferedImage[] loadImages(java.net.URL[] filename, java.awt.Component observer, boolean alphaInImage)
          Loads an array of image filenames into an array of BufferedImages.
static java.awt.image.BufferedImage[] loadImages(java.net.URL[] filename, java.awt.Component observer, boolean alphaInImage, java.awt.Dimension maxSize)
          Returns the maximum width and height in maxSize
static int optimalPower(int value, int threshhold, int max)
          Returns an optimal power of two for the value given.
static void repositonBounds(java.awt.Rectangle bounds, int[] relativePosition, java.awt.Dimension canvasSize, java.awt.Dimension offset)
          Will offset the rectangle within the dimension according to the criteria in the array.
static void setBackgroundColor(OverlayBase[] overlay, java.awt.Color backgroundColor)
          Will update the background color on a set of Overlays and not allow and of them to update until all have been set.
static int smallestPower(int value)
          Return the smallest power of 2 greater than value
static java.util.Vector 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.
 
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)
Return an appropriate buffered image for the size and format.

loadImages

public static java.awt.image.BufferedImage[] loadImages(java.net.URL[] filename,
                                                        java.awt.Component observer,
                                                        boolean alphaInImage)
Loads an array of image filenames into an array of BufferedImages. Images must be loaded in relation to an ImageObserver, this is what the component provides. The loading uses the MediaTracker to make sure that the image is loaded correctly so it has to be Component rather than ImageObserver,

loadImages

public static java.awt.image.BufferedImage[] loadImages(java.net.URL[] filename,
                                                        java.awt.Component observer,
                                                        boolean alphaInImage,
                                                        java.awt.Dimension maxSize)
Returns the maximum width and height in maxSize

setBackgroundColor

public static void setBackgroundColor(OverlayBase[] overlay,
                                      java.awt.Color backgroundColor)
Will update the background color on a set of Overlays and not allow and of them to update until all have been set. Intended to set the background on grouping classes like an OverlayScroller.

subdivide

public static java.util.Vector 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.

components

public static java.util.Vector components(int value,
                                          int threshhold,
                                          int max)
Breaks an integer into powers of 2. The returned vector 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.

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

buildShape

public static javax.media.j3d.Shape3D buildShape(javax.media.j3d.Appearance appearance,
                                                 java.awt.Rectangle bounds)
Builds a Shape3D with the specified appearanace covering the specified rectangle.

repositonBounds

public static void repositonBounds(java.awt.Rectangle bounds,
                                   int[] relativePosition,
                                   java.awt.Dimension canvasSize,
                                   java.awt.Dimension offset)
Will offset the rectangle within the dimension according to the criteria in the array. The elements in relativePosition are set according to the format of Overlay#setRelativePosition().