Пример #1
0
  @Override
  public void init() {
    // linking this property with the behavior defined in the XML
    hue = new RangedIntBehaviorLogic((RangedIntBehavior) getPojo().getBehavior(BEHAVIOR_HUE));
    hue.addListener(
        new RangedIntBehaviorLogic.Listener() {

          @Override
          public void onLowerBoundValue(Config params, boolean fireCommand) {
            executePowerOff(params);
          }

          @Override
          public void onUpperBoundValue(Config params, boolean fireCommand) {
            executePowerOn(params);
          }

          @Override
          public void onRangeValue(int rangeValue, Config params, boolean fireCommand) {
            setHue(rangeValue, params);
          }
        });
    // register this behavior to the superclass to make it visible to it
    registerBehavior(hue);

    saturation =
        new RangedIntBehaviorLogic((RangedIntBehavior) getPojo().getBehavior(BEHAVIOR_SATURATION));
    saturation.addListener(
        new RangedIntBehaviorLogic.Listener() {

          @Override
          public void onLowerBoundValue(Config params, boolean fireCommand) {
            executePowerOff(params);
          }

          @Override
          public void onUpperBoundValue(Config params, boolean fireCommand) {
            executePowerOn(params);
          }

          @Override
          public void onRangeValue(int rangeValue, Config params, boolean fireCommand) {
            setSaturation(rangeValue, params);
          }
        });
    // register this behavior to the superclass to make it visible to it
    registerBehavior(saturation);

    // linking this powered property with the screenMode behavior defined in the XML
    effect = new ListBehaviorLogic((ListBehavior) getPojo().getBehavior(BEHAVIOR_EFFECT));
    effect.addListener(
        new ListBehaviorLogic.Listener() {
          // TODO: in the kuro the screen modes available depends of the source.

          @Override
          public void selectedChanged(Config params, boolean fireCommand) {
            if (fireCommand) {
              executeSetEffect(params);
            } else {
              setEffect(params.getProperty("value"));
            }
          }
        });
    registerBehavior(effect);

    super.init();
  }
Пример #2
0
 public void setEffect(String value) {
   if (!effect.getSelected().equals(value)) {
     effect.setSelected(value);
     setChanged(true);
   }
 }