19 package org.sleuthkit.autopsy.timeline.ui.detailview;
21 import javafx.scene.Cursor;
22 import javafx.scene.control.Tooltip;
23 import javafx.scene.input.MouseEvent;
24 import javafx.scene.paint.Color;
25 import javafx.scene.shape.Line;
26 import org.joda.time.DateTime;
27 import org.openide.util.NbBundle;
33 class GuideLine
extends Line {
35 private final DateAxis dateAxis;
37 private double startLayoutX;
39 protected Tooltip tooltip;
41 private double dragStartX = 0;
43 GuideLine(
double startX,
double startY,
double endX,
double endY, DateAxis axis) {
44 super(startX, startY, endX, endY);
46 setCursor(Cursor.E_RESIZE);
47 getStrokeDashArray().setAll(5.0, 5.0);
52 setOnMouseEntered((MouseEvent event) -> {
56 setOnMousePressed((MouseEvent event) -> {
57 startLayoutX = getLayoutX();
58 dragStartX =
event.getScreenX();
60 setOnMouseDragged((MouseEvent event) -> {
61 double dX =
event.getScreenX() - dragStartX;
63 relocate(startLayoutX + dX, 0);
67 private void setTooltip() {
68 Tooltip.uninstall(
this, tooltip);
69 tooltip =
new Tooltip(
70 NbBundle.getMessage(
this.getClass(),
"Timeline.ui.detailview.tooltip.text", formatSpan(getDateTime())));
71 Tooltip.install(
this, tooltip);
74 private String formatSpan(DateTime date) {
75 return date.toString(TimeLineController.getZonedFormatter());
78 private DateTime getDateTime() {
79 return dateAxis.getValueForDisplay(dateAxis.parentToLocal(getLayoutX(), 0).getX());