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

项目:cyoastudio    文件:HtmlImageExporter.java   
private HtmlImageExporter(Project project, Path targetFolder, String prefix, OutputFormat outputFormat,
        Consumer<String> callback) {
    this.project = project;
    this.targetFoler = targetFolder;
    this.prefix = prefix;
    this.callback = callback;
    this.outputFormat = outputFormat;

    stage = new Stage();
    browser = new WebView();
    browser.setFontSmoothingType(FontSmoothingType.GRAY);
    ScrollPane scrollPane = new ScrollPane(browser);
    bar = new ProgressBar();
    bar.setMaxWidth(Double.MAX_VALUE);
    bar.setPadding(new Insets(8));
    bar.setProgress(0);
    VBox vBox = new VBox(bar, scrollPane);
    Scene scene = new Scene(vBox);
    stage.setScene(scene);
    stage.show();
}
项目:EvernoteLinkInNote    文件:EvernoteLinkInNote.java   
public void generateLinks(ActionEvent e) {
    lblError.setText("");

    if(txtJump.getText() != null && !txtJump.getText().isEmpty() 
            && txtLink.getText() != null && !txtLink.getText().isEmpty()
            && txtDestination.getText() != null && !txtDestination.getText().isEmpty()){
        jump = txtJump.getText();
        linkText = txtLink.getText();
        destination = txtDestination.getText();
        String anchor = "<a name=\""+jump+"\">"+destination+"</a>";
        String link = "<a href=\"file:///#"+jump+"\">"+linkText+"</a><br><br>";

        webLink.setFontSmoothingType(FontSmoothingType.LCD);
        webLink.getEngine().loadContent(firstHalf+link+anchor+secondHalf);
    }else{
        lblError.setText(ERROR_TEXT);
    }




}
项目:Nanasetter    文件:MainController.java   
public void setup() {
    this.dialog = new Dialog(this.root.getScene().getWindow());
    this.pluginLoader = new PluginLoader(this.dialog, this.logger);

    WebEngine webEngine = this.htmlRoot.getEngine();
    webEngine.setOnAlert(event -> this.dialog.info(event.getData()));
    webEngine.load(getClass().getResource("/page/index.html").toString());

    this.htmlRoot.setFontSmoothingType(FontSmoothingType.GRAY);
    this.htmlRoot.setContextMenuEnabled(false);

    webEngine.getLoadWorker().stateProperty().addListener(
            (ov, oldState, newState) -> {
                if (newState == State.SUCCEEDED) this.onLoaded();
            });
}
项目:RadialFx    文件:RadialMovieMenu.java   
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;
   }
