Autopsy  4.4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
PrimaryDetailsChartLane.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2016 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 java.util.Map;
22 import java.util.concurrent.ConcurrentHashMap;
23 import javafx.collections.ListChangeListener;
24 import javafx.scene.chart.Axis;
25 import javafx.scene.shape.Line;
26 import javafx.scene.shape.StrokeLineCap;
31 
46 public final class PrimaryDetailsChartLane extends DetailsChartLane<EventStripe> implements ContextMenuProvider {
47 
48  private static final int PROJECTED_LINE_Y_OFFSET = 5;
49  private static final int PROJECTED_LINE_STROKE_WIDTH = 5;
50 
52  private final Map<EventCluster, Line> projectionMap = new ConcurrentHashMap<>();
53 
54  PrimaryDetailsChartLane(DetailsChart parentChart, DateAxis dateAxis, final Axis<EventStripe> verticalAxis) {
55  super(parentChart, dateAxis, verticalAxis, true);
56 
57  //add listener for events that should trigger layout
58  getController().getQuickHideFilters().addListener(layoutInvalidationListener);
59 
60  parentChart.getRootEventStripes().addListener((ListChangeListener.Change<? extends EventStripe> change) -> {
61  while (change.next()) {
62  change.getAddedSubList().stream().forEach(this::addEvent);
63  change.getRemoved().stream().forEach(this::removeEvent);
64  }
65  requestChartLayout();
66  });
67  parentChart.getRootEventStripes().stream().forEach(this::addEvent);
68  requestChartLayout();
69 
70  getSelectedNodes().addListener((ListChangeListener.Change<? extends EventNodeBase<?>> change) -> {
71  while (change.next()) {
72  change.getRemoved().forEach(removedNode -> {
73  removedNode.getEvent().getClusters().forEach(cluster -> {
74  Line removedLine = projectionMap.remove(cluster);
75  getChartChildren().removeAll(removedLine);
76  });
77 
78  });
79  change.getAddedSubList().forEach(addedNode -> {
80  for (EventCluster range : addedNode.getEvent().getClusters()) {
81  double y = dateAxis.getLayoutY() + PROJECTED_LINE_Y_OFFSET;
82  Line line =
83  new Line(dateAxis.localToParent(getXForEpochMillis(range.getStartMillis()), 0).getX(), y,
84  dateAxis.localToParent(getXForEpochMillis(range.getEndMillis()), 0).getX(), y);
85  line.setStroke(addedNode.getEventType().getColor().deriveColor(0, 1, 1, .5));
86  line.setStrokeWidth(PROJECTED_LINE_STROKE_WIDTH);
87  line.setStrokeLineCap(StrokeLineCap.ROUND);
88  projectionMap.put(range, line);
89  getChartChildren().add(line);
90  }
91  });
92  }
93  });
94  }
95 
96  private double getParentXForEpochMillis(Long epochMillis) {
97  return getXAxis().localToParent(getXForEpochMillis(epochMillis), 0).getX();
98  }
99 
100  @Override
101  void doAdditionalLayout() {
102  for (final Map.Entry<EventCluster, Line> entry : projectionMap.entrySet()) {
103  final EventCluster cluster = entry.getKey();
104  final Line line = entry.getValue();
105 
106  line.setStartX(getParentXForEpochMillis(cluster.getStartMillis()));
107  line.setEndX(getParentXForEpochMillis(cluster.getEndMillis()));
108 
109  line.setStartY(getXAxis().getLayoutY() + PROJECTED_LINE_Y_OFFSET);
110  line.setEndY(getXAxis().getLayoutY() + PROJECTED_LINE_Y_OFFSET);
111  }
112  }
113 
114 }
ObservableList< DescriptionFilter > getQuickHideFilters()

Copyright © 2012-2016 Basis Technology. Generated on: Fri Sep 29 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.