下面列出了javafx.scene.text.Text#setStyle ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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);
}
/**
* Create the loading pane.
*/
public LoadingPane() {
setAlignment(Pos.CENTER);
VBox content = new VBox();
content.setAlignment(Pos.CENTER);
Text text = new Text(LabelGrabber.INSTANCE.getLabel("loading.text") + "...");
text.setStyle(" -fx-font: bold italic 20pt \"Arial\";");
FadeTransition textTransition = new FadeTransition(Duration.seconds(1.5), text);
textTransition.setAutoReverse(true);
textTransition.setFromValue(0);
textTransition.setToValue(1);
textTransition.setCycleCount(Transition.INDEFINITE);
textTransition.play();
content.getChildren().add(text);
bar = new ProgressBar();
content.getChildren().add(bar);
getChildren().add(content);
setOpacity(0);
setStyle("-fx-background-color: #555555;");
setVisible(false);
}
public void miniLogText(Color color, String text) {
if (cbx_useLog.isSelected()) {
String color2 = "#" + color.toString().substring(2, 8);
Calendar rightNow = Calendar.getInstance();
String hour = addToNumber(""+rightNow.get(Calendar.HOUR_OF_DAY));
String minutes = addToNumber(""+rightNow.get(Calendar.MINUTE));
String seconds = addToNumber(""+rightNow.get(Calendar.SECOND));
String timestamp = "["+hour+":"+minutes+":"+seconds+"] ";
timestamp = timestamp.replace(" ", "\u00A0"); // disable automatic linebreaks
Text time = new Text(timestamp);
time.setStyle("-fx-opacity: "+0.5+";");
text = text.replace(" ", "\u00A0");
Text otherText = new Text(text + "\n");
otherText.setStyle("-fx-fill: "+color2+";");
txt_logField.getChildren().addAll(time, otherText);
}
}
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);
}
private Menu createColoursMenu() {
final Menu coloursMenu = new Menu("Attribute Editor Colours");
final Color schemaColour = ConstellationColor.fromHtmlColor(prefs.get(AttributePreferenceKey.SCHEMA_ATTRIBUTE_COLOUR, SCHEMA_ATTRIBUTE_COLOUR)).getJavaFXColor();
coloursMenu.getItems().add(createColourMenuItem("Schema Attributes", AttributePreferenceKey.SCHEMA_ATTRIBUTE_COLOUR, schemaColour));
final Color primaryKeyColour = ConstellationColor.fromHtmlColor(prefs.get(AttributePreferenceKey.PRIMARY_KEY_ATTRIBUTE_COLOUR, PRIMARY_KEY_ATTRIBUTE_COLOUR)).getJavaFXColor();
coloursMenu.getItems().add(createColourMenuItem("Primary Key Attributes", AttributePreferenceKey.PRIMARY_KEY_ATTRIBUTE_COLOUR, primaryKeyColour));
final Color customColour = ConstellationColor.fromHtmlColor(prefs.get(AttributePreferenceKey.CUSTOM_ATTRIBUTE_COLOUR, CUSTOM_ATTRIBUTE_COLOUR)).getJavaFXColor();
coloursMenu.getItems().add(createColourMenuItem("Custom Attributes (Not in the Schema)", AttributePreferenceKey.CUSTOM_ATTRIBUTE_COLOUR, customColour));
final Color hiddenColour = ConstellationColor.fromHtmlColor(prefs.get(AttributePreferenceKey.HIDDEN_ATTRIBUTE_COLOUR, HIDDEN_ATTRIBUTE_COLOUR)).getJavaFXColor();
coloursMenu.getItems().add(createColourMenuItem("Hidden Attributes", AttributePreferenceKey.HIDDEN_ATTRIBUTE_COLOUR, hiddenColour));
final HBox restoreMenuNode = new HBox(5);
final MenuItem restoreMenuItem = new MenuItem(null, restoreMenuNode);
final Text restoreMenuText = new Text("Restore Default Colours");
restoreMenuText.setStyle("-fx-fill: white; -fx-font-smoothing-type:lcd;");
restoreMenuNode.getChildren().add(restoreMenuText);
restoreMenuItem.setOnAction(e -> {
prefs.put(AttributePreferenceKey.SCHEMA_ATTRIBUTE_COLOUR, SCHEMA_ATTRIBUTE_COLOUR);
prefs.put(AttributePreferenceKey.PRIMARY_KEY_ATTRIBUTE_COLOUR, PRIMARY_KEY_ATTRIBUTE_COLOUR);
prefs.put(AttributePreferenceKey.CUSTOM_ATTRIBUTE_COLOUR, CUSTOM_ATTRIBUTE_COLOUR);
prefs.put(AttributePreferenceKey.HIDDEN_ATTRIBUTE_COLOUR, HIDDEN_ATTRIBUTE_COLOUR);
});
coloursMenu.getItems().add(restoreMenuItem);
return coloursMenu;
}
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("#aaaaaa"));
final InnerShadow innerShadow = new InnerShadow();
innerShadow.setRadius(4);
innerShadow.setOffsetX(1);
innerShadow.setOffsetY(1);
innerShadow.setColor(Color.web("#333333"));
sample.setEffect(innerShadow);
return sample;
}
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;
}
@Override
protected void seriesAdded(Series<X, Y> series, int seriesIndex) {
super.seriesAdded(series, seriesIndex);
if (labelType == null || labelType == LabelType.NotDisplay || labelType == LabelType.Pop) {
return;
}
try {
for (int j = 0; j < series.getData().size(); j++) {
Data<X, Y> item = series.getData().get(j);
String name = item.getYValue() + "";
String value = item.getXValue() + "";
String labelValue = StringTools.format(FxmlControl.realValue(chartCoordinate, Double.valueOf(value)));
String label;
switch (labelType) {
case Name:
label = name;
break;
case Value:
label = labelValue;
break;
case NameAndValue:
default:
label = name + " " + labelValue;
break;
}
Text text = new Text(label);
text.setStyle("-fx-font-size: " + textSize + "px; -fx-text-fill: black;");
TextFlow textFlow = new TextFlow(text);
textFlow.setTextAlignment(TextAlignment.CENTER);
nodeMap.put(item.getNode(), textFlow);
this.getPlotChildren().add(textFlow);
}
} catch (Exception e) {
logger.debug(e.toString());
}
}
private void makeImagePopup() {
try {
imagePop = new Popup();
imagePop.setWidth(600);
imagePop.setHeight(600);
VBox vbox = new VBox();
VBox.setVgrow(vbox, Priority.ALWAYS);
HBox.setHgrow(vbox, Priority.ALWAYS);
vbox.setMaxWidth(Double.MAX_VALUE);
vbox.setMaxHeight(Double.MAX_VALUE);
vbox.setStyle("-fx-background-color: white;");
imagePop.getContent().add(vbox);
view = new ImageView();
view.setFitWidth(500);
view.setFitHeight(500);
vbox.getChildren().add(view);
text = new Text();
text.setStyle("-fx-font-size: 1.2em;");
vbox.getChildren().add(text);
vbox.setPadding(new Insets(15, 15, 15, 15));
} catch (Exception e) {
logger.debug(e.toString());
}
}
public Text createTextNode(String word) {
Text textNode = new Text(word);
textNode.getStyleClass().setAll("tag");
textNode.setStyle("-fx-padding: 10px");
textNode.applyCss();
textNode.setFont(configuration.font);
textNode.setCache(true);
// textNode.setCacheHint(CacheHint.SPEED);
return textNode;
}
private void initGraphics() {
Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.5 * PREFERRED_HEIGHT)); // "OpenSans"
font = Font.font("Open Sans", 0.5 * PREFERRED_HEIGHT);
background = new Region();
background.getStyleClass().setAll("background");
background.setStyle("-switch-color: " + Util.colorToCss((Color) getSkinnable().getSwitchColor()) + ";");
selectedText = new Text("1");
selectedText.setFont(font);
selectedText.getStyleClass().setAll("selected-text");
selectedText.setStyle("-text-color-on: " + Util.colorToCss((Color) getSkinnable().getTextColorOn()) + ";");
deselectedText = new Text("0");
deselectedText.setFont(font);
deselectedText.getStyleClass().setAll("deselected-text");
deselectedText.setStyle("-text-color-off: " + Util.colorToCss((Color) getSkinnable().getTextColorOff()) + ";");
thumb = new Region();
thumb.getStyleClass().setAll("thumb");
thumb.setMouseTransparent(true);
thumb.setStyle("-thumb-color: " + Util.colorToCss((Color) getSkinnable().getThumbColor()) + ";");
pane = new Pane(background, selectedText, deselectedText, thumb);
pane.getStyleClass().setAll("on-off-switch");
moveToDeselected = new TranslateTransition(Duration.millis(180), thumb);
moveToSelected = new TranslateTransition(Duration.millis(180), thumb);
// Add all nodes
getChildren().setAll(pane);
}
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("#aaaaaa"));
final InnerShadow innerShadow = new InnerShadow();
innerShadow.setRadius(4);
innerShadow.setOffsetX(1);
innerShadow.setOffsetY(1);
innerShadow.setColor(Color.web("#333333"));
sample.setEffect(innerShadow);
return sample;
}
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;
}
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 DropShadow dropShadow = new DropShadow();
dropShadow.setOffsetX(4);
dropShadow.setOffsetY(6);
dropShadow.setColor(Color.rgb(0,0,0,0.7));
sample.setEffect(dropShadow);
return sample;
}
public Loading(URL imageUrl) {
super();
// 设置背景颜色
setBackgroundColor(20,20,20,0.5f);
contentBox = new VBox();
// 间隔
Region topRegion = new Region();
topRegion.setPrefHeight(20);
contentBox.getChildren().add(topRegion);
// gif动态图
imageView = new ImageView();
imageView.setSmooth(true);
setImage(imageUrl);
contentBox.getChildren().add(imageView);
// 间隔
Region region = new Region();
region.setPrefHeight(15);
contentBox.getChildren().add(region);
// 提示信息
text = new Text();
text.setStyle("-fx-fill: white; -fx-font-size:24;");
contentBox.getChildren().add(text);
// 设置内容居中
contentBox.alignmentProperty().set(Pos.CENTER);
// 设置布局居中
setAlignment(contentBox,Pos.CENTER);
getChildren().add(contentBox);
}
@SuppressWarnings("unchecked")
public RegexConfigFragment(PlainDictAppOptions _opt){
super();
tabPane = new TabPane();
statusBar = new Text();
tabPane.setPadding(new Insets(4,0,0,0));
opt=_opt;
bundle = ResourceBundle.getBundle("UIText", Locale.getDefault());
Tab tab1 = new Tab();
tab1.setText(bundle.getString(onegine));
tab1.setTooltip(new Tooltip("词条、全文检索时,可选用正则引擎,或快速 .* 通配"));
tab1.setClosable(false);
Text lable = new Text("");
lable.setStyle("-fx-fill: #ff0000;");
tab1.setGraphic(lable);
Tab tab2 = new Tab();
tab2.setText(bundle.getString(findpage));
tab2.setTooltip(new Tooltip("基于 Mark.js"));
tab2.setClosable(false);
Text lable1 = new Text("");
lable1.setStyle("-fx-fill: #ff0000;");
tab2.setGraphic(lable1);
tabPane.getSelectionModel().selectedIndexProperty().addListener((observable, oldValue, newValue) -> {
if(newValue.intValue()==1){
if(tab2.getContent()==null)
tab2.setContent(getSubpageContent());
}
});
tabPane.setRotateGraphic(false);
tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.SELECTED_TAB);
tabPane.setSide(Side.TOP);
tabPane.getTabs().addAll(tab1,tab2);
tabPane.getStyleClass().add(TabPane.STYLE_CLASS_FLOATING);
final String lvCss = HiddenSplitPaneApp.class.getResource("lvCss.css").toExternalForm();
tabPane.getStylesheets().add(lvCss);
tab1.setContent(getMainContent());
VBox.setVgrow(tabPane, Priority.ALWAYS);
getChildren().addAll(tabPane, statusBar);
}
public void setStylesheet(Text t, String cssFile) {
// t.getStylesheets().clear();
t.setStyle(getClass().getResource(cssFile).toExternalForm());
}
private void makeImagePopup(VBox imageBox, ImageInformation imageInfo,
ImageView iView) {
try {
File file = imageInfo.getImageFileInformation().getFile();
final Image iImage = imageInfo.getImage();
imagePop = new Popup();
imagePop.setWidth(popSize + 40);
imagePop.setHeight(popSize + 40);
imagePop.setAutoHide(true);
VBox vbox = new VBox();
VBox.setVgrow(vbox, Priority.ALWAYS);
HBox.setHgrow(vbox, Priority.ALWAYS);
vbox.setMaxWidth(Double.MAX_VALUE);
vbox.setMaxHeight(Double.MAX_VALUE);
vbox.setStyle("-fx-background-color: white;");
imagePop.getContent().add(vbox);
popView = new ImageView();
popView.setImage(iImage);
if (iImage.getWidth() > iImage.getHeight()) {
popView.setFitWidth(popSize);
} else {
popView.setFitHeight(popSize);
}
popView.setPreserveRatio(true);
vbox.getChildren().add(popView);
popText = new Text();
popText.setStyle("-fx-font-size: 1.0em;");
vbox.getChildren().add(popText);
vbox.setPadding(new Insets(15, 15, 15, 15));
String info = imageInfo.getFileName() + "\n"
+ AppVariables.message("Format") + ":" + imageInfo.getImageFormat() + " "
+ AppVariables.message("ModifyTime") + ":" + DateTools.datetimeToString(file.lastModified()) + "\n"
+ AppVariables.message("Size") + ":" + FileTools.showFileSize(file.length()) + " "
+ AppVariables.message("Pixels") + ":" + imageInfo.getWidth() + "x" + imageInfo.getHeight() + "\n"
+ AppVariables.message("LoadedSize") + ":"
+ (int) iView.getImage().getWidth() + "x" + (int) iView.getImage().getHeight() + " "
+ AppVariables.message("DisplayedSize") + ":"
+ (int) iView.getFitWidth() + "x" + (int) iView.getFitHeight();
popText.setText(info);
popText.setWrappingWidth(popSize);
Bounds bounds = imageBox.localToScreen(imageBox.getBoundsInLocal());
imagePop.show(imageBox, bounds.getMinX() + bounds.getWidth() / 2, bounds.getMinY());
} catch (Exception e) {
logger.debug(e.toString());
}
}
public Node getFxElement() {
Text text = new Text(this.text != null ? this.text : ""); //$NON-NLS-1$
text.setStyle(style.getCSS());
return text;
}