• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java WeakEventHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javafx.event.WeakEventHandler的典型用法代码示例。如果您正苦于以下问题:Java WeakEventHandler类的具体用法?Java WeakEventHandler怎么用?Java WeakEventHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WeakEventHandler类属于javafx.event包,在下文中一共展示了WeakEventHandler类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: registerListeners

import javafx.event.WeakEventHandler; //导入依赖的package包/类
private void registerListeners() {
    widthProperty().addListener(o -> resize());
    heightProperty().addListener(o -> resize());
    sceneProperty().addListener(o -> {
        if (!locations.isEmpty()) { addShapesToScene(locations.values()); }
        if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); }

        locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> {
            if (CHANGE.wasAdded()) {
                addShapesToScene(CHANGE.getValueAdded());
            } else if(CHANGE.wasRemoved()) {
                Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved()));
            }
        });
    });
}
 
开发者ID:HanSolo,项目名称:worldheatmap,代码行数:17,代码来源:World.java


示例2: addLocation

import javafx.event.WeakEventHandler; //导入依赖的package包/类
public void addLocation(final Location LOCATION) {
    double x = (LOCATION.getLongitude() + 180) * (PREFERRED_WIDTH / 360) + MAP_OFFSET_X;
    double y = (PREFERRED_HEIGHT / 2) - (PREFERRED_WIDTH * (Math.log(Math.tan((Math.PI / 4) + (Math.toRadians(LOCATION.getLatitude()) / 2)))) / (2 * Math.PI)) + MAP_OFFSET_Y;

    Circle locationIcon = new Circle(x, y, size * 0.01);
    locationIcon.setFill(null == LOCATION.getColor() ? getLocationColor() : LOCATION.getColor());

    StringBuilder tooltipBuilder = new StringBuilder();
    if (!LOCATION.getName().isEmpty()) tooltipBuilder.append(LOCATION.getName());
    if (!LOCATION.getInfo().isEmpty()) tooltipBuilder.append("\n").append(LOCATION.getInfo());
    String tooltipText = tooltipBuilder.toString();
    if (!tooltipText.isEmpty()) {
        Tooltip tooltip = new Tooltip(tooltipText);
        tooltip.setFont(Font.font(10));
        Tooltip.install(locationIcon, tooltip);
    }

    if (null != LOCATION.getMouseEnterHandler()) locationIcon.setOnMouseEntered(new WeakEventHandler<>(LOCATION.getMouseEnterHandler()));
    if (null != LOCATION.getMousePressHandler()) locationIcon.setOnMousePressed(new WeakEventHandler<>(LOCATION.getMousePressHandler()));
    if (null != LOCATION.getMouseReleaseHandler()) locationIcon.setOnMouseReleased(new WeakEventHandler<>(LOCATION.getMouseReleaseHandler()));
    if (null != LOCATION.getMouseExitHandler()) locationIcon.setOnMouseExited(new WeakEventHandler<>(LOCATION.getMouseExitHandler()));


    locations.put(LOCATION, locationIcon);
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:26,代码来源:World.java


示例3: createSegment

import javafx.event.WeakEventHandler; //导入依赖的package包/类
private Path createSegment(final double START_ANGLE, final double END_ANGLE, final double INNER_RADIUS, final double OUTER_RADIUS, final Color FILL, final Color STROKE, final TreeNode NODE) {
    double  startAngleRad = Math.toRadians(START_ANGLE + 90);
    double  endAngleRad   = Math.toRadians(END_ANGLE + 90);
    boolean largeAngle    = Math.abs(END_ANGLE - START_ANGLE) > 180.0;

    double x1 = centerX + INNER_RADIUS * Math.sin(startAngleRad);
    double y1 = centerY - INNER_RADIUS * Math.cos(startAngleRad);

    double x2 = centerX + OUTER_RADIUS * Math.sin(startAngleRad);
    double y2 = centerY - OUTER_RADIUS * Math.cos(startAngleRad);

    double x3 = centerX + OUTER_RADIUS * Math.sin(endAngleRad);
    double y3 = centerY - OUTER_RADIUS * Math.cos(endAngleRad);

    double x4 = centerX + INNER_RADIUS * Math.sin(endAngleRad);
    double y4 = centerY - INNER_RADIUS * Math.cos(endAngleRad);

    MoveTo moveTo1 = new MoveTo(x1, y1);
    LineTo lineTo2 = new LineTo(x2, y2);
    ArcTo  arcTo3  = new ArcTo(OUTER_RADIUS, OUTER_RADIUS, 0, x3, y3, largeAngle, true);
    LineTo lineTo4 = new LineTo(x4, y4);
    ArcTo  arcTo1  = new ArcTo(INNER_RADIUS, INNER_RADIUS, 0, x1, y1, largeAngle, false);

    Path path = new Path(moveTo1, lineTo2, arcTo3, lineTo4, arcTo1);

    path.setFill(FILL);
    path.setStroke(STROKE);

    String tooltipText = new StringBuilder(NODE.getData().getName()).append("\n").append(String.format(Locale.US, formatString, NODE.getData().getValue())).toString();
    Tooltip.install(path, new Tooltip(tooltipText));

    path.setOnMousePressed(new WeakEventHandler<>(e -> NODE.getTreeRoot().fireTreeNodeEvent(new TreeNodeEvent(NODE, EventType.NODE_SELECTED))));

    return path;
}
 
开发者ID:HanSolo,项目名称:SunburstChart,代码行数:36,代码来源:SunburstChart.java


示例4: showPopup

import javafx.event.WeakEventHandler; //导入依赖的package包/类
protected void showPopup() {
	init();
	
	isShowing = true;
   	
       VBox popupLayout = new VBox();
       popupLayout.setSpacing(10);
       popupLayout.setPadding(new Insets(10, 10, 10, 10));

       StackPane popupContent = new StackPane();
       popupContent.setPrefSize(width, height);
       popupContent.getStyleClass().add("notification");
       popupContent.getChildren().addAll(popupLayout);

       popup = new Popup();
       popup.setX(getX());
       popup.setY(getY());
       popup.getContent().add(popupContent);
       popup.addEventHandler(MouseEvent.MOUSE_PRESSED, new WeakEventHandler<>(event -> {
           fireNotificationEvent(new NotificationEvent(this, popup, NotificationEvent.NOTIFICATION_PRESSED));
           hidePopUp();
       }));            
       popups.add(popup);

       // Add a timeline for popup fade out
       KeyValue fadeOutBegin = new KeyValue(popup.opacityProperty(), 1.0);            
       KeyValue fadeOutEnd   = new KeyValue(popup.opacityProperty(), 0.0);

       KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
       KeyFrame kfEnd   = new KeyFrame(popupAnimationTime, fadeOutEnd);

       timeline = new Timeline(kfBegin, kfEnd);
       timeline.setDelay(popupLifetime);
       timeline.setOnFinished(actionEvent -> Platform.runLater(() -> {
       	hidePopUp();
       }));
       
       if (stage.isShowing()) {
           stage.toFront();
       } else {
           stage.show();
       }

       popup.show(stage);
       fireNotificationEvent(new NotificationEvent(this, popup, NotificationEvent.SHOW_NOTIFICATION));
       timeline.play();
}
 
开发者ID:Team-Sprout,项目名称:Clipcon-Client,代码行数:48,代码来源:ClipboardNotification.java


示例5: addLocation

import javafx.event.WeakEventHandler; //导入依赖的package包/类
public void addLocation(final Location LOCATION) {
    double x = (LOCATION.getLongitude() + 180) * (PREFERRED_WIDTH / 360) + MAP_OFFSET_X;
    double y = (PREFERRED_HEIGHT / 2) - (PREFERRED_WIDTH * (Math.log(Math.tan((Math.PI / 4) + (Math.toRadians(LOCATION.getLatitude()) / 2)))) / (2 * Math.PI)) + MAP_OFFSET_Y;

    FontIcon locationIcon = new FontIcon(null == LOCATION.getIconCode() ? locationIconCode : LOCATION.getIconCode());
    locationIcon.setIconSize(LOCATION.getIconSize());
    locationIcon.setTextOrigin(VPos.CENTER);
    locationIcon.setIconColor(null == LOCATION.getColor() ? getLocationColor() : LOCATION.getColor());
    locationIcon.setX(x - LOCATION.getIconSize() * 0.5);
    locationIcon.setY(y);

    StringBuilder tooltipBuilder = new StringBuilder();
    if (!LOCATION.getName().isEmpty()) tooltipBuilder.append(LOCATION.getName());
    if (!LOCATION.getInfo().isEmpty()) tooltipBuilder.append("\n").append(LOCATION.getInfo());
    String tooltipText = tooltipBuilder.toString();
    if (!tooltipText.isEmpty()) {
        Tooltip tooltip = new Tooltip(tooltipText);
        tooltip.setFont(Font.font(10));
        Tooltip.install(locationIcon, tooltip);
    }

    if (null != LOCATION.getMouseEnterHandler()) locationIcon.setOnMouseEntered(new WeakEventHandler<>(LOCATION.getMouseEnterHandler()));
    if (null != LOCATION.getMousePressHandler()) locationIcon.setOnMousePressed(new WeakEventHandler<>(LOCATION.getMousePressHandler()));
    if (null != LOCATION.getMouseReleaseHandler()) locationIcon.setOnMouseReleased(new WeakEventHandler<>(LOCATION.getMouseReleaseHandler()));
    if (null != LOCATION.getMouseExitHandler()) locationIcon.setOnMouseExited(new WeakEventHandler<>(LOCATION.getMouseExitHandler()));

    locations.put(LOCATION, locationIcon);
}
 
开发者ID:HanSolo,项目名称:worldheatmap,代码行数:29,代码来源:World.java


示例6: createSegment

import javafx.event.WeakEventHandler; //导入依赖的package包/类
private Path createSegment(final double START_ANGLE, final double END_ANGLE, final double INNER_RADIUS, final double OUTER_RADIUS, final Paint FILL, final Color STROKE, final TreeNode NODE) {
    double  startAngleRad = Math.toRadians(START_ANGLE + 90);
    double  endAngleRad   = Math.toRadians(END_ANGLE + 90);
    boolean largeAngle    = Math.abs(END_ANGLE - START_ANGLE) > 180.0;

    double x1 = centerX + INNER_RADIUS * Math.sin(startAngleRad);
    double y1 = centerY - INNER_RADIUS * Math.cos(startAngleRad);

    double x2 = centerX + OUTER_RADIUS * Math.sin(startAngleRad);
    double y2 = centerY - OUTER_RADIUS * Math.cos(startAngleRad);

    double x3 = centerX + OUTER_RADIUS * Math.sin(endAngleRad);
    double y3 = centerY - OUTER_RADIUS * Math.cos(endAngleRad);

    double x4 = centerX + INNER_RADIUS * Math.sin(endAngleRad);
    double y4 = centerY - INNER_RADIUS * Math.cos(endAngleRad);

    MoveTo moveTo1 = new MoveTo(x1, y1);
    LineTo lineTo2 = new LineTo(x2, y2);
    ArcTo  arcTo3  = new ArcTo(OUTER_RADIUS, OUTER_RADIUS, 0, x3, y3, largeAngle, true);
    LineTo lineTo4 = new LineTo(x4, y4);
    ArcTo  arcTo1  = new ArcTo(INNER_RADIUS, INNER_RADIUS, 0, x1, y1, largeAngle, false);

    Path path = new Path(moveTo1, lineTo2, arcTo3, lineTo4, arcTo1);

    path.setFill(FILL);
    path.setStroke(STROKE);

    String tooltipText = new StringBuilder(NODE.getItem().getName()).append("\n").append(String.format(Locale.US, formatString, NODE.getItem().getValue())).toString();
    Tooltip.install(path, new Tooltip(tooltipText));

    path.setOnMousePressed(new WeakEventHandler<>(e -> NODE.getTreeRoot().fireTreeNodeEvent(new TreeNodeEvent(NODE, EventType.NODE_SELECTED))));

    return path;
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:36,代码来源:SunburstChart.java


示例7: initGraphics

import javafx.event.WeakEventHandler; //导入依赖的package包/类
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)));
}
 
