Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeline event grouping #2094

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,7 @@ TimeLineGraph.uncheckEventItems=Uncheck corresponding event type items
IntervalDefinitionDialog.Title=Time line chart defined ranges
IntervalDefinitionDialog.dateFormat=MM/dd/yyyy
IntervalDefinitionDialog.hourFormat=HH:mm:ss
IntervalDefinitionDialog.Exit=Exit
IntervalDefinitionDialog.Exit=Exit
TimeEventGroup.BasicProperties=Basic Properties
IndexTimeStampCache.loadingMessage=Starting to load time cache of [{}] to {} event type group.
IndexTimeStampCache.buildingMessage=Starting to build time cache of [{}] to {} event type group.
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,6 @@ IntervalDefinitionDialog.Title=Zeitlininechart festgelegte Bereiche
IntervalDefinitionDialog.dateFormat=MM/dd/yyyy
IntervalDefinitionDialog.hourFormat=HH:mm:ss
IntervalDefinitionDialog.Exit=Beenden
TimeEventGroup.BasicProperties=Basic Properties(TBT)
IndexTimeStampCache.loadingMessage=Starting to load time cache of [{}] to {} event type group.(TBT)
IndexTimeStampCache.buildingMessage=Starting to build time cache of [{}] to {} event type group.(TBT)
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,6 @@ IntervalDefinitionDialog.Title=Rangos definidos en el gráfico de tiempo
IntervalDefinitionDialog.dateFormat=MM/dd/yyyy
IntervalDefinitionDialog.hourFormat=HH:mm:ss
IntervalDefinitionDialog.Exit=Salir
TimeEventGroup.BasicProperties=Basic Properties(TBT)
IndexTimeStampCache.loadingMessage=Starting to load time cache of [{}] to {} event type group.(TBT)
IndexTimeStampCache.buildingMessage=Starting to build time cache of [{}] to {} event type group.(TBT)
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,6 @@ IntervalDefinitionDialog.Title=Grafico sequenza temporale con intervalli definit
IntervalDefinitionDialog.dateFormat=dd/MM/yyyy
IntervalDefinitionDialog.hourFormat=HH:mm:ss
IntervalDefinitionDialog.Exit=Esci
TimeEventGroup.BasicProperties=Basic Properties(TBT)
IndexTimeStampCache.loadingMessage=Starting to load time cache of [{}] to {} event type group.(TBT)
IndexTimeStampCache.buildingMessage=Starting to build time cache of [{}] to {} event type group.(TBT)
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,6 @@ IntervalDefinitionDialog.Title=Intervalos definidos no gráfico
IntervalDefinitionDialog.dateFormat=MM/dd/yyyy
IntervalDefinitionDialog.hourFormat=HH:mm:ss
IntervalDefinitionDialog.Exit=Sair
TimeEventGroup.BasicProperties=Propriedades básicas
IndexTimeStampCache.loadingMessage=Carregando índice de [{}] para o grupo de eventos {}.
IndexTimeStampCache.buildingMessage=Construindo índice de [{}] para o grupo de eventos {}.
117 changes: 88 additions & 29 deletions iped-app/src/main/java/iped/app/timelinegraph/IpedChartsPanel.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package iped.app.timelinegraph;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
Expand All @@ -8,6 +9,8 @@
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseAdapter;
Expand Down Expand Up @@ -36,9 +39,12 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Predicate;

