本文整理匯總了Java中javafx.scene.text.FontPosture.REGULAR屬性的典型用法代碼示例。如果您正苦於以下問題:Java FontPosture.REGULAR屬性的具體用法?Java FontPosture.REGULAR怎麽用?Java FontPosture.REGULAR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javafx.scene.text.FontPosture
的用法示例。
在下文中一共展示了FontPosture.REGULAR屬性的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: changeFont
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: toFont
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);
}
示例3: setFont
/**
* Sets the font to be used for drawing text.
*
* @param font the font ({@code null} is permitted but ignored).
*
* @see #getFont()
*/
@Override
public void setFont(Font font) {
if (font == null) {
return;
}
this.font = font;
FontWeight weight = font.isBold() ? FontWeight.BOLD : FontWeight.NORMAL;
FontPosture posture = font.isItalic()
? FontPosture.ITALIC : FontPosture.REGULAR;
this.gc.setFont(javafx.scene.text.Font.font(font.getFamily(),
weight, posture, font.getSize()));
}
示例4: extractPosture
private static FontPosture extractPosture(String style) {
for (String styleWord : style.split("\\s")) {
FontPosture posture = FontPosture.findByName(styleWord);
if (posture != null && posture != FontPosture.REGULAR) {
return posture;
}
}
return FontPosture.REGULAR;
}
示例5: convert
/** Convert font
* @param font AWT font
* @return JFX font
*/
public static Font convert(final java.awt.Font font)
{
final FontWeight weight = font.isBold() ? FontWeight.BOLD : FontWeight.NORMAL;
final FontPosture posture = font.isItalic() ? FontPosture.ITALIC : FontPosture.REGULAR;
return Font.font(font.getFamily(), weight, posture, font.getSize());
}
示例6: applyFont
private void applyFont(Font font) {
this.font = font;
FontWeight weight = font.isBold() ? FontWeight.BOLD : FontWeight.NORMAL;
FontPosture posture = font.isItalic()
? FontPosture.ITALIC : FontPosture.REGULAR;
javafx.scene.text.Font jfxfont = javafx.scene.text.Font.font(
font.getFamily(), weight, posture, font.getSize());
this.gc.setFont(jfxfont);
}
示例7: getStringBounds
@Override
public Rectangle2D getStringBounds(String str, Graphics context) {
Text text = new Text(str);
FontWeight weight = font.isBold() ? FontWeight.BOLD : FontWeight.NORMAL;
FontPosture posture = font.isItalic()
? FontPosture.ITALIC : FontPosture.REGULAR;
javafx.scene.text.Font jfxfont = javafx.scene.text.Font.font(
font.getFamily(), weight, posture, font.getSize());
text.setFont(jfxfont);
Bounds b = text.getLayoutBounds();
return new Rectangle2D.Double(b.getMinX(), b.getMinY(), b.getWidth(),
b.getHeight());
}
示例8: setFont
/**
* Sets the font to be used for drawing text.
*
* @param font the font ({@code null} is permitted but ignored).
* @see #getFont()
*/
@Override
public void setFont(Font font) {
if (font == null) {
return;
}
this.font = font;
FontWeight weight = font.isBold() ? FontWeight.BOLD : FontWeight.NORMAL;
FontPosture posture = font.isItalic()
? FontPosture.ITALIC : FontPosture.REGULAR;
this.gc.setFont(javafx.scene.text.Font.font(font.getFamily(),
weight, posture, font.getSize()));
}
示例9: findFont
/**
* Find a {@link Font} that best matches the given specs.
*
* @param names
* the list of acceptable font families
* @param size
* the requested size in pt.
* @param bold
* whether the font should be bold
* @param italic
* whether the font should be italic
* @return a suitable {@link Font}, never <code>null</code>, might not be a perfect match
*/
public static Font findFont(List<String> names, double size, boolean bold, boolean italic) {
FontWeight weight = (bold ? FontWeight.BOLD : FontWeight.NORMAL);
FontPosture posture = (italic ? FontPosture.ITALIC : FontPosture.REGULAR);
for (String name : names) {
for (String font : allFonts) {
if (font.toLowerCase().equals(name.toLowerCase())) {
return Font.font(font, weight, posture, size);
}
}
}
// let JavaFX choose an appropriate alternative for the first font.
return Font.font(names.get(0), weight, posture, size);
}
示例10: FontStyle
public FontStyle(FontWeight weight, FontPosture posture) {
this.posture = posture == null ? FontPosture.REGULAR : posture;
this.weight = weight;
}
示例11: getPosture
private FontPosture getPosture() {
return chkItalic.isSelected() ? FontPosture.ITALIC : FontPosture.REGULAR;
}