下面列出了怎么用javafx.scene.text.FontSmoothingType的API类实例代码及写法,或者点击链接到github查看源代码。
private void updateTemplateObjectHelp(final String itemName, final String itemDescription) {
templateObjectHelp.getChildren().clear();
final Text objectNameText = new Text(itemName + ":\n");
objectNameText.setFont(Font.font(FONT_FAMILY, FontWeight.NORMAL, 16));
objectNameText.setFill(Color.web(TEXT_COLOR));
templateObjectHelp.getChildren().add(objectNameText);
String objDescrip = " " + itemDescription + "\n";
final Text objectDescripText = new Text(objDescrip + "\n");
objectDescripText.setFont(Font.font(FONT_FAMILY, FontWeight.BOLD, 12));
objectDescripText.setFill(Color.WHITE);
objectDescripText.setFontSmoothingType(FontSmoothingType.LCD);
templateObjectHelp.getChildren().add(objectDescripText);
}
private List<Text> getTextNodes(final String title, final double startAngle) {
final List<Text> texts = new ArrayList<Text>();
final char[] titleCharArray = title.toCharArray();
for (int i = titleCharArray.length - 1; i >= 0; i--) {
final Text charText = new Text(
Character.toString(titleCharArray[i]));
charText.setFontSmoothingType(FontSmoothingType.LCD);
charText.setSmooth(true);
charText.setMouseTransparent(true);
charText.setFill(textColor);
charText.setBlendMode(BlendMode.COLOR_BURN);
charText.setFont(textFont);
texts.add(charText);
}
return texts;
}
private void formatText() {
if (!this.title) {
text.setUnderline(false);
if (this.bold)
if (!this.italic)
text.setStyle("-fx-font-weight: bold");
if (!this.bold)
if (this.italic)
text.setStyle("-fx-font-style: italic");
if (this.bold)
if (this.italic)
text.setStyle("-fx-font-weight: bold;-fx-font-style: italic");
if (!this.bold)
if (!this.italic)
text.setStyle("-fx-font-weight:normal;-fx-font-style:normal");
if (this.specialcolor != null) {
text.setFill(this.specialcolor);
}
}
if (this.title) {
text.setStyle("");
text.setFont(Font.font(text.getFont().getName(), FontWeight.BOLD, text.getFont().getSize()));
text.setUnderline(true);
}
text.setFontSmoothingType(FontSmoothingType.LCD);
}
public TrexAlertBuilder setContent(String content) {
Text text = new Text(content);
text.setWrappingWidth(WRAPPING_WIDTH);
text.getStyleClass().add("alert-text");
text.setFontSmoothingType(FontSmoothingType.LCD);
HBox container = new HBox();
container.getChildren().add(text);
alert.getDialogPane().setContent(container);
return this;
}
@Override
public void start(final Stage stage)
{
// Create the WebView
WebView webView = new WebView();
// Disable the context menu
webView.setContextMenuEnabled(false);
// Increase the text font size by 20%
webView.setFontScale(1.20);
// Set the Zoom 20%
webView.setZoom(1.20);
// Set font smoothing type to GRAY
webView.setFontSmoothingType(FontSmoothingType.GRAY);
// Create the WebEngine
final WebEngine webEngine = webView.getEngine();
// Load the StartPage
webEngine.load("http://www.google.com");
// Update the stage title when a new web page title is available
webEngine.titleProperty().addListener(new ChangeListener<String>()
{
public void changed(ObservableValue<? extends String> ov,
final String oldvalue, final String newvalue)
{
stage.setTitle(newvalue);
}
});
// Create the VBox
VBox root = new VBox();
// Add the Children to the VBox
root.getChildren().add(webView);
// Set the Style-properties of the VBox
root.setStyle("-fx-padding: 10;" +
"-fx-border-style: solid inside;" +
"-fx-border-width: 2;" +
"-fx-border-insets: 5;" +
"-fx-border-radius: 5;" +
"-fx-border-color: blue;");
// Create the Scene
Scene scene = new Scene(root);
// Add the Scene to the Stage
stage.setScene(scene);
// Display the Stage
stage.show();
}
/**
* Creates a new canvas to display the supplied chart in JavaFX. If
* {@code chart} is {@code null}, a blank canvas will be displayed.
*
* @param chart the chart ({@code null} permitted).
*/
public ChartCanvas(JFreeChart chart) {
this.chart = chart;
if (this.chart != null) {
this.chart.addChangeListener(this);
}
this.tooltip = null;
this.tooltipEnabled = true;
this.chartMouseListeners = new ArrayList<>();
widthProperty().addListener(e -> draw());
heightProperty().addListener(e -> draw());
// change the default font smoothing for better results
GraphicsContext gc = getGraphicsContext2D();
gc.setFontSmoothingType(FontSmoothingType.LCD);
FXGraphics2D fxg2 = new FXGraphics2D(gc);
fxg2.setRenderingHint(FXHints.KEY_USE_FX_FONT_METRICS, true);
fxg2.setZeroStrokeWidth(0.1);
fxg2.setRenderingHint(
RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
this.g2 = fxg2;
this.liveHandler = null;
this.availableMouseHandlers = new ArrayList<>();
this.availableMouseHandlers.add(new PanHandlerFX("pan", true, false,
false, false));
this.auxiliaryMouseHandlers = new ArrayList<>();
this.auxiliaryMouseHandlers.add(new TooltipHandlerFX("tooltip"));
this.auxiliaryMouseHandlers.add(new ScrollHandlerFX("scroll"));
this.domainZoomable = true;
this.rangeZoomable = true;
this.auxiliaryMouseHandlers.add(new AnchorHandlerFX("anchor"));
this.auxiliaryMouseHandlers.add(new DispatchHandlerFX("dispatch"));
this.overlays = FXCollections.observableArrayList();
setOnMouseMoved(e -> handleMouseMoved(e));
setOnMouseClicked(e -> handleMouseClicked(e));
setOnMousePressed(e -> handleMousePressed(e));
setOnMouseDragged(e -> handleMouseDragged(e));
setOnMouseReleased(e -> handleMouseReleased(e));
setOnScroll(e -> handleScroll(e));
}
/**
* Creates a new canvas to display the supplied org.sjwimmer.tacharting.chart in JavaFX. If
* {@code org.sjwimmer.tacharting.chart} is {@code null}, a blank canvas will be displayed.
*
* @param chart the org.sjwimmer.tacharting.chart.
*/
public TaChartCanvas(JFreeChart chart) {
this.chart = chart;
if (this.chart != null) {
this.chart.addChangeListener(this);
}
this.tooltip = null;
this.tooltipEnabled = true;
this.chartMouseListeners = new ArrayList<>();
widthProperty().addListener(e -> draw());
heightProperty().addListener(e -> draw());
// change the default font smoothing for better results
GraphicsContext gc = getGraphicsContext2D();
gc.setFontSmoothingType(FontSmoothingType.LCD);
FXGraphics2D fxg2 = new FXGraphics2D(gc);
fxg2.setZeroStrokeWidth(0.1);
fxg2.setRenderingHint(
RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
this.g2 = fxg2;
this.liveHandler = null;
this.availableMouseHandlers = new ArrayList<>();
this.availableMouseHandlers.add(new TaPanHandlerFX("pan", true, false,
false, false));
this.auxiliaryMouseHandlers = new ArrayList<>();
this.auxiliaryMouseHandlers.add(new TaTooltipHandler("tooltip"));
this.auxiliaryMouseHandlers.add(new TaScrollHandlerFX("scroll"));
this.domainZoomable = true;
this.rangeZoomable = true;
this.auxiliaryMouseHandlers.add(new TaAnchorHandler("anchor"));
this.auxiliaryMouseHandlers.add(new TaDispatchHandler("dispatch"));
this.overlays = FXCollections.observableArrayList();
javafx.event.EventHandler<MouseEvent> mouseMovedHandler = e ->{
handleMouseMoved(e);
};
this.addEventHandler(MouseEvent.MOUSE_MOVED,mouseMovedHandler);
setOnMouseClicked(e -> handleMouseClicked(e));
setOnMousePressed(e -> handleMousePressed(e));
setOnMouseDragged(e -> handleMouseDragged(e));
setOnMouseReleased(e -> handleMouseReleased(e));
setOnScroll(e -> handleScroll(e));
}