public class AmbientLight
extends java.lang.Object
implements java.lang.Runnable
start()
function to run this class
in a seperate thread.Constructor and Description |
---|
AmbientLight(Lights lights)
This constructor creates a new ambient light capturing the screen as
often as possible and extracting 9 pixels (a 3x3 grid) in each loop.
|
AmbientLight(Lights lights,
int nx,
int ny)
This constructor creates a new ambient light capturing the screen as
often as possible.
|
AmbientLight(Lights lights,
int nx,
int ny,
long sleepInterval)
This constructor creates a new ambient light.
|
Modifier and Type | Method and Description |
---|---|
static java.awt.Color |
averageColor(java.util.Set<java.awt.Color> colors)
This function computes the average of a set of colors.
|
static java.util.Set<java.awt.Color> |
extractColors(java.awt.image.BufferedImage image,
int nx,
int ny)
This function extracts the colors of some pixels from a BufferedImage.
|
void |
run()
This functions runs a loop to set the ambient light until the
stop() function is called. |
void |
start()
This function starts the ambient light in a new thread.
|
void |
stop()
This function stops the thread running the ambient light.
|
java.lang.String |
toString()
This function describes the objet as a string.
|
public AmbientLight(Lights lights, int nx, int ny, long sleepInterval)
start()
function to run it in a seperate thread.lights
- is the group of lights to controlnx
- is the number of pixels to be extracted in each loop in
horizontal directionny
- is the number of pixels to be extracted in each loop in
vertical directionsleepInterval
- is the time to sleep between to screen captures in milli
secondspublic AmbientLight(Lights lights, int nx, int ny)
start()
function to run
it in a seperate thread.lights
- is the group of lights to controlnx
- is the number of pixels to be extracted in each loop in
horizontal directionny
- is the number of pixels to be extracted in each loop in
vertical directionpublic void run()
stop()
function is called. In each iteration a
capture of the screen is made, some pixels according to the
nx
and ny
values are extracted,
the average of these colors is computed and then this color is sent to
the controlled group of lights. Use start()
to run
this function in a seperate thread.run
in interface java.lang.Runnable
public static java.util.Set<java.awt.Color> extractColors(java.awt.image.BufferedImage image, int nx, int ny)
image
- is the image where the colors should be extractednx
- is the number of pixels to be read in horizontal directionny
- is the number of pixels to be read in vertical directionpublic static java.awt.Color averageColor(java.util.Set<java.awt.Color> colors)
colors
- is the set of colors to compute the average ofpublic void stop()
start()
public void start()
public java.lang.String toString()
toString
in class java.lang.Object