Java Code Examples for javafx.scene.text.FontPosture#REGULAR
The following examples show how to use
javafx.scene.text.FontPosture#REGULAR .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FXGraphics2D.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * 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())); }
Example 2
Source File: FontUtils.java From PDF4Teachers with Apache License 2.0 | 6 votes |
public static FontPosture getFontPosture(Font font) { String[] style = font.getStyle().split(" "); if(style.length == 1){ if(style[0].equals("Italic")){ return FontPosture.ITALIC; } }else if(style.length == 2){ if(style[1].equals("Italic")){ return FontPosture.ITALIC; } } return FontPosture.REGULAR; }
Example 3
Source File: GraphicsUtils.java From phoebus with Eclipse Public License 1.0 | 6 votes |
/** 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()); }
Example 4
Source File: XMLPersistence.java From phoebus with Eclipse Public License 1.0 | 6 votes |
/** Load font from XML document * @param node Parent node of the color * @param font_tag Name of tag that contains the font * @return {@link Font} */ public static Optional<Font> loadFontFromDocument(final Element node, final String font_tag) { final String desc = XMLUtil.getChildString(node, font_tag).orElse(""); if (desc.isEmpty()) return Optional.empty(); String family = DEFAULT_FONT_FAMILY; FontPosture posture = FontPosture.REGULAR; FontWeight weight = FontWeight.NORMAL; double size = DEFAULT_FONT_SIZE; // Legacy format was "Liberation Sans|20|1" final String[] items = desc.split("\\|"); if (items.length == 3) { family = items[0]; size = Double.parseDouble(items[1]); switch (items[2]) { case "1": // SWT.BOLD weight = FontWeight.BOLD; break; case "2": // SWT.ITALIC posture = FontPosture.ITALIC; break; case "3": // SWT.BOLD | SWT.ITALIC weight = FontWeight.BOLD; posture = FontPosture.ITALIC; break; } } return Optional.of(Font.font(family, weight, posture, size )); }
Example 5
Source File: FXGraphics2D.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * 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())); }
Example 6
Source File: FXGraphics2D.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * 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())); }
Example 7
Source File: Exercise_16_14.java From Intro-to-Java-Programming with MIT License | 6 votes |
private FontPosture getPosture() { return chkItalic.isSelected() ? FontPosture.ITALIC : FontPosture.REGULAR; }
Example 8
Source File: FXGraphics2D.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * 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())); }
Example 9
Source File: FXGraphics2D.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * 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())); }
Example 10
Source File: FXGraphics2D.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * 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())); }
Example 11
Source File: ImageManufactureTextController.java From MyBox with Apache License 2.0 | 4 votes |
public void write(boolean editing) { if (isSettingValues || imageView.getImage() == null || x < 0 || y < 0 || x >= imageView.getImage().getWidth() || y >= imageView.getImage().getHeight() || textInput.getText().isBlank()) { return; } synchronized (this) { if (task != null) { return; } task = new SingletonTask<Void>() { private Image newImage; @Override protected boolean handle() { if (fontWeight == FontWeight.BOLD) { if (fontPosture == FontPosture.REGULAR) { font = new java.awt.Font(fontFamily, java.awt.Font.BOLD, fontSize); } else { font = new java.awt.Font(fontFamily, java.awt.Font.BOLD + java.awt.Font.ITALIC, fontSize); } } else { if (fontPosture == FontPosture.REGULAR) { font = new java.awt.Font(fontFamily, java.awt.Font.PLAIN, fontSize); } else { font = new java.awt.Font(fontFamily, java.awt.Font.ITALIC, fontSize); } } newImage = FxmlImageManufacture.addText(imageView.getImage(), textInput.getText(), font, (Color) colorRect.getFill(), x, y, fontOpacity, shadow, angle, outlineCheck.isSelected(), verticalCheck.isSelected()); return newImage != null; } @Override protected void whenSucceeded() { if (editing) { maskView.setImage(newImage); maskView.setOpacity(1); maskView.setFitWidth(imageView.getFitWidth()); maskView.setFitHeight(imageView.getFitHeight()); maskView.setLayoutX(imageView.getLayoutX()); maskView.setLayoutY(imageView.getLayoutY()); } else { parent.updateImage(ImageOperation.Text, textInput.getText(), null, newImage, cost); imageController.clearValues(); imageController.imageLabel.setText(message("ClickImageForText")); } } }; parent.openHandlingStage(task, Modality.WINDOW_MODAL); Thread thread = new Thread(task); thread.setDaemon(true); thread.start(); } }