use of javafx.event.WeakEventHandler in project Board-Instrumentation-Framework by intel.
the class VuMeterSkin method initGraphics.
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);
}
use of javafx.event.WeakEventHandler in project tilesfx by HanSolo.
the class SunburstChart method createSegment.
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;
}
Aggregations