开发者ID:haris44,项目名称:Paradinc-FX,代码行数:36,代码来源:World.java


示例8: initializePresenter

import javafx.event.WeakEventHandler; //导入依赖的package包/类
@Override
protected void initializePresenter() {
	addProfileTile = new Tile();
	FXUtils.setButtonGraphic(addProfileTile, new AddNewProfileTileView());
	addProfileTile.textProperty().bind(I18N.localize("org.to2mbn.lolixl.ui.impl.container.presenter.panel.sidebar.authtypes.button.add.text"));
	Panel panel = displayService.newPanel();
	panel.bindButton(addProfileTile);
	view.rootContainer.setBottom(addProfileTile);

	authProfileManager.selectedProfileProperty().addListener((ob, oldVal, newVal) -> {
		Tile tile = null;
		if (newVal != null) {
			tile = mappedProfileTiles.mapping().get(newVal);
		}
		if (tile == null) {
			tile = addProfileTile;
		}
		sideBarPresenter.getView().userProfileContainer.getChildren().setAll(tile);
	});

	List<Node> children = view.profilesContainer.getChildren();
	mappedProfileTiles = new MappedObservableList<>(authProfileManager.getProfiles(), profile -> {
		Tile t = profile.createTile(); // TODO: graphic->AuthProfileTileView?
		t.addEventHandler(MouseEvent.MOUSE_CLICKED, new WeakEventHandler<>(event -> {
			authProfileManager.selectedProfileProperty().set(profile);
			sideBarPresenter.getView().userProfileContainer.getChildren().setAll(t);
		}));
		children.add(t);
		return t;
	});
	Bindings.bindContent(view.profilesContainer.getChildren(), mappedProfileTiles);
}
 
