19 package org.sleuthkit.autopsy.timeline.ui.detailview;
21 import javafx.scene.chart.Axis;
22 import javafx.scene.control.Tooltip;
23 import javafx.scene.input.MouseButton;
24 import javafx.scene.shape.Line;
25 import org.joda.time.DateTime;
26 import org.openide.util.NbBundle;
34 @NbBundle.Messages({
"# {0} - date/time at guideline position",
35 "GuideLine.tooltip.text={0}\nRight-click to remove.\nDrag to reposition."})
36 class GuideLine extends Line {
38 private final Tooltip CHART_DEFAULT_TOOLTIP = AbstractTimelineChart.
getDefaultTooltip();
40 private final Tooltip tooltip =
new Tooltip();
41 private final DetailsChart chart;
44 private double startLayoutX;
45 private double dragStartX = 0;
50 GuideLine(DetailsChart chart) {
53 Axis<DateTime> xAxis = chart.getXAxis();
54 endYProperty().bind(chart.heightProperty().subtract(xAxis.heightProperty().subtract(xAxis.tickLengthProperty())));
56 getStyleClass().add(
"guide-line");
58 Tooltip.install(
this, tooltip);
59 tooltip.setOnShowing(showing -> tooltip.setText(Bundle.GuideLine_tooltip_text(getDateTimeAsString())));
62 setOnMouseEntered(entered -> Tooltip.uninstall(chart, CHART_DEFAULT_TOOLTIP));
63 setOnMouseExited(exited -> Tooltip.install(chart, CHART_DEFAULT_TOOLTIP));
65 setOnMouseClicked(clickedEvent -> {
66 if (clickedEvent.getButton() == MouseButton.SECONDARY
67 && clickedEvent.isStillSincePress()) {
68 chart.clearGuideLine(
this);
69 clickedEvent.consume();
72 setOnMousePressed(pressedEvent -> {
73 startLayoutX = getLayoutX();
74 dragStartX = pressedEvent.getScreenX();
76 setOnMouseDragged(dragEvent -> {
77 double dX = dragEvent.getScreenX() - dragStartX;
78 relocate(startLayoutX + dX, 0);
83 private String getDateTimeAsString() {
84 return chart.getDateTimeForPosition(getLayoutX()).toString(TimeLineController.getZonedFormatter());
static Tooltip getDefaultTooltip()