Java 类javafx.scene.text.Text 实例源码
项目:marathonv5
文件:KeyStrokeMotion.java
private void createLetter(String c) {
final Text letter = new Text(c);
letter.setFill(Color.BLACK);
letter.setFont(FONT_DEFAULT);
letter.setTextOrigin(VPos.TOP);
letter.setTranslateX((getWidth() - letter.getBoundsInLocal().getWidth()) / 2);
letter.setTranslateY((getHeight() - letter.getBoundsInLocal().getHeight()) / 2);
getChildren().add(letter);
// over 3 seconds move letter to random position and fade it out
final Timeline timeline = new Timeline();
timeline.getKeyFrames().add(
new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
// we are done remove us from scene
getChildren().remove(letter);
}
},
new KeyValue(letter.translateXProperty(), getRandom(0.0f, getWidth() - letter.getBoundsInLocal().getWidth()),INTERPOLATOR),
new KeyValue(letter.translateYProperty(), getRandom(0.0f, getHeight() - letter.getBoundsInLocal().getHeight()),INTERPOLATOR),
new KeyValue(letter.opacityProperty(), 0f)
));
timeline.play();
}
项目:cemu_UI
文件:JFXTextAreaInfoDialog.java
public void show() {
textArea = new JFXTextArea(bodyText);
JFXDialogLayout content = new JFXDialogLayout();
content.setHeading(new Text(headingText));
content.setBody(textArea);
content.setPrefSize(dialogWidth, dialogHeight);
StackPane stackPane = new StackPane();
stackPane.autosize();
JFXDialog dialog = new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true);
JFXButton button = new JFXButton("Okay");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
dialog.close();
}
});
button.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
button.setPrefHeight(32);
button.setStyle(dialogBtnStyle);
content.setActions(button);
pane.getChildren().add(stackPane);
AnchorPane.setTopAnchor(stackPane, (pane.getHeight() - content.getPrefHeight()) / 2);
AnchorPane.setLeftAnchor(stackPane, (pane.getWidth() - content.getPrefWidth()) / 2);
dialog.show();
}
项目:boomer-tuner
文件:RootController.java
private void displayText(final String s, final String title) {
final Scene scene = new Scene(new Pane());
String text = s;
if (s == null || s.isEmpty()) { text = "Whoops! Nothing to see here"; }
final Text textItem = new Text(text);
final Button okButton = new Button("OK");
final GridPane grid = new GridPane();
grid.setVgap(4);
grid.setHgap(10);
grid.setPadding(new Insets(5, 5, 5, 5));
grid.add(textItem, 0, 0);
grid.add(okButton, 1, 0);
final Pane root = (Pane) scene.getRoot();
root.getChildren().add(grid);
if (rootModel.darkModeProperty().get()) {
scene.getStylesheets().add("root/darkMode.css");
textItem.getStyleClass().add("text");
}
final Stage stage = new Stage();
stage.setScene(scene);
stage.setTitle(title);
stage.show();
okButton.setOnAction(e -> {
stage.close();
});
}
项目:Squid
文件:ExpressionBuilderController.java
public void makeAndAuditExpression() {
// make and audit expression
StringBuilder sb = new StringBuilder();
for (Node node : expressionTextFlow.getChildren()) {
if (node instanceof Text) {
sb.append(((Text) node).getText());
}
}
String fullText = makeStringFromTextFlow();
if (fullText.trim().length() > 0) {
Expression exp = squidProject.getTask().generateExpressionFromRawExcelStyleText(
"Editing Expression",
fullText.trim().replace("\n", ""),
false);
expressionAuditTextArea.setText(exp.produceExpressionTreeAudit());
} else {
expressionAuditTextArea.setText("");
}
}
项目:hygene
文件:NodePropertiesController.java
/**
* Create a table cell that wraps the text inside.
*
* @param param the table column
* @return a table cell that wraps the text inside
*/
TableCell<Annotation, String> wrappableTableCell(final TableColumn<Annotation, String> param) {
return new TableCell<Annotation, String>() {
@Override
protected void updateItem(final String item, final boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setGraphic(null);
return;
}
final Text text = new Text(item);
text.setWrappingWidth(param.getWidth());
setPrefHeight(text.getLayoutBounds().getHeight());
setGraphic(text);
}
};
}
项目:voogasalad-ltub
文件:MonsterAdder.java
public MonsterAdder(AllPossibleMonsters possibleMonsters) {
myPossibleMonsters = possibleMonsters;
loadMonster = new Button(LOAD_A_MONSTER_FROM_FILE);
loadMonster.setOnAction(click -> {
XStreamHandler xstream = new XStreamHandler();
SpriteMakerModel monster = (SpriteMakerModel) xstream.getAttributeFromFile();
myPossibleMonsters.loadFromFile(monster);
});
refresh = new Button("Refresh");
refresh.setOnAction(click -> {
myPossibleMonsters.getMonstersOnScreen();
});
this.getChildren().addAll(new Text(CREATE_A_SPAWNER), loadMonster, //refresh,
numberOfMonsters);
}
项目:PolygonChart
文件:PolygonChart.java
private void setRadarValuesLabels() {
Text startValueText = new Text(xCenter - 20, yCenter, String.valueOf(minValue));
startValueText.setFill(Color.RED);
startValueText.setFont(Font.font(15));
Text middleValueText = new Text(xCenter - 20, yCenter - radius / 2, String.valueOf(maxValue / 2));
middleValueText.setFill(Color.RED);
middleValueText.setFont(Font.font(15));
Text maxValueText = new Text(xCenter - 20, yCenter - radius, String.valueOf(maxValue));
maxValueText.setFill(Color.RED);
maxValueText.setFont(Font.font(15));
getChildren().addAll(startValueText, middleValueText, maxValueText);
}
项目:voogasalad-ltub
文件:View.java
private List<Text> createText(PlayerStatsModel playerStatsModel, Player player) {
List<Text> statsLabels = new ArrayList<Text>();
playerStatsModel.getWealth(player).ifPresent((wealthMap) -> {
for (WealthType type: wealthMap.keySet()) {
statsLabels.add(new Text(type + ": " + wealthMap.get(type)));
}
});
//TODO map to resource file
playerStatsModel.getLives(player).ifPresent((life) -> {
statsLabels.add(new Text(LIVES + life));
});
// playerStatsModel.getScore(player).ifPresent((score) -> {
// statsLabels.add(new Text("Scores:" + score));
// });
return statsLabels;
}
项目:vars-annotation
文件:DeleteSelectedAnnotationsBC.java
public void init() {
button.setTooltip(new Tooltip(toolBox.getI18nBundle().getString("buttons.delete")));
MaterialIconFactory iconFactory = MaterialIconFactory.get();
Text deleteIcon = iconFactory.createIcon(MaterialIcon.DELETE, "30px");
button.setText(null);
button.setGraphic(deleteIcon);
button.setDisable(true);
toolBox.getEventBus()
.toObserverable()
.ofType(AnnotationsSelectedEvent.class)
.subscribe(e -> {
User user = toolBox.getData().getUser();
boolean enabled = (user != null) && e.get().size() > 0;
button.setDisable(!enabled);
});
toolBox.getEventBus()
.toObserverable()
.ofType(DeleteAnnotationsMsg.class)
.subscribe(m -> apply());
button.setOnAction(e -> apply());
}
项目:marathonv5
文件:HTMLEditorSample.java
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);
}
项目:marathonv5
文件:InnerShadowSample.java
public InnerShadowSample() {
Text sample = new Text(0,100,"Shadow");
sample.setFont(Font.font("Arial Black",80));
sample.setFill(Color.web("#BBBBBB"));
final InnerShadow innerShadow = new InnerShadow();
innerShadow.setRadius(5d);
innerShadow.setOffsetX(2);
innerShadow.setOffsetY(2);
sample.setEffect(innerShadow);
getChildren().add(sample);
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Text Fill", sample.fillProperty()),
new SimplePropertySheet.PropDesc("Inner Shadow Radius", innerShadow.radiusProperty(), 0d,60d),
new SimplePropertySheet.PropDesc("Inner Shadow Offset X", innerShadow.offsetXProperty(), -10d, 10d),
new SimplePropertySheet.PropDesc("Inner Shadow Offset Y", innerShadow.offsetYProperty(), -10d, 10d),
new SimplePropertySheet.PropDesc("Inner Shadow Color", innerShadow.colorProperty())
);
// END REMOVE ME
}
项目:marathonv5
文件:StopWatchSample.java
private void configureDigits() {
for (int i : numbers) {
digits[i] = new Text("0");
digits[i].setFont(FONT);
digits[i].setTextOrigin(VPos.TOP);
digits[i].setLayoutX(2.3);
digits[i].setLayoutY(-1);
Rectangle background;
if (i < 6) {
background = createBackground(Color.web("#a39f91"), Color.web("#FFFFFF"));
digits[i].setFill(Color.web("#000000"));
} else {
background = createBackground(Color.web("#bdbeb3"), Color.web("#FF0000"));
digits[i].setFill(Color.web("#FFFFFF"));
}
digitsGroup[i] = new Group(background, digits[i]);
}
}
项目:dynamo
文件:SwitchSkin.java
private void initGraphics() {
background = new Region();
background.getStyleClass().setAll("background");
upBar = new Region();
upBar.getStyleClass().setAll("up-bar");
downBar = new Region();
downBar.getStyleClass().setAll("down-bar");
barRotate = new Rotate(ANGLE_IN_CLOSED_POSITION);
mobileBar = new Region();
mobileBar.getStyleClass().setAll("mobile-bar");
mobileBar.getTransforms().add(barRotate);
name = new Text(getSkinnable().getName());
name.getStyleClass().setAll("name-text");
pane = new Pane(background, upBar, downBar, mobileBar, name);
getChildren().add(pane);
resize();
}
项目:voogasalad-ltub
文件:GameStatsView.java
private void makeStatsPane(Map<String, String> stats) {
myStats = new VBox(5);
for(String statName : stats.keySet()){
Text nameAndValue = new Text(statName + ": " + stats.get(statName));
//TODO: set text size
TextFlow wrapper = new TextFlow(nameAndValue);
wrapper.setTextAlignment(TextAlignment.LEFT);
wrapper.getStylesheets().add("resources/socialStyle.css");
wrapper.getStyleClass().add("textfill");
myStats.getChildren().add(wrapper);
}
myStats.getStylesheets().add("resources/socialStyle.css");
myStats.getStyleClass().add("statsbox");
}
项目:marathonv5
文件:ColorPickerSample.java
public ColorPickerSample() {
final ColorPicker colorPicker = new ColorPicker(Color.GRAY);
ToolBar standardToolbar = ToolBarBuilder.create().items(colorPicker).build();
final Text coloredText = new Text("Colors");
Font font = new Font(53);
coloredText.setFont(font);
final Button coloredButton = new Button("Colored Control");
Color c = colorPicker.getValue();
coloredText.setFill(c);
coloredButton.setStyle(createRGBString(c));
colorPicker.setOnAction(new EventHandler() {
public void handle(Event t) {
Color newColor = colorPicker.getValue();
coloredText.setFill(newColor);
coloredButton.setStyle(createRGBString(newColor));
}
});
VBox coloredObjectsVBox = VBoxBuilder.create().alignment(Pos.CENTER).spacing(20).children(coloredText, coloredButton).build();
VBox outerVBox = VBoxBuilder.create().alignment(Pos.CENTER).spacing(150).padding(new Insets(0, 0, 120, 0)).children(standardToolbar, coloredObjectsVBox).build();
getChildren().add(outerVBox);
}
项目:marathonv5
文件:FXUIUtils.java
public static void _showMessageDialog(Window parent, String message, String title, AlertType type, boolean monospace) {
Alert alert = new Alert(type);
alert.initOwner(parent);
alert.setTitle(title);
alert.setHeaderText(title);
alert.setContentText(message);
alert.initModality(Modality.APPLICATION_MODAL);
alert.setResizable(true);
if (monospace) {
Text text = new Text(message);
alert.getDialogPane().setStyle("-fx-padding: 0 10px 0 10px;");
text.setStyle(" -fx-font-family: monospace;");
alert.getDialogPane().contentProperty().set(text);
}
alert.showAndWait();
}
项目:marathonv5
文件:MarathonCheckListStage.java
private void initCheckList() {
ToolBar toolBar = new ToolBar();
toolBar.getItems().add(new Text("Check Lists"));
toolBar.setMinWidth(Region.USE_PREF_SIZE);
leftPane.setTop(toolBar);
checkListElements = checkListInfo.getCheckListElements();
checkListView = new ListView<CheckListForm.CheckListElement>(checkListElements);
checkListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
CheckListElement selectedItem = checkListView.getSelectionModel().getSelectedItem();
if (selectedItem == null) {
doneButton.setDisable(true);
return;
}
Node checkListForm = getChecklistFormNode(selectedItem, Mode.DISPLAY);
if (checkListForm == null) {
doneButton.setDisable(true);
return;
}
doneButton.setDisable(false);
ScrollPane sp = new ScrollPane(checkListForm);
sp.setFitToWidth(true);
sp.setPadding(new Insets(0, 0, 0, 10));
rightPane.setCenter(sp);
});
leftPane.setCenter(checkListView);
}
项目:WebPLP
文件:ProgrammerSettingsPanel.java
private Node timeoutSelection( ProgrammerSettingDetails settingDetails )
{
HBox hBox = new HBox();
Text receiveTimeoutLabel = new Text("Receive timout (ms): ");
receiveTimeoutLabel.setId(UIConstants.TEXT_COLOR);
TextField receiveTimeoutTextField = new TextField();
receiveTimeoutTextField.setText(settingDetails.getReceiveTimeoutMilliseconds());
receiveTimeoutTextField.textProperty().addListener(( observable, oldValue, newValue ) -> {
if ( !newValue.isEmpty() )
UIStyle.applyError(VerifyUtil.simpleIntegerCheck(newValue), receiveTimeoutTextField);
});
receiveTimeoutSelectionModel = receiveTimeoutTextField.textProperty();
hBox.getChildren().addAll(receiveTimeoutLabel, receiveTimeoutTextField);
return hBox;
}
项目:marathonv5
文件:StopWatchSample.java
private void configureDigits() {
for (int i : numbers) {
digits[i] = new Text("0");
digits[i].setFont(FONT);
digits[i].setTextOrigin(VPos.TOP);
digits[i].setLayoutX(2.3);
digits[i].setLayoutY(-1);
Rectangle background;
if (i < 6) {
background = createBackground(Color.web("#a39f91"), Color.web("#FFFFFF"));
digits[i].setFill(Color.web("#000000"));
} else {
background = createBackground(Color.web("#bdbeb3"), Color.web("#FF0000"));
digits[i].setFill(Color.web("#FFFFFF"));
}
digitsGroup[i] = new Group(background, digits[i]);
}
}
项目:marathonv5
文件:ColorPickerSample.java
public ColorPickerSample() {
final ColorPicker colorPicker = new ColorPicker(Color.GRAY);
ToolBar standardToolbar = ToolBarBuilder.create().items(colorPicker).build();
final Text coloredText = new Text("Colors");
Font font = new Font(53);
coloredText.setFont(font);
final Button coloredButton = new Button("Colored Control");
Color c = colorPicker.getValue();
coloredText.setFill(c);
coloredButton.setStyle(createRGBString(c));
colorPicker.setOnAction(new EventHandler() {
public void handle(Event t) {
Color newColor = colorPicker.getValue();
coloredText.setFill(newColor);
coloredButton.setStyle(createRGBString(newColor));
}
});
VBox coloredObjectsVBox = VBoxBuilder.create().alignment(Pos.CENTER).spacing(20).children(coloredText, coloredButton).build();
VBox outerVBox = VBoxBuilder.create().alignment(Pos.CENTER).spacing(150).padding(new Insets(0, 0, 120, 0)).children(standardToolbar, coloredObjectsVBox).build();
getChildren().add(outerVBox);
}
项目:PhotoScript
文件:DragBox.java
/**
* 向DragBox添加一般性节点时调用
*
* @param node 一般节点
* @param onBuildListener 在构建节点时使用监听器可以使代码更加简洁
*/
public void setContentNode(Node node, OnBuildListener onBuildListener) {
this.node = node;
getChildren().add(0, node);
if (onBuildListener != null) {
onBuildListener.onBuild(node, this);
}
if (this.node instanceof Ellipse) {
this.type = SHAPE.TYPE.ELLIPSE;
} else if (this.node instanceof Rectangle) {
this.type = SHAPE.TYPE.RECT;
} else if (this.node instanceof Text) {
this.type = SHAPE.TYPE.TEXT;
} else if (this.node instanceof SVGPath) {
this.type = SHAPE.TYPE.SVG;
} else if (this.node instanceof Line) {
this.type = SHAPE.TYPE.LINE;
}
initNode();
}
项目:fxutils
文件:EditableLabelSkin.java
/**
* Truncates text to fit into the EditableLabel
*
* @param text The text that needs to be truncated
* @return The truncated text with an appended "..."
*/
private String calculateClipString(String text) {
double labelWidth = editableLabel.getWidth();
Text layoutText = new Text(text);
layoutText.setFont(editableLabel.getFont());
if (layoutText.getLayoutBounds().getWidth() < labelWidth) {
return text;
} else {
layoutText.setText(text+"...");
while ( layoutText.getLayoutBounds().getWidth() > labelWidth ) {
text = text.substring(0, text.length()-1);
layoutText.setText(text+"...");
}
return text+"...";
}
}
项目:Automekanik
文件:Mesazhi.java
public Mesazhi(String titulli, String titulli_msg, String mesazhi){
stage.setTitle(titulli);
stage.initModality(Modality.APPLICATION_MODAL);
stage.setResizable(false);
HBox root = new HBox(15);
VBox sub_root = new VBox(10);
HBox btn = new HBox();
Text ttl = new Text(titulli_msg);
ttl.setFont(Font.font(16));
Button btnOk = new Button("Ne rregull");
btn.getChildren().add(btnOk);
btn.setAlignment(Pos.CENTER_RIGHT);
btnOk.setOnAction(e -> stage.close());
btnOk.setOnKeyPressed(e -> {
if (e.getCode().equals(KeyCode.ENTER)) stage.close();
else if (e.getCode().equals(KeyCode.ESCAPE)) stage.close();
});
root.setPadding(new Insets(20));
sub_root.getChildren().addAll(ttl, new Label(mesazhi), btn);
if (titulli == "Gabim")
root.getChildren().add(new ImageView(new Image("/sample/foto/error.png")));
else if (titulli == "Sukses")
root.getChildren().add(new ImageView(new Image("/sample/foto/success.png")));
else if (titulli == "Informacion")
root.getChildren().add(new ImageView(new Image("/sample/foto/question.png")));
else if (titulli == "Info")
root.getChildren().add(new ImageView(new Image("/sample/foto/info.png")));
root.getChildren().add(sub_root);
root.setAlignment(Pos.TOP_CENTER);
Scene scene = new Scene(root, 450, 150);
scene.getStylesheets().add(getClass().getResource("/sample/style.css").toExternalForm());
stage.setScene(scene);
stage.show();
}
项目:vars-annotation
文件:ImageViewController.java
private ToolBar getToolBar() {
if (toolBar == null) {
MaterialIconFactory iconFactory = MaterialIconFactory.get();
Text icon = iconFactory.createIcon(MaterialIcon.SAVE, "30px");
String tooltip = toolBox.getI18nBundle().getString("imageview.button.save");
Button saveBtn = new JFXButton();
saveBtn.setTooltip(new Tooltip(tooltip));
saveBtn.setGraphic(icon);
saveBtn.setOnAction(evt -> saveImage(imageStage.getOwner()));
toolBar = new ToolBar(saveBtn);
}
return toolBar;
}
项目:Squid
文件:ExpressionBuilderController.java
private String makeStringFromTextFlow() {
// make and audit expression
StringBuilder sb = new StringBuilder();
for (Node node : expressionTextFlow.getChildren()) {
if (node instanceof Text) {
sb.append(((Text) node).getText());
}
}
return sb.toString();
}
项目:Squid
文件:AbstractTopsoilPlot.java
public List<Node> toolbarControlsFactory() {
List<Node> controls = new ArrayList<>();
JavaScriptPlot javaScriptPlot = (JavaScriptPlot) plot;
Text loadingIndicator = new Text("Loading...");
javaScriptPlot.getLoadFuture().thenRunAsync(() -> {
loadingIndicator.visibleProperty().bind(
javaScriptPlot.getWebEngine().getLoadWorker()
.stateProperty().isEqualTo(Worker.State.RUNNING));
},
Platform::runLater
);
Button saveToSVGButton = new Button("Save as SVG");
saveToSVGButton.setOnAction(mouseEvent -> {
new SVGSaver().save(javaScriptPlot.displayAsSVGDocument());
});
Button recenterButton = new Button("Re-center");
recenterButton.setOnAction(mouseEvent -> {
javaScriptPlot.recenter();
});
controls.add(loadingIndicator);
controls.add(saveToSVGButton);
controls.add(recenterButton);
return controls;
}
项目:PhotoScript
文件:DragBox.java
/**
* 设置图形节点外框宽度
*
* @param lineWidth
*/
public void setLineWidth(double lineWidth) {
this.strokeWidth = lineWidth;
if (this.node instanceof Ellipse) {
((Ellipse) this.node).setStrokeWidth(lineWidth);
} else if (this.node instanceof Rectangle) {
((Rectangle) this.node).setStrokeWidth(lineWidth);
} else if (this.node instanceof SVGPath) {
((SVGPath) this.node).setStrokeWidth(lineWidth);
} else if (this.node instanceof Text) {
((Text) this.node).setStrokeWidth(lineWidth);
} else if (this.node instanceof Line) {
((Line) this.node).setStrokeWidth(lineWidth);
}
}
项目:dynamo
文件:LoadSkin.java
private void initGraphics() {
background = new Region();
background.getStyleClass().setAll("background");
load = new Region();
load.getStyleClass().addAll("load-shape");
name = new Text(getSkinnable().getName());
name.getStyleClass().setAll("name-text");
pane = new Pane(background, load, name);
getChildren().add(pane);
resize();
}
项目:voogasalad-ltub
文件:PasswordManager.java
private void show() {
BorderPane bp = new BorderPane();
bp.setPadding(new Insets(10,50,50,50));
HBox hb = new HBox();
hb.setPadding(new Insets(20,20,20,30));
//Implementing Nodes for GridPane
Label lblUserName = new Label("Username");
Label lblPassword = new Label("Password");
Label lblLanguage = new Label("Language");
Button btnReset = createButton("Reset", "btnLogin");
Button btnRegister = createButton("Register", "btnReset");
Button btnLogin = createButton("Login", "btnReset");
//Adding GridPane
GridPane gridPane = createGridPane(lblUserName, lblPassword, lblLanguage, btnLogin, btnReset, btnRegister);
gridPane.setId("root");
Text text = createText("Game Login");
text.setId("text");
//Adding text to HBox
hb.getChildren().add(text);
//Add ID's to Nodes
bp.setId("bp");
//Add HBox and GridPane layout to BorderPane Layout
bp.setTop(hb);
bp.setCenter(gridPane);
//Adding BorderPane to the scene and loading CSS
scene = new Scene(bp);
scene.getStylesheets().setAll(CSS_LOCATION);
//Action for btnLogin
btnLogin.setOnAction(e -> buttonLoginAction());
//Action for btnReset
btnReset.setOnAction(e -> buttonResetAction());
//Action for btnRegister
btnRegister.setOnAction(p -> {
tempCheckUser = txtUserName.getText().toString();
tempCheckPw = pf.getText().toString();
if(tempCheckUser.length() < LENGTH_OF_USER || tempCheckPw.length() < LENGTH_OF_PASSWORD ){
MessageShowing unsuccess = new MessageShowing();
unsuccess.show("failure");
tempCheckUser="";
tempCheckPw = "";
buttonResetAction();
return;
}
usersModel.addUser(tempCheckUser, tempCheckPw);
writer.write(tempCheckUser, tempCheckPw);
((PopUpMessage) p).show("success");
buttonResetAction();});
scene.setOnKeyPressed(e -> handleKeyInput(e.getCode()));
}
项目:hygene
文件:SequenceVisualizer.java
/**
* Draw square on canvas with given message.
*
* @param message text to display in middle of square
* @param x upper left x of square
* @param y upper left y of square
* @param squareFill {@link Color} fill of background of square
* @param textFill {@link Color} fill of text in square
*/
private void drawSquare(final String message, final double x, final double y,
final Color squareFill, final Color textFill) {
graphicsContext.setStroke(squareFill);
graphicsContext.strokeRoundRect(x, y, SQUARE_WIDTH, SQUARE_HEIGHT, ARC_SIZE, ARC_SIZE);
final Text messageText = new Text(message);
messageText.setFont(graphicsContext.getFont());
final double textWidth = messageText.getBoundsInLocal().getWidth();
graphicsContext.setStroke(textFill);
graphicsContext.fillText(
message,
x + SQUARE_WIDTH / 2 - textWidth / 2,
y + SQUARE_HEIGHT * TEXT_HEIGHT_PORTION_OFFSET);
}
项目:board-client
文件:Checkers.java
public Node createPiece(int piece, int column, int row) {
StackPane pane = new StackPane();
Rectangle background = new Rectangle(0, 0, 60, 60);
background.setFill(((column + row) % 2) == 0 ? Color.WHITE : Color.GRAY);
pane.getChildren().add(background);
if (piece >=0 && piece < 8) {
Circle circle = new Circle(30, 30, 25);
if (piece / 4 == 1) {
circle.setStrokeWidth(3);
} else {
circle.setStrokeWidth(0);
}
if ((piece % 4) / 2 == 0) {
circle.setFill(Color.WHITE);
circle.setStroke(Color.BLACK);
} else {
circle.setFill(Color.BLACK);
circle.setStroke(Color.WHITE);
}
pane.getChildren().add(circle);
if ((piece % 4) % 2 == 1) {
Text text = new Text("♔");
text.setFont(new Font(32));
text.setFill(((piece % 4) / 2 == 0) ? Color.BLACK : Color.WHITE);
text.setBoundsType(TextBoundsType.VISUAL);
pane.getChildren().add(text);
}
}
return pane;
}
项目:Parallator
文件:Toast.java
public static void makeText(Stage ownerStage, String toastMsg, int time) {
Platform.runLater(() -> {
Stage toastStage = new Stage();
toastStage.initOwner(ownerStage);
toastStage.setResizable(false);
toastStage.initStyle(StageStyle.TRANSPARENT);
Text text = new Text(toastMsg);
text.setFont(Font.font("Verdana", 20));
text.setFill(Color.WHITE);
StackPane root = new StackPane(text);
root.setStyle("-fx-background-radius: 20; -fx-background-color: rgba(0, 0, 0, 0.5); -fx-padding: 25px;");
root.setOpacity(0);
Scene scene = new Scene(root);
scene.setFill(Color.TRANSPARENT);
toastStage.setScene(scene);
toastStage.show();
Timeline fadeInTimeline = new Timeline();
KeyFrame fadeInKey1 = new KeyFrame(Duration.millis(200), new KeyValue(toastStage.getScene().getRoot().opacityProperty(), 1));
fadeInTimeline.getKeyFrames().add(fadeInKey1);
fadeInTimeline.setOnFinished((ae) -> new Thread(() -> {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
e.printStackTrace();
}
Timeline fadeOutTimeline = new Timeline();
KeyFrame fadeOutKey1 = new KeyFrame(Duration.millis(200), new KeyValue(toastStage.getScene().getRoot().opacityProperty(), 0));
fadeOutTimeline.getKeyFrames().add(fadeOutKey1);
fadeOutTimeline.setOnFinished((aeb) -> toastStage.close());
fadeOutTimeline.play();
}).start());
fadeInTimeline.play();
});
}
项目:Breadth-First-Search
文件:GraphDrawer.java
/**
* Ritorna il crea il componente grafico testo utilizzando la stringa passata come parametro
* @param s testo da visualizzare
* @return testo creato come componente grafico.
*/
private Text createText(String s) {
Text t = new Text();
t.setText(s);
t.setFont(new Font(16));
t.setBoundsType(TextBoundsType.VISUAL);
t.setStroke(Color.BLACK);
this.centerText(t);
return t;
}
项目:lttng-scope
文件:StateRectangle.java
public void addTooltipRow(Object... objects) {
Node[] labels = Arrays.stream(objects)
.map(Object::toString)
.map(Text::new)
.peek(text -> {
text.fontProperty().bind(fOpts.toolTipFont);
text.fillProperty().bind(fOpts.toolTipFontFill);
})
.toArray(Node[]::new);
appendRow(labels);
}
项目:Curriculum-design-of-data-structure
文件:DrawHuffmanCode.java
private void connectLeftChild(Pane pane, double x1, int y1, double x2, int y2) {
double d = Math.sqrt(vPane * vPane + (x2 - x1) * (x2 - x1));
//起始坐标
int x11 = (int)(x1 - radius * (x1 - x2) / d);
int y11 = (int)(y1 - radius * vPane / d);
//结束坐标
int x21 = (int)(x2 + radius * (x1 - x2) / d);
int y21 = (int)(y2 + radius * vPane / d);
Line line = new Line(x11, y11, x21, y21);
Text text = new Text((x11 + x21) / 2 , (y11 + y21) / 2 + 2, "0");
pane.getChildren().addAll(line, text);
}
项目:charts
文件:Axis.java
private double calcTextWidth(final Font FONT, final String TEXT) {
Text text = new Text(TEXT);
text.setFont(FONT);
double width = text.getBoundsInParent().getWidth();
text = null;
return width;
}
项目:waterrower-workout
文件:ActivityDiagramSkin.java
private void updateMonthLabels() {
monthLabelPositions = new int[WEEKS];
fill(monthLabelPositions, -1);
String[] monthStrings = getSkinnable().getMonths();
monthLabels = new Text[12];
for (int month = 0; month < MONTHS; month++) {
monthLabels[month] = new Text(monthStrings[month]);
monthLabels[month].getStyleClass().add("week-activity-label-month");
getChildren().addAll(monthLabels[month]);
}
}
项目:Example.EMA.Java.SpeedGuide
文件:SpeedGuideViewController.java
public void updateStatus(String status, StatusIndicator indicator, String item)
{
// This will avoid a InvalidState Exception to ensure we are within the JavaFX thread
Platform.runLater(new Runnable()
{
@Override
public void run()
{
if ( !item.isEmpty() )
ric.setText(item);
ObservableList<Node> nodes = statusText.getChildren();
Text time = new Text();
time.setId("status-time"); // Defined in CSS
time.setText(new SimpleDateFormat("HH.mm.ss: ").format(new java.util.Date()));
Text txt = new Text();
txt.setText(status + SpeedGuide.NEWLINE);
switch (indicator)
{
case REQUEST:
txt.setId("status-request"); // Defined in CSS
break;
case RESPONSE_SUCCESS:
txt.setId("status-response-success"); // Defined in CSS
break;
case RESPONSE_ERROR:
txt.setId("status-response-error"); // Defined in CSS
break;
}
nodes.add(0, txt);
nodes.add(0, time);
}
});
}
项目:marathonv5
文件:GaussianBlurSample.java
public static Node createIconContent() {
Text sample = new Text("FX");
sample.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD,80));
sample.setStyle("-fx-font-size: 80px;");
sample.setFill(Color.web("#333333"));
final GaussianBlur GaussianBlur = new GaussianBlur();
GaussianBlur.setRadius(15);
sample.setEffect(GaussianBlur);
return sample;
}
项目:dynamo
文件:TransformerSkin.java
private void initGraphics() {
background = new Region();
background.getStyleClass().setAll("background");
transformer = new Region();
transformer.getStyleClass().addAll("transformer-shape");
name = new Text(getSkinnable().getName());
name.getStyleClass().setAll("name-text");
pane = new Pane(background, transformer, name);
getChildren().add(pane);
resize();
}