mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-18 18:47:43 +00:00
cleanup and fix codacy issues
This commit is contained in:
parent
eddab91e43
commit
b7a91a7a8c
@ -1,10 +1,3 @@
|
|||||||
<div style="font-size:{{size}}px;">
|
<html>
|
||||||
{{#pinned}}
|
<div style="font-size:{{size}}px;">{{#pinned}}<img style="vertical-align: middle;" height={{size}} width={{size}} src={{MARKER_PIN_URL}}>{{/pinned}}{{#locked}}<img style="vertical-align: middle;"height={{size}} width={{size}} src={{LOCK_URL}}>{{/locked}}<img style="vertical-align: middle;" height={{size}} width={{size}} src={{iconFileName}}>{{accountName}}</div>
|
||||||
<img height={{size}} width={{size}} src={{MARKER_PIN_URL}}>
|
</html>
|
||||||
{{/pinned}}
|
|
||||||
{{#locked}}
|
|
||||||
<img height={{size}} width={{size}} src={{LOCK_URL}}>
|
|
||||||
{{/locked}}
|
|
||||||
<img height={{size}} width={{size}} src={{iconFileName}}>
|
|
||||||
{{accountName}}
|
|
||||||
</div>
|
|
@ -154,7 +154,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
rubberband = new mxRubberband(graphComponent);
|
rubberband = new mxRubberband(graphComponent);
|
||||||
|
|
||||||
final mxEventSource.mxIEventListener scaleListener = (Object sender, mxEventObject evt) ->
|
final mxEventSource.mxIEventListener scaleListener = (Object sender, mxEventObject evt) ->
|
||||||
zoomLabel.setText(DecimalFormat.getPercentInstance().format(graph.getScale()));
|
zoomLabel.setText(DecimalFormat.getPercentInstance().format(graph.getView().getScale()));
|
||||||
graph.getView().addListener(mxEvent.SCALE, scaleListener);
|
graph.getView().addListener(mxEvent.SCALE, scaleListener);
|
||||||
graph.getView().addListener(mxEvent.SCALE_AND_TRANSLATE, scaleListener);
|
graph.getView().addListener(mxEvent.SCALE_AND_TRANSLATE, scaleListener);
|
||||||
|
|
||||||
@ -164,9 +164,9 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
public void mouseWheelMoved(final MouseWheelEvent e) {
|
public void mouseWheelMoved(final MouseWheelEvent e) {
|
||||||
super.mouseWheelMoved(e);
|
super.mouseWheelMoved(e);
|
||||||
if (e.getPreciseWheelRotation() > 0) {
|
if (e.getPreciseWheelRotation() > 0) {
|
||||||
graphComponent.zoomTo(graph.getScale() / graphComponent.getZoomFactor(), true);
|
graphComponent.zoomIn();
|
||||||
} else if (e.getPreciseWheelRotation() < 0) {
|
} else if (e.getPreciseWheelRotation() < 0) {
|
||||||
graphComponent.zoomTo(graph.getScale() * graphComponent.getZoomFactor(), true);
|
graphComponent.zoomOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -291,7 +291,10 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void rebuildGraph() throws TskCoreException {
|
private void rebuildGraph() throws TskCoreException {
|
||||||
if (graph.hasPinnedAccounts()) {
|
if (graph.isEmpty()) {
|
||||||
|
borderLayoutPanel.remove(graphComponent);
|
||||||
|
borderLayoutPanel.add(placeHolderPanel, BorderLayout.CENTER);
|
||||||
|
} else {
|
||||||
borderLayoutPanel.remove(placeHolderPanel);
|
borderLayoutPanel.remove(placeHolderPanel);
|
||||||
borderLayoutPanel.add(graphComponent, BorderLayout.CENTER);
|
borderLayoutPanel.add(graphComponent, BorderLayout.CENTER);
|
||||||
if (worker != null) {
|
if (worker != null) {
|
||||||
@ -303,15 +306,16 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
public void propertyChange(PropertyChangeEvent evt) {
|
||||||
if (worker.isDone()) {
|
if (worker.isDone()) {
|
||||||
|
if (graph.getModel().getChildCount(graph.getDefaultParent()) < 64) {
|
||||||
applyOrganicLayout(10);
|
applyOrganicLayout(10);
|
||||||
|
} else {
|
||||||
|
statusLabel.setText("Too many cells, layout aborted.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
worker.execute();
|
worker.execute();
|
||||||
|
|
||||||
} else {
|
|
||||||
borderLayoutPanel.remove(graphComponent);
|
|
||||||
borderLayoutPanel.add(placeHolderPanel, BorderLayout.CENTER);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -665,12 +669,15 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
private void morph(mxIGraphLayout layout) {
|
private void morph(mxIGraphLayout layout) {
|
||||||
// layout using morphing
|
// layout using morphing
|
||||||
graph.getModel().beginUpdate();
|
graph.getModel().beginUpdate();
|
||||||
try {
|
|
||||||
progressBar.setVisible(true);
|
progressBar.setVisible(true);
|
||||||
progressBar.setIndeterminate(true);
|
progressBar.setIndeterminate(true);
|
||||||
progressBar.setString("applying layout");
|
progressBar.setString("applying layout");
|
||||||
|
|
||||||
|
new SwingWorker<Void, Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground() throws Exception {
|
||||||
layout.execute(graph.getDefaultParent());
|
layout.execute(graph.getDefaultParent());
|
||||||
} finally {
|
|
||||||
mxMorphing morph = new mxMorphing(graphComponent, 20, 1.2, 20);
|
mxMorphing morph = new mxMorphing(graphComponent, 20, 1.2, 20);
|
||||||
morph.addListener(mxEvent.DONE, (Object sender, mxEventObject event) -> {
|
morph.addListener(mxEvent.DONE, (Object sender, mxEventObject event) -> {
|
||||||
graph.getModel().endUpdate();
|
graph.getModel().endUpdate();
|
||||||
@ -680,7 +687,10 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
});
|
});
|
||||||
|
|
||||||
morph.startAnimation();
|
morph.startAnimation();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
}.execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
@ -709,9 +719,8 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
|
|
||||||
final private class SelectionListener implements mxEventSource.mxIEventListener {
|
final private class SelectionListener implements mxEventSource.mxIEventListener {
|
||||||
|
|
||||||
@Override
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
public void invoke(Object sender, mxEventObject evt) {
|
public void invoke(Object sender, mxEventObject evt) {
|
||||||
Object[] selectionCells = graph.getSelectionCells();
|
Object[] selectionCells = graph.getSelectionCells();
|
||||||
Node rootNode = Node.EMPTY;
|
Node rootNode = Node.EMPTY;
|
||||||
@ -814,7 +823,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
|
|
||||||
final private class mxFastOrganicLayoutImpl extends mxFastOrganicLayout {
|
final private class mxFastOrganicLayoutImpl extends mxFastOrganicLayout {
|
||||||
|
|
||||||
private mxFastOrganicLayoutImpl(mxGraph graph) {
|
mxFastOrganicLayoutImpl(mxGraph graph) {
|
||||||
super(graph);
|
super(graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,7 +845,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
|
|
||||||
final private class mxCircleLayoutImpl extends mxCircleLayout {
|
final private class mxCircleLayoutImpl extends mxCircleLayout {
|
||||||
|
|
||||||
private mxCircleLayoutImpl(mxGraph graph) {
|
mxCircleLayoutImpl(mxGraph graph) {
|
||||||
super(graph);
|
super(graph);
|
||||||
setResetEdges(true);
|
setResetEdges(true);
|
||||||
}
|
}
|
||||||
@ -859,7 +868,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
|
|
||||||
final private class mxOrganicLayoutImpl extends mxOrganicLayout {
|
final private class mxOrganicLayoutImpl extends mxOrganicLayout {
|
||||||
|
|
||||||
private mxOrganicLayoutImpl(mxGraph graph) {
|
mxOrganicLayoutImpl(mxGraph graph) {
|
||||||
super(graph);
|
super(graph);
|
||||||
setResetEdges(true);
|
setResetEdges(true);
|
||||||
}
|
}
|
||||||
@ -882,7 +891,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
|
|
||||||
final private class mxHierarchicalLayoutImpl extends mxHierarchicalLayout {
|
final private class mxHierarchicalLayoutImpl extends mxHierarchicalLayout {
|
||||||
|
|
||||||
private mxHierarchicalLayoutImpl(mxGraph graph) {
|
mxHierarchicalLayoutImpl(mxGraph graph) {
|
||||||
super(graph);
|
super(graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,33 +106,6 @@ final class mxGraphImpl extends mxGraph {
|
|||||||
setKeepEdgesInBackground(true);
|
setKeepEdgesInBackground(true);
|
||||||
setResetEdgesOnMove(true);
|
setResetEdgesOnMove(true);
|
||||||
setHtmlLabels(true);
|
setHtmlLabels(true);
|
||||||
|
|
||||||
// new mxLayoutManager(graph) {
|
|
||||||
// final private mxOrganicLayout layout;
|
|
||||||
// private int counter;
|
|
||||||
// {
|
|
||||||
// this.layout = new mxOrganicLayout(graph);
|
|
||||||
// this.layout.setMaxIterations(1);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void executeLayout(mxIGraphLayout layout, Object parent) {
|
|
||||||
// if (counter % 10 == 0)
|
|
||||||
// {
|
|
||||||
// super.executeLayout(layout, parent);
|
|
||||||
//// fitGraph();
|
|
||||||
// }
|
|
||||||
// counter++;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public mxIGraphLayout getLayout(Object parent) {
|
|
||||||
// if (graph.getModel().getChildCount(parent) > 0) {
|
|
||||||
// return layout;
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
@ -156,9 +129,7 @@ final class mxGraphImpl extends mxGraph {
|
|||||||
|
|
||||||
scopes.put("accountName", adiKey.getAccountDeviceInstance().getAccount().getTypeSpecificID());
|
scopes.put("accountName", adiKey.getAccountDeviceInstance().getAccount().getTypeSpecificID());
|
||||||
scopes.put("size", Math.round(Math.log(adiKey.getMessageCount()) + 5));
|
scopes.put("size", Math.round(Math.log(adiKey.getMessageCount()) + 5));
|
||||||
|
scopes.put("iconFileName", mxGraphImpl.class.getResource("/org/sleuthkit/autopsy/communications/images/"
|
||||||
scopes.put("iconFileName", mxGraphImpl.class
|
|
||||||
.getResource("/org/sleuthkit/autopsy/communications/images/"
|
|
||||||
+ Utils.getIconFileName(adiKey.getAccountDeviceInstance().getAccount().getAccountType())));
|
+ Utils.getIconFileName(adiKey.getAccountDeviceInstance().getAccount().getAccountType())));
|
||||||
scopes.put("pinned", pinnedAccountDevices.contains(adiKey));
|
scopes.put("pinned", pinnedAccountDevices.contains(adiKey));
|
||||||
scopes.put("MARKER_PIN_URL", MARKER_PIN_URL);
|
scopes.put("MARKER_PIN_URL", MARKER_PIN_URL);
|
||||||
@ -175,25 +146,69 @@ final class mxGraphImpl extends mxGraph {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getToolTipForCell(Object cell) {
|
public String getToolTipForCell(Object cell) {
|
||||||
|
final StringWriter stringWriter = new StringWriter();
|
||||||
|
HashMap<String, Object> scopes = new HashMap<>();
|
||||||
|
|
||||||
|
Object value = getModel().getValue(cell);
|
||||||
|
if (value instanceof AccountDeviceInstanceKey) {
|
||||||
|
final AccountDeviceInstanceKey adiKey = (AccountDeviceInstanceKey) value;
|
||||||
|
|
||||||
|
scopes.put("accountName", adiKey.getAccountDeviceInstance().getAccount().getTypeSpecificID());
|
||||||
|
scopes.put("size", 12);// Math.round(Math.log(adiKey.getMessageCount()) + 5));
|
||||||
|
scopes.put("iconFileName", mxGraphImpl.class.getResource("/org/sleuthkit/autopsy/communications/images/"
|
||||||
|
+ Utils.getIconFileName(adiKey.getAccountDeviceInstance().getAccount().getAccountType())));
|
||||||
|
scopes.put("pinned", pinnedAccountDevices.contains(adiKey));
|
||||||
|
scopes.put("MARKER_PIN_URL", MARKER_PIN_URL);
|
||||||
|
scopes.put("locked", lockedVertices.contains((mxCell) cell));
|
||||||
|
scopes.put("LOCK_URL", LOCK_URL);
|
||||||
|
|
||||||
|
labelMustache.execute(stringWriter, scopes);
|
||||||
|
|
||||||
|
return stringWriter.toString();
|
||||||
|
} else {
|
||||||
return ((mxICell) cell).getId();
|
return ((mxICell) cell).getId();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unpin the given accounts from the graph. Pinned accounts will always be
|
||||||
|
* shown regardless of the filter state. Furthermore, accounts with
|
||||||
|
* relationships that pass the filters will also be shown.
|
||||||
|
*
|
||||||
|
* @param accountDeviceInstances The accounts to unpin.
|
||||||
|
*/
|
||||||
void unpinAccount(ImmutableSet<AccountDeviceInstanceKey> accountDeviceInstances) {
|
void unpinAccount(ImmutableSet<AccountDeviceInstanceKey> accountDeviceInstances) {
|
||||||
pinnedAccountDevices.removeAll(accountDeviceInstances);
|
pinnedAccountDevices.removeAll(accountDeviceInstances);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pin the given accounts to the graph. Pinned accounts will always be shown
|
||||||
|
* regardless of the filter state. Furthermore, accounts with relationships
|
||||||
|
* that pass the filters will also be shown.
|
||||||
|
*
|
||||||
|
* @param accountDeviceInstances The accounts to pin.
|
||||||
|
*/
|
||||||
void pinAccount(ImmutableSet<AccountDeviceInstanceKey> accountDeviceInstances) {
|
void pinAccount(ImmutableSet<AccountDeviceInstanceKey> accountDeviceInstances) {
|
||||||
pinnedAccountDevices.addAll(accountDeviceInstances);
|
pinnedAccountDevices.addAll(accountDeviceInstances);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lock the given vertex so that applying a layout algorithm doesn't move
|
||||||
|
* it. The user can still manually position the vertex.
|
||||||
|
*
|
||||||
|
* @param vertex The vertex to lock.
|
||||||
|
*/
|
||||||
void lockVertex(mxCell vertex) {
|
void lockVertex(mxCell vertex) {
|
||||||
lockedVertices.add(vertex);
|
lockedVertices.add(vertex);
|
||||||
|
|
||||||
final mxCellState state = getView().getState(vertex, true);
|
|
||||||
getView().clear(vertex, true, true);
|
getView().clear(vertex, true, true);
|
||||||
getView().validate();
|
getView().validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lock the given vertex so that applying a layout algorithm can move it.
|
||||||
|
*
|
||||||
|
* @param vertex The vertex to unlock.
|
||||||
|
*/
|
||||||
void unlockVertex(mxCell vertex) {
|
void unlockVertex(mxCell vertex) {
|
||||||
lockedVertices.remove(vertex);
|
lockedVertices.remove(vertex);
|
||||||
|
|
||||||
@ -204,8 +219,7 @@ final class mxGraphImpl extends mxGraph {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SwingWorker<?, ?> rebuild(ProgressIndicator progress, CommunicationsManager commsManager, CommunicationsFilter currentFilter) {
|
SwingWorker<?, ?> rebuild(ProgressIndicator progress, CommunicationsManager commsManager, CommunicationsFilter currentFilter) {
|
||||||
|
return new RebuildWorker(progress, commsManager, currentFilter);
|
||||||
return new SwingWorkerImpl(progress, commsManager, currentFilter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetGraph() {
|
void resetGraph() {
|
||||||
@ -261,12 +275,14 @@ final class mxGraphImpl extends mxGraph {
|
|||||||
return edge;
|
return edge;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasPinnedAccounts() {
|
/**
|
||||||
return pinnedAccountDevices.isEmpty() == false;
|
* Are there any accounts in this graph? If there are no pinned accounts the
|
||||||
}
|
* graph will be empty.
|
||||||
|
*
|
||||||
double getScale() {
|
* @return True if this graph is empty.
|
||||||
return getView().getScale();
|
*/
|
||||||
|
boolean isEmpty() {
|
||||||
|
return pinnedAccountDevices.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isVertexLocked(mxCell vertex) {
|
boolean isVertexLocked(mxCell vertex) {
|
||||||
@ -274,13 +290,17 @@ final class mxGraphImpl extends mxGraph {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SwingWorkerImpl extends SwingWorker<Void, Void> {
|
/**
|
||||||
|
* SwingWorker that loads the accounts and edges for this graph according to
|
||||||
|
* the pinned accounts and the current filters.
|
||||||
|
*/
|
||||||
|
private class RebuildWorker extends SwingWorker<Void, Void> {
|
||||||
|
|
||||||
private final ProgressIndicator progress;
|
private final ProgressIndicator progress;
|
||||||
private final CommunicationsManager commsManager;
|
private final CommunicationsManager commsManager;
|
||||||
private final CommunicationsFilter currentFilter;
|
private final CommunicationsFilter currentFilter;
|
||||||
|
|
||||||
SwingWorkerImpl(ProgressIndicator progress, CommunicationsManager commsManager, CommunicationsFilter currentFilter) {
|
RebuildWorker(ProgressIndicator progress, CommunicationsManager commsManager, CommunicationsFilter currentFilter) {
|
||||||
this.progress = progress;
|
this.progress = progress;
|
||||||
this.currentFilter = currentFilter;
|
this.currentFilter = currentFilter;
|
||||||
this.commsManager = commsManager;
|
this.commsManager = commsManager;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user