项目:openjfx-8u-dev-tests    文件:RichTextPropertiesApp.java   
public void setFst(FontSmoothingType fst) {
    if (textFlowPage.pages.valueProperty().get().equals(Pages.TextPage)) {
        textPage.textFontSmoothingType.setValue(fst);
    } else {
        Assert.fail();
    }
}
项目:openjfx-8u-dev-tests    文件:RichTextPropertiesApp.java   
public void getPage() {
    items = new HashMap<Text, Text>();
    VBox textProp = new VBox();
    this.textText = new TextField();
    textStyle = new TextField();
    applyFont = new Button("apply font");
    applyFont.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
            updateFont();
        }
    });
    textFontSmoothingType = new ChoiceBox();
    textFontSmoothingType.getItems().addAll(FontSmoothingType.values());
    textUnderline = new CheckBox();
    textStrikethrough = new CheckBox();
    HBox textUnderlineBox = new HBox();
    textUnderlineBox.getChildren().addAll(new Label("Underline"), textUnderline);
    HBox textStrikethroughBox = new HBox();
    textStrikethroughBox.getChildren().addAll(new Label("Strikethrough"), textStrikethrough);
    fontPane = new FontPane();
    textProp.getChildren().addAll(new Label("Text"), textText,
            new Label("Style"), textStyle,
            new Label("Font"), fontPane, applyFont,
            new Label("FontSmoothingType"), textFontSmoothingType,
            textUnderlineBox,
            textStrikethroughBox);
    textProp.setSpacing(10);
    getChildren().add(textProp);
}
项目:openjfx-8u-dev-tests    文件:LcdAPITestApp.java   
@Override
protected Scene getScene() {
    VBox root = VBoxBuilder.create()
            .padding(new Insets(10))
            .spacing(10)
            .children(
                TextBuilder.create()
                    .id("GrayGray")
                    .text("Text")
                    .fontSmoothingType(FontSmoothingType.GRAY)
                    .style("-fx-font-size: 16;-fx-font-smoothing-type: gray; ")
                    .build(),
                TextBuilder.create()
                    .id("LCDGray")
                    .text("Text")
                    .fontSmoothingType(FontSmoothingType.LCD)
                    .style("-fx-font-size: 16;-fx-font-smoothing-type: gray; ")
                    .build(),
                TextBuilder.create()
                    .id("GrayLCD")
                    .text("Text")
                    .fontSmoothingType(FontSmoothingType.GRAY)
                    .style("-fx-font-size: 16;-fx-font-smoothing-type: lcd; ")
                    .build(),
                TextBuilder.create()
                    .id("LCDLCD")
                    .text("Text")
                    .fontSmoothingType(FontSmoothingType.LCD)
                    .style("-fx-font-size: 16;-fx-font-smoothing-type: lcd;")
                    .build()
                )
            .build();

    return new Scene(root, 200, 200);
}
项目:openjfx-8u-dev-tests    文件:RichTextPropertiesFunctional.java   
protected void setFst(final FontSmoothingType fst) {
    (new GetAction() {
        @Override
        public void run(Object... os) throws Exception {
            application.setFst(fst);
        }
    }).dispatch(Root.ROOT.getEnvironment());
}
项目:Simulizer    文件:Editor.java   
public Editor() {
    WebView view = new WebView();
    view.setFontSmoothingType(FontSmoothingType.GRAY); // looks better than colored (LCD) blurring IMO

    // caching with SPEED hint is awful on Linux and or low power machines (see issue #24)
    // caching with QUALITY hint is indistinguishable from no caching as far as I can tell
    // to to remove potential problems it's probably not worth enabling caching at all
    view.setCache(false);

    pageLoaded = false;
    bridge = new Bridge(this);

    engine = view.getEngine();
    engine.setJavaScriptEnabled(true);

    // these error messages seem useless because they only warn about re-using web cache directories
    // which means that opening multiple instances of Simulizer gives error messages because both are trying to access
    // ~/.simulizer.GuiMode$App and ~/.simulizer.Simulizer
    //engine.setOnError((errorEvent) -> UIUtils.showErrorDialog("Editor JS Error", errorEvent.toString()));

    // making it so calling alert() from javascript outputs to the console
    engine.setOnAlert((event) -> System.out.println("javascript alert: " + event.getData()));

    mode = Mode.EDIT_MODE;

    // javascript does not have access to the outside clipboard
    view.setContextMenuEnabled(false);

    // handle copy and paste and other key-combinations manually
    getEventManager().addEventFilter(KeyEvent.KEY_PRESSED, this::handleKeyEvent);

    getContentPane().getChildren().add(view);
}
项目:asciidoctor-intellij-plugin    文件:JavaFxHtmlPanel.java   
private static void updateFontSmoothingType(@NotNull WebView view, boolean isGrayscale) {
  final FontSmoothingType typeToSet;
  if (isGrayscale) {
    typeToSet = FontSmoothingType.GRAY;
  } else {
    typeToSet = FontSmoothingType.LCD;
  }
  view.fontSmoothingTypeProperty().setValue(typeToSet);
}
项目:Fishification    文件:FishEntity.java   
private void initFlagText(String text) {
    m_flagText.setText(text);
    m_flagText.setTranslateY(m_fishSprite.getHeight() / 2); // set relative
    // Y-Position
    m_flagText.setFont(Font.font(FLAG_TEXT_FONT_TYPE, FLAG_TEXT_FONT_SIZE));
    m_flagText.setFontSmoothingType(FontSmoothingType.LCD);
    m_flagText.setWrappingWidth(FLAG_TEXT_WRAPPING_WIDTH);

    if (m_fishWorld.isWaveEffectEnabled()) {
        applyWaveEffect(m_flagText, s_flagWaveEffectValue);
    }
}
项目:HotaruFX    文件:TextNode.java   
public PropertyTimeline<String> fontSmoothingTypeProperty() {
    return fontSmoothingType.setIfEmptyThenGet(enumToString(FontSmoothingType.class, text.fontSmoothingTypeProperty()));
}
项目:jfreechart-fx    文件:ChartCanvas.java   
/**
 * 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. 
 */
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));
}
项目:openjfx-8u-dev-tests    文件:AnimationLCDTextTestApp.java   
@Override
public void start(Stage primaryStage) {


    final TextArea testText = TextAreaBuilder.create()
            .text("Test")
            .prefHeight(50)
            .prefWidth(500)
            .build();

    final ChoiceBox<Interpolator> interpolatorChoiceBox = new ChoiceBox<Interpolator>();
    interpolatorChoiceBox.getItems().addAll(FXCollections.observableArrayList(
                Interpolator.LINEAR,
                Interpolator.DISCRETE,
                Interpolator.EASE_BOTH,
                Interpolator.EASE_IN,
                Interpolator.EASE_OUT
                ));
    interpolatorChoiceBox.setPrefHeight(25);
    interpolatorChoiceBox.setPrefWidth(500);

    interpolatorChoiceBox.getSelectionModel().selectFirst();


    final Text lcdText = TextBuilder.create()
            .x(100)
            .y(100)
            .fontSmoothingType(FontSmoothingType.LCD)
            .build();

    lcdText.textProperty().bind(testText.textProperty());

    final Circle point = CircleBuilder.create()
            .centerX(100)
            .centerY(100)
            .radius(2)
            .fill(Color.RED)
            .build();

    Pane root = VBoxBuilder.create()
            .children(
                PaneBuilder.create()
                .minWidth(500)
                .minHeight(500)
                .children(
                    lcdText,
                    point)
                .onMouseClicked(new EventHandler<MouseEvent>() {

                    @Override
                    public void handle(MouseEvent event) {
                        point.setCenterX(event.getX());
                        point.setCenterY(event.getY());

                        TimelineBuilder.create()
                            .keyFrames(
                                new KeyFrame(Duration.seconds(5),
                                    new KeyValue(lcdText.xProperty(), event.getX(),
                                        interpolatorChoiceBox.getSelectionModel().getSelectedItem())),
                                new KeyFrame(Duration.seconds(5),
                                    new KeyValue(lcdText.yProperty(), event.getY(),
                                        interpolatorChoiceBox.getSelectionModel().getSelectedItem()))
                                )
                            .build()
                            .play();
                    }
                })
                .build(),
                testText,
                interpolatorChoiceBox)
            .build();



    Scene scene = new Scene(root, 500, 575);

    primaryStage.setTitle("Test Animnation LCD Text");
    primaryStage.setResizable(false);
    primaryStage.setScene(scene);
    primaryStage.show();
}
项目:CircuitSim    文件:CircuitSim.java   
public void showWindow() {
    runFxSync(() -> {
        if(stage.isShowing()) return;

        stage.show();
        stage.setOnCloseRequest(event -> {
            if(checkUnsavedChanges()) {
                event.consume();
            } else {
                saveConfFile();
            }
        });

        (currentTimer = new AnimationTimer() {
            private long lastRepaint;
            private int lastFrameCount;
            private int frameCount;

            @Override
            public void handle(long now) {
                if(now - lastRepaint >= 1e9) {
                    lastFrameCount = frameCount;
                    frameCount = 0;
                    lastRepaint = now;
                }

                frameCount++;

                CircuitManager manager = getCurrentCircuit();
                if(manager != null && (needsRepaint || manager.needsRepaint())) {
                    manager.paint();
                    needsRepaint = false;
                }

                GraphicsContext graphics = overlayCanvas.getGraphicsContext2D();

                graphics.clearRect(0, 0, overlayCanvas.getWidth(), overlayCanvas.getHeight());

                graphics.setFontSmoothingType(FontSmoothingType.LCD);

                graphics.setFont(GuiUtils.getFont(12));
                graphics.setFill(Color.BLACK);
                if(showFps) {
                    graphics.fillText("FPS: " + lastFrameCount, 6, 50);
                }
                if(Clock.getLastTickCount(simulator) > 0) {
                    graphics.fillText("Clock: " + (Clock.getLastTickCount(simulator) >> 1) + " Hz", 6, 65);
                }

                if(manager != null && !loadingFile) {
                    String message = getCurrentError();

                    if(message != null && !message.isEmpty() && Clock.isRunning(simulator)) {
                        clockEnabled.setSelected(false);
                    }

                    graphics.setFont(GuiUtils.getFont(20));
                    graphics.setFill(Color.RED);
                    Bounds bounds = GuiUtils.getBounds(graphics.getFont(), message);
                    graphics.fillText(message,
                                      (overlayCanvas.getWidth() - bounds.getWidth()) * 0.5,
                                      overlayCanvas.getHeight() - 50);
                }
            }
        }).start();
    });
}
项目:rapidminer-studio    文件:BrowserPopup.java   
/**
 * Creates scene with the webview and the close button
 */