import javax.swing.BoxLayout;
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 +101,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 +116,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, ActionListener {
JTable resultsTable;
IMultiSearchResultProvider resultsProvider;
GUIProvider guiProvider;
Expand Down Expand Up @@ -145,14 +156,18 @@ public class IpedChartsPanel extends JPanel implements ResultSetViewer, TableMod
IpedChartPanel chartPanel = null;
JList legendList = new JList();
JScrollPane listScroller = new JScrollPane(legendList);
JPanel legendPane = new JPanel();
JComboBox<TimeEventGroup> tegCombo = new JComboBox<>();

IpedStackedXYBarRenderer renderer = null;
XYLineAndShapeRenderer highlightsRenderer = new XYLineAndShapeRenderer();
XYToolTipGenerator toolTipGenerator = null;

String metadataToBreakChart = null;
ImageIcon loading = null;
JLabel loadingLabel;
JPanel loadingPanel = new JPanel();
JLabel loadingLabelImage;
JLabel loadingLabelText;

IpedSplitPane splitPane;

Expand All @@ -170,6 +185,7 @@ public class IpedChartsPanel extends JPanel implements ResultSetViewer, TableMod

Color fgColor;
Color bgColor;
private ArrayList<TimeEventGroup> selectedTeGroups = new ArrayList<TimeEventGroup>();

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

Expand All @@ -180,6 +196,8 @@ public IpedChartsPanel() {
}
combinedPlot.setDomainPannable(true);

selectedTeGroups.add(TimeEventGroup.BASIC_EVENTS);

toolTipGenerator = new XYToolTipGenerator() {
@Override
public String generateToolTip(XYDataset dataset, int series, int item) {
Expand All @@ -194,6 +212,7 @@ public IpedChartsPanel(boolean b) {
super(b);

this.setLayout(new GridLayout());

}

class LegendCellRenderer extends JLabel implements ListCellRenderer<LegendItemBlockContainer> {
Expand Down Expand Up @@ -286,7 +305,19 @@ public void init(JTable resultsTable, IMultiSearchResultProvider resultsProvider
splitPane = new IpedSplitPane();
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);


chartPanel = new IpedChartPanel(chart, this);

CheckboxListCellRenderer cblcRenderer = new CheckboxListCellRenderer<TimeEventGroup>(
new Predicate<TimeEventGroup>() {
@Override
public boolean test(TimeEventGroup t) {
return selectedTeGroups.contains(t);
}
});
tegCombo.setRenderer(cblcRenderer);
tegCombo.setMaximumSize(new Dimension(100, 0));

legendListModel = new DefaultListModel<LegendItemBlockContainer>();
legendList.setModel(legendListModel);
legendList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
Expand Down Expand Up @@ -337,24 +368,32 @@ public void check(MouseEvent e) {
ttm.setEnabled(true);

splitPane.setTopComponent(chartPanel);
splitPane.setBottomComponent(listScroller);

legendPane.setPreferredSize(new Dimension(Integer.MAX_VALUE, 80));
legendPane.setLayout(new BorderLayout());
legendPane.add(tegCombo, BorderLayout.NORTH);
legendPane.add(listScroller, BorderLayout.CENTER);
splitPane.setBottomComponent(legendPane);
splitPane.setVisible(false);

chartPanel.setPopupMenu(null);
this.addComponentListener(this);

loading = (ImageIcon) new ImageIcon(IconUtil.class.getResource(resPath + "loading.gif"));
loadingLabel = new JLabel("", loading, JLabel.CENTER);
this.add(loadingLabel);
loadingLabelImage = new JLabel("", loading, JLabel.CENTER);
loadingLabelText = new JLabel("", JLabel.CENTER);
loadingPanel.setAlignmentY(Component.CENTER_ALIGNMENT);
loadingPanel.setLayout(new BoxLayout(loadingPanel, BoxLayout.Y_AXIS));
loadingLabelImage.setAlignmentX(Component.CENTER_ALIGNMENT);
loadingLabelText.setAlignmentX(Component.CENTER_ALIGNMENT);
loadingPanel.add(loadingLabelImage, BorderLayout.CENTER);
loadingPanel.add(loadingLabelText, BorderLayout.CENTER);
this.add(loadingPanel);

domainAxis.setTickMarkPosition(DateTickMarkPosition.START);
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 @@ -391,6 +430,7 @@ public HashMap<String, XYDataset> createAlertDataSets() {
}

public HashMap<String, AbstractIntervalXYDataset> createDataSets() {

HashMap<String, AbstractIntervalXYDataset> result = new HashMap<String, AbstractIntervalXYDataset>();
try {
Set<String> selectedBookmarks = guiProvider.getSelectedBookmarks();
Expand All @@ -399,14 +439,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, selectedTeGroups, 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, selectedTeGroups, category));
}
} else {
result.put("Items", ipedTimelineDatasetManager.getBestDataset(timePeriodClass, null));
result.put("Items", ipedTimelineDatasetManager.getBestDataset(timePeriodClass, selectedTeGroups, null));
}
return result;
} catch (Exception e) {
Expand Down Expand Up @@ -451,8 +493,8 @@ public Future<?> refreshChart(boolean resetDomainRange) {
IpedChartsPanel self = this;

self.remove(splitPane);
self.remove(loadingLabel);
self.add(loadingLabel);
self.remove(loadingPanel);
self.add(loadingPanel);
self.repaint();

if (swRefresh != null) {
Expand Down Expand Up @@ -517,11 +559,11 @@ public void run() {
}

if (chart != null && !isCancelled()) {
self.remove(loadingLabel);
self.remove(loadingPanel);
self.remove(splitPane);
self.add(splitPane);
splitPane.setTopComponent(chartPanel);
splitPane.setBottomComponent(listScroller);
splitPane.setBottomComponent(legendPane);
splitPane.setVisible(true);

// hide hidden events
Expand Down Expand Up @@ -588,15 +630,6 @@ public void setDockableContainer(DefaultSingleCDockable dockable) {
public void changed(CDockableLocationEvent dockableEvent) {
if (!isUpdated && dockableEvent.isShowingChanged()) {
refreshChart();
if (!loadingCacheStarted.getAndSet(true)) {
Runnable r = new Runnable() {
@Override
public void run() {
ipedTimelineDatasetManager.startCacheCreation();
}
};
new Thread(r).start();
}
}
}
};
Expand Down Expand Up @@ -1038,7 +1071,7 @@ public void setLegendList(JList legendList) {

@Override
public void componentResized(ComponentEvent e) {
this.remove(loadingLabel);
this.remove(loadingPanel);
this.remove(splitPane);
this.add(splitPane);
}
Expand All @@ -1065,13 +1098,22 @@ 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);

// updates tegCombo with updated time event groups of the case
tegCombo.removeActionListener(this);
tegCombo.removeAllItems();
tegCombo.addItem(TimeEventGroup.BASIC_EVENTS);
for (TimeEventGroup teGroup : ipedTimelineDatasetManager.getTimeEventGroupsFromMetadataPrefix()) {
tegCombo.addItem(teGroup);
}
tegCombo.addActionListener(this);

this.dataSetUpdated.set(false);
}

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


@Override
public void actionPerformed(ActionEvent e) {
TimeEventGroup teGroup = (TimeEventGroup) tegCombo.getSelectedItem();
if (selectedTeGroups.contains(teGroup)) {
selectedTeGroups.remove(teGroup);
} else {
selectedTeGroups.add(teGroup);
}
if (selectedTeGroups.isEmpty()) {
selectedTeGroups.add(TimeEventGroup.BASIC_EVENTS);
}
refreshChart(false);
}

public void info(String info, String period, String groupname) {
loadingLabelText.setText(info.replaceFirst("\\{\\}", period).replaceFirst("\\{\\}", groupname));
}
}
Loading
Loading