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()));
}
});
});
}
java类javafx.event.WeakEventHandler的实例源码
World.java 文件源码
项目:worldheatmap
阅读 22
收藏 0
点赞 0
评论 0
World.java 文件源码
项目:charts
阅读 25
收藏 0
点赞 0
评论 0
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()));
}
});
});
}
World.java 文件源码
项目:charts
阅读 23
收藏 0
点赞 0
评论 0
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);
}
World.java 文件源码
项目:Paradinc-FX
阅读 28
收藏 0
点赞 0
评论 0
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()));
}
});
});
}
World.java 文件源码
项目:worldfx
阅读 30
收藏 0
点赞 0
评论 0
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()));
}
});
});
}
SunburstChart.java 文件源码
项目:SunburstChart
阅读 20
收藏 0
点赞 0
评论 0
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;
}
ClipboardNotification.java 文件源码
项目:Clipcon-Client
阅读 77
收藏 0
点赞 0
评论 0
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();
}
World.java 文件源码
项目:worldheatmap
阅读 41
收藏 0
点赞 0
评论 0
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);
}
SunburstChart.java 文件源码
项目:charts
阅读 25
收藏 0
点赞 0
评论 0
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;
}
SunburstChart.java 文件源码
项目:tilesfx
阅读 22
收藏 0
点赞 0
评论 0
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;
}
World.java 文件源码
项目:Paradinc-FX
阅读 21
收藏 0
点赞 0
评论 0
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)));
}
World.java 文件源码
项目:Paradinc-FX
阅读 29
收藏 0
点赞 0
评论 0
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);
}
World.java 文件源码
项目:worldfx
阅读 25
收藏 0
点赞 0
评论 0
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)));
}
World.java 文件源码
项目:worldfx
阅读 25
收藏 0
点赞 0
评论 0
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);
}
AuthProfilesPresenter.java 文件源码
项目:LoliXL
阅读 16
收藏 0
点赞 0
评论 0
@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);
}
World.java 文件源码
项目:worldheatmap
阅读 19
收藏 0
点赞 0
评论 0
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)));
}
World.java 文件源码
项目:charts
阅读 23
收藏 0
点赞 0
评论 0
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)));
}
VuMeterSkin.java 文件源码
项目:FXImgurUploader
阅读 20
收藏 0
点赞 0
评论 0
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);
}
VuMeterSkin.java 文件源码
项目:Enzo
阅读 24
收藏 0
点赞 0
评论 0
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);
}