org.hccp.net
Class InetAddressColorFactory

java.lang.Object
  |
  +--org.hccp.net.InetAddressColorFactory

public class InetAddressColorFactory
extends java.lang.Object

A simple hack for converting IPv4 addresses into RGB+alpha colors, as well as resolving RGB+alpha colors into IPv4 addresses. In the case of address -> color, it simply takes each of the octets and assigns it's value to a particular channel. For instance, 64.81.140.31 would resolve to a color similar to this.* In the case of color -> address, the color's red, green, blue, and alpha channel values will become the four octet values. For example, java.awt.Color.RED would resolve to the IP address 255.0.0.255.**

* This is not an exact representation, due to the fact that we cannot render the alpha channel transparency effected by the last octet (the "31").

** One can see that the resolution of color -> address may not necessarily produce a real or "pingable" IP address.


Constructor Summary
InetAddressColorFactory()
           
 
Method Summary
static java.awt.Color getColor(java.net.InetAddress address)
          This simply takes each of the octets and assigns it's value to a particular channel.
static java.awt.Color getColor(java.lang.String address)
          Takes a string representation ("xxx.xxx.xxx.xxx") and for each of the octets, assigns it's value to a particular channel.
static java.net.InetAddress getInetAddress(java.awt.Color color)
          Converts a java.awt.Color object into a corresponding java.net.InetAddress.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InetAddressColorFactory

public InetAddressColorFactory()
Method Detail

getColor

public static java.awt.Color getColor(java.lang.String address)
Takes a string representation ("xxx.xxx.xxx.xxx") and for each of the octets, assigns it's value to a particular channel.


getColor

public static java.awt.Color getColor(java.net.InetAddress address)
This simply takes each of the octets and assigns it's value to a particular channel.


getInetAddress

public static java.net.InetAddress getInetAddress(java.awt.Color color)
Converts a java.awt.Color object into a corresponding java.net.InetAddress. Each of the RGB+alpha channels provides an octet of an IPv4 address. For example, the color java.awt.Color.RED would convert to 255.0.0.255.