private void createScene() {
    // make it possible to create the dialog a second time
    Platform.setImplicitExit(false);

    Platform.runLater(() -> {
                // Transparent root pane
                BorderPane rootPane = new BorderPane();
                rootPane.setBackground(Background.EMPTY);
                // Add padding to see the Shadow
                rootPane.setPadding(new Insets(BORDER_PADDING - SHADOW_OFFSET_Y, RIGHT_MARGIN, BORDER_PADDING + SHADOW_OFFSET_Y,
                        BORDER_PADDING));
                rootPane.setCenter(animatedPane);

                // Enable cache for smoother animation
                animatedPane.setCache(true);
                animatedPane.setCacheHint(CacheHint.SPEED);
                animatedPane.setCacheShape(true);
                /** Just fill the whole pane and add a background */
                animatedPane.setPadding(new Insets(BORDER_SIZE));
                animatedPane.setBackground(BORDER_BG);

                // Reduce dropShadow Quality
                dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
                animatedPane.setEffect(dropShadow);

                webView = new WebView();
                Button closeButton = createCloseButton();
                // Show button only on hover
                closeButton.opacityProperty()
                        .bind(Bindings.when(webView.hoverProperty().or(closeButton.hoverProperty())).then(1).otherwise(0));

                // Reduce WebView Quality
                webView.setContextMenuEnabled(false);
                webView.setFontSmoothingType(FontSmoothingType.GRAY);
                webView.setCache(true);
                webView.setCacheHint(CacheHint.SPEED);
                // Translate the animatedPane out of sight
                animatedPane.setTranslateX(translationDistance);
                // The webView is overlayed by the close button
                animatedPane.getChildren().addAll(webView, closeButton);
                // move close button to the upper right corner
                StackPane.setAlignment(closeButton, Pos.TOP_RIGHT);
                StackPane.setMargin(closeButton, CLOSE_MARGIN);
                // Create a transparent root scene
                Scene rootScene = new Scene(rootPane, Color.TRANSPARENT);
                contentPanel.setScene(rootScene);
                // prepare the browser
                configureWebEngine(webView);
            }

    );

}
项目:Fishification    文件:BubbleEntity.java   
public BubbleEntity(ContentItem contentItem, double initialPosX, double initialPosY, double radius, boolean directionInvertedX) {

        double posX = initialPosX;

        // Large bubble for the contents
        Circle bigBubble = createBubbleCircle(radius);
        addNode(bigBubble);

        if (!directionInvertedX) {
            posX += SMALL_BUBBLE_OFFSET_X;
        }

        // Decorator bubble
        Circle smallBubble01 = createBubbleCircle(8);
        smallBubble01.setTranslateX(-4 + posX);
        if (!directionInvertedX) {
            smallBubble01.setTranslateX(4 + posX);
        }
        smallBubble01.setTranslateY(-6 + SMALL_BUBBLE_OFFSET_Y - initialPosY);
        addNode(smallBubble01);

        // Decorator bubble
        Circle smallBubble02 = createBubbleCircle(5);
        smallBubble02.setTranslateX(10 + posX);
        if (!directionInvertedX) {
            smallBubble02.setTranslateX(-10 + posX);
        }
        smallBubble02.setTranslateY(SMALL_BUBBLE_OFFSET_Y - initialPosY);
        addNode(smallBubble02);

        // Decorator bubble
        Circle smallBubble03 = createBubbleCircle(4);
        smallBubble03.setTranslateX(4 + posX);
        if (!directionInvertedX) {
            smallBubble03.setTranslateX(-4 + posX);
        }
        smallBubble03.setTranslateY(8 + SMALL_BUBBLE_OFFSET_Y - initialPosY);
        addNode(smallBubble03);

        // Set initial position
        setPosition(new Point2D(posX, initialPosY));

        // Show text in bubble
        double width = radius * BUBBLE_TEXT_WIDTH_FACTOR;
        double height = radius * BUBBLE_TEXT_HEIGHT_FACTOR;
        Text bubbleText = new Text();
        bubbleText.setText(contentItem.getFlagContent());
        bubbleText.setWrappingWidth(width);
        bubbleText.setTranslateX(-width / 2);
        bubbleText.setTranslateY(-height / 2);
        bubbleText.setFont(Font.font(BUBBLE_TEXT_FONT_TYPE, BUBBLE_TEXT_FONT_SIZE));
        bubbleText.setFill(Color.WHITE);
        bubbleText.setSmooth(true);
        bubbleText.setFontSmoothingType(FontSmoothingType.LCD);
        bubbleText.setTextOrigin(VPos.TOP);
        Rectangle clip = new Rectangle(width, height);
        bubbleText.setClip(clip);
        addNode(bubbleText);
    }
