19 package org.sleuthkit.autopsy.timeline.ui.filtering;
21 import javafx.application.Platform;
22 import javafx.geometry.Pos;
23 import javafx.scene.control.ContentDisplay;
24 import javafx.scene.control.TextField;
25 import javafx.scene.control.TreeTableCell;
26 import javafx.scene.image.ImageView;
27 import javafx.scene.layout.HBox;
28 import javafx.scene.paint.Color;
29 import javafx.scene.shape.Rectangle;
30 import org.openide.util.NbBundle;
36 import org.
sleuthkit.datamodel.TimelineFilter.EventTypeFilter;
43 final class LegendCell
extends TreeTableCell<FilterState<?>, FilterState<?>> {
45 private static final Color CLEAR = Color.rgb(0, 0, 0, 0);
47 private final TimeLineController controller;
49 private final EventsModel filteredEvents;
52 LegendCell(TimeLineController controller) {
54 this.controller = controller;
55 this.filteredEvents = this.controller.getEventsModel();
59 @NbBundle.Messages(
"Timeline.ui.filtering.promptText=enter filter string")
60 public void updateItem(FilterState<?> item,
boolean empty) {
61 super.updateItem(item, empty);
63 Platform.runLater(() -> {
70 if (item instanceof TextFilterState) {
71 TextFilterState filterState = (TextFilterState)item;
72 TextField textField =
new TextField();
73 textField.setPromptText(Bundle.Timeline_ui_filtering_promptText());
74 textField.textProperty().bindBidirectional(filterState.descriptionSubstringProperty());
75 Platform.runLater(() -> setGraphic(textField));
77 }
else if (item.getFilter() instanceof EventTypeFilter) {
78 EventTypeFilter filter = (EventTypeFilter) item.getFilter();
79 Rectangle rect =
new Rectangle(20, 20);
83 rect.setStrokeWidth(3);
84 setLegendColor(filter, rect, this.filteredEvents.getEventTypeZoom());
85 this.filteredEvents.eventTypesHierarchyLevelProperty().addListener((obs, oldZoomLevel, newZoomLevel) -> {
86 setLegendColor(filter, rect, newZoomLevel);
89 HBox hBox =
new HBox(
new Rectangle(filter.getRootEventType().getTypeHierarchyLevel().ordinal() * 10, 5, CLEAR),
90 new ImageView(EventTypeUtils.getImagePath(filter.getRootEventType())), rect
92 hBox.setAlignment(Pos.CENTER);
93 Platform.runLater(() -> {
95 setContentDisplay(ContentDisplay.CENTER);
99 Platform.runLater(() -> {
107 private void setLegendColor(EventTypeFilter filter, Rectangle rect, TimelineEventType.HierarchyLevel eventTypeZoom) {
109 if (eventTypeZoom.equals(filter.getRootEventType().getTypeHierarchyLevel())) {
110 Platform.runLater(() -> {
111 rect.setStroke(EventTypeUtils.getColor(filter.getRootEventType().getParent()));
112 rect.setFill(EventTypeUtils.getColor(filter.getRootEventType()));
115 Platform.runLater(() -> {
116 rect.setStroke(CLEAR);