Skip to content

Commit

Permalink
'#1864 Initial implementations of modifications to support Time event
Browse files Browse the repository at this point in the history
grouping on Timeline tab.
  • Loading branch information
patrickdalla committed Feb 21, 2024
1 parent 6e484b6 commit daae03c
Show file tree
Hide file tree
Showing 11 changed files with 350 additions and 52 deletions.
55 changes: 44 additions & 11 deletions iped-app/src/main/java/iped/app/timelinegraph/IpedChartsPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.awt.Rectangle;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.font.TextAttribute;
Expand All @@ -36,9 +38,11 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Predicate;

import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
Expand Down Expand Up @@ -95,6 +99,7 @@
import iped.app.ui.App;
import iped.app.ui.ClearFilterListener;
import iped.app.ui.ColumnsManager;
import iped.app.ui.controls.CheckboxListCellRenderer;
import iped.app.ui.themes.ThemeManager;
import iped.data.IItemId;
import iped.engine.search.QueryBuilder;
Expand All @@ -109,7 +114,11 @@
import iped.viewers.api.ResultSetViewer;
import iped.viewers.api.events.RowSorterTableDataChange;

public class IpedChartsPanel extends JPanel implements ResultSetViewer, TableModelListener, ListSelectionListener, IQueryFilterer, ClearFilterListener, ComponentListener {
/**
* @author Patrick Dalla Bernardina
*/
public class IpedChartsPanel extends JPanel implements ResultSetViewer, TableModelListener, ListSelectionListener,
IQueryFilterer, ClearFilterListener, ComponentListener, ItemListener {
JTable resultsTable;
IMultiSearchResultProvider resultsProvider;
GUIProvider guiProvider;
Expand Down Expand Up @@ -145,6 +154,7 @@ public class IpedChartsPanel extends JPanel implements ResultSetViewer, TableMod
IpedChartPanel chartPanel = null;
JList legendList = new JList();
JScrollPane listScroller = new JScrollPane(legendList);
JComboBox<TimeEventGroup> tegCombo = new JComboBox<>();

IpedStackedXYBarRenderer renderer = null;
XYLineAndShapeRenderer highlightsRenderer = new XYLineAndShapeRenderer();
Expand All @@ -170,6 +180,7 @@ public class IpedChartsPanel extends JPanel implements ResultSetViewer, TableMod

Color fgColor;
Color bgColor;
private TimeEventGroup currentTeGroup = TimeEventGroup.BASIC_EVENTS;

private static final String resPath = '/' + App.class.getPackageName().replace('.', '/') + '/';

Expand Down Expand Up @@ -286,7 +297,18 @@ public void init(JTable resultsTable, IMultiSearchResultProvider resultsProvider
splitPane = new IpedSplitPane();
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);


chartPanel = new IpedChartPanel(chart, this);
tegCombo.setRenderer(new CheckboxListCellRenderer<TimeEventGroup>(new Predicate<TimeEventGroup>() {
@Override
public boolean test(TimeEventGroup t) {
return true;
}
}));
chartPanel.add(tegCombo);

tegCombo.addItemListener(this);

legendListModel = new DefaultListModel<LegendItemBlockContainer>();
legendList.setModel(legendListModel);
legendList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
Expand Down Expand Up @@ -351,10 +373,6 @@ public void check(MouseEvent e) {
domainAxis.setLowerMargin(0.01);
domainAxis.setUpperMargin(0.01);
combinedPlot.setDomainAxis(domainAxis);

if (ipedTimelineDatasetManager == null) {
ipedTimelineDatasetManager = new IpedTimelineDatasetManager(this);
}
}

public String getTimeEventColumnName(String timeEvent) {
Expand Down Expand Up @@ -399,14 +417,16 @@ public HashMap<String, AbstractIntervalXYDataset> createDataSets() {

if (selectedBookmarks.size() > 0 && chartPanel.getSplitByBookmark()) {
for (String bookmark : selectedBookmarks) {
result.put(bookmark, ipedTimelineDatasetManager.getBestDataset(timePeriodClass, bookmark));
result.put(bookmark,
ipedTimelineDatasetManager.getBestDataset(timePeriodClass, currentTeGroup, bookmark));
}
} else if (selectedCategories.size() > 0 && chartPanel.getSplitByCategory()) {
for (String category : selectedCategories) {
result.put(category, ipedTimelineDatasetManager.getBestDataset(timePeriodClass, category));
result.put(category,
ipedTimelineDatasetManager.getBestDataset(timePeriodClass, currentTeGroup, category));
}
} else {
result.put("Items", ipedTimelineDatasetManager.getBestDataset(timePeriodClass, null));
result.put("Items", ipedTimelineDatasetManager.getBestDataset(timePeriodClass, currentTeGroup, null));
}
return result;
} catch (Exception e) {
Expand Down Expand Up @@ -1065,13 +1085,19 @@ public void setSyncViewWithTableSelection(boolean syncViewWithTableSelection) {

@Override
public void checkAll(boolean value) {
// TODO Auto-generated method stub

}

@Override
public void notifyCaseDataChanged() {
populateEventNames.run();
this.ipedTimelineDatasetManager = new IpedTimelineDatasetManager(this);

tegCombo.removeAllItems();
tegCombo.addItem(TimeEventGroup.BASIC_EVENTS);
for (TimeEventGroup teGroup : ipedTimelineDatasetManager.getTimeEventGroupsFromMetadataPrefix()) {
tegCombo.addItem(teGroup);
}

this.dataSetUpdated.set(false);
}

Expand All @@ -1084,5 +1110,12 @@ public void resetZoom() {
public static String[] getOrdToEventName() {
return ordToEventName;
}


@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
currentTeGroup = (TimeEventGroup) e.getItem();
refreshChart(true);
}
}
}
61 changes: 61 additions & 0 deletions iped-app/src/main/java/iped/app/timelinegraph/TimeEventGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package iped.app.timelinegraph;

import java.util.HashSet;

/**
* Class that represents a collection of event to use as a filter to graph
* events viewing. Also, the cache will be managed/persisted based on this event
* groups
*
* @author Patrick Dalla Bernardina [email protected]
*/
public class TimeEventGroup {
public static final TimeEventGroup ALL_EVENTS = new TimeEventGroup();
public static final TimeEventGroup BASIC_EVENTS = new TimeEventGroup("BasicProperties");

HashSet eventNames = new HashSet<String>();

String name;

private TimeEventGroup() {
this.name = "ALL";
}

public TimeEventGroup(String name) {
this.name = name;
}

public boolean hasEvent(String eventType) {
if (this == ALL_EVENTS) {
return true;
}
return eventNames.contains(eventType);
}

@Override
public int hashCode() {
return name.hashCode();
}

@Override
public boolean equals(Object obj) {
if (obj instanceof TimeEventGroup) {
return name.equals(((TimeEventGroup) obj).name);
} else {
return true;
}
}

public String getName() {
return name;
}

public void addEvent(String eventName) {
eventNames.add(eventName);
}

@Override
public String toString() {
return name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.roaringbitmap.RoaringBitmap;

import iped.app.timelinegraph.IpedChartsPanel;
import iped.app.timelinegraph.TimeEventGroup;
import iped.app.timelinegraph.cache.persistance.CachePersistance;
import iped.engine.core.Manager;
import iped.viewers.api.IMultiSearchResultProvider;
Expand All @@ -36,6 +37,7 @@ public class IndexTimeStampCache implements TimeStampCache {
IMultiSearchResultProvider resultsProvider;
IpedChartsPanel ipedChartsPanel;
TimeZone timezone;
TimeEventGroup teGroup = TimeEventGroup.ALL_EVENTS;//default TimeEventGroup

TimeIndexedMap newCache = new TimeIndexedMap();

Expand Down Expand Up @@ -91,7 +93,7 @@ public void run() {
int ord = 0;
while (ord < cachedEventNames.length) {
String eventType = cachedEventNames[ord];
if (eventType != null && !eventType.isEmpty()) {
if (eventType != null && !eventType.isEmpty() && teGroup.hasEvent(eventType)) {
cacheLoaders.add(new EventTimestampCache(ipedChartsPanel, resultsProvider, this, cachedEventNames[ord], ord));
}
ord++;
Expand All @@ -118,7 +120,7 @@ public void run() {

newCache = new TimeIndexedMap();
for (Class periodClasses : periodClassesToCache) {
newCache.setIndexFile(periodClasses.getSimpleName(), cp.getBaseDir());
newCache.setIndexFile(teGroup, periodClasses.getSimpleName(), cp.getBaseDir());
LinkedHashSet<CacheTimePeriodEntry> times = new LinkedHashSet<CacheTimePeriodEntry>();
newCache.put(periodClasses.getSimpleName(), times);
}
Expand Down Expand Up @@ -301,4 +303,19 @@ public void add(Class<? extends TimePeriod> timePeriodClass, Date t, Integer eve
selectedCt.addEventEntry(eventInternalOrd, doc);
}

@Override
public boolean isFromEventGroup(TimeEventGroup teGroup) {
return this.teGroup.equals(teGroup);
}

@Override
public void setTimeEventGroup(TimeEventGroup teGroup) {
this.teGroup = teGroup;
}

@Override
public TimeEventGroup getTimeEventGroup() {
return this.teGroup;
}

}
Loading

0 comments on commit daae03c

Please sign in to comment.