19 package org.sleuthkit.autopsy.timeline.zooming;
21 import java.lang.reflect.InvocationTargetException;
22 import java.util.function.Function;
23 import java.util.logging.Level;
24 import javafx.application.Platform;
25 import javafx.beans.InvalidationListener;
26 import javafx.beans.binding.BooleanBinding;
27 import javafx.beans.property.ReadOnlyObjectProperty;
28 import javafx.fxml.FXML;
29 import javafx.scene.control.Label;
30 import javafx.scene.control.Slider;
31 import javafx.scene.control.TitledPane;
32 import javafx.util.StringConverter;
33 import org.controlsfx.control.Notifications;
34 import org.openide.util.NbBundle;
89 "ZoomSettingsPane.descrLODLabel.text=Description Detail:",
90 "ZoomSettingsPane.typeZoomLabel.text=Event Type:",
91 "ZoomSettingsPane.timeUnitLabel.text=Time Units:",
92 "ZoomSettingsPane.zoomLabel.text=Zoom"})
94 zoomLabel.setText(Bundle.ZoomSettingsPane_zoomLabel_text());
96 typeZoomSlider.setMin(1);
97 typeZoomSlider.setMax(TimelineEventType.HierarchyLevel.values().length - 1);
98 configureSliderListeners(typeZoomSlider,
99 controller::pushEventTypeZoom,
101 TimelineEventType.HierarchyLevel.class,
102 TimelineEventType.HierarchyLevel::ordinal,
103 Function.identity());
104 typeZoomLabel.setText(Bundle.ZoomSettingsPane_typeZoomLabel_text());
106 descrLODSlider.setMax(TimelineLevelOfDetail.values().length - 1);
107 configureSliderListeners(descrLODSlider,
108 controller::pushDescrLOD,
110 TimelineLevelOfDetail.class,
111 TimelineLevelOfDetail::ordinal,
112 Function.identity());
113 descrLODLabel.setText(Bundle.ZoomSettingsPane_descrLODLabel_text());
124 timeUnitSlider.setMax(
TimeUnits.values().length - 2);
125 configureSliderListeners(timeUnitSlider,
126 controller::pushTimeUnit,
132 timeUnitLabel.setText(Bundle.ZoomSettingsPane_timeUnitLabel_text());
136 visibleProperty().bind(notListMode);
137 managedProperty().bind(notListMode);
178 @NbBundle.Messages({
"ZoomSettingsPane.sliderChange.errorText=Error responding to slider value change."})
180 private <DriverType, EnumType extends Enum<EnumType>>
void configureSliderListeners(
182 CheckedConsumer<EnumType> sliderValueConsumer,
183 ReadOnlyObjectProperty<DriverType> modelProperty,
184 Class<EnumType> enumClass,
185 Function<DriverType, Integer> driverValueMapper,
186 Function<Integer, Integer> labelIndexMapper) {
189 slider.setLabelFormatter(
new EnumSliderLabelFormatter<>(enumClass, labelIndexMapper));
192 final InvalidationListener sliderListener = observable -> {
194 if (slider.isValueChanging() ==
false) {
196 EnumType sliderValueAsEnum = enumClass.getEnumConstants()[Math.round((
float) slider.getValue())];
198 sliderValueConsumer.accept(sliderValueAsEnum);
199 }
catch (TskCoreException exception) {
200 logger.log(Level.SEVERE,
"Error responding to slider value change.", exception);
201 Notifications.create().owner(getScene().getWindow())
202 .text(Bundle.ZoomSettingsPane_sliderChange_errorText())
208 slider.valueProperty().addListener(sliderListener);
209 slider.valueChangingProperty().addListener(sliderListener);
212 slider.setValue(driverValueMapper.apply(modelProperty.get()));
215 modelProperty.addListener(modelProp -> {
217 slider.valueProperty().removeListener(sliderListener);
218 slider.valueChangingProperty().removeListener(sliderListener);
220 Platform.runLater(() -> {
222 slider.setValue(driverValueMapper.apply(modelProperty.get()));
225 slider.valueProperty().addListener(sliderListener);
226 slider.valueChangingProperty().addListener(sliderListener);
244 private final Class<EnumType>
clazz;
253 this.clazz = enumClass;
254 this.indexAdjsuter = indexMapper;
265 EnumType enumConstant = clazz.getEnumConstants()[indexAdjsuter.apply(dbl.intValue())];
267 return (String) clazz.getMethod(
"getDisplayName", (Class<?>[]) null).invoke(enumConstant, (Object[]) null);
268 }
catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
269 return enumConstant.toString();
275 throw new UnsupportedOperationException(
"This method should not be used. This EnumSliderLabelFormatter is being used in an unintended way.");
287 void accept(T input)
throws TskCoreException;
final ReadOnlyObjectWrapper< TimelineEventType.HierarchyLevel > eventTypesHierarchyLevelProperty
static final Logger logger
final EventsModel filteredEvents
final ReadOnlyObjectWrapper< Interval > timeRangeProperty
final TimeLineController controller
ZoomSettingsPane(TimeLineController controller)
static DateTimeZone getJodaTimeZone()
EventsModel getEventsModel()
synchronized ReadOnlyObjectProperty< ViewMode > viewModeProperty()
synchronized static Logger getLogger(String name)
synchronized ReadOnlyObjectProperty< TimelineLevelOfDetail > descriptionLODProperty()
static void construct(Node node, String fxmlFileName)
static RangeDivision getRangeDivision(Interval timeRange, DateTimeZone timeZone)