开发者ID:to2mbn,项目名称:LoliXL,代码行数:33,代码来源:AuthProfilesPresenter.java


示例9: initGraphics

import javafx.event.WeakEventHandler; //导入依赖的package包/类
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);

    heatMap  = HeatMapBuilder.create()
                             .prefSize(1009, 665)
                             .colorMapping(colorMapping)
                             .eventRadius(eventRadius)
                             .fadeColors(fadeColors)
                             .opacityDistribution(opacityDistribution)
                             .heatMapOpacity(heatMapOpacity)
                             .build();

    getChildren().setAll(group, heatMap);

    setBackground(new Background(new BackgroundFill(getBackgroundColor(), CornerRadii.EMPTY, Insets.EMPTY)));
}
 
开发者ID:HanSolo,项目名称:worldheatmap,代码行数:45,代码来源:World.java


示例10: initGraphics

import javafx.event.WeakEventHandler; //导入依赖的package包/类
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);

    heatMap  = HeatMapBuilder.create()
                             .prefSize(1009, 665)
                             .colorMapping(colorMapping)
                             .spotRadius(spotRadius)
                             .fadeColors(fadeColors)
                             .opacityDistribution(opacityDistribution)
                             .heatMapOpacity(heatMapOpacity)
                             .build();

    getChildren().setAll(group, heatMap);

    setBackground(new Background(new BackgroundFill(getBackgroundColor(), CornerRadii.EMPTY, Insets.EMPTY)));
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:45,代码来源:World.java


