当前位置: 首页>>代码示例>>Java>>正文


Java HSBType.getSaturation方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:17,代码来源:HomekitColorfulLightbulbImpl.java

示例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);
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:17,代码来源:HomekitColorfulLightbulbImpl.java

示例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);
}
 
开发者ID:openhab,项目名称:org.openhab.binding.zigbee,代码行数:9,代码来源:ZigBeeConverterColorColor.java

示例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;
}
 
开发者ID:comdata,项目名称:HomeAutomation,代码行数:25,代码来源:TradfriColor.java


注:本文中的org.eclipse.smarthome.core.library.types.HSBType.getSaturation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。