本文整理汇总了Java中org.eclipse.smarthome.core.library.types.HSBType.getSaturation方法的典型用法代码示例。如果您正苦于以下问题:Java HSBType.getSaturation方法的具体用法?Java HSBType.getSaturation怎么用?Java HSBType.getSaturation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.smarthome.core.library.types.HSBType
的用法示例。
在下文中一共展示了HSBType.getSaturation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setHue
import org.eclipse.smarthome.core.library.types.HSBType; //导入方法依赖的package包/类
@Override
public CompletableFuture<Void> setHue(Double value) throws Exception {
if (value == null) {
value = 0.0;
}
State state = getItem().getStateAs(HSBType.class);
if (state instanceof HSBType) {
HSBType hsb = (HSBType) state;
HSBType newState = new HSBType(new DecimalType(value), hsb.getSaturation(), hsb.getBrightness());
((ColorItem) getItem()).send(newState);
return CompletableFuture.completedFuture(null);
} else {
// state is undefined (light is not connected)
return CompletableFuture.completedFuture(null);
}
}
示例2: setBrightness
import org.eclipse.smarthome.core.library.types.HSBType; //导入方法依赖的package包/类
@Override
public CompletableFuture<Void> setBrightness(Integer value) throws Exception {
if (value == null) {
value = 0;
}
State state = getItem().getStateAs(HSBType.class);
if (state instanceof HSBType) {
HSBType hsb = (HSBType) state;
HSBType newState = new HSBType(hsb.getHue(), hsb.getSaturation(), new PercentType(value));
((ColorItem) getItem()).send(newState);
return CompletableFuture.completedFuture(null);
} else {
// state is undefined (light is not connected)
return CompletableFuture.completedFuture(null);
}
}
示例3: updateBrightness
import org.eclipse.smarthome.core.library.types.HSBType; //导入方法依赖的package包/类
private void updateBrightness(PercentType brightness) {
// Extra temp variable to avoid thread sync concurrency issues on currentUSB
HSBType oldHSB = currentHSB;
HSBType newHSB = new HSBType(oldHSB.getHue(), oldHSB.getSaturation(), brightness);
currentHSB = newHSB;
lastBrightness = brightness;
updateChannelState(newHSB);
}
示例4: constructHsbTypeFromRgbWithBrightnessPercent
import org.eclipse.smarthome.core.library.types.HSBType; //导入方法依赖的package包/类
/**
* Construct a {@link HSBType} from the given RGB values and the xyBrightness.
* RGB is converted to hue, and then the brightness gets applied.
*
* @param rgbR
* RGB red value 0 to 255
* @param rgbG
* RGB green value 0 to 255
* @param rgbB
* RGB blue value 0 to 255
* @param xyBrightness
* xy brightness level 0 to 254
* @return {@link HSBType}
*/
private static HSBType constructHsbTypeFromRgbWithBrightnessPercent(final int rgbR, final int rgbG, final int rgbB,
final int xyBrightness) {
// construct HSBType from RGB values
final HSBType hsbFullBright = HSBType.fromRGB(rgbR, rgbG, rgbB);
// get hue and saturation from HSBType and construct new HSBType based on these
// values with the given brightness
final PercentType brightnessPercent = xyBrightnessToPercentType(xyBrightness);
final HSBType hsb = new HSBType(hsbFullBright.getHue(), hsbFullBright.getSaturation(), brightnessPercent);
return hsb;
}