World.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:Paradinc-FX 作者:
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 ||
        Double.compare(getWidth(), 0.0) <= 0 || Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    getStyleClass().add("world");

    Color fill   = getFillColor();
    Color stroke = getStrokeColor();

    countryPaths.forEach((name, pathList) -> {
        Country country = Country.valueOf(name);
        pathList.forEach(path -> {
            path.setFill(null == country.getColor() ? fill : country.getColor());
            path.setStroke(stroke);
            path.setStrokeWidth(0.2);
            path.setOnMouseEntered(new WeakEventHandler<>(_mouseEnterHandler));
            path.setOnMousePressed(new WeakEventHandler<>(_mousePressHandler));
            path.setOnMouseReleased(new WeakEventHandler<>(_mouseReleaseHandler));
            path.setOnMouseExited(new WeakEventHandler<>(_mouseExitHandler));
        });
        pane.getChildren().addAll(pathList);
    });

    group.getChildren().add(pane);

    getChildren().setAll(group);

    setBackground(new Background(new BackgroundFill(getBackgroundColor(), CornerRadii.EMPTY, Insets.EMPTY)));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号