mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-18 10:37:43 +00:00
layouts respect cell 'locking'
This commit is contained in:
parent
b6ea00af8c
commit
d1f07e033d
@ -163,16 +163,16 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
super.mouseClicked(e);
|
super.mouseClicked(e);
|
||||||
if (SwingUtilities.isRightMouseButton(e)) {
|
if (SwingUtilities.isRightMouseButton(e)) {
|
||||||
mxICell cellAt = (mxICell) graphComponent.getCellAt(e.getX(), e.getY());
|
mxCell cellAt = (mxCell) graphComponent.getCellAt(e.getX(), e.getY());
|
||||||
if (cellAt != null && cellAt.isVertex()) {
|
if (cellAt != null && cellAt.isVertex()) {
|
||||||
JPopupMenu jPopupMenu = new JPopupMenu();
|
JPopupMenu jPopupMenu = new JPopupMenu();
|
||||||
AccountDeviceInstanceKey adiKey = (AccountDeviceInstanceKey) cellAt.getValue();
|
AccountDeviceInstanceKey adiKey = (AccountDeviceInstanceKey) cellAt.getValue();
|
||||||
|
|
||||||
if (graph.isAccountLocked(adiKey)) {
|
if (graph.isVertexLocked(cellAt)) {
|
||||||
jPopupMenu.add(new JMenuItem(new AbstractAction("UnLock " + cellAt.getId(), unlockIcon) {
|
jPopupMenu.add(new JMenuItem(new AbstractAction("UnLock " + cellAt.getId(), unlockIcon) {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
graph.unlockAccount((AccountDeviceInstanceKey) cellAt.getValue());
|
graph.unlockVertex(cellAt);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
jPopupMenu.add(new JMenuItem(new AbstractAction("Lock " + cellAt.getId(), lockIcon) {
|
jPopupMenu.add(new JMenuItem(new AbstractAction("Lock " + cellAt.getId(), lockIcon) {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
graph.lockAccount((AccountDeviceInstanceKey) cellAt.getValue());
|
graph.lockVertex(cellAt);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -583,7 +583,22 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
}//GEN-LAST:event_zoomOutButtonActionPerformed
|
}//GEN-LAST:event_zoomOutButtonActionPerformed
|
||||||
|
|
||||||
private void circleLayoutButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_circleLayoutButtonActionPerformed
|
private void circleLayoutButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_circleLayoutButtonActionPerformed
|
||||||
final mxCircleLayout mxCircleLayout = new mxCircleLayout(graph);
|
final mxCircleLayout mxCircleLayout = new mxCircleLayout(graph) {
|
||||||
|
@Override
|
||||||
|
public boolean isVertexIgnored(Object vertex) {
|
||||||
|
return super.isVertexIgnored(vertex)
|
||||||
|
|| VisualizationPanel.this.graph.isVertexLocked((mxCell) vertex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public mxRectangle setVertexLocation(Object vertex, double x, double y) {
|
||||||
|
if (isVertexIgnored(vertex)) {
|
||||||
|
return getVertexBounds(vertex);
|
||||||
|
} else {
|
||||||
|
return super.setVertexLocation(vertex, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
mxCircleLayout.setResetEdges(true);
|
mxCircleLayout.setResetEdges(true);
|
||||||
morph(mxCircleLayout);
|
morph(mxCircleLayout);
|
||||||
}//GEN-LAST:event_circleLayoutButtonActionPerformed
|
}//GEN-LAST:event_circleLayoutButtonActionPerformed
|
||||||
@ -593,23 +608,62 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
}//GEN-LAST:event_OrganicLayoutButtonActionPerformed
|
}//GEN-LAST:event_OrganicLayoutButtonActionPerformed
|
||||||
|
|
||||||
private void fastOrganicLayoutButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_fastOrganicLayoutButtonActionPerformed
|
private void fastOrganicLayoutButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_fastOrganicLayoutButtonActionPerformed
|
||||||
final mxFastOrganicLayout mxFastOrganicLayout = new mxFastOrganicLayout(graph);
|
final mxFastOrganicLayout mxFastOrganicLayout = new mxFastOrganicLayout(graph) {
|
||||||
|
@Override
|
||||||
|
public boolean isVertexIgnored(Object vertex) {
|
||||||
|
return super.isVertexIgnored(vertex)
|
||||||
|
|| VisualizationPanel.this.graph.isVertexLocked((mxCell) vertex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public mxRectangle setVertexLocation(Object vertex, double x, double y) {
|
||||||
|
if (isVertexIgnored(vertex)) {
|
||||||
|
return getVertexBounds(vertex);
|
||||||
|
} else {
|
||||||
|
return super.setVertexLocation(vertex, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
morph(mxFastOrganicLayout);
|
morph(mxFastOrganicLayout);
|
||||||
}//GEN-LAST:event_fastOrganicLayoutButtonActionPerformed
|
}//GEN-LAST:event_fastOrganicLayoutButtonActionPerformed
|
||||||
|
|
||||||
private void hierarchyLayoutButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_hierarchyLayoutButtonActionPerformed
|
private void hierarchyLayoutButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_hierarchyLayoutButtonActionPerformed
|
||||||
final mxHierarchicalLayout mxHierarchicalLayout = new mxHierarchicalLayout(graph);
|
final mxHierarchicalLayout mxHierarchicalLayout = new mxHierarchicalLayout(graph) {
|
||||||
|
@Override
|
||||||
|
public boolean isVertexIgnored(Object vertex) {
|
||||||
|
return super.isVertexIgnored(vertex)
|
||||||
|
|| VisualizationPanel.this.graph.isVertexLocked((mxCell) vertex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public mxRectangle setVertexLocation(Object vertex, double x, double y) {
|
||||||
|
if (isVertexIgnored(vertex)) {
|
||||||
|
return getVertexBounds(vertex);
|
||||||
|
} else {
|
||||||
|
return super.setVertexLocation(vertex, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
morph(mxHierarchicalLayout);
|
morph(mxHierarchicalLayout);
|
||||||
}//GEN-LAST:event_hierarchyLayoutButtonActionPerformed
|
}//GEN-LAST:event_hierarchyLayoutButtonActionPerformed
|
||||||
|
|
||||||
private void applyOrganicLayout(int iterations) {
|
private void applyOrganicLayout(int iterations) {
|
||||||
mxOrganicLayout mxOrganicLayout = new mxOrganicLayout(graph) {
|
mxOrganicLayout mxOrganicLayout = new mxOrganicLayout(graph) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isVertexMovable(Object vertex) {
|
public boolean isVertexIgnored(Object vertex) {
|
||||||
return super.isVertexMovable(vertex); //To change body of generated methods, choose Tools | Templates.
|
return super.isVertexIgnored(vertex)
|
||||||
|
|| VisualizationPanel.this.graph.isVertexLocked((mxCell) vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public mxRectangle setVertexLocation(Object vertex, double x, double y) {
|
||||||
|
if (isVertexIgnored(vertex)) {
|
||||||
|
return getVertexBounds(vertex);
|
||||||
|
} else {
|
||||||
|
return super.setVertexLocation(vertex, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
mxOrganicLayout.setResetEdges(true);
|
mxOrganicLayout.setResetEdges(true);
|
||||||
mxOrganicLayout.setMaxIterations(iterations);
|
mxOrganicLayout.setMaxIterations(iterations);
|
||||||
|
@ -55,7 +55,7 @@ final class mxGraphImpl extends mxGraph {
|
|||||||
|
|
||||||
static final private mxStylesheet mxStylesheet = new mxStylesheet();
|
static final private mxStylesheet mxStylesheet = new mxStylesheet();
|
||||||
private final HashSet<AccountDeviceInstanceKey> pinnedAccountDevices = new HashSet<>();
|
private final HashSet<AccountDeviceInstanceKey> pinnedAccountDevices = new HashSet<>();
|
||||||
private final HashSet<AccountDeviceInstanceKey> lockedAccountDevices = new HashSet<>();
|
private final HashSet<mxCell> lockedVertices = new HashSet<>();
|
||||||
|
|
||||||
private final Map<String, mxCell> nodeMap = new HashMap<>();
|
private final Map<String, mxCell> nodeMap = new HashMap<>();
|
||||||
private final Multimap<Content, mxCell> edgeMap = MultimapBuilder.hashKeys().hashSetValues().build();
|
private final Multimap<Content, mxCell> edgeMap = MultimapBuilder.hashKeys().hashSetValues().build();
|
||||||
@ -123,23 +123,6 @@ final class mxGraphImpl extends mxGraph {
|
|||||||
// };
|
// };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCellMovable(Object cell) {
|
|
||||||
final mxICell mxCell = (mxICell) cell;
|
|
||||||
if (mxCell.isEdge()) {
|
|
||||||
return super.isCellMovable(cell);
|
|
||||||
} else {
|
|
||||||
final boolean cellMovable = super.isCellMovable(cell);
|
|
||||||
final boolean unlocked = false == lockedAccountDevices.contains((AccountDeviceInstanceKey) mxCell.getValue());
|
|
||||||
|
|
||||||
if (cellMovable && unlocked) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
nodeMap.clear();
|
nodeMap.clear();
|
||||||
edgeMap.clear();
|
edgeMap.clear();
|
||||||
@ -163,10 +146,10 @@ final class mxGraphImpl extends mxGraph {
|
|||||||
if (pinnedAccountDevices.contains(adiKey)) {
|
if (pinnedAccountDevices.contains(adiKey)) {
|
||||||
label += "<img src=\"" + MARKER_PIN_URL + "\">";
|
label += "<img src=\"" + MARKER_PIN_URL + "\">";
|
||||||
}
|
}
|
||||||
if (lockedAccountDevices.contains(adiKey)) {
|
if (lockedVertices.contains((mxCell) cell)) {
|
||||||
label += "<img src=\"" + LOCK_URL + "\">";
|
label += "<img src=\"" + LOCK_URL + "\">";
|
||||||
}
|
}
|
||||||
return "<div width=\"" + (Math.sqrt(adiKey.getMessageCount()) + 10) + "\">" + label + "</div>";
|
return "<div style=\" font-size: "+ (Math.log(adiKey.getMessageCount())+10)+ "px;\" >" + label + "</div>";
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -185,12 +168,21 @@ final class mxGraphImpl extends mxGraph {
|
|||||||
pinnedAccountDevices.addAll(accountDeviceInstances);
|
pinnedAccountDevices.addAll(accountDeviceInstances);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lockAccount(AccountDeviceInstanceKey accountDeviceInstance) {
|
void lockVertex(mxCell vertex) {
|
||||||
lockedAccountDevices.add(accountDeviceInstance);
|
lockedVertices.add(vertex);
|
||||||
|
|
||||||
|
final mxCellState state = getView().getState(vertex, true);
|
||||||
|
getView().clear(vertex, true, true);
|
||||||
|
getView().validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void unlockAccount(AccountDeviceInstanceKey accountDeviceInstance) {
|
void unlockVertex(mxCell vertex) {
|
||||||
lockedAccountDevices.remove(accountDeviceInstance);
|
lockedVertices.remove(vertex);
|
||||||
|
|
||||||
|
final mxCellState state = getView().getState(vertex, true);
|
||||||
|
getView().updateLabel(state);
|
||||||
|
getView().updateLabelBounds(state);
|
||||||
|
getView().updateBoundingBox(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
SwingWorker<?, ?> rebuild(ProgressIndicator progress, CommunicationsManager commsManager, CommunicationsFilter currentFilter) {
|
SwingWorker<?, ?> rebuild(ProgressIndicator progress, CommunicationsManager commsManager, CommunicationsFilter currentFilter) {
|
||||||
@ -201,7 +193,7 @@ final class mxGraphImpl extends mxGraph {
|
|||||||
void resetGraph() {
|
void resetGraph() {
|
||||||
clear();
|
clear();
|
||||||
pinnedAccountDevices.clear();
|
pinnedAccountDevices.clear();
|
||||||
lockedAccountDevices.clear();
|
lockedVertices.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private mxCell getOrCreateVertex(AccountDeviceInstanceKey accountDeviceInstanceKey) {
|
private mxCell getOrCreateVertex(AccountDeviceInstanceKey accountDeviceInstanceKey) {
|
||||||
@ -258,8 +250,8 @@ final class mxGraphImpl extends mxGraph {
|
|||||||
return getView().getScale();
|
return getView().getScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isAccountLocked(AccountDeviceInstanceKey adiKey) {
|
boolean isVertexLocked(mxCell vertex) {
|
||||||
return lockedAccountDevices.contains(adiKey);
|
return lockedVertices.contains(vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SwingWorkerImpl extends SwingWorker<Void, Void> {
|
private class SwingWorkerImpl extends SwingWorker<Void, Void> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user