项目:afc    文件:ZoomableGraphicsContext.java   
/**
 * Sets the current Font Smoothing Type.
 * The default value is {@link FontSmoothingType#GRAY GRAY}.
 * The font smoothing type is a text attribute
 * used for any of the text methods as specified in the
 * Rendering Attributes Table of {@link GraphicsContext}.
 * A {@code null} value will be ignored and the current value will remain unchanged.
 *
 * <p><b>Note</b> that the {@code FontSmoothingType} value of
 * {@link FontSmoothingType#LCD LCD} is only supported over an opaque
 * background.  {@code LCD} text will generally appear as {@code GRAY}
 * text over transparent or partially transparent pixels, and in some
 * implementations it may not be supported at all on a {@link Canvas}
 * because the required support does not exist for surfaces which contain
 * an alpha channel as all {@code Canvas} objects do.
 *
 * @param fontsmoothing the {@link FontSmoothingType} or null
 */
public void setFontSmoothingType(FontSmoothingType fontsmoothing) {
    this.gc.setFontSmoothingType(fontsmoothing);
}
项目:afc    文件:ZoomableGraphicsContext.java   
/**
 * Gets the current Font Smoothing Type.
 * The default value is {@link FontSmoothingType#GRAY GRAY}.
 * The font smoothing type is a text attribute
 * used for any of the text methods as specified in the
 * Rendering Attributes Table of {@link GraphicsContext}.
 *
 * @return the {@link FontSmoothingType}
 */
public FontSmoothingType getFontSmoothingType() {
    return this.gc.getFontSmoothingType();
}