19 package org.sleuthkit.autopsy.timeline.ui.detailview;
21 import javafx.application.Platform;
22 import javafx.beans.Observable;
23 import javafx.geometry.Orientation;
24 import javafx.scene.control.ScrollBar;
25 import javafx.scene.input.KeyEvent;
26 import javafx.scene.layout.BorderPane;
27 import javafx.scene.layout.Priority;
28 import javafx.scene.layout.Region;
29 import javafx.scene.layout.VBox;
34 class ScrollingLaneWrapper
extends BorderPane {
36 private static final double LINE_SCROLL_PERCENTAGE = .10;
37 private static final double PAGE_SCROLL_PERCENTAGE = .70;
38 private final ScrollBar vertScrollBar =
new ScrollBar();
39 private final Region scrollBarSpacer =
new Region();
40 private final DetailsChartLane<?> chart;
42 ScrollingLaneWrapper(DetailsChartLane<?> center) {
46 scrollBarSpacer.minHeightProperty().bind(chart.getXAxis().heightProperty());
49 vertScrollBar.setOrientation(Orientation.VERTICAL);
50 vertScrollBar.maxProperty().bind(chart.maxVScrollProperty().subtract(chart.heightProperty()));
51 vertScrollBar.visibleAmountProperty().bind(chart.heightProperty());
52 vertScrollBar.visibleProperty().bind(vertScrollBar.visibleAmountProperty().greaterThanOrEqualTo(0));
53 VBox.setVgrow(vertScrollBar, Priority.ALWAYS);
54 setRight(
new VBox(vertScrollBar, scrollBarSpacer));
57 this.vertScrollBar.valueProperty().addListener((Observable observable) -> {
58 chart.setVScroll(vertScrollBar.getValue());
61 setOnMouseClicked(mouseEvent -> requestFocus());
64 this.setOnScroll(scrollEvent ->
65 vertScrollBar.valueProperty().set(clampScroll(vertScrollBar.getValue() - scrollEvent.getDeltaY())));
68 this.setOnKeyPressed((KeyEvent t) -> {
69 switch (t.getCode()) {
71 incrementScrollValue(-PAGE_SCROLL_PERCENTAGE);
75 incrementScrollValue(PAGE_SCROLL_PERCENTAGE);
80 incrementScrollValue(-LINE_SCROLL_PERCENTAGE);
85 incrementScrollValue(LINE_SCROLL_PERCENTAGE);
93 Platform.runLater(() -> {
94 vertScrollBar.setValue(0);
98 private void incrementScrollValue(
double factor) {
99 vertScrollBar.valueProperty().set(clampScroll(vertScrollBar.getValue() + factor * chart.getHeight()));
102 private Double clampScroll(Double value) {
103 return Math.max(0, Math.min(vertScrollBar.getMax() + 50, value));