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;
42 final class LegendCell
extends TreeTableCell<AbstractFilter, AbstractFilter> {
44 private static final Color CLEAR = Color.rgb(0, 0, 0, 0);
46 private final TimeLineController controller;
48 private final FilteredEventsModel filteredEvents;
51 LegendCell(TimeLineController controller) {
53 this.controller = controller;
54 this.filteredEvents = this.controller.getEventsModel();
58 @NbBundle.Messages(
"Timeline.ui.filtering.promptText=enter filter string")
59 public void updateItem(AbstractFilter item,
boolean empty) {
60 super.updateItem(item, empty);
62 Platform.runLater(() -> {
69 if (item instanceof TypeFilter) {
70 TypeFilter filter = (TypeFilter) item;
71 Rectangle rect =
new Rectangle(20, 20);
75 rect.setStrokeWidth(3);
76 setLegendColor(filter, rect, this.filteredEvents.getEventTypeZoom());
77 this.filteredEvents.eventTypeZoomProperty().addListener((obs, oldZoomLevel, newZoomLevel) -> {
78 setLegendColor(filter, rect, newZoomLevel);
81 HBox hBox =
new HBox(
new Rectangle(filter.getEventType().getZoomLevel().ordinal() * 10, 5, CLEAR),
82 new ImageView(((TypeFilter) item).getFXImage()), rect
84 hBox.setAlignment(Pos.CENTER);
85 Platform.runLater(() -> {
87 setContentDisplay(ContentDisplay.CENTER);
90 }
else if (item instanceof TextFilter) {
91 TextFilter f = (TextFilter) item;
92 TextField textField =
new TextField();
93 textField.setPromptText(Bundle.Timeline_ui_filtering_promptText());
94 textField.textProperty().bindBidirectional(f.textProperty());
95 Platform.runLater(() -> {
96 setGraphic(textField);
100 Platform.runLater(() -> {
108 private void setLegendColor(TypeFilter filter, Rectangle rect, EventTypeZoomLevel eventTypeZoom) {
110 if (eventTypeZoom.equals(filter.getEventType().getZoomLevel())) {
111 Platform.runLater(() -> {
112 rect.setStroke(filter.getEventType().getSuperType().getColor());
113 rect.setFill(filter.getColor());
116 Platform.runLater(() -> {
117 rect.setStroke(CLEAR);