示例11: initGraphics

import javafx.event.WeakEventHandler; //导入依赖的package包/类
private void initGraphics() {                
    hBox = new HBox();        
    hBox.getStyleClass().setAll("vu-meter");
    hBox.setSpacing(getSkinnable().getLedSpacing());        
    
    vBox = new VBox();
    vBox.getStyleClass().setAll("vu-meter");
    vBox.setSpacing(getSkinnable().getLedSpacing());        

    leds = FXCollections.observableArrayList();
    for (int i = 0 ; i < getSkinnable().getNoOfLeds() ; i++) {
        Region led = new Region();                    
        led.setOnMouseClicked(new WeakEventHandler<>(event -> active = !active));
        led.setOnMouseEntered(new WeakEventHandler<>(event -> handleMouseEvent(event)));                                    
        if (getSkinnable().getSections().isEmpty()) {
            led.getStyleClass().setAll("led");
        } else {                
            for (Section section : getSkinnable().getSections()) {
                if (section.contains(i * stepSize.doubleValue())) {
                    led.getStyleClass().setAll("led", section.getStyleClass());
                }
            }                
        }            
        leds.add(led);
    }
    
    if (Orientation.HORIZONTAL == getSkinnable().getOrientation()) {
        vBox.setManaged(false);            
        vBox.setVisible(false);
        hBox.getChildren().setAll(leds);
        peakLedIndex = 0;
    } else {
        hBox.setManaged(false);
        hBox.setVisible(false); 
        FXCollections.reverse(leds);
        vBox.getChildren().setAll(leds);
        peakLedIndex = leds.size() - 1;
    }
                                    
    // Add all nodes
    getChildren().setAll(hBox, vBox);        
}
 
开发者ID:Simego,项目名称:FXImgurUploader,代码行数:43,代码来源:VuMeterSkin.java



注:本文中的javafx.event.WeakEventHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Constants类代码示例发布时间:2022-05-22
下一篇:
Java TreeRange类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap