javafx.scene.text.Font Java Examples
The following examples show how to use
javafx.scene.text.Font.
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: AreaHeatMap.java From charts with Apache License 2.0 | 6 votes |
private void drawDataPoints() { ctx.setTextAlign(TextAlignment.CENTER); ctx.setTextBaseline(VPos.CENTER); ctx.setFont(Font.font(size * 0.0175)); for (int i = 0 ; i < points.size() ; i++) { DataPoint point = points.get(i); ctx.setFill(Color.rgb(255, 255, 255, 0.5)); ctx.fillOval(point.getX() - 8, point.getY() - 8, 16, 16); //ctx.setStroke(getUseColorMapping() ? getColorForValue(point.getValue(), 1) : getColorForValue(point.getValue(), isDiscreteColors())); ctx.setStroke(Color.BLACK); ctx.strokeOval(point.getX() - 8, point.getY() - 8, 16, 16); ctx.setFill(Color.BLACK); ctx.fillText(Long.toString(Math.round(point.getValue())), point.getX(), point.getY(), 16); } }
Example #2
Source File: ListViewSample.java From marathonv5 with Apache License 2.0 | 6 votes |
@Override public void start(Stage stage) { VBox box = new VBox(); Scene scene = new Scene(box, 200, 200); stage.setScene(scene); stage.setTitle("ListViewSample"); box.getChildren().addAll(list, label); VBox.setVgrow(list, Priority.ALWAYS); label.setLayoutX(10); label.setLayoutY(115); label.setFont(Font.font("Verdana", 20)); list.setItems(data); list.setCellFactory((ListView<String> l) -> new ColorRectCell()); list.getSelectionModel().selectedItemProperty() .addListener((ObservableValue<? extends String> ov, String old_val, String new_val) -> { label.setText(new_val); label.setTextFill(Color.web(new_val)); }); stage.show(); }
Example #3
Source File: PluginParametersPane.java From constellation with Apache License 2.0 | 6 votes |
@Override public Pane getParamPane(final PluginParametersNode node) { if (node.getChildren().isEmpty()) { return null; } if (currentChild == -1) { titleLabel = new Label(title); titleLabel.setFont(Font.font(Font.getDefault().getFamily(), FontPosture.ITALIC, fontSize)); final Separator separator = new Separator(); separator.setStyle("-fx-background-color:#444444;"); HBox separatorBox = new HBox(separator); HBox.setHgrow(separator, Priority.ALWAYS); HBox.setMargin(separator, new Insets(PADDING, 0, 0, 0)); return new VBox(titleLabel, separatorBox); } final Pane paramPane = super.getParamPane(node); final SimpleDoubleProperty updated = new SimpleDoubleProperty(); updated.bind(Bindings.max(maxParamWidth, paramPane.widthProperty())); maxParamWidth = updated; if (titleLabel != null) { titleLabel.prefWidthProperty().bind(maxParamWidth); } return paramPane; }
Example #4
Source File: ImagePanel.java From marathonv5 with Apache License 2.0 | 6 votes |
private void drawGraphics() { graphics.clearRect(0, 0, canvas.getWidth(), canvas.getHeight()); graphics.drawImage(image, 0, 0); if (annotations.size() > 0) { for (int i = 0; i < annotations.size(); i++) { Annotation annotationFX = annotations.get(i); double x = annotationFX.getX(); double y = annotationFX.getY(); graphics.setFill(ANNOTATION_COLOR); graphics.fillRect(x, y, annotationFX.getWidth(), annotationFX.getHeight()); graphics.setFill(Color.RED); graphics.fillArc(x - 25, y - 25, 50, 50, 270, 90, ArcType.ROUND); graphics.setFill(Color.WHITE); graphics.setFont(Font.font(null, FontWeight.EXTRA_BOLD, 14)); if (i > 8) { graphics.fillText(Integer.toString(i + 1), x + 5, y + 15); } else { graphics.fillText(Integer.toString(i + 1), x + 5, y + 15); } } } }
Example #5
Source File: RadarNodeChart.java From tilesfx with Apache License 2.0 | 6 votes |
private void drawText() { final double CENTER_X = 0.5 * width; final double CENTER_Y = 0.5 * height; final int NO_OF_SECTORS = getNoOfSectors(); Font font = Fonts.latoRegular(0.035 * size); double radAngle = RadarChartMode.SECTOR == getMode() ? Math.toRadians(180 + angleStep * 0.5) : Math.toRadians(180); double radAngleStep = Math.toRadians(angleStep); textGroup.getChildren().clear(); for (int i = 0 ; i < NO_OF_SECTORS ; i++) { double r = size * 0.48; double x = CENTER_X - size * 0.015 + (-Math.sin(radAngle) * r); double y = CENTER_Y + (+Math.cos(radAngle) * r); Text text = new Text(data.get(i).getName()); text.setFont(font); text.setFill(data.get(i).getTextColor()); text.setTextOrigin(VPos.CENTER); text.setTextAlignment(TextAlignment.CENTER); text.setRotate(Math.toDegrees(radAngle) - 180); text.setX(x); text.setY(y); textGroup.getChildren().add(text); radAngle += radAngleStep; } }
Example #6
Source File: GenericAxes.java From latexdraw with GNU General Public License v3.0 | 6 votes |
default void updatePathLabels() { final Axes model = getModel(); final Font font = new Font("cmr10", model.getLabelsSize()); //NON-NLS final PlottingStyle labelsDisplay = model.getLabelsDisplayed(); final PlottingStyle ticksDisplay = model.getTicksDisplayed(); final TicksStyle ticksStyle = model.getTicksStyle(); // This fake text is used to compute widths and heights and other font metrics of a current text. final Text fooText = new Text("foo"); //NON-NLS fooText.setFont(font); if(labelsDisplay.isX()) { updatePathLabelsX(ticksDisplay, ticksStyle, fooText); } if(labelsDisplay.isY()) { updatePathLabelsY(ticksDisplay, ticksStyle, fooText); } }
Example #7
Source File: JFXUtil.java From phoebus with Eclipse Public License 1.0 | 6 votes |
/** Convert model font into JFX font * @param font {@link WidgetFont} * @return {@link Font} */ public static Font convert(final WidgetFont font) { return fontCache.computeIfAbsent(font, f -> { final double calibrated = f.getSize() * font_calibration; switch (f.getStyle()) { case BOLD: return Font.font(f.getFamily(), FontWeight.BOLD, FontPosture.REGULAR, calibrated); case ITALIC: return Font.font(f.getFamily(), FontWeight.NORMAL, FontPosture.ITALIC, calibrated); case BOLD_ITALIC: return Font.font(f.getFamily(), FontWeight.BOLD, FontPosture.ITALIC, calibrated); default: return Font.font(f.getFamily(), FontWeight.NORMAL, FontPosture.REGULAR, calibrated); } }); }
Example #8
Source File: LetterAvatar.java From youtube-comment-suite with MIT License | 6 votes |
private void draw() { Canvas canvas = new Canvas(scale, scale); GraphicsContext gc = canvas.getGraphicsContext2D(); gc.setFill(Color.TRANSPARENT); gc.fillRect(0, 0, scale, scale); gc.setFill(background); gc.fillRect(0, 0, scale, scale); gc.setFill(Color.WHITE); gc.setTextAlign(TextAlignment.CENTER); gc.setTextBaseline(VPos.CENTER); gc.setFont(Font.font("Tahoma", FontWeight.SEMI_BOLD, scale * 0.6)); gc.fillText(String.valueOf(character), Math.round(scale / 2.0), Math.round(scale / 2.0)); Platform.runLater(() -> canvas.snapshot(null, this)); }
Example #9
Source File: StringBindingSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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); }
Example #10
Source File: ParticlesClockApp.java From FXTutorials with MIT License | 6 votes |
private void populateDigits() { for (int i = 0; i < digits.length; i++) { digits[i] = new Digit(); Text text = new Text(i + ""); text.setFont(Font.font(144)); text.setFill(Color.BLACK); Image snapshot = text.snapshot(null, null); for (int y = 0; y < snapshot.getHeight(); y++) { for (int x = 0; x < snapshot.getWidth(); x++) { if (snapshot.getPixelReader().getColor(x, y).equals(Color.BLACK)) { digits[i].positions.add(new Point2D(x, y)); } } } if (digits[i].positions.size() > maxParticles) { maxParticles = digits[i].positions.size(); } } }
Example #11
Source File: PollenDashboard.java From medusademo with Apache License 2.0 | 6 votes |
private HBox getHBox(final String TEXT, final Gauge GAUGE) { Label label = new Label(TEXT); label.setPrefWidth(150); label.setFont(Font.font(26)); label.setTextFill(MaterialDesign.GREY_800.get()); label.setAlignment(Pos.CENTER_LEFT); label.setPadding(new Insets(0, 10, 0, 0)); GAUGE.setBarBackgroundColor(Color.rgb(232, 231, 223)); GAUGE.setAnimated(true); GAUGE.setAnimationDuration(1000); HBox hBox = new HBox(label, GAUGE); hBox.setSpacing(20); hBox.setAlignment(Pos.CENTER_LEFT); return hBox; }
Example #12
Source File: Model.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** @param font Scale font */ public void setLegendFont(final Font font) { legend_font = font; for (ModelListener listener : listeners) listener.changedColorsOrFonts(); }
Example #13
Source File: GraphicsContextImpl.java From openchemlib-js with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public java.awt.Dimension getBounds(String s) { Font currentFont = ctx.getFont(); Text t = new Text(s); t.setFont(currentFont); Bounds b = t.getLayoutBounds(); java.awt.Dimension bounds = new java.awt.Dimension((int)b.getWidth(), (int)b.getHeight()); return bounds; }
Example #14
Source File: FireSmokeTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@Override protected void resizeStaticText() { double maxWidth = width - size * 0.1; double fontSize = size * textSize.factor; boolean customFontEnabled = tile.isCustomFontEnabled(); Font customFont = tile.getCustomFont(); Font font = (customFontEnabled && customFont != null) ? Font.font(customFont.getFamily(), fontSize) : Fonts.latoRegular(fontSize); titleText.setFont(font); if (titleText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(titleText, maxWidth, fontSize); } switch(tile.getTitleAlignment()) { default : case LEFT : titleText.relocate(size * 0.05, size * 0.05); break; case CENTER: titleText.relocate((width - titleText.getLayoutBounds().getWidth()) * 0.5, size * 0.05); break; case RIGHT : titleText.relocate(width - (size * 0.05) - titleText.getLayoutBounds().getWidth(), size * 0.05); break; } text.setText(tile.getText()); text.setFont(font); if (text.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(text, maxWidth, fontSize); } switch(tile.getTextAlignment()) { default : case LEFT : text.setX(size * 0.05); break; case CENTER: text.setX((width - text.getLayoutBounds().getWidth()) * 0.5); break; case RIGHT : text.setX(width - (size * 0.05) - text.getLayoutBounds().getWidth()); break; } text.setY(height - size * 0.05); }
Example #15
Source File: ThemeDTO.java From Quelea with GNU General Public License v3.0 | 5 votes |
/** * Get the font of the theme. * <p/> * @return the theme font. */ public Font getFont() { if (font == null) { return null; } return font.getFont(); }
Example #16
Source File: StageDrawer.java From Quelea with GNU General Public License v3.0 | 5 votes |
/** * Determine the largest font size we can safely use for every section of a * text displayable. * <p> * @param displayable the displayable to check. * @return the font size to use */ private double getUniformFontSize(TextDisplayable displayable) { if (!QueleaProperties.get().getUseUniformFontSize()) { return -1; } Font font = theme.getFont(); font = Font.font(font.getName(), theme.isBold() ? FontWeight.BOLD : FontWeight.NORMAL, theme.isItalic() ? FontPosture.ITALIC : FontPosture.REGULAR, QueleaProperties.get().getMaxFontSize()); double fontSize = Double.POSITIVE_INFINITY; for (TextSection section : displayable.getSections()) { String[] textArr; if (QueleaProperties.get().getShowChords()) { textArr = section.getText(true, false); } else { textArr = section.getText(false, false); } double newSize; List<LyricLine> newText; if (displayable instanceof BiblePassage) { newText = new ArrayList<>(); for (String str : section.getText(false, false)) { for (String line : str.split("\n")) { newText.add(new LyricLine(line)); } } } else { newText = sanctifyText(textArr); } newSize = pickFontSize(font, newText, getCanvas().getWidth() * 0.92, getCanvas().getHeight() * 0.9); if (newSize < fontSize) { fontSize = newSize; } } if (fontSize == Double.POSITIVE_INFINITY) { fontSize = -1; } return fontSize; }
Example #17
Source File: DefaultRenderColorScheme.java From chart-fx with Apache License 2.0 | 5 votes |
public static void setGraphicsContextAttributes(final GraphicsContext gc, final String style) { if ((gc == null) || (style == null)) { return; } final Color strokeColor = StyleParser.getColorPropertyValue(style, XYChartCss.STROKE_COLOR); if (strokeColor != null) { gc.setStroke(strokeColor); } final Color fillColor = StyleParser.getColorPropertyValue(style, XYChartCss.FILL_COLOR); if (fillColor != null) { gc.setFill(fillColor); } final Double strokeWidth = StyleParser.getFloatingDecimalPropertyValue(style, XYChartCss.STROKE_WIDTH); if (strokeWidth != null) { gc.setLineWidth(strokeWidth); } final Font font = StyleParser.getFontPropertyValue(style); if (font != null) { gc.setFont(font); } final double[] dashPattern = StyleParser.getFloatingDecimalArrayPropertyValue(style, XYChartCss.STROKE_DASH_PATTERN); if (dashPattern != null) { gc.setLineDashes(dashPattern); } }
Example #18
Source File: ADCProjectInitWindow.java From arma-dialog-creator with MIT License | 5 votes |
public ProjectInitWizardStep(@NotNull ADCProjectInitWindow projectInitWindow) { super(new VBox(5)); this.projectInitWindow = projectInitWindow; stepIsCompleteProperty.set(false); //header final Label lblProjectSetup = new Label(bundle.getString("project_setup")); lblProjectSetup.setFont(Font.font(18d)); initTabPane(); getContent().getChildren().addAll(lblProjectSetup, new Separator(Orientation.HORIZONTAL), tabPane); final ComboBox<LocaleDescriptor> comboBoxLanguage = new ComboBox<>(); for (Locale locale : Lang.SUPPORTED_LOCALES) { comboBoxLanguage.getItems().add(new LocaleDescriptor(locale)); } comboBoxLanguage.getSelectionModel().select(new LocaleDescriptor(Locale.US)); comboBoxLanguage.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<LocaleDescriptor>() { @Override public void changed(ObservableValue<? extends LocaleDescriptor> observable, LocaleDescriptor oldValue, LocaleDescriptor newValue) { if (newValue == null) { return; } // ApplicationProperty.LOCALE.put(ApplicationDataManager.getApplicationProperties(), newValue.getLocale()); // ApplicationDataManager.getInstance().saveApplicationProperties(); // boolean restart = ADCMustRestartDialog.getResponse(); // if (restart) { // ArmaDialogCreator.restartApplication(false); // } } }); }
Example #19
Source File: Config.java From LogFX with GNU General Public License v3.0 | 5 votes |
/** * The properties are all set in the JavaFX Thread, therefore we need to make copies of everything * in the JavaFX Thread before being able to safely use them in another Thread, * where we write the config file. */ private void dumpConfigToFile() { CompletableFuture<LogLineColors> standardLogColorsFuture = new CompletableFuture<>(); Platform.runLater( () -> standardLogColorsFuture.complete( properties.standardLogColors.get() ) ); CompletableFuture<List<HighlightExpression>> expressionsFuture = new CompletableFuture<>(); Platform.runLater( () -> expressionsFuture.complete( new ArrayList<>( properties.observableExpressions ) ) ); CompletableFuture<Boolean> enableFiltersFuture = new CompletableFuture<>(); Platform.runLater( () -> enableFiltersFuture.complete( properties.enableFilters.getValue() ) ); CompletableFuture<Set<File>> filesFuture = new CompletableFuture<>(); Platform.runLater( () -> filesFuture.complete( new LinkedHashSet<>( properties.observableFiles ) ) ); CompletableFuture<Orientation> panesOrientationFuture = new CompletableFuture<>(); Platform.runLater( () -> panesOrientationFuture.complete( properties.panesOrientation.get() ) ); CompletableFuture<List<Double>> paneDividersFuture = new CompletableFuture<>(); Platform.runLater( () -> paneDividersFuture.complete( new ArrayList<>( properties.paneDividerPositions ) ) ); CompletableFuture<Font> fontFuture = new CompletableFuture<>(); Platform.runLater( () -> fontFuture.complete( properties.font.getValue() ) ); standardLogColorsFuture.thenAccept( logLineColors -> expressionsFuture.thenAccept( expressions -> enableFiltersFuture.thenAccept( enableFilters -> filesFuture.thenAccept( files -> panesOrientationFuture.thenAccept( orientation -> paneDividersFuture.thenAccept( dividers -> fontFuture.thenAccept( font -> dumpConfigToFile( logLineColors, expressions, enableFilters, files, orientation, dividers, font, path.toFile() ) ) ) ) ) ) ) ); }
Example #20
Source File: ADCProjectInitWindow.java From arma-dialog-creator with MIT License | 5 votes |
public WorkspaceSelectionStep(@NotNull ADCProjectInitWindow adcProjectInitWindow) { super(new VBox(20)); this.adcProjectInitWindow = adcProjectInitWindow; workspaceDirectory = ApplicationProperty.LAST_WORKSPACE.getValue(); if (workspaceDirectory == null) { workspaceDirectory = Workspace.DEFAULT_WORKSPACE_DIRECTORY; } content.setAlignment(Pos.CENTER); content.setMaxWidth(STAGE_WIDTH / 4 * 3); final Label lblChooseWorkspace = new Label(bundle.getString("choose_workspace")); lblChooseWorkspace.setFont(Font.font(20)); content.getChildren().add(new VBox(5, lblChooseWorkspace, new Label(bundle.getString("workspace_about")))); final FileChooserPane chooserPane = new FileChooserPane( ArmaDialogCreator.getPrimaryStage(), FileChooserPane.ChooserType.DIRECTORY, lblChooseWorkspace.getText(), workspaceDirectory ); chooserPane.setChosenFile(workspaceDirectory); chooserPane.getChosenFileObserver().addListener(new ValueListener<File>() { @Override public void valueUpdated(@NotNull ValueObserver<File> observer, File oldValue, File newValue) { if (newValue != null) { workspaceDirectory = newValue; } } }); content.getChildren().add(chooserPane); }
Example #21
Source File: Notice.java From Quelea with GNU General Public License v3.0 | 5 votes |
/** * Parse some XML representing this object and return the object it * represents. * <p> * @param node the XML node representing this object. * @return the object as defined by the XML. */ public static Notice parseXML(Node node) { NodeList list = node.getChildNodes(); String text = ""; int duration = 0; String colorString = "0xffffffff"; String fontString = "System Regular,50.0"; for (int i = 0; i < list.getLength(); i++) { switch (list.item(i).getNodeName()) { case "text": text = list.item(i).getTextContent(); break; case "duration": duration = Integer.parseInt(list.item(i).getTextContent()); if (duration == 0) { duration = Integer.MAX_VALUE; } break; case "color": colorString = list.item(i).getTextContent(); break; case "font": fontString = list.item(i).getTextContent(); break; } } SerializableColor color = new SerializableColor(Color.web(colorString)); String[] fontTemp = fontString.split(","); SerializableFont font = new SerializableFont(new Font(fontTemp[0], Double.parseDouble(fontTemp[1]))); return new Notice(text, duration, color, font); }
Example #22
Source File: Clock.java From Medusa with Apache License 2.0 | 5 votes |
public ObjectProperty<Font> customFontProperty() { if (null == customFont) { customFont = new ObjectPropertyBase<Font>() { @Override protected void invalidated() { fireUpdateEvent(RESIZE_EVENT); } @Override public Object getBean() { return Clock.this; } @Override public String getName() { return "customFont"; } }; _customFont = null; } return customFont; }
Example #23
Source File: TemplateManager.java From latexdraw with GNU General Public License v3.0 | 5 votes |
@Override public void initialize(final URL location, final ResourceBundle resources) { mainPane.managedProperty().bind(mainPane.visibleProperty()); emptyLabel.managedProperty().bind(emptyLabel.visibleProperty()); emptyLabel.visibleProperty().bind(Bindings.createBooleanBinding(() -> templatePane.getChildren().isEmpty(), templatePane.getChildren())); emptyLabel.setFont(Font.font(emptyLabel.getFont().getFamily(), FontPosture.ITALIC, emptyLabel.getFont().getSize())); Command.executeAndFlush(new UpdateTemplates(templatePane, svgGen, false)); setActivated(true); templatePane.setCursor(Cursor.MOVE); }
Example #24
Source File: HyperlinkWebViewSample.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void start(Stage stage) { VBox vbox = new VBox(); Scene scene = new Scene(vbox); stage.setTitle("Hyperlink Sample"); stage.setWidth(570); stage.setHeight(550); selectedImage.setLayoutX(100); selectedImage.setLayoutY(10); final WebView browser = new WebView(); final WebEngine webEngine = browser.getEngine(); for (int i = 0; i < captions.length; i++) { final Hyperlink hpl = hpls[i] = new Hyperlink(captions[i]); final Image image = images[i] = new Image(getClass().getResourceAsStream(imageFiles[i])); hpl.setGraphic(new ImageView(image)); hpl.setFont(Font.font("Arial", 14)); final String url = urls[i]; hpl.setOnAction((ActionEvent e) -> { webEngine.load(url); }); } HBox hbox = new HBox(); hbox.setAlignment(Pos.BASELINE_CENTER); hbox.getChildren().addAll(hpls); vbox.getChildren().addAll(hbox, browser); VBox.setVgrow(browser, Priority.ALWAYS); stage.setScene(scene); stage.show(); }
Example #25
Source File: SparkLineTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@Override protected void resizeStaticText() { double maxWidth = width - size * 0.1; double fontSize = size * textSize.factor; boolean customFontEnabled = tile.isCustomFontEnabled(); Font customFont = tile.getCustomFont(); Font font = (customFontEnabled && customFont != null) ? Font.font(customFont.getFamily(), fontSize) : Fonts.latoRegular(fontSize); titleText.setFont(font); if (titleText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(titleText, maxWidth, fontSize); } switch(tile.getTitleAlignment()) { default : case LEFT : titleText.relocate(size * 0.05, size * 0.05); break; case CENTER: titleText.relocate((width - titleText.getLayoutBounds().getWidth()) * 0.5, size * 0.05); break; case RIGHT : titleText.relocate(width - (size * 0.05) - titleText.getLayoutBounds().getWidth(), size * 0.05); break; } maxWidth = width - (width - size * 0.275); fontSize = upperUnitText.getText().isEmpty() ? size * 0.12 : size * 0.10; upperUnitText.setFont(Fonts.latoRegular(fontSize)); if (upperUnitText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(upperUnitText, maxWidth, fontSize); } fontSize = upperUnitText.getText().isEmpty() ? size * 0.12 : size * 0.10; unitText.setFont(Fonts.latoRegular(fontSize)); if (unitText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(unitText, maxWidth, fontSize); } averageText.setX(size * 0.05); highText.setX(size * 0.05); lowText.setX(size * 0.05); }
Example #26
Source File: ConsoleWindow.java From SmartModInserter with GNU Lesser General Public License v3.0 | 5 votes |
public ProcessTab(Process process) { this.process = process; hbox = new HBox(); vbox = new VBox(log, hbox); Button killButton = new Button("Kill"); killButton.setOnAction((e) -> { process.destroyForcibly(); }); hbox.setAlignment(Pos.CENTER_RIGHT); hbox.getChildren().add(killButton); VBox.setVgrow(log, Priority.ALWAYS); this.setContent(vbox); log.setWrapText(true); log.setFont(Font.font("Courier", 12)); reader = new Thread(() -> { BufferedReader stream = new BufferedReader(new InputStreamReader(process.getInputStream())); String line = null; try { while ((line = stream.readLine()) != null) { final String tmpLine = line; Platform.runLater(() -> { String old = log.getText(); old += tmpLine; old += "\n"; log.setText(old); log.setScrollTop(Double.MAX_VALUE); }); } } catch (IOException e) { e.printStackTrace(); } }); reader.start(); }
Example #27
Source File: FontManagerType1.java From dm3270 with Apache License 2.0 | 5 votes |
@Override public Font getStatusBarFont () { if (statusBarFont == null) statusBarFont = Font.font ("Monospaced", 14); return statusBarFont; }
Example #28
Source File: AnimatedTableRow.java From mars-sim with GNU General Public License v3.0 | 5 votes |
private Node createTableContainer(final String labelText, final TableView<Person> table) { final VBox tableAndLabelContainer = new VBox(); tableAndLabelContainer.setSpacing(5); tableAndLabelContainer.setPadding(new Insets(10, 0, 0, 10)); final Label label = new Label(labelText); label.setFont(new Font("Arial", 20)); tableAndLabelContainer.getChildren().addAll(label, table); final HBox container = new HBox(); container.getChildren().add(tableAndLabelContainer); return container; }
Example #29
Source File: FormattedText.java From Quelea with GNU General Public License v3.0 | 5 votes |
/** * Set the font of this formatted text. * <p> * @param font the font. */ public void setFont(Font font) { for(Node node : getChildren()) { if(node instanceof Text) { ((Text) node).setFont(font); } } }
Example #30
Source File: DeckView.java From Solitaire with GNU General Public License v2.0 | 5 votes |
private Canvas createNewGameImage() { double width = CardImages.getBack().getWidth(); double height = CardImages.getBack().getHeight(); Canvas canvas = new Canvas( width, height ); GraphicsContext context = canvas.getGraphicsContext2D(); // The reset image context.setStroke(Color.DARKGREEN); context.setLineWidth(IMAGE_NEW_LINE_WIDTH); context.strokeOval(width/4, height/2-width/4 + IMAGE_FONT_SIZE, width/2, width/2); // The text context.setTextAlign(TextAlignment.CENTER); context.setTextBaseline(VPos.CENTER); context.setFill(Color.DARKKHAKI); context.setFont(Font.font(Font.getDefault().getName(), IMAGE_FONT_SIZE)); if( GameModel.instance().isCompleted() ) { context.fillText("You won!", Math.round(width/2), IMAGE_FONT_SIZE); } else { context.fillText("Give up?", Math.round(width/2), IMAGE_FONT_SIZE); } context.setTextAlign(TextAlignment.CENTER); return canvas; }