Package org.sleuthkit.autopsy.timeline.utils

Examples of org.sleuthkit.autopsy.timeline.utils.RangeDivisionInfo


            protected Void call() throws Exception {

                updateMessage("preparing");

                long max = 0;
                final RangeDivisionInfo rangeInfo = RangeDivisionInfo.getRangeDivisionInfo(filteredEvents.getSpanningInterval());
                final long lowerBound = rangeInfo.getLowerBound();
                final long upperBound = rangeInfo.getUpperBound();
                Interval timeRange = new Interval(new DateTime(lowerBound, TimeLineController.getJodaTimeZone()), new DateTime(upperBound, TimeLineController.getJodaTimeZone()));

                //extend range to block bounderies (ie day, month, year)
                int p = 0; // progress counter

                //clear old data, and reset ranges and series
                Platform.runLater(() -> {
                    updateMessage("resetting ui");

                });

                ArrayList<Long> bins = new ArrayList<>();

                DateTime start = timeRange.getStart();
                while (timeRange.contains(start)) {
                    if (isCancelled()) {
                        return null;
                    }
                    DateTime end = start.plus(rangeInfo.getPeriodSize().getPeriod());
                    final Interval interval = new Interval(start, end);
                    //increment for next iteration

                    start = end;
View Full Code Here


            refreshTimeUI(filteredEvents.timeRange().get());
        });
    }

    private void refreshTimeUI(Interval interval) {
        RangeDivisionInfo rangeDivisionInfo = RangeDivisionInfo.getRangeDivisionInfo(filteredEvents.getSpanningInterval());

        final Long minTime = rangeDivisionInfo.getLowerBound();
        final long maxTime = rangeDivisionInfo.getUpperBound();

        if (minTime > 0 && maxTime > minTime) {

            Platform.runLater(() -> {
                startPicker.localDateTimeProperty().removeListener(startListener);
View Full Code Here

    private List<AggregateEvent> getAggregatedEvents(Interval timeRange, Filter filter, EventTypeZoomLevel zoomLevel, DescriptionLOD lod) {
        String descriptionColumn = getDescriptionColumn(lod);
        final boolean useSubTypes = (zoomLevel.equals(EventTypeZoomLevel.SUB_TYPE));

        //get some info about the time range requested
        RangeDivisionInfo rangeInfo = RangeDivisionInfo.getRangeDivisionInfo(timeRange);
        //use 'rounded out' range
        long start = timeRange.getStartMillis() / 1000;//.getLowerBound();
        long end = timeRange.getEndMillis() / 1000;//Millis();//rangeInfo.getUpperBound();
        if (Objects.equals(start, end)) {
            end++;
        }

        //get a sqlite srtftime format string
        String strfTimeFormat = getStrfTimeFormat(rangeInfo.getPeriodSize());

        //effectively map from type to (map from description to events)
        Map<EventType, SetMultimap< String, AggregateEvent>> typeMap = new HashMap<>();

        //get all agregate events in this time unit
        dbReadLock();
        String query = "select strftime('" + strfTimeFormat + "',time , 'unixepoch'" + (TimeLineController.getTimeZone().get().equals(TimeZone.getDefault()) ? ", 'localtime'" : "") + ") as interval,  group_concat(event_id) as event_ids, Min(time), Max(time),  " + descriptionColumn + ", " + (useSubTypes ? SUB_TYPE_COLUMN : BASE_TYPE_COLUMN)
                + " from events where time >= " + start + " and time < " + end + " and " + getSQLWhere(filter)
                + " group by interval, " + (useSubTypes ? SUB_TYPE_COLUMN : BASE_TYPE_COLUMN) + " , " + descriptionColumn
                + " order by Min(time)";
        //System.out.println(query);
        ResultSet rs = null;
        try (Statement stmt = con.createStatement(); // scoop up requested events in groups organized by interval, type, and desription
                ) {

            Stopwatch stopwatch = new Stopwatch();
            stopwatch.start();

            rs = stmt.executeQuery(query);
            stopwatch.stop();
            //System.out.println(stopwatch.elapsedMillis() / 1000.0 + " seconds");
            while (rs.next()) {
                EventType type = useSubTypes ? RootEventType.allTypes.get(rs.getInt(SUB_TYPE_COLUMN)) : BaseTypes.values()[rs.getInt(BASE_TYPE_COLUMN)];

                AggregateEvent aggregateEvent = new AggregateEvent(
                        new Interval(rs.getLong("Min(time)") * 1000, rs.getLong("Max(time)") * 1000, TimeLineController.getJodaTimeZone()),
                        type,
                        Arrays.asList(rs.getString("event_ids").split(",")),
                        rs.getString(descriptionColumn), lod);

                //put events in map from type/descrition -> event
                SetMultimap<String, AggregateEvent> descrMap = typeMap.get(type);
                if (descrMap == null) {
                    descrMap = HashMultimap.<String, AggregateEvent>create();
                    typeMap.put(type, descrMap);
                }
                descrMap.put(aggregateEvent.getDescription(), aggregateEvent);
            }

        } catch (SQLException ex) {
            Exceptions.printStackTrace(ex);
        } finally {
            try {
                rs.close();
            } catch (SQLException ex) {
                Exceptions.printStackTrace(ex);
            }
            dbReadUnlock();
        }

        //result list to return
        ArrayList<AggregateEvent> aggEvents = new ArrayList<>();

        //save this for use when comparing gap size
        Period timeUnitLength = rangeInfo.getPeriodSize().getPeriod();

        //For each (type, description) key, merge agg events
        for (SetMultimap<String, AggregateEvent> descrMap : typeMap.values()) {
            for (String descr : descrMap.keySet()) {
                //run through the sorted events, merging together adjacent events
View Full Code Here

                });

                updateProgress(-1, 1);
                updateMessage("preparing");

                final RangeDivisionInfo rangeInfo = RangeDivisionInfo.getRangeDivisionInfo(filteredEvents.timeRange().get());
                final long lowerBound = rangeInfo.getLowerBound();
                final long upperBound = rangeInfo.getUpperBound();

                updateMessage("querying db");
                aggregatedEvents.setAll(filteredEvents.getAggregatedEvents());

                Platform.runLater(() -> {
View Full Code Here

        }

        @Override
        protected Interval adjustInterval(Interval i) {
            //extend range to block bounderies (ie day, month, year)
            RangeDivisionInfo iInfo = RangeDivisionInfo.getRangeDivisionInfo(i);
            final long lowerBound = iInfo.getLowerBound();
            final long upperBound = iInfo.getUpperBound();
            final DateTime lowerDate = new DateTime(lowerBound, TimeLineController.getJodaTimeZone());
            final DateTime upperDate = new DateTime(upperBound, TimeLineController.getJodaTimeZone());
            //add extra block to end that gets cut of by conversion from string/category.
            return new Interval(lowerDate, upperDate.plus(rangeInfo.getPeriodSize().getPeriod()));
        }
View Full Code Here

                updateMessage("preparing update");
                Platform.runLater(() -> {
                    setCursor(Cursor.WAIT);
                });

                final RangeDivisionInfo rangeInfo = RangeDivisionInfo.getRangeDivisionInfo(filteredEvents.timeRange().get());
                chart.setRangeInfo(rangeInfo);
                //extend range to block bounderies (ie day, month, year)
                final long lowerBound = rangeInfo.getLowerBound();
                final long upperBound = rangeInfo.getUpperBound();
                final Interval timeRange = new Interval(new DateTime(lowerBound, TimeLineController.getJodaTimeZone()), new DateTime(upperBound, TimeLineController.getJodaTimeZone()));

                int max = 0;
                int p = 0; // progress counter

                //clear old data, and reset ranges and series
                Platform.runLater(() -> {
                    updateMessage("resetting ui");
                    eventTypeMap.clear();
                    dataSets.clear();
                    dateAxis.getCategories().clear();

                    DateTime start = timeRange.getStart();
                    while (timeRange.contains(start)) {
                        //add bar/'category' label for the current interval
                        final String dateString = start.toString(rangeInfo.getTickFormatter());
                        dateAxis.getCategories().add(dateString);

                        //increment for next iteration
                        start = start.plus(rangeInfo.getPeriodSize().getPeriod());
                    }

                    //make all series to ensure they get created in consistent order
                    EventType.allTypes.forEach(CountsViewPane.this::getSeries);
                });

                DateTime start = timeRange.getStart();
                while (timeRange.contains(start)) {

                    final String dateString = start.toString(rangeInfo.getTickFormatter());
                    DateTime end = start.plus(rangeInfo.getPeriodSize().getPeriod());
                    final Interval interval = new Interval(start, end);

                    //query for current range
                    Map<EventType, Long> eventCounts = filteredEvents.getEventCounts(interval);

                    //increment for next iteration
                    start = end;

                    int dateMax = 0; //used in max tracking

                    //for each type add data to graph
                    for (final EventType et : eventCounts.keySet()) {
                        if (isCancelled()) {
                            return null;
                        }

                        final Long count = eventCounts.get(et);
                        final int fp = p++;
                        if (count > 0) {
                            final double adjustedCount = count == 0 ? 0 : scale.get().adjust(count);

                            dateMax += adjustedCount;
                            final XYChart.Data<String, Number> xyData = new BarChart.Data<>(dateString, adjustedCount);

                            xyData.nodeProperty().addListener((Observable o) -> {
                                final Node node = xyData.getNode();
                                if (node != null) {
                                    node.setStyle("-fx-border-width: 2; -fx-border-color: " + ColorUtilities.getRGBCode(et.getSuperType().getColor()) + "; -fx-bar-fill: " + ColorUtilities.getRGBCode(et.getColor()));
                                    node.setCursor(Cursor.HAND);

                                    node.setOnMouseEntered((MouseEvent event) -> {
                                        //defer tooltip creation till needed, this had a surprisingly large impact on speed of loading the chart
                                        final Tooltip tooltip = new Tooltip(count + " " + et.getDisplayName() + " events\n"
                                                + "between " + dateString + "\n"
                                                + "and     "
                                                + interval.getEnd().toString(rangeInfo.getTickFormatter()));
                                        tooltip.setGraphic(new ImageView(et.getFXImage()));
                                        Tooltip.install(node, tooltip);
                                        node.setEffect(new DropShadow(10, et.getColor()));
                                    });
                                    node.setOnMouseExited((MouseEvent event) -> {
                                        if (selectedNodes.contains(node)) {
                                            node.setEffect(SELECTED_NODE_EFFECT);
                                        } else {
                                            node.setEffect(null);
                                        }
                                    });

                                    node.addEventHandler(MouseEvent.MOUSE_CLICKED, new BarClickHandler(node, dateString, interval, et));
                                }
                            });

                            max = Math.max(max, dateMax);

                            final double fmax = max;

                            Platform.runLater(() -> {
                                updateMessage("updating counts");
                                getSeries(et).getData().add(xyData);
                                if (scale.get().equals(ScaleType.LINEAR)) {
                                    countAxis.setTickUnit(Math.pow(10, Math.max(0, Math.floor(Math.log10(fmax)) - 1)));
                                } else {
                                    countAxis.setTickUnit(Double.MAX_VALUE);
                                }
                                countAxis.setUpperBound(1 + fmax * 1.2);
                                layoutDateLabels();
                                updateProgress(fp, rangeInfo.getPeriodsInRange());
                            });
                        } else {
                            final double fmax = max;

                            Platform.runLater(() -> {
                                updateMessage("updating counts");
                                updateProgress(fp, rangeInfo.getPeriodsInRange());
                            });
                        }
                    }
                }

View Full Code Here

                        controller.pushTimeRange(IntervalUtils.getIntervalAround(IntervalUtils.middleOf(ZoomSettingsPane.this.filteredEvents.timeRange().get()), requestedUnit.getPeriod()));
                    }
                },
                this.filteredEvents.timeRange(),
                () -> {
                    RangeDivisionInfo rangeInfo = RangeDivisionInfo.getRangeDivisionInfo(this.filteredEvents.timeRange().get());
                    ChronoUnit chronoUnit = rangeInfo.getPeriodSize().getChronoUnit();

                    timeUnitSlider.setValue(TimeUnits.fromChronoUnit(chronoUnit).ordinal() - 1);
                });

        initializeSlider(descrLODSlider,
View Full Code Here

TOP

Related Classes of org.sleuthkit.autopsy.timeline.utils.RangeDivisionInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.