public class Lights
extends java.lang.Object
WiFiBox
instance and call
WiFiBox.getLights(int)
.Modifier | Constructor and Description |
---|---|
protected |
Lights(java.net.InetAddress address,
int group)
This constructor creates a new group of lights and a connection to a WiFi
box using the default port.
|
protected |
Lights(java.net.InetAddress address,
int port,
int group)
This constructor creates a new group of lights and a connection to a WiFi
box.
|
protected |
Lights(java.lang.String host,
int group)
This constructor creates a new group of lights and a connection to a WiFi
box using the default port.
|
protected |
Lights(java.lang.String host,
int port,
int group)
This constructor creates a new group of lights and a connection to a WiFi
box.
|
protected |
Lights(WiFiBox wifiBox,
int group)
This constructor creates a new group of lights for a given WiFi box.
|
Modifier and Type | Method and Description |
---|---|
void |
addLightListener(LightListener listener)
Use this function to add a new listener to the group of lights.
|
void |
blink(java.awt.Color color)
This function makes the light blink in a given color three times as a
notification.
|
void |
blink(java.awt.Color color,
int times)
This function makes the light blink in a given color as a notification.
|
void |
blink(java.awt.Color color,
int times,
long colorTime,
long whiteTime)
This function makes the light blink in a given color as a notification.
|
void |
brightness(int value)
Set the brightness value for the group of lights.
|
void |
color(java.awt.Color color)
Set the color value for the group of lights.
|
void |
color(java.awt.Color color,
boolean forceColoredMode)
Set the color value for the group of lights.
|
void |
color(int value)
Set the color value for the group of lights.
|
void |
color(MilightColor color)
Set the color value for the group of lights.
|
void |
color(MilightColor color,
boolean forceColoredMode)
Set the color value for the group of lights.
|
void |
colorAndBrightness(java.awt.Color color)
Set the color and brightness values for the group of lights.
|
void |
colorAndBrightness(java.awt.Color color,
boolean forceColoredMode)
Set the color and brightness values for the group of lights.
|
void |
colorAndBrightness(MilightColor color)
Set the color and brightness values for the group of lights.
|
void |
colorAndBrightness(MilightColor color,
boolean forceColoredMode)
Set the color and brightness values for the group of lights.
|
void |
discoMode()
Switch the group of lights to the disco mode.
|
void |
discoModeFaster()
Increase the disco mode's speed.
|
void |
discoModeSlower()
Decrease the disco mode's speed.
|
int |
getGroup()
Get the number of the group of lights at the WiFi box.
|
LightObserver |
getObserver()
This function returns the LightObserver storing all the states of the
group of lights.
|
WiFiBox |
getWifiBox()
Get the WiFi box used to control this group of lights.
|
void |
off()
Switch the group of lights off.
|
void |
on()
Switch the group of lights on and restore the last state.
|
void |
removeLightListener(LightListener listener)
This function removes a listener from this group of lights which was
added before by
addLightListener(LightListener) . |
java.lang.String |
toString()
This function describes the objet as a string.
|
void |
white()
Switch the group of lights to the wight mode and restore the last
brightness value.
|
protected Lights(WiFiBox wifiBox, int group) throws java.lang.IllegalArgumentException
wifiBox
- is the box controlling the group of lightsgroup
- is the number of the group at the WiFi box (between 1 and 4)java.lang.IllegalArgumentException
- if the group number is not between 1 and 4protected Lights(java.net.InetAddress address, int port, int group)
address
- is the address of the WiFi boxport
- is the port of the WiFi box (omit this if unsure)group
- is the number of the group at the WiFi box (between 1 and 4)java.lang.IllegalArgumentException
- if the group number is not between 1 and 4to get the WiFi box connected to group of lights
,
to get another group of lights for the same
WiFi box
protected Lights(java.net.InetAddress address, int group)
address
- is the address of the WiFi box listening on the default portgroup
- is the number of the group at the WiFi box (between 1 and 4)java.lang.IllegalArgumentException
- if the group number is not between 1 and 4to get the WiFi box connected to group of lights
,
to get another group of lights for the same
WiFi box
protected Lights(java.lang.String host, int port, int group) throws java.net.UnknownHostException
host
- is the host given as hostname such as "domain.tld" or string
repesentation of an ip addressport
- is the port of the WiFi box (omit this if unsure)group
- is the number of the group at the WiFi box (between 1 and 4)java.lang.IllegalArgumentException
- if the group number is not between 1 and 4java.net.UnknownHostException
- if the hostname could not be resolvedto get the WiFi box connected to group of lights
,
to get another group of lights for the same
WiFi box
protected Lights(java.lang.String host, int group) throws java.net.UnknownHostException
host
- is the host given as hostname such as "domain.tld" or string
repesentation of an ip addressgroup
- is the number of the group at the WiFi box (between 1 and 4)java.lang.IllegalArgumentException
- if the group number is not between 1 and 4java.net.UnknownHostException
- if the hostname could not be resolvedto get the WiFi box connected to group of lights
,
to get another group of lights for the same
WiFi box
public WiFiBox getWifiBox()
public int getGroup()
public void on() throws java.io.IOException
java.io.IOException
- if the message could not be sentpublic void off() throws java.io.IOException
java.io.IOException
- if the message could not be sentpublic void white() throws java.io.IOException
java.io.IOException
- if the message could not be sentpublic void discoMode() throws java.io.IOException
java.io.IOException
- if the message could not be sentpublic void discoModeFaster() throws java.io.IOException
java.io.IOException
- if the message could not be sentpublic void discoModeSlower() throws java.io.IOException
java.io.IOException
- if the message could not be sentpublic void brightness(int value) throws java.io.IOException, java.lang.IllegalArgumentException
value
- is the brightness value to set (between WiFiBox.MIN_BRIGHTNESS
and WiFiBox.MAX_BRIGHTNESS)java.io.IOException
- if the message could not be sentjava.lang.IllegalArgumentException
- if the brightness value is not between WiFiBox.MIN_BRIGHTNESS
and WiFiBox.MAX_BRIGHTNESSpublic void color(int value) throws java.io.IOException, java.lang.IllegalArgumentException
value
- is the color value to set (between WiFiBox.MIN_COLOR and
WiFiBox.MAX_COLOR)java.io.IOException
- if the message could not be sentjava.lang.IllegalArgumentException
- if the color value is not between WiFiBox.MIN_COLOR and
WiFiBox.MAX_COLORpublic void color(MilightColor color, boolean forceColoredMode) throws java.io.IOException
color
- is the color to setforceColoredMode
- true if all colors should be displayed in colored mode, false
to use white mode for colors with low saturation and else
colored modejava.io.IOException
- if the message could not be sentpublic void color(MilightColor color) throws java.io.IOException
color
- is the color to setjava.io.IOException
- if the message could not be sentpublic void color(java.awt.Color color, boolean forceColoredMode) throws java.io.IOException
color
- is the color to setforceColoredMode
- true if all colors should be displayed in colored mode, false
to use white mode for colors with low saturation and else
colored modejava.io.IOException
- if the message could not be sentpublic void color(java.awt.Color color) throws java.io.IOException
color
- is the color to setjava.io.IOException
- if the message could not be sentpublic void colorAndBrightness(MilightColor color, boolean forceColoredMode)
color
- is the color to extract hue and brightness fromforceColoredMode
- true if all colors should be displayed in colored mode, false
to use white mode for colors with low saturation and else
colored modepublic void colorAndBrightness(MilightColor color)
color
- is the color to extract hue and brightness frompublic void colorAndBrightness(java.awt.Color color, boolean forceColoredMode)
color
- is the color to extract hue and brightness fromforceColoredMode
- true if all colors should be displayed in colored mode, false
to use white mode for colors with low saturation and else
colored modepublic void colorAndBrightness(java.awt.Color color)
color
- is the color to extract hue and brightness frompublic void blink(java.awt.Color color, int times, long colorTime, long whiteTime) throws java.lang.IllegalArgumentException
color
- is the color to blink in (white mode in the mean time)times
- is the number of times to blinkcolorTime
- is the time to stay in colored mode in millisecondswhiteTime
- is the time to stay in white mode (between blinking) in
millisecondsjava.lang.IllegalArgumentException
- if the time in colored or white mode is not at least
2*WiFiBox.MIN_SLEEP_BETWEEN_MESSAGES or the times variable is
non-positivepublic void blink(java.awt.Color color, int times) throws java.lang.IllegalArgumentException
color
- is the color to blink in (white mode in the mean time)times
- is the number of times to blinkjava.lang.IllegalArgumentException
- if the times variable is non-positivepublic void blink(java.awt.Color color) throws java.lang.IllegalArgumentException
color
- is the color to blink in (white mode in the mean time)java.lang.IllegalArgumentException
public void addLightListener(LightListener listener)
listener
- is the listener to addpublic void removeLightListener(LightListener listener)
addLightListener(LightListener)
.listener
- is the listener to removepublic LightObserver getObserver()
public java.lang.String toString()
toString
in class java.lang.Object