Autopsy  4.16.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
TimeLineChart.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014-16 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;
20 
21 import javafx.collections.ObservableList;
22 import javafx.event.EventHandler;
23 import javafx.event.EventType;
24 import javafx.scene.Cursor;
25 import javafx.scene.Node;
26 import javafx.scene.chart.Axis;
27 import javafx.scene.control.ContextMenu;
28 import javafx.scene.input.MouseButton;
29 import javafx.scene.input.MouseEvent;
30 import javafx.scene.layout.Region;
31 import org.controlsfx.control.action.ActionGroup;
32 import org.openide.util.NbBundle;
37 
44 
45  ObservableList<? extends Node> getSelectedNodes();
46 
47  @Override
49 
50  @Override
52 
59  @Override
61 
62  @Override
63  void clearIntervalSelector();
64 
65  @Override
66  public Axis<X> getXAxis();
67 
68  @Override
70 
71 
78  public static class ChartDragHandler<X, Y extends Region & IntervalSelectorProvider<X>> implements EventHandler<MouseEvent> {
79 
80  private final Y chart;
81 
82  private double startX; //hanlder maintains position of drag start
83 
84  public ChartDragHandler(Y chart) {
85  this.chart = chart;
86  }
87 
88  @Override
89  public void handle(MouseEvent mouseEvent) {
90  EventType<? extends MouseEvent> mouseEventType = mouseEvent.getEventType();
91  if (mouseEventType == MouseEvent.MOUSE_PRESSED) {
92  //caputure x-position, incase we are repositioning existing selector
93  startX = mouseEvent.getX();
94  chart.setCursor(Cursor.H_RESIZE);
95  } else if (mouseEventType == MouseEvent.MOUSE_DRAGGED) {
96  if (chart.getIntervalSelector() == null) {
97  //make new interval selector
98  chart.setIntervalSelector(chart.newIntervalSelector());
99  chart.getIntervalSelector().prefHeightProperty().bind(chart.heightProperty());
100  startX = mouseEvent.getX();
101  chart.getIntervalSelector().relocate(startX, 0);
102  } else if (mouseEvent.getX() > startX) {
103  //resize/position existing selector
104  chart.getIntervalSelector().relocate(startX, 0);
105  chart.getIntervalSelector().setPrefWidth(mouseEvent.getX() - startX);
106  } else {
107  chart.getIntervalSelector().relocate(mouseEvent.getX(), 0);
108  chart.getIntervalSelector().setPrefWidth(startX - mouseEvent.getX());
109  }
110  chart.getIntervalSelector().autosize();
111  } else if (mouseEventType == MouseEvent.MOUSE_RELEASED) {
112  chart.setCursor(Cursor.DEFAULT);
113  } else if (mouseEventType == MouseEvent.MOUSE_CLICKED) {
114  chart.setCursor(Cursor.DEFAULT);
115  }
116  }
117  }
118 
119  static class MouseClickedHandler<X, C extends Region & TimeLineChart<X>> implements EventHandler<MouseEvent> {
120 
121  private final C chart;
122 
123  public MouseClickedHandler(C chart) {
124  this.chart = chart;
125  }
126 
127  @Override
128  public void handle(MouseEvent mouseEvent) {
129  if (MouseEvent.MOUSE_CLICKED == mouseEvent.getEventType() && mouseEvent.isPopupTrigger() && mouseEvent.isStillSincePress()) {
130  ContextMenu chartContextMenu = chart.getContextMenu(mouseEvent);
131  chartContextMenu.show(chart, mouseEvent.getScreenX(), mouseEvent.getScreenY());
132  chart.clearContextMenu();
133  } else if (mouseEvent.getButton() == MouseButton.PRIMARY && mouseEvent.isStillSincePress()) {
134  chart.getSelectedNodes().clear();
135  }
136  mouseEvent.consume();
137  }
138  }
139 
140  @NbBundle.Messages({"TimeLineChart.zoomHistoryActionGroup.name=Zoom History"})
141  static ActionGroup newZoomHistoyActionGroup(TimeLineController controller) {
142  return new ActionGroup(Bundle.TimeLineChart_zoomHistoryActionGroup_name(),
143  new Back(controller),
144  new Forward(controller));
145  }
146 }
static ActionGroup newZoomHistoyActionGroup(TimeLineController controller)
ObservableList<?extends Node > getSelectedNodes()
void setIntervalSelector(IntervalSelector<?extends X > newIntervalSelector)
IntervalSelector<?extends X > getIntervalSelector()

Copyright © 2012-2020 Basis Technology. Generated on: Tue Sep 22 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.