本文整理汇总了Java中org.reactfx.Change类的典型用法代码示例。如果您正苦于以下问题:Java Change类的具体用法?Java Change怎么用?Java Change使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Change类属于org.reactfx包,在下文中一共展示了Change类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changesTest
import org.reactfx.Change; //导入依赖的package包/类
@Test
public void changesTest() {
IntegerProperty src = new SimpleIntegerProperty(0);
Val<Number> val = Val.wrap(src);
List<Change<Number>> changes = new ArrayList<>();
val.changes().subscribe(changes::add);
src.set(1);
src.set(2);
src.set(3);
assertArrayEquals(Arrays.asList(0, 1, 2).toArray(),
changes.stream().map(change -> change.getOldValue()).toArray());
assertArrayEquals(Arrays.asList(1, 2, 3).toArray(),
changes.stream().map(change -> change.getNewValue()).toArray());
}
示例2: initialize
import org.reactfx.Change; //导入依赖的package包/类
/**
* Initializes the controller class.
*
* @param url
* @param rb
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
//
codeArea.textProperty().addListener(
(ov, oldText, newText) -> {
Matcher matcher = KEYWORD_PATTERN.matcher(newText);
int lastKwEnd = 0;
StyleSpansBuilder<Collection<String>> spansBuilder
= new StyleSpansBuilder<>();
while (matcher.find()) {
spansBuilder.add(Collections.emptyList(),
matcher.start() - lastKwEnd);
spansBuilder.add(Collections.singleton("keyword"),
matcher.end() - matcher.start());
lastKwEnd = matcher.end();
}
spansBuilder.add(Collections.emptyList(),
newText.length() - lastKwEnd);
codeArea.setStyleSpans(0, spansBuilder.create());
});
EventStream<Change<String>> textEvents
= EventStreams.changesOf(codeArea.textProperty());
textEvents.reduceSuccessions((a, b) -> b, Duration.ofMillis(500)).
subscribe(code -> {
if (autoCompile) {
compile(code.getNewValue());
}
});
codeArea.replaceText(
"CSG cube = new Cube(2).toCSG()\n"
+ "CSG sphere = new Sphere(1.25).toCSG()\n"
+ "\n"
+ "cube.difference(sphere)");
editorContainer.setContent(codeArea);
subScene = new SubScene(viewGroup, 100, 100, true,
SceneAntialiasing.BALANCED);
subScene.widthProperty().bind(viewContainer.widthProperty());
subScene.heightProperty().bind(viewContainer.heightProperty());
PerspectiveCamera subSceneCamera = new PerspectiveCamera(false);
subScene.setCamera(subSceneCamera);
viewContainer.getChildren().add(subScene);
}
示例3: ColorChange
import org.reactfx.Change; //导入依赖的package包/类
public ColorChange(Change<Paint> c) {
this((Color) c.getOldValue(), (Color) c.getNewValue());
}
示例4: RadiusChange
import org.reactfx.Change; //导入依赖的package包/类
public RadiusChange(Change<Number> c) {
super(c.getOldValue().doubleValue(), c.getNewValue().doubleValue());
}
示例5: CenterXChange
import org.reactfx.Change; //导入依赖的package包/类
public CenterXChange(Change<Number> c) {
super(c.getOldValue().doubleValue(), c.getNewValue().doubleValue());
}
示例6: CenterYChange
import org.reactfx.Change; //导入依赖的package包/类
public CenterYChange(Change<Number> c) {
super(c.getOldValue().doubleValue(), c.getNewValue().doubleValue());
}
示例7: changes
import org.reactfx.Change; //导入依赖的package包/类
/**
* Returns a stream of changed values, which emits the changed value
* (i.e. the old and the new value) on each change of this observable value.
*/
default EventStream<Change<T>> changes() {
return EventStreams.changesOf(this);
}