Autopsy  4.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-15 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.event.EventHandler;
22 import javafx.event.EventType;
23 import javafx.scene.Cursor;
24 import javafx.scene.chart.Axis;
25 import javafx.scene.chart.Chart;
26 import javafx.scene.control.ContextMenu;
27 import javafx.scene.input.MouseButton;
28 import javafx.scene.input.MouseEvent;
29 import org.controlsfx.control.action.ActionGroup;
30 import org.openide.util.NbBundle;
34 
40 public interface TimeLineChart<X> {
41 
42 // void setController(TimeLineController controller);
44 
46 
54 
59  void clearIntervalSelector();
60 
61  public Axis<X> getXAxis();
62 
64 
65  ContextMenu getChartContextMenu();
66 
67  ContextMenu getChartContextMenu(MouseEvent m);
68 
76  static class ChartDragHandler<X, Y extends Chart & TimeLineChart<X>> implements EventHandler<MouseEvent> {
77 
78  private final Y chart;
79 
80  private double startX; //hanlder mainstains position of drag start
81 
82  public ChartDragHandler(Y chart) {
83  this.chart = chart;
84  }
85 
86  @Override
87  public void handle(MouseEvent mouseEvent) {
88  EventType<? extends MouseEvent> mouseEventType = mouseEvent.getEventType();
89  if (mouseEventType == MouseEvent.MOUSE_PRESSED) {
90  //caputure x-position, incase we are repositioning existing selector
91  startX = mouseEvent.getX();
92  chart.setCursor(Cursor.H_RESIZE);
93  } else if (mouseEventType == MouseEvent.MOUSE_DRAGGED) {
94  if (chart.getIntervalSelector() == null) {
95  //make new interval selector
96  chart.setIntervalSelector(chart.newIntervalSelector());
97  chart.getIntervalSelector().prefHeightProperty().bind(chart.heightProperty());
98  startX = mouseEvent.getX();
99  chart.getIntervalSelector().relocate(startX, 0);
100  } else {
101  //resize/position existing selector
102  if (mouseEvent.getX() > startX) {
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  }
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 
120  static class MouseClickedHandler<X, C extends Chart & TimeLineChart<X>> implements EventHandler<MouseEvent> {
121 
122  private final C chart;
123 
124  public MouseClickedHandler(C chart) {
125  this.chart = chart;
126  }
127 
128  @Override
129  public void handle(MouseEvent clickEvent) {
130  if (chart.getChartContextMenu() != null) {
131  chart.getChartContextMenu().hide();
132  }
133  if (clickEvent.getButton() == MouseButton.SECONDARY && clickEvent.isStillSincePress()) {
134  chart.getChartContextMenu(clickEvent);
135  chart.setOnMouseMoved(this);
136  chart.getChartContextMenu().show(chart, clickEvent.getScreenX(), clickEvent.getScreenY());
137  clickEvent.consume();
138  }
139  }
140  }
141 
147 
150  RIGHT
151  }
152 
153  @NbBundle.Messages({"TimeLineChart.zoomHistoryActionGroup.name=Zoom History"})
154  static ActionGroup newZoomHistoyActionGroup(TimeLineController controller) {
155  return new ActionGroup(Bundle.TimeLineChart_zoomHistoryActionGroup_name(),
156  new Back(controller),
157  new Forward(controller));
158  }
159 }
static ActionGroup newZoomHistoyActionGroup(TimeLineController controller)
void setIntervalSelector(IntervalSelector<?extends X > newIntervalSelector)
IntervalSelector<?extends X > getIntervalSelector()

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.