下面列出了javafx.scene.text.Text#setLayoutY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static Node createIconContent() {
Text htmlStart = new Text("<html>");
Text htmlEnd = new Text("</html>");
htmlStart.setFont(Font.font(null, FontWeight.BOLD, 20));
htmlStart.setStyle("-fx-font-size: 20px;");
htmlStart.setTextOrigin(VPos.TOP);
htmlStart.setLayoutY(11);
htmlStart.setLayoutX(20);
htmlEnd.setFont(Font.font(null, FontWeight.BOLD, 20));
htmlEnd.setStyle("-fx-font-size: 20px;");
htmlEnd.setTextOrigin(VPos.TOP);
htmlEnd.setLayoutY(31);
htmlEnd.setLayoutX(20);
return new Group(htmlStart, htmlEnd);
}
public static Node createIconContent() {
Text text = new Text("abc");
text.setTextOrigin(VPos.TOP);
text.setLayoutX(10);
text.setLayoutY(11);
text.setFill(Color.BLACK);
text.setOpacity(0.5);
text.setFont(Font.font(null, FontWeight.BOLD, 20));
text.setStyle("-fx-font-size: 20px;");
Text text2 = new Text("abc");
text2.setTextOrigin(VPos.TOP);
text2.setLayoutX(28);
text2.setLayoutY(51);
text2.setFill(Color.BLACK);
text2.setFont(javafx.scene.text.Font.font(null, FontWeight.BOLD, 20));
text2.setStyle("-fx-font-size: 20px;");
Line line = new Line(30, 32, 45, 57);
line.setStroke(Color.DARKMAGENTA);
return new javafx.scene.Group(text, line, text2);
}
public static Node createIconContent() {
Text htmlStart = new Text("<html>");
Text htmlEnd = new Text("</html>");
htmlStart.setFont(Font.font(null, FontWeight.BOLD, 20));
htmlStart.setStyle("-fx-font-size: 20px;");
htmlStart.setTextOrigin(VPos.TOP);
htmlStart.setLayoutY(11);
htmlStart.setLayoutX(20);
htmlEnd.setFont(Font.font(null, FontWeight.BOLD, 20));
htmlEnd.setStyle("-fx-font-size: 20px;");
htmlEnd.setTextOrigin(VPos.TOP);
htmlEnd.setLayoutY(31);
htmlEnd.setLayoutX(20);
return new Group(htmlStart, htmlEnd);
}
public static Node createIconContent() {
Text text = new Text("abc");
text.setTextOrigin(VPos.TOP);
text.setLayoutX(10);
text.setLayoutY(11);
text.setFill(Color.BLACK);
text.setOpacity(0.5);
text.setFont(Font.font(null, FontWeight.BOLD, 20));
text.setStyle("-fx-font-size: 20px;");
Text text2 = new Text("abc");
text2.setTextOrigin(VPos.TOP);
text2.setLayoutX(28);
text2.setLayoutY(51);
text2.setFill(Color.BLACK);
text2.setFont(javafx.scene.text.Font.font(null, FontWeight.BOLD, 20));
text2.setStyle("-fx-font-size: 20px;");
Line line = new Line(30, 32, 45, 57);
line.setStroke(Color.DARKMAGENTA);
return new javafx.scene.Group(text, line, text2);
}
private Text createNumber(String number, double layoutX, double layoutY) {
Text text = new Text(number);
text.setLayoutX(layoutX);
text.setLayoutY(layoutY);
text.setTextAlignment(TextAlignment.CENTER);
text.setFill(FILL_COLOR);
text.setFont(NUMBER_FONT);
return text;
}
private Text createDot(String string) {
Text text = new Text(string);
text.setFill(Color.web("#000000"));
text.setFont(FONT);
text.setTextOrigin(VPos.TOP);
text.setLayoutX(1);
text.setLayoutY(-4);
return text;
}
public LettersPane() {
setId("LettersPane");
setPrefSize(480,480);
setFocusTraversable(true);
setOnMousePressed(new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent me) {
requestFocus();
me.consume();
}
});
setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override public void handle(KeyEvent ke) {
createLetter(ke.getText());
ke.consume();
}
});
// create press keys text
pressText = new Text("Press Keys");
pressText.setTextOrigin(VPos.TOP);
pressText.setFont(new Font(Font.getDefault().getFamily(), 40));
pressText.setLayoutY(5);
pressText.setFill(Color.rgb(80, 80, 80));
DropShadow effect = new DropShadow();
effect.setRadius(0);
effect.setOffsetY(1);
effect.setColor(Color.WHITE);
pressText.setEffect(effect);
getChildren().add(pressText);
}
public MyEnsembleNode(String name) {
text = new Text(name);
text.setTextOrigin(VPos.TOP);
text.setLayoutX(4);
text.setLayoutY(2);
rectangle = new Rectangle(50, 20, Color.WHITESMOKE);
rectangle.setStroke(Color.BLACK);
//add nodes as childrens, order matters, first is on the bottom
getChildren().addAll(rectangle, text);
}
public static Node createIconContent() {
MyEnsembleNode myNode = new MyEnsembleNode("MyNode");
myNode.setLayoutY(50);
MyEnsembleNode parent = new MyEnsembleNode("Parent");
Polygon arrow = createUMLArrow();
arrow.setLayoutY(20);
arrow.setLayoutX(25-7.5);
Text text = new Text("<<extends>>");
text.setTextOrigin(VPos.TOP);
text.setLayoutY(31);
text.setLayoutX(30);
return new Group(parent, arrow, text, myNode);
}
private Text createNumber(String number, double layoutX, double layoutY) {
Text text = new Text(number);
text.setLayoutX(layoutX);
text.setLayoutY(layoutY);
text.setTextAlignment(TextAlignment.CENTER);
text.setFill(FILL_COLOR);
text.setFont(NUMBER_FONT);
return text;
}
private Text createDot(String string) {
Text text = new Text(string);
text.setFill(Color.web("#000000"));
text.setFont(FONT);
text.setTextOrigin(VPos.TOP);
text.setLayoutX(1);
text.setLayoutY(-4);
return text;
}
public LettersPane() {
setId("LettersPane");
setPrefSize(480,480);
setFocusTraversable(true);
setOnMousePressed(new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent me) {
requestFocus();
me.consume();
}
});
setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override public void handle(KeyEvent ke) {
createLetter(ke.getText());
ke.consume();
}
});
// create press keys text
pressText = new Text("Press Keys");
pressText.setTextOrigin(VPos.TOP);
pressText.setFont(new Font(Font.getDefault().getFamily(), 40));
pressText.setLayoutY(5);
pressText.setFill(Color.rgb(80, 80, 80));
DropShadow effect = new DropShadow();
effect.setRadius(0);
effect.setOffsetY(1);
effect.setColor(Color.WHITE);
pressText.setEffect(effect);
getChildren().add(pressText);
}
public MyEnsembleNode(String name) {
text = new Text(name);
text.setTextOrigin(VPos.TOP);
text.setLayoutX(4);
text.setLayoutY(2);
rectangle = new Rectangle(50, 20, Color.WHITESMOKE);
rectangle.setStroke(Color.BLACK);
//add nodes as childrens, order matters, first is on the bottom
getChildren().addAll(rectangle, text);
}
public static Node createIconContent() {
MyEnsembleNode myNode = new MyEnsembleNode("MyNode");
myNode.setLayoutY(50);
MyEnsembleNode parent = new MyEnsembleNode("Parent");
Polygon arrow = createUMLArrow();
arrow.setLayoutY(20);
arrow.setLayoutX(25-7.5);
Text text = new Text("<<extends>>");
text.setTextOrigin(VPos.TOP);
text.setLayoutY(31);
text.setLayoutX(30);
return new Group(parent, arrow, text, myNode);
}
private Text createNumber(String number, double layoutX, double layoutY) {
Text text = new Text(number);
text.setLayoutX(layoutX);
text.setLayoutY(layoutY);
text.setTextAlignment(TextAlignment.CENTER);
text.setFill(FILL_COLOR);
text.setFont(NUMBER_FONT);
return text;
}
private Text createDot(String string) {
Text text = new Text(string);
text.setFill(Color.web("#000000"));
text.setFont(FONT);
text.setTextOrigin(VPos.TOP);
text.setLayoutX(1);
text.setLayoutY(-4);
return text;
}
public LettersPane() {
setId("LettersPane");
setPrefSize(480,480);
setFocusTraversable(true);
setOnMousePressed(new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent me) {
requestFocus();
me.consume();
}
});
setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override public void handle(KeyEvent ke) {
createLetter(ke.getText());
ke.consume();
}
});
// create press keys text
pressText = new Text("Press Keys");
pressText.setTextOrigin(VPos.TOP);
pressText.setFont(new Font(Font.getDefault().getFamily(), 40));
pressText.setLayoutY(5);
pressText.setFill(Color.rgb(80, 80, 80));
DropShadow effect = new DropShadow();
effect.setRadius(0);
effect.setOffsetY(1);
effect.setColor(Color.WHITE);
pressText.setEffect(effect);
getChildren().add(pressText);
}
/**
* Creates a new instance of Node
* @param simulator the arm simulator
*/
public LedView(ArmSimulator simulator){
this.simulator = simulator;
this.mainPane = new ScrollPane();
ledOff = new Image(getClass().getResource("/resources/ledOff.png").toExternalForm());
ledOn = new Image(getClass().getResource("/resources/ledOn.png").toExternalForm());
leverOff = new Image(getClass().getResource("/resources/leverOff.png").toExternalForm());
leverOn = new Image(getClass().getResource("/resources/leverOn.png").toExternalForm());
gameContainer = new HBox();
ledContainer = new VBox();
buttonContainer = new VBox();
for(int i=0 ; i < 8 ; i++) { //creating 8 leds at the start of the view
IOLed led = simulator.newIOLed();
AnchorPane newLedAddress = new AnchorPane();
ImageView newLedImage = new ImageView();
ledArray.add(led);
ledImageArrayList.add(newLedImage);
if(led.isOn()) {
newLedImage.setImage(ledOn);
}else {
newLedImage.setImage(ledOff);
}
newLedImage.setLayoutX(0);
newLedImage.setLayoutY(0);
Text newAddress = new Text();
newAddress.setText("0x" + Long.toHexString(led.getPortAddress()) + " Bit N°" + led.shift);
newAddress.setLayoutX(95);
newAddress.setLayoutY(55);
newLedAddress.getChildren().addAll(newLedImage, newAddress);
ledContainer.getChildren().add(newLedAddress);
}
for(int i=0 ; i < 2 ; i++) { //creating 3 buttons at the start of the view
IOButton IOpressButton = simulator.newIOButton();
IOSwitch IOleverButton = simulator.newIOSwitch();
AnchorPane buttonAndTextAndLeverAndTextAnchorPane = new AnchorPane();
Text leverText = new Text();
leverText.setText("0x" + Long.toHexString(IOpressButton.getPortAddress()) + " Bit N°" + IOpressButton.shift);
leverText.setLayoutX(30);
leverText.setLayoutY(100);
Text pushingText = new Text();
pushingText.setText("0x" + Long.toHexString(IOleverButton.getPortAddress()) + " Bit N°" + IOleverButton.shift);
pushingText.setLayoutX(30);
pushingText.setLayoutY(190);
ImageView lever = new ImageView(leverOff);
Button leverButton = new Button("", lever);
Button pushingButton = new Button("", new ImageView(new Image(getClass().getResource("/resources/pushingButton.png").toExternalForm())));
leverButton.setOnAction(ActionEvent -> {
IOleverButton.flip();
refresh();
});
pushingButton.setOnAction(ActionEvent -> {
IOpressButton.push();
refresh();
});
leverButton.setLayoutX(70);
leverButton.setLayoutY(25);
pushingButton.setLayoutX(70);
pushingButton.setLayoutY(115);
leverButtonArray.add(IOleverButton);
pressButtonArray.add(IOpressButton);
leverImageArrayList.add(lever);
buttonAndTextAndLeverAndTextAnchorPane.getChildren().addAll(leverButton, leverText, pushingButton, pushingText);
buttonContainer.getChildren().add(buttonAndTextAndLeverAndTextAnchorPane);
}
gameContainer.getChildren().addAll(ledContainer, buttonContainer);
this.dockNode = new DockNode(mainPane, "Led Game", new ImageView(dockImage));
dockNode.setPrefSize(300,666);
this.mainPane.setContent(gameContainer);
this.mainPane.setFitToWidth(true);
this.mainPane.setFitToHeight(true);
this.mainPane.setHmin(dockNode.getHeight());
}