19 package org.sleuthkit.autopsy.timeline.ui.filtering;
21 import javafx.application.Platform;
22 import javafx.beans.value.ObservableValue;
23 import javafx.geometry.Pos;
24 import javafx.scene.control.ContentDisplay;
25 import javafx.scene.control.TextField;
26 import javafx.scene.control.TreeTableCell;
27 import javafx.scene.image.ImageView;
28 import javafx.scene.layout.HBox;
29 import javafx.scene.paint.Color;
30 import javafx.scene.shape.Rectangle;
31 import org.openide.util.NbBundle;
44 class LegendCell
extends TreeTableCell<AbstractFilter, AbstractFilter> implements TimeLineView {
46 private static final Color CLEAR = Color.rgb(0, 0, 0, 0);
48 private TimeLineController controller;
50 private FilteredEventsModel filteredEvents;
53 public LegendCell(TimeLineController controller) {
55 setController(controller);
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.eventTypeZoom().addListener((
78 ObservableValue<? extends EventTypeZoomLevel> observable,
79 EventTypeZoomLevel oldValue,
80 EventTypeZoomLevel newValue) -> {
81 setLegendColor(filter, rect, newValue);
84 HBox hBox =
new HBox(
new Rectangle(filter.getEventType().getZoomLevel().ordinal() * 10, 5, CLEAR),
85 new ImageView(((TypeFilter) item).getFXImage()), rect
87 hBox.setAlignment(Pos.CENTER);
88 Platform.runLater(() -> {
90 setContentDisplay(ContentDisplay.CENTER);
93 }
else if (item instanceof TextFilter) {
94 TextFilter f = (TextFilter) item;
95 TextField textField =
new TextField();
96 textField.setPromptText(NbBundle.getMessage(
this.getClass(),
"Timeline.ui.filtering.promptText"));
97 textField.textProperty().bindBidirectional(f.textProperty());
98 Platform.runLater(() -> {
99 setGraphic(textField);
103 Platform.runLater(() -> {
111 private void setLegendColor(TypeFilter filter, Rectangle rect, EventTypeZoomLevel eventTypeZoom) {
113 if (eventTypeZoom.equals(filter.getEventType().getZoomLevel())) {
114 Platform.runLater(() -> {
115 rect.setStroke(filter.getEventType().getSuperType().getColor());
116 rect.setFill(filter.getColor());
119 Platform.runLater(() -> {
120 rect.setStroke(CLEAR);
127 synchronized public final void setController(TimeLineController controller) {
128 this.controller = controller;
129 setModel(this.controller.getEventsModel());
133 public void setModel(FilteredEventsModel filteredEvents) {
134 this.filteredEvents = filteredEvents;
void setModel(final FilteredEventsModel filteredEvents)