本文整理汇总了Java中com.jpl.games.model.Rubik类的典型用法代码示例。如果您正苦于以下问题:Java Rubik类的具体用法?Java Rubik怎么用?Java Rubik使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Rubik类属于com.jpl.games.model包,在下文中一共展示了Rubik类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RubikView
import com.jpl.games.model.Rubik; //导入依赖的package包/类
public RubikView(String name) {
super(name);
rubik = new Rubik();
setCenter(rubik.getSubScene());
timer = new Timeline(
new KeyFrame(Duration.ZERO,
e -> clock.set(LocalTime.now().minusNanos(time.toNanoOfDay()).format(fmt))),
new KeyFrame(Duration.seconds(1)));
timer.setCycleCount(Animation.INDEFINITE);
timeLabel = new Label();
timeLabel.setStyle("-fx-text-fill: white; -fx-font-size: 0.9em;");
timeLabel.textProperty().bind(clock);
rubik.isSolved().addListener((ov,b,b1)->{
if(b1){
timer.stop();
MobileApplication.getInstance().showMessage("Solved in " + (rubik.getCount().get() + 1) + " movements!");
}
});
getStylesheets().add(RubikView.class.getResource("rubik.css").toExternalForm());
addEventHandler(MouseEvent.ANY, rubik.eventHandler);
}
示例2: start
import com.jpl.games.model.Rubik; //导入依赖的package包/类
@Override
public void start(Stage stage) {
/*
Import Rubik's Cube model and arrows
*/
rubik=new Rubik();
// create toolbars
ToolBar tbTop=new ToolBar(new Button("U"),new Button("Ui"),new Button("F"),
new Button("Fi"),new Separator(),new Button("Y"),
new Button("Yi"),new Button("Z"),new Button("Zi"));
pane.setTop(tbTop);
ToolBar tbBottom=new ToolBar(new Button("B"),new Button("Bi"),new Button("D"),
new Button("Di"),new Button("E"),new Button("Ei"));
pane.setBottom(tbBottom);
ToolBar tbRight=new ToolBar(new Button("R"),new Button("Ri"),new Separator(),
new Button("X"),new Button("Xi"));
tbRight.setOrientation(Orientation.VERTICAL);
pane.setRight(tbRight);
ToolBar tbLeft=new ToolBar(new Button("L"),new Button("Li"),new Button("M"),
new Button("Mi"),new Button("S"),new Button("Si"));
tbLeft.setOrientation(Orientation.VERTICAL);
pane.setLeft(tbLeft);
pane.setCenter(rubik.getSubScene());
pane.getChildren().stream()
.filter(n -> (n instanceof ToolBar))
.forEach(tb->{
((ToolBar)tb).getItems().stream()
.filter(n -> (n instanceof Button))
.forEach(n->((Button)n).setOnAction(e->rubik.rotateFace(((Button)n).getText())));
});
rubik.isOnRotation().addListener((ov,b,b1)->{
pane.getChildren().stream()
.filter(n -> (n instanceof ToolBar))
.forEach(tb->tb.setDisable(b1));
});
final Scene scene = new Scene(pane, 880, 680, true);
scene.setFill(Color.ALICEBLUE);
stage.setTitle("Rubik's Cube - JavaFX3D");
stage.setScene(scene);
stage.show();
}