Autopsy  4.1
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 
77  public static class ChartDragHandler<X, Y extends Region & IntervalSelectorProvider<X>> implements EventHandler<MouseEvent> {
78 
79  private final Y chart;
80 
81  private double startX; //hanlder maintains position of drag start
82 
83  public ChartDragHandler(Y chart) {
84  this.chart = chart;
85  }
86 
87  @Override
88  public void handle(MouseEvent mouseEvent) {
89  EventType<? extends MouseEvent> mouseEventType = mouseEvent.getEventType();
90  if (mouseEventType == MouseEvent.MOUSE_PRESSED) {
91  //caputure x-position, incase we are repositioning existing selector
92  startX = mouseEvent.getX();
93  chart.setCursor(Cursor.H_RESIZE);
94  } else if (mouseEventType == MouseEvent.MOUSE_DRAGGED) {
95  if (chart.getIntervalSelector() == null) {
96  //make new interval selector
97  chart.setIntervalSelector(chart.newIntervalSelector());
98  chart.getIntervalSelector().prefHeightProperty().bind(chart.heightProperty());
99  startX = mouseEvent.getX();
100  chart.getIntervalSelector().relocate(startX, 0);
101  } else if (mouseEvent.getX() > startX) {
102  //resize/position existing selector
103  chart.getIntervalSelector().relocate(startX, 0);
104  chart.getIntervalSelector().setPrefWidth(mouseEvent.getX() - startX);
105  } else {
106  chart.getIntervalSelector().relocate(mouseEvent.getX(), 0);
107  chart.getIntervalSelector().setPrefWidth(startX - mouseEvent.getX());
108  }
109  chart.getIntervalSelector().autosize();
110  } else if (mouseEventType == MouseEvent.MOUSE_RELEASED) {
111  chart.setCursor(Cursor.DEFAULT);
112  } else if (mouseEventType == MouseEvent.MOUSE_CLICKED) {
113  chart.setCursor(Cursor.DEFAULT);
114  }
115  }
116  }
117 
118  static class MouseClickedHandler<X, C extends Region & TimeLineChart<X>> implements EventHandler<MouseEvent> {
119 
120  private final C chart;
121 
122  public MouseClickedHandler(C chart) {
123  this.chart = chart;
124  }
125 
126  @Override
127  public void handle(MouseEvent mouseEvent) {
128  if (MouseEvent.MOUSE_CLICKED == mouseEvent.getEventType() && mouseEvent.isPopupTrigger() && mouseEvent.isStillSincePress()) {
129  ContextMenu chartContextMenu = chart.getContextMenu(mouseEvent);
130  chartContextMenu.show(chart, mouseEvent.getScreenX(), mouseEvent.getScreenY());
131  chart.clearContextMenu();
132  } else if (mouseEvent.getButton() == MouseButton.PRIMARY && mouseEvent.isStillSincePress()) {
133  chart.getSelectedNodes().clear();
134  }
135  mouseEvent.consume();
136  }
137  }
138 
139  @NbBundle.Messages({"TimeLineChart.zoomHistoryActionGroup.name=Zoom History"})
140  static ActionGroup newZoomHistoyActionGroup(TimeLineController controller) {
141  return new ActionGroup(Bundle.TimeLineChart_zoomHistoryActionGroup_name(),
142  new Back(controller),
143  new Forward(controller));
144  }
145 }
static ActionGroup newZoomHistoyActionGroup(TimeLineController controller)
ObservableList<?extends Node > getSelectedNodes()
void setIntervalSelector(IntervalSelector<?extends X > newIntervalSelector)
IntervalSelector<?extends X > getIntervalSelector()

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