react.Value.connect()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(67)

本文整理了Java中react.Value.connect()方法的一些代码示例,展示了Value.connect()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Value.connect()方法的具体详情如下:
包路径:react.Value
类名称:Value
方法名:connect

Value.connect介绍

暂无

代码示例

代码示例来源:origin: threerings/tripleplay

/** Create a selector with a null initial selection. */
public Selector () {
  selected.connect(new ValueView.Listener<Element<?>> () {
    @Override public void onChange (Element<?> selected, Element<?> deselected) {
      if (deselected != null) get(deselected).update(false);
      if (selected != null) get(selected).update(true);
    }
  });
}

代码示例来源:origin: threerings/tripleplay

/** Creates a sound board which will play sounds via {@code plat} and connect to {@code paint}
 * to receive per-frame updates. */
public SoundBoard (Platform plat, Signal<Clock> paint) {
  this.plat = plat;
  paint.connect(new Slot<Clock>() {
    public void onEmit (Clock clock) { update(clock.dt); }
  });
  volume.connect(new Slot<Float>() {
    @Override public void onEmit (Float volume) {
      for (LoopImpl active : _active) active.updateVolume(volume);
    }});
  muted.connect(new Slot<Boolean>() {
    @Override public void onEmit (Boolean muted) {
      for (LoopImpl active : _active) active.fadeForMute(muted);
    }});
}

代码示例来源:origin: threerings/tripleplay

protected CheckBox (char checkChar, Icon checkIcon) {
  _checkStr = String.valueOf(checkChar);
  _checkIcon = checkIcon;
  selected().connect(new Slot<Boolean> () {
    @Override public void onEmit (Boolean checked) {
      updateCheckViz(checked);
    }
  });
}

代码示例来源:origin: threerings/tripleplay

public Toggle (T owner) {
  super(owner);
  selected.connect(selectedDidChange());
}

代码示例来源:origin: threerings/tripleplay

public Slider (float value, float min, float max) {
  this.value = Value.create(value);
  range = Value.create(new Range(min, max));
  // update our display if the slider value is changed externally
  UnitSlot updateThumb = new UnitSlot () { @Override public void onEmit () { updateThumb(); }};
  this.value.connect(updateThumb);
  range.connect(updateThumb);
}

代码示例来源:origin: threerings/tripleplay

/**
 * Creates a new menu item with the given label and icon.
 */
public MenuItem (String label, Icon icon) {
  this.text.update(label);
  this.text.connect(textDidChange());
  // update after connect so we trigger iconDidChange, in case our icon is a not-ready-image
  this.icon.connect(iconDidChange());
  this.icon.update(icon);
}

代码示例来源:origin: threerings/tripleplay

/** Creates a label with the supplied text and icon. */
public Label (String text, Icon icon) {
  this.text.update(text);
  this.text.connect(textDidChange());
  // update after connect so we trigger iconDidChange, in case our icon is a not-ready-image
  this.icon.connect(iconDidChange());
  this.icon.update(icon);
}

代码示例来源:origin: threerings/tripleplay

protected AbstractTextButton (String text, Icon icon) {
  this.text.update(text);
  this.text.connect(textDidChange());
  // update after connect so we trigger iconDidChange, in case our icon is a not-ready-image
  this.icon.connect(iconDidChange());
  this.icon.update(icon);
}

代码示例来源:origin: threerings/tripleplay

/**
 * Exposes the specified property as a {@link Value}. The supplied default value will be used
 * if the property has no current value. Updates to the value will be written back to the
 * storage system. Note that each call to this method yields a new {@link Value} and those
 * values will not coordinate with one another, so the caller must be sure to only call this
 * method once for a given property and share that value properly.
 */
public <E extends Enum<E>> Value<E> valueFor (final String key, E defval) {
  Value<E> value = Value.create(get(key, defval));
  value.connect(new Slot<E>() {
    @Override public void onEmit (E value) {
      set(key, value);
    }
  });
  return value;
}

代码示例来源:origin: threerings/tripleplay

/**
 * Exposes the specified property as a {@link Value}. The supplied default value will be used
 * if the property has no current value. Updates to the value will be written back to the
 * storage system. Note that each call to this method yields a new {@link Value} and those
 * values will not coordinate with one another, so the caller must be sure to only call this
 * method once for a given property and share that value properly.
 */
public Value<String> valueFor (final String key, String defval) {
  Value<String> value = Value.create(get(key, defval));
  value.connect(new Slot<String>() {
    @Override public void onEmit (String value) {
      set(key, value);
    }
  });
  return value;
}

代码示例来源:origin: threerings/tripleplay

/**
 * Exposes the specified property as a {@link Value}. The supplied default value will be used
 * if the property has no current value. Updates to the value will be written back to the
 * storage system. Note that each call to this method yields a new {@link Value} and those
 * values will not coordinate with one another, so the caller must be sure to only call this
 * method once for a given property and share that value properly.
 */
public Value<Long> valueFor (final String key, long defval) {
  Value<Long> value = Value.create(get(key, defval));
  value.connect(new Slot<Long>() {
    @Override public void onEmit (Long value) {
      set(key, value);
    }
  });
  return value;
}

代码示例来源:origin: threerings/tripleplay

/**
 * Exposes the specified property as a {@link Value}. The supplied default value will be used
 * if the property has no current value. Updates to the value will be written back to the
 * storage system. Note that each call to this method yields a new {@link Value} and those
 * values will not coordinate with one another, so the caller must be sure to only call this
 * method once for a given property and share that value properly.
 */
public Value<Double> valueFor (final String key, double defval) {
  Value<Double> value = Value.create(get(key, defval));
  value.connect(new Slot<Double>() {
    @Override public void onEmit (Double value) {
      set(key, value);
    }
  });
  return value;
}

代码示例来源:origin: threerings/tripleplay

/**
 * Exposes the specified property as a {@link Value}. The supplied default value will be used
 * if the property has no current value. Updates to the value will be written back to the
 * storage system. Note that each call to this method yields a new {@link Value} and those
 * values will not coordinate with one another, so the caller must be sure to only call this
 * method once for a given property and share that value properly.
 */
public Value<Boolean> valueFor (final String key, boolean defval) {
  Value<Boolean> value = Value.create(get(key, defval));
  value.connect(new Slot<Boolean>() {
    @Override public void onEmit (Boolean value) {
      set(key, value);
    }
  });
  return value;
}

代码示例来源:origin: threerings/tripleplay

public BoxPointWidget (String label) {
  setLayout(AxisLayout.vertical());
  initChildren(new Label(label),
    new Group(AxisLayout.horizontal()).add(new Label("N:"), nx, ny),
    new Group(AxisLayout.horizontal()).add(new Label("O:"), ox, oy));
  UnitSlot update = new UnitSlot() {
    @Override public void onEmit () {
      point.update(new BoxPoint(
        nx.value.get(), ny.value.get(), ox.value.get(), oy.value.get()));
    }
  };
  nx.value.connect(update);
  ny.value.connect(update);
  ox.value.connect(update);
  oy.value.connect(update);
  addStyles(Style.BACKGROUND.is(Background.solid(Colors.LIGHT_GRAY)));
}

代码示例来源:origin: threerings/tripleplay

ColumnEditor () {
    super(new FlowLayout());
    add(slider("Weight:", weight), slider("Min Width:", minWidth), stretch, halign);
    stretch.selected().update(col.isStretch());
    weight.value.connect(new Slot<Float>() {
      @Override public void onEmit (Float event) {
        col = new ExposedColumn(col.halign(), col.isStretch(), event, col.minWidth());
      }
    });
    minWidth.value.connect(new Slot<Float>() {
      @Override public void onEmit (Float event) {
        col = new ExposedColumn(col.halign(), col.isStretch(), col.weight(), event);
      }
    });
    stretch.selected().connect(new Slot<Boolean>() {
      @Override public void onEmit (Boolean event) {
        col = new ExposedColumn(col.halign(), event, col.weight(), col.minWidth());
      }
    });
    halign.clicked().connect(new Slot<Button>() {
      @Override public void onEmit (Button event) {
        Style.HAlign[] values = Style.HAlign.values();
        Style.HAlign next = values[
          (Style.HAlign.valueOf(halign.text.get()).ordinal() + 1) % values.length];
        halign.text.update(next.name());
        col = new ExposedColumn(next, col.isStretch(), col.weight(), col.minWidth());
      }
    });
  }
}

代码示例来源:origin: threerings/tripleplay

protected Group hookup (String name, Selector sel) {
  final Label label = new Label();
  sel.selected.connect(new Slot<Element<?>>() {
    @Override public void onEmit (Element<?> event) {
      update(label, (ToggleButton)event);
    }
  });
  update(label, (ToggleButton)sel.selected.get());
  return new Group(AxisLayout.horizontal()).add(new Label(name), label);
}

代码示例来源:origin: threerings/tripleplay

public Field (String initialText, Styles styles) {
  setStyles(styles);
  text = Value.create("");
  _finishedEditing = Signal.create();
  if (hasNative()) {
    _finishedEditing.connect(new Slot<Boolean>() {
      @Override public void onEmit (Boolean event) {
        if (!_fullTimeNative) updateMode(false);
      }
    });
  }
  this.text.update(initialText);
  this.text.connect(textDidChange());
}

代码示例来源:origin: threerings/tripleplay

width.value.connect(updateConstraint);
height.value.connect(updateConstraint);
position.point.connect(updateConstraint);
origin.point.connect(updateConstraint);
updateConstraint.onEmit();
return new Group(AxisLayout.vertical().offStretch()).add(

代码示例来源:origin: threerings/tripleplay

tabButtonSelector.selected.connect(new Slot<Element<?>> () {
  @Override public void onEmit (Element<?> button) {
    selected.update(forWidget(button));
selected.connect(new ValueView.Listener<Tab>() {
  @Override public void onChange (Tab selected, Tab deselected) {

代码示例来源:origin: threerings/tripleplay

@Override public Menu createMenu () {
  final PagedMenu menu = new PagedMenu(AxisLayout.vertical(), 32);
  final Slider slider = new Slider().setIncrement(1);
  slider.value.connect(new Slot<Float>() {
    @Override public void onEmit (Float val) {
      menu.setPage(FloatMath.round(val));

相关文章

微信公众号

最新文章

更多