Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
GuideLine.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.timeline.ui.detailview;
20 
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;
29 
33 class GuideLine extends Line {
34 
35  private final DateAxis dateAxis;
36 
37  private double startLayoutX;
38 
39  protected Tooltip tooltip;
40 
41  private double dragStartX = 0;
42 
43  GuideLine(double startX, double startY, double endX, double endY, DateAxis axis) {
44  super(startX, startY, endX, endY);
45  dateAxis = axis;
46  setCursor(Cursor.E_RESIZE);
47  getStrokeDashArray().setAll(5.0, 5.0);
48  setStroke(Color.RED);
49  setOpacity(.5);
50  setStrokeWidth(3);
51 
52  setOnMouseEntered((MouseEvent event) -> {
53  setTooltip();
54  });
55 
56  setOnMousePressed((MouseEvent event) -> {
57  startLayoutX = getLayoutX();
58  dragStartX = event.getScreenX();
59  });
60  setOnMouseDragged((MouseEvent event) -> {
61  double dX = event.getScreenX() - dragStartX;
62 
63  relocate(startLayoutX + dX, 0);
64  });
65  }
66 
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);
72  }
73 
74  private String formatSpan(DateTime date) {
75  return date.toString(TimeLineController.getZonedFormatter());
76  }
77 
78  private DateTime getDateTime() {
79  return dateAxis.getValueForDisplay(dateAxis.parentToLocal(getLayoutX(), 0).getX());
80  }
81 
82 }

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.