org.afcs.warts.util
Class GuiUtils

java.lang.Object
  extended byorg.afcs.warts.util.GuiUtils

public final class GuiUtils
extends java.lang.Object

The GuiUtils class defines utility methods used by GUI classes.

LICENSE: This code is released to the public domain and may be used for any purpose whatsoever without permission or acknowledgment.

Version:
Last Modified 18 September 2003
Author:
Warren Hedley ( whedley at sdsc dot edu )

Method Summary
static java.awt.Color averageColors(java.awt.Color colorOne, java.awt.Color colorTwo)
          Returns a color halfway in between the two specified colors, created by averaging the red, green, and blue components of the inputs.
static java.lang.String colorToHex(java.awt.Color color)
          Returns the hexidecimal representation of the specified color (e.g., ff0000), which is suitable for use in HTML.
static java.lang.String generateColorKeyLabelHtml(java.awt.Color[] colors, java.lang.String[] text)
          Given two arrays of colors and labels, respectively, this method generates some HTML that can be placed on a label to generate a color-key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

colorToHex

public static java.lang.String colorToHex(java.awt.Color color)
Returns the hexidecimal representation of the specified color (e.g., ff0000), which is suitable for use in HTML.

Parameters:
color - The color to obtain a hex representation of.
Returns:
The hexidecimal representation of the specified color.
Throws:
java.lang.NullPointerException - If color is null.

averageColors

public static java.awt.Color averageColors(java.awt.Color colorOne,
                                           java.awt.Color colorTwo)
Returns a color halfway in between the two specified colors, created by averaging the red, green, and blue components of the inputs.

Parameters:
colorOne - The first color.
colorTwo - The second color.
Returns:
A color halfway in between the two specified colors.
Throws:
java.lang.NullPointerException - If either argument is null.

generateColorKeyLabelHtml

public static java.lang.String generateColorKeyLabelHtml(java.awt.Color[] colors,
                                                         java.lang.String[] text)
Given two arrays of colors and labels, respectively, this method generates some HTML that can be placed on a label to generate a color-key. The cells are laid out horizontally.

Parameters:
colors - The array of colors.
text - The array of labels.
Returns:
A string containg HTML defining a color-key chart.
Throws:
java.lang.NullPointerException - If either argument is null.
java.lang.IllegalArgumentException - If the arrays are different lengths.