Java 类javafx.scene.text.FontPosture 实例源码

项目:fxexperience2    文件:FontPickerController.java   
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);
    }
}
项目:fx-gson    文件:FontTypeAdapter.java   
@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);
}
项目:JttDesktop    文件:JobPolicyPanel.java   
/**
 * 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() );
}
项目:MULE    文件:VisualGrid.java   
@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);
}
项目:MULE    文件:VisualGrid.java   
@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);
}
项目:markdown-writer-fx    文件:GeneralOptionsPane.java   
/**
 * 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;
}
项目:org.csstudio.display.builder    文件:JFXUtil.java   
/** 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);
    }
}
项目:contentment    文件:ExceptionsScript.java   
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));
}
项目:contentment    文件:Slide.java   
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));

}
项目:closurefx-builder    文件:PreferenceClosureController.java   
@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));
        }
    }
}
项目:closurefx-builder    文件:PreferenceVariablesController.java   
@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));
        }
    }
}
项目:closurefx-builder    文件:PreferenceEditorsController.java   
@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));
        }
    }
}
项目:marathonv5    文件:StatusBar.java   
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());
}
项目:HotaruFX    文件:FontValue.java   
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);
}
项目:xpanderfx    文件:MainFXMLDocumentController.java   
/**
 * 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);        
}
项目:xpanderfx    文件:GameOver.java   
/**
 * 
 * @return center_box
 */
private HBox getCenterBox() {
    @SuppressWarnings("deprecation")
    HBox center = HBoxBuilder.create()
         .children(LabelBuilder.create().text("Game Over!!")
            .textFill(Color.BLACK)
             .font(Font.font("System", FontWeight.MEDIUM, FontPosture.REGULAR, 30))
             .build())
         .alignment(Pos.CENTER)
         .build();
    return center;
}
项目:xpanderfx    文件:GameOver.java   
/**
 * 
 * @param controller
 * @return restart-button
 */
public Button getRestartButton(MainFXMLDocumentController controller) {
    @SuppressWarnings("deprecation")
    Button restart = ButtonBuilder.create().text("Restart")
            .minWidth(50).minHeight(24)
            .font(Font.font("System", FontWeight.SEMI_BOLD, FontPosture.REGULAR, 20))
            .style("-fx-base:darkslategrey;"
                       + "-fx-background-radius:7;"
                 + "-fx-border-radius:7;")
            .onAction(e -> {
                controller.restart();
                pp.hide();
            })
            .build();
    return restart;
}
项目:xpanderfx    文件:GameOver.java   
/**
 * 
 * @param controller
 * @return exit-button
 */
public Button getQuitButton(MainFXMLDocumentController controller) {
    @SuppressWarnings("deprecation")
    Button quit = ButtonBuilder.create().text("Exit")
            .minWidth(50).minHeight(24)
            .font(Font.font("System", FontWeight.SEMI_BOLD, FontPosture.REGULAR, 20))
            .style("-fx-base:darkslategrey;"
                       + "-fx-background-radius:7;"
                 + "-fx-border-radius:7;")
            .onAction(e -> Platform.exit())
            .build();
    return quit;
}
项目:xpanderfx    文件:Completion.java   
/**
 * 
 * @return root-node
 */
@SuppressWarnings("deprecation")
private BorderPane getBody() {
    return BorderPaneBuilder.create().minHeight(200).minWidth(440).center(
            VBoxBuilder.create().alignment(Pos.CENTER).children(
                    LabelBuilder.create()
                            .minHeight(10).build(),
                    LabelBuilder.create().text("Congratulation !! You won the game.")
                        .font(Font.font("", FontWeight.BOLD, FontPosture.ITALIC, 20))
                            .textFill(Color.WHITE).build(),
                    LabelBuilder.create()
                            .minHeight(30).build(),
                    HBoxBuilder.create().alignment(Pos.CENTER).spacing(20).children(
                            ButtonBuilder.create().text("Continue").font(Font.font("", FontWeight.SEMI_BOLD, FontPosture.REGULAR, 18))
                                    .minWidth(140).textFill(Color.WHITE).style("-fx-base:darkslategrey")
                                    .onAction(e -> this.close()).build(),
                            ButtonBuilder.create().text("Try Again").font(Font.font("", FontWeight.SEMI_BOLD, FontPosture.REGULAR, 18))
                                    .minWidth(140).textFill(Color.WHITE).style("-fx-base:darkslategrey")
                                    .onAction(e -> {
                                        controller.restart();   
                                        this.close();
                                    }).build()
                    ).build()
            )
            .build()
    ).style("-fx-background-color: linear-gradient(#000000cc, darkslategrey); -fx-background-radius: 15; -fx-border-radius:15;"
            + "-fx-border-width:1; -fx-border-color:lightgrey").build();
}
项目:CORNETTO    文件:MyVertexView.java   
/**
 * Adds Label Display to every Node containing the Taxon ID
 */
private void addLabel() {
    vertexLabel = new Label(myVertex.getTaxonName());
    vertexLabel.translateXProperty().bind(vertexShape.translateXProperty());
    vertexLabel.translateYProperty().bind(vertexShape.translateYProperty().add(getRadiusProperty()));
    vertexLabel.setFont(Font.font("Verdana", FontWeight.BOLD, FontPosture.ITALIC, 12));
    getChildren().add(vertexLabel);
}
项目:ccu-historian    文件:FXGraphics2D.java   
/**
 * 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()));
}
项目:fx-gson    文件:FontTypeAdapter.java   
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;
}
项目:fx-gson    文件:FontTypeAdapterTest.java   
@DataPoints
public static FontExpectation[] expectations() {
    // no exotic fonts as the test must pass on most machines
    return new FontExpectation[]{
            new FontExpectation(Font.font("System", FontWeight.NORMAL, 12.0), "\"System,Regular,12.0\""),
            new FontExpectation(Font.font("SansSerif", FontWeight.BOLD, 10.0), "\"SansSerif,Bold,10.0\""),
            new FontExpectation(Font.font("System", FontPosture.ITALIC, 10.0), "\"System,Italic,10.0\""),
            new FontExpectation(Font.font("System", FontWeight.BOLD, FontPosture.ITALIC, 10.0),
                    "\"System,Bold Italic,10.0\""),
            new FontExpectation(Font.font("SansSerif", FontWeight.BOLD, FontPosture.ITALIC, 20.0),
                    "\"SansSerif,Bold Italic,20.0\""),
            new FontExpectation(null, "null"),
    };
}
项目:Project-Templates    文件:ApplicationPresenter.java   
private void onActionSetTextItalicAndStrikethrough(final Tab tab) {
    final Text text = new Text();
    final Font font = text.getFont();
    text.setFill(Color.DIMGRAY.darker());
    text.setFont(Font.font(font.getFamily(), FontPosture.ITALIC, font.getSize()));
    text.setStrikethrough(Boolean.TRUE);
    text.setText(tab.getId());

    tab.setGraphic(text);
    tab.setText(null);
}
项目:Gargoyle    文件:SpecExample.java   
@Override
public void start(Stage primaryStage) throws Exception {
    String projectDir = System.getProperty("user.dir");

    File file = new File(projectDir, "src/main/java/com/kyj/fx/voeditor/visual/example/SpecExample.java");
    SpecResource specResource = new SpecResource(new File(projectDir), file);

    SpecTabPane center = new SpecTabPane(specResource);
    Button btnCapture = new Button("SnapShot");
    ImageView ivOrigin = new ImageView();

    btnCapture.setOnAction(ev -> {

        FxUtil.snapShot(center, new File("example.png"));

        FxUtil.printJob(primaryStage, center);
    });

    Text text1 = new Text("Big italic red text");
    text1.setFill(Color.RED);
    text1.setFont(Font.font("Helvetica", FontPosture.ITALIC, 40));
    Text text2 = new Text(" little bold blue text");
    text2.setFill(Color.BLUE);
    text2.setFont(Font.font("Helvetica", FontWeight.BOLD, 10));
    TextFlow textFlow = new TextFlow(text1, text2);

    BorderPane root = new BorderPane(center);
    root.setTop(new HBox(textFlow, btnCapture));
    root.setBottom(ivOrigin);
    root.setPrefSize(800, 600);
    Scene value = new Scene(root, 800, 600);

    primaryStage.setScene(value);
    primaryStage.show();
}
项目:Gargoyle    文件:FontViewComposite.java   
/**
 * @작성자 : KYJ
 * @작성일 : 2016. 12. 2.
 */
private void loadFont() {
    FontWeight fontWeight = FontWeight.findByWeight((int) sliderFontWeight.getValue());
    FontPosture fontStyle = FontPosture.findByName(cbFontStyles.getValue());
    double fontSize = sliderFontSize.getValue();
    String fontName = cbFontNames.getValue();
    LOGGER.debug("{} {} {} {}", fontName, fontWeight, fontStyle, fontSize);
    Font font = Font.font(fontName, fontWeight, fontStyle, fontSize);
    if (font != null)
        lblPreviewText.setFont(font);

}
项目:Gargoyle    文件:FontViewComposite.java   
public FontStyle(String styles) {
    this();
    String[] fontStyles = (styles == null ? "" : styles.trim().toUpperCase()).split(" "); //$NON-NLS-1$ //$NON-NLS-2$
    for (String style : fontStyles) {
        FontWeight w = FontWeight.findByName(style);
        if (w != null) {
            weight = w;
        } else {
            FontPosture p = FontPosture.findByName(style);
            if (p != null)
                posture = p;
        }
    }
}
项目:aya-lang    文件:FXGraphics2D.java   
/**
 * 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()));
}
项目:programmierpraktikum-abschlussprojekt-proprawunderbar    文件:UIRunner.java   
public void decorate(BorderPane border, Button Neues_Projekt, Button Laden, Button Beenden, Blend blend){
    GridPane root = new GridPane();
    GridPane title = new GridPane();
    GridPane empty_space = new GridPane();
    GridPane empty_space2 = new GridPane();
    GridPane empty_space3 = new GridPane();

    border.setTop(title);
    border.setLeft(empty_space);
    border.setRight(empty_space2);
    border.setCenter(root);
    border.setBottom(empty_space3);
    border.setStyle("-fx-background-color: #E0E0E0");

    root.setAlignment(Pos.TOP_CENTER);
    root.setPadding(new Insets(25, 25, 25, 25));
    root.add(Neues_Projekt, 0, 0);
    root.setVgap(10);
    root.add(Laden, 0, 1);
    root.add(Beenden, 0, 2);

    Text text = new Text("Willkommen!");
    text.setFont(Font.font("Verdana", FontPosture.ITALIC, 35));
    text.setStyle("-fx-font-weight: bold;");
    text.setFill(Color.BLACK);
    text.setEffect(blend);
    text.setCache(true);


    title.setAlignment(Pos.BOTTOM_CENTER);
    title.setPadding(new Insets(25, 25, 25, 25));
    title.add(text, 0, 6);
}
项目:JttDesktop    文件:JavaFxStyle.java   
/**
 * Method to create a bold {@link Label}.
 * @param title the text in the {@link Label}.
 * @param fontSize the size of the {@link Font}.
 * @return the constructed {@link Label}.
 */
public Label createBoldLabel( String title, double fontSize ) {
   Label label = new Label( title );
   Font existingFont = label.getFont();
   label.setFont( Font.font( existingFont.getFamily(), FontWeight.BOLD, FontPosture.REGULAR, fontSize ) );
   return label;
}
项目:FXImgurUploader    文件:OnOffSwitchSkin.java   
private void resize() {
    width  = getSkinnable().getWidth();
    height = getSkinnable().getHeight();

    if (width > 0 && height > 0) {
        if (aspectRatio * width > height) {
            width = 1 / (aspectRatio / height);
        } else if (1 / (aspectRatio / height) > width) {
            height = aspectRatio * width;
        }

        font = Font.font("Open Sans", FontWeight.EXTRA_BOLD, FontPosture.REGULAR, 0.4 * height);

        background.setPrefSize(width, height);

        selectedText.setFont(font);
        selectedText.setTextOrigin(VPos.CENTER);
        selectedText.relocate(height * 0.2, (height - selectedText.getLayoutBounds().getHeight()) * 0.5);

        deselectedText.setFont(font);
        deselectedText.setTextOrigin(VPos.CENTER);
        deselectedText.relocate(width - height * 0.2 - deselectedText.getLayoutBounds().getWidth(), (height - deselectedText.getLayoutBounds().getHeight()) * 0.5);

        thumb.setPrefSize((height * 0.75), (height * 0.75));
        thumb.setTranslateX(getSkinnable().isSelected() ? height * 1.125 : height * 0.125);
        thumb.setTranslateY(height * 0.125);

        moveToDeselected.setFromX(height * 1.125);
        moveToDeselected.setToX(height * 0.125);

        moveToSelected.setFromX(height * 0.125);
        moveToSelected.setToX(height * 1.125);
    }
}
项目:FXImgurUploader    文件:IconSwitchSkin.java   
private void resize() {
    width  = getSkinnable().getWidth();
    height = getSkinnable().getHeight();
    size   = width < height ? width : height;

    if (width > 0 && height > 0) {
        if (aspectRatio * width > height) {
            width = 1 / (aspectRatio / height);
        } else if (1 / (aspectRatio / height) > width) {
            height = aspectRatio * width;
        }

        font = Font.font("Open Sans", FontWeight.BOLD, FontPosture.REGULAR, height * 0.5);

        background.setPrefSize(width, height);

        symbol.setPrefSize(height * 0.59375 * getSkinnable().getSymbolType().WIDTH_FACTOR, height * 0.59375 * getSkinnable().getSymbolType().HEIGHT_FACTOR);
        symbol.relocate(height * 0.15 + (height * 0.59375 - height * 0.59375 * getSkinnable().getSymbolType().WIDTH_FACTOR) * 0.5,
                        height * 0.18 + (height * 0.59375 - height * 0.59375 * getSkinnable().getSymbolType().HEIGHT_FACTOR) * 0.5);

        text.setFont(font);
        text.setVisible(!getSkinnable().getText().isEmpty() && SymbolType.NONE == getSkinnable().getSymbolType());
        text.setPrefSize(height * 0.59375, height * 0.59375);
        text.relocate(height * 0.125, height * 0.15);

        thumb.setPrefSize((height * 0.75), (height * 0.75));
        thumb.setTranslateX(getSkinnable().isSelected() ? height * 1.625 : height * 0.875);
        thumb.setTranslateY(height * 0.125);

        moveToDeselected.setFromX(height * 1.625);
        moveToDeselected.setToX(height * 0.875);

        moveToSelected.setFromX(height * 0.875);
        moveToSelected.setToX(height * 1.625);
    }
}
项目:populus    文件:FXGraphics2D.java   
/**
 * 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()));
}
项目:JVx.javafx    文件:JavaFXFont.java   
/**
 * Creates a new instance of {@link JavaFXFont}.
 *
 * @param pFontName the font name.
 * @param pStyle the style.
 * @param pSize the size.
 */
public JavaFXFont(String pFontName, int pStyle, int pSize)
{
    super(Font.font(pFontName,
            (pStyle & IFont.BOLD) == IFont.BOLD ? FontWeight.BOLD : FontWeight.NORMAL,
            (pStyle & IFont.ITALIC) == IFont.ITALIC ? FontPosture.ITALIC : FontPosture.REGULAR,
            pSize));
}
项目:JVx.javafx    文件:TestStyleContainer.java   
@Test
public void setFont()
{
    style.setFont(Font.font("System", FontWeight.BOLD, FontPosture.ITALIC, 25.6));

    Assert.assertEquals("-fx-font-size: 25.60px;\n-fx-font-style: italic;\n-fx-font-family: \"System\";\n-fx-font-weight: bold;\n", style.toString());
}
项目:org.csstudio.display.builder    文件:GraphicsUtils.java   
/** 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());
}
项目:ECG-Viewer    文件:FXGraphics2D.java   
/**
 * 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()));
}
项目:ISAAC    文件:SimpleRelRow.java   
@Override
public void addRelRow(RelationshipVersionBI<?> rel) {
    Rectangle rec = createAnnotRectangle(rel);
    Label relLabel = labelHelper.createLabel(rel, OTFUtility.getConPrefTerm(rel.getDestinationNid()), ComponentType.RELATIONSHIP, rel.getDestinationNid());
    Label relTypeLabel = labelHelper.createLabel(rel, OTFUtility.getConPrefTerm(rel.getTypeNid()), ComponentType.RELATIONSHIP, rel.getTypeNid());

    if (rel.isUncommitted()) {
        if (rel.getVersions().size() == 1) {
            Font f = relLabel.getFont();
            relLabel.setFont(Font.font(f.getFamily(), FontPosture.ITALIC, f.getSize()));

            f = relTypeLabel.getFont();
            relTypeLabel.setFont(Font.font(f.getFamily(), FontPosture.ITALIC, f.getSize()));
        } else {
            relLabel.setUnderline(true);
            relTypeLabel.setUnderline(true);
        }
    }

    //setConstraints(Node child, int columnIndex, int rowIndex, int columnspan, int rowspan, HPos halignment, 
    //               VPos valignment, Priority hgrow, Priority vgrow, Insets margin)
    GridPane.setConstraints(rec,  0,  0,  1,  1,  HPos.CENTER,  VPos.CENTER, Priority.NEVER, Priority.ALWAYS);
    GridPane.setConstraints(relLabel,  1,  0,  1,  1,  HPos.LEFT,  VPos.CENTER, Priority.SOMETIMES, Priority.ALWAYS);
    GridPane.setConstraints(relTypeLabel,  2,  0,  1,  1,  HPos.RIGHT,  VPos.CENTER, Priority.SOMETIMES, Priority.ALWAYS);

    GridPane.setMargin(relLabel, new Insets(0, 20, 0, 0));
    GridPane.setMargin(relTypeLabel, new Insets(0, 0, 0, 20));

    gp.addRow(counter++, rec, relLabel, relTypeLabel);
}
项目:ISAAC    文件:SimpleTermRow.java   
@Override
public void addTermRow(DescriptionVersionBI<?> desc, boolean isPrefTerm) {
    Rectangle rec = createAnnotRectangle(desc);
    Label descLabel = labelHelper.createLabel(desc, desc.getText(), ComponentType.DESCRIPTION, 0);
    Label descTypeLabel = null;

    if (isPrefTerm) {
        descTypeLabel = labelHelper.createLabel(desc, prefTermTypeStr, ComponentType.DESCRIPTION, prefTermTypeNid);
    } else {
        descTypeLabel = labelHelper.createLabel(desc, OTFUtility.getConPrefTerm(desc.getTypeNid()), ComponentType.DESCRIPTION, desc.getTypeNid());
    }

    if (desc.isUncommitted()) {
        if (desc.getVersions().size() == 1) {
            Font f = descLabel.getFont();
            descLabel.setFont(Font.font(f.getFamily(), FontPosture.ITALIC, f.getSize()));

            f = descTypeLabel.getFont();
            descTypeLabel.setFont(Font.font(f.getFamily(), FontPosture.ITALIC, f.getSize()));
        } else {
            descLabel.setUnderline(true);
            descTypeLabel.setUnderline(true);
        }
    }

    //setConstraints(Node child, int columnIndex, int rowIndex, int columnspan, int rowspan, HPos halignment, 
    //               VPos valignment, Priority hgrow, Priority vgrow, Insets margin)
    GridPane.setConstraints(rec,  0,  0,  1,  1,  HPos.CENTER,  VPos.CENTER);
    GridPane.setConstraints(descLabel,  1,  0,  1,  1,  HPos.LEFT,  VPos.CENTER);
    GridPane.setConstraints(descTypeLabel,  2,  0,  1,  1,  HPos.RIGHT,  VPos.CENTER);

    GridPane.setMargin(descLabel, new Insets(0, 20, 0, 0));
    GridPane.setMargin(descTypeLabel, new Insets(0, 0, 0, 20));
    gp.addRow(counter++, rec, descLabel, descTypeLabel);
}