本文整理匯總了Java中javafx.scene.text.FontPosture類的典型用法代碼示例。如果您正苦於以下問題:Java FontPosture類的具體用法?Java FontPosture怎麽用?Java FontPosture使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FontPosture類屬於javafx.scene.text包,在下文中一共展示了FontPosture類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: changeFont
import javafx.scene.text.FontPosture; //導入依賴的package包/類
private void changeFont() {
try {
double size = numberFormat.parse(sizeComboBox.getValue()).doubleValue();
FontWeight weight = styleChoiceBox.getSelectionModel().isSelected(0) ||
styleChoiceBox.getSelectionModel().isSelected(1)
? FontWeight.BOLD : FontWeight.NORMAL;
FontPosture posture = styleChoiceBox.getSelectionModel().isSelected(1) ||
styleChoiceBox.getSelectionModel().isSelected(2)
? FontPosture.ITALIC : FontPosture.REGULAR;
String family = familyComboBox.getValue();
font.setValue(Font.font(family, weight, posture, size));
sampleFontText.setFont(font.get());
} catch (java.text.ParseException ex) {
Logger.getLogger(FontPickerController.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例2: read
import javafx.scene.text.FontPosture; //導入依賴的package包/類
@Override
public Font read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
String value = in.nextString();
String path = in.getPath();
String[] components = splitComponents(value, path);
String family = components[0];
String style = components[1];
String sizeStr = components[2];
FontWeight weight = extractWeight(style);
FontPosture posture = extractPosture(style);
double size = extractSize(sizeStr, path);
return Font.font(family, weight, posture, size);
}
示例3: provideSetAllControl
import javafx.scene.text.FontPosture; //導入依賴的package包/類
/**
* Method to provide the control to set {@link BuildWallJobPolicy} for all {@link JenkinsJob}s at once.
*/
private void provideSetAllControl() {
setAllBox = new SimplePropertyBox<>();
setAllBox.getItems().addAll( BuildWallJobPolicy.values() );
setAllBox.setMaxWidth( Double.MAX_VALUE );
setAllBox.getSelectionModel().select( BuildWallJobPolicy.NeverShow );
add( setAllBox, 0, 0 );
setAllButton = new Button( "Set All" );
Font setAllButtonFont = setAllButton.getFont();
setAllButton.setFont( Font.font( setAllButtonFont.getFamily(), FontWeight.BOLD, FontPosture.REGULAR, setAllButtonFont.getSize() ) );
setAllButton.setMaxWidth( Double.MAX_VALUE );
add( setAllButton, 1, 0 );
setAllButton.setOnAction( event -> setAllBoxesToSelectedPolicy() );
}
示例4: printText
import javafx.scene.text.FontPosture; //導入依賴的package包/類
@Override
public void printText(String toPrint) {
if (overlayText != null) {
clearText();
}
overlayText = new Text(0, 0, toPrint);
overlayText.setFont(Font.font("monospaced", FontWeight.BOLD, FontPosture.REGULAR, 25));
overlayText.yProperty().bind(
this.upperPane.heightProperty().multiply(TEXT_DISPLAY_RATIO));
overlayText.xProperty().bind(this.upperPane.widthProperty().multiply(0).add(TEXT_BUFFER));
overlayText.wrappingWidthProperty().bind(this.upperPane.widthProperty().subtract(TEXT_BUFFER * 2));
overlayText.setTextAlignment(TextAlignment.CENTER);
this.upperPane.getChildren().add(overlayText);
}
示例5: printHeadline
import javafx.scene.text.FontPosture; //導入依賴的package包/類
@Override
public void printHeadline(String toPrint) {
if (overlayHeadline != null) {
clearText();
}
overlayHeadline = new Text(0, 0, toPrint);
overlayHeadline.setFont(Font.font("monospaced", FontWeight.BOLD, FontPosture.REGULAR, 25));
overlayHeadline.yProperty().bind(
this.upperPane.heightProperty().multiply(HEADLINE_DISPLAY_RATIO));
overlayHeadline.xProperty().bind(this.upperPane.widthProperty().multiply(0).add(TEXT_BUFFER));
overlayHeadline.wrappingWidthProperty().bind(this.upperPane.widthProperty().subtract(TEXT_BUFFER * 2));
overlayHeadline.setTextAlignment(TextAlignment.CENTER);
this.upperPane.getChildren().add(overlayHeadline);
}
示例6: getMonospacedFonts
import javafx.scene.text.FontPosture; //導入依賴的package包/類
/**
* Return a list of all the mono-spaced fonts on the system.
*
* @author David D. Clark http://clarkonium.net/2015/07/finding-mono-spaced-fonts-in-javafx/
*/
private static Collection<String> getMonospacedFonts() {
// Compare the layout widths of two strings. One string is composed
// of "thin" characters, the other of "wide" characters. In mono-spaced
// fonts the widths should be the same.
final Text thinTxt = new Text("1 l"); // note the space
final Text thikTxt = new Text("MWX");
List<String> fontFamilyList = Font.getFamilies();
List<String> monospacedFonts = new ArrayList<>();
for (String fontFamilyName : fontFamilyList) {
Font font = Font.font(fontFamilyName, FontWeight.NORMAL, FontPosture.REGULAR, 14.0d);
thinTxt.setFont(font);
thikTxt.setFont(font);
if (thinTxt.getLayoutBounds().getWidth() == thikTxt.getLayoutBounds().getWidth())
monospacedFonts.add(fontFamilyName);
}
return monospacedFonts;
}
示例7: convert
import javafx.scene.text.FontPosture; //導入依賴的package包/類
/** Convert model font into JFX font
* @param font {@link WidgetFont}
* @return {@link Font}
*/
public static Font convert(final WidgetFont font)
{
final double calibrated = font.getSize() * font_calibration;
switch (font.getStyle())
{
case BOLD:
return Font.font(font.getFamily(), FontWeight.BOLD, calibrated);
case ITALIC:
return Font.font(font.getFamily(), FontPosture.ITALIC, calibrated);
case BOLD_ITALIC:
return Font.font(font.getFamily(), FontWeight.BOLD, FontPosture.ITALIC, calibrated);
default:
return Font.font(font.getFamily(), calibrated);
}
}
示例8: ExceptionsScript
import javafx.scene.text.FontPosture; //導入依賴的package包/類
public ExceptionsScript()
{
slide = new Slide(world);
Paint commentColor = color(48, 201, 137);
Font commentFont = Font.font("Chewed Pen BB", FontPosture.ITALIC, 50d);
commentFormat = new Format(TypeFace.font(commentFont, 1d, 1d), TypeFace.color(commentColor, 1d),
Frames.frame(commentColor, 3d, 1d));
knowsFormat = new Format(TypeFace.font(commentFont, 1d, 1d), TypeFace.color(Color.BLUEVIOLET, 1d),
Frames.frame(Color.BLUEVIOLET, 2d, 1d, Dash.dash(4d)));
Paint codeColor = Color.WHITE;
largeCodeFormat = new Format(TypeFace.font(new Font("Consolas", 60d), 2d, 1d), TypeFace.color(codeColor, 1d));
this.stackGrid = new Grid(1, STACK_ROWS, new PointPair(900d, 230d, 1480d, 820d));
Font codeFont = new Font("Consolas", 25d);
codeFormat = new Format(TypeFace.font(codeFont, 2d, 1d), TypeFace.color(codeColor, 1d),
Frames.frame(codeColor, 2d, 1d));
stackFormat = new Format(Frames.frame(Color.YELLOW, 2d, 1d));
lightComment = new Format(TypeFace.font(commentFont, 1d, 1d), TypeFace.color(commentColor, 1d),
Frames.frame(commentColor, 2d, 1d));
}
示例9: Slide
import javafx.scene.text.FontPosture; //導入依賴的package包/類
public Slide(ScriptWorld world)
{
super(world);
this.lines = new ArrayList<>();
Paint majorColor = color(13, 165, 15);
Font majorHand = Font.font("Times New Roman", FontPosture.ITALIC, 90d);
majorFormat = new Format(TypeFace.font(majorHand, 2d, 1d), TypeFace.color(majorColor, 1d),
Frames.frame(majorColor, 5d, 1d));
Paint subColor = color(163, 232, 78);
Font subHand = Font.font("Times New Roman", FontPosture.ITALIC, 68d);
subFormat = new Format(majorFormat, TypeFace.font(subHand, 2d, 1d), TypeFace.color(subColor, 1d),
Frames.frame(subColor, 5d, 1d));
Paint minorColor = color(240, 255, 30);
Font minorFont = Font.font("Times New Roman", FontPosture.ITALIC, 50d);
minorFormat = new Format(TypeFace.font(minorFont, 1d, 1d), TypeFace.color(minorColor, 1d),
Frames.frame(minorColor, 5d, 1d));
}
示例10: updateItem
import javafx.scene.text.FontPosture; //導入依賴的package包/類
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (!isEmpty()) {
if (!new File(item).exists()) {
setText("<invalid path> " + item);
setTooltip(new Tooltip(item));
setTextFill(Color.RED);
setFont(Font.font("Arial", FontPosture.ITALIC, 11));
} else {
setText(item);
setTooltip(new Tooltip(item));
setTextFill(Color.BLACK);
setFont(Font.font("Arial", FontPosture.REGULAR, 11));
}
}
}
示例11: updateItem
import javafx.scene.text.FontPosture; //導入依賴的package包/類
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
Editor editor = (Editor) getTableRow().getItem();
if (editor != null) {
if (EditorLoader.isSupported(editor)) {
if (editor.getPath() == null || editor.getPath().isEmpty()) {
setText("");
} else if (!EditorLoader.isValid((Editor) getTableRow().getItem())) {
setText("<invalid path> " + item);
setTooltip(new Tooltip(item));
setTextFill(Color.RED);
setFont(Font.font("Arial", FontPosture.ITALIC, 11));
} else {
setText(item);
setTooltip(new Tooltip(item));
setTextFill(Color.BLACK);
setFont(Font.font("Arial", FontPosture.REGULAR, 11));
}
} else {
setText("<unsupported for your os>");
setTextFill(Color.LIGHTCORAL);
setFont(Font.font("Arial", FontPosture.ITALIC, 11));
}
}
}
示例12: StatusBar
import javafx.scene.text.FontPosture; //導入依賴的package包/類
public StatusBar() {
setId("status-bar");
msgLabel = createLabel("");
extraLabel = createLabel(" ");
extraLabel.setFont(Font.font("System", FontPosture.ITALIC, 12.0));
fixtureLabel = createLabel(" ");
fixtureLabel.setFont(Font.font("System", FontWeight.BOLD, 12.0));
rowLabel = createLabel(" ");
columnLabel = createLabel(" ");
insertLabel = createLabel(" ");
Region region = new Region();
getChildren().addAll(msgLabel, region, createSeparator(), extraLabel, createSeparator(), fixtureLabel, createSeparator(),
rowLabel, createSeparator(), columnLabel, createSeparator(), insertLabel, createSeparator());
HBox.setHgrow(region, Priority.ALWAYS);
getStylesheets().add(ModalDialog.class.getClassLoader().getResource("net/sourceforge/marathon/fx/api/css/marathon.css")
.toExternalForm());
}
示例13: toFont
import javafx.scene.text.FontPosture; //導入依賴的package包/類
public static Font toFont(MapValue mapValue) {
val map = mapValue.getMap();
val family = map.getOrDefault("family", new StringValue(Font.getDefault().getFamily())).asString();
val weight = map.getOrDefault("weight", NumberValue.of(FontWeight.NORMAL.getWeight())).asInt();
val isItalic = map.getOrDefault("italic", NumberValue.ZERO).asBoolean();
val posture = isItalic ? FontPosture.ITALIC : FontPosture.REGULAR;
val size = map.getOrDefault("size", NumberValue.MINUS_ONE).asDouble();
return Font.font(family, FontWeight.findByWeight(weight), posture, size);
}
示例14: showHelpContent
import javafx.scene.text.FontPosture; //導入依賴的package包/類
/**
* Help content of XpanderFX
*/
@SuppressWarnings("deprecation")
private void showHelpContent() {
try {
Node content = FXMLLoader.load(getClass().getResource("/com/shekkar/xpanderfx/top/popup/HelpFXML.fxml"));
help_box = new VBox();
help_box.getChildren().addAll(content,
HBoxBuilder.create().alignment(Pos.CENTER_LEFT)
.padding(new Insets(0,3,0,0))
.children(
VBoxBuilder.create().minWidth(720).alignment(Pos.CENTER_LEFT).padding(new Insets(0,0,0,10))
.children(
HyperlinkBuilder.create().text("open-source on GitHub [ShekkarRaee/XpanderFX]")
.onAction(e -> this.browse("https://github.com/ShekkarRaee/XpanderFX-2048-Game-JavaFX")).build(),
LabelBuilder.create().text("[email protected]").build()
)
.build(),
ButtonBuilder.create().text("OK")
.minHeight(40)
.minWidth(70)
.style("-fx-base:black;"
+ "-fx-border-radius: 7;"
+ "-fx-background-radius: 7;")
.onAction(e -> this.popupCloser(help, help_box))
.font(Font.font("System", FontWeight.MEDIUM, FontPosture.REGULAR, 20))
.build()
).style("-fx-background-color:white")
.build()
);
help_box.setStyle("-fx-background-color: linear-gradient(lightgrey, white, lightgrey);"
+ "-fx-border-color: white;"
+ "-fx-border-width: 1;");
help.getContent().add(help_box);
} catch (IOException ex) {
Logger.getLogger(MainFXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
}
help.show(this.ICON.getScene().getWindow(), this.getNodeMaxX() + 20, this.getNodeMaxY() + 40);
this.popupOpener(help_box);
}
示例15: showAboutContent
import javafx.scene.text.FontPosture; //導入依賴的package包/類
/**
* About content
*/
@SuppressWarnings("deprecation")
private void showAboutContent() {
try {
Node content = FXMLLoader.load(getClass().getResource("/com/shekkar/xpanderfx/top/popup/AboutFXMLDocument.fxml"));
about_box = new VBox();
about_box.getChildren().addAll(content,
HBoxBuilder.create().alignment(Pos.CENTER_RIGHT)
.padding(new Insets(0,3,0,0))
.children(
ButtonBuilder.create().text("OK")
.minHeight(40)
.minWidth(70)
.style("-fx-base:black;"
+ "-fx-border-radius: 7;"
+ "-fx-background-radius: 7;")
.onAction(e -> this.popupCloser(about, about_box))
.font(Font.font("System", FontWeight.MEDIUM, FontPosture.REGULAR, 20))
.build()
)
.build()
);
about_box.setStyle("-fx-background-color: linear-gradient(black, lightgrey);"
+ "-fx-background-radius: 7;"
+ "-fx-border-radius: 7;");
about.getContent().add(about_box);
} catch (IOException ex) {
Logger.getLogger(MainFXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
}
about.show(this.ICON.getScene().getWindow(), this.getNodeMaxX() - 14, this.getNodeMaxY() + 12);
this.popupOpener(about_box);
}