mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 19:14:55 +00:00
improve layout and zooming controls
This commit is contained in:
parent
5d948b7dfd
commit
168cc8bea6
@ -35,3 +35,5 @@ VisualizationPanel.circleLayoutButton.text=Circle
|
|||||||
VisualizationPanel.OrganicLayoutButton.text=Organic
|
VisualizationPanel.OrganicLayoutButton.text=Organic
|
||||||
VisualizationPanel.fastOrganicLayoutButton.text=Fast Organic
|
VisualizationPanel.fastOrganicLayoutButton.text=Fast Organic
|
||||||
VisualizationPanel.hierarchyLayoutButton.text=Hierarchy
|
VisualizationPanel.hierarchyLayoutButton.text=Hierarchy
|
||||||
|
VisualizationPanel.jLabel2.text=Zoom:
|
||||||
|
VisualizationPanel.zoomLabel.text=100%
|
||||||
|
@ -165,7 +165,11 @@
|
|||||||
<Component id="zoomActualButton" min="-2" pref="33" max="-2" attributes="0"/>
|
<Component id="zoomActualButton" min="-2" pref="33" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="fitZoomButton" min="-2" pref="32" max="-2" attributes="0"/>
|
<Component id="fitZoomButton" min="-2" pref="32" max="-2" attributes="0"/>
|
||||||
<EmptySpace pref="214" max="32767" attributes="0"/>
|
<EmptySpace pref="110" max="32767" attributes="0"/>
|
||||||
|
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="zoomLabel" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace min="-2" pref="27" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
@ -184,6 +188,8 @@
|
|||||||
<Component id="zoomInButton" alignment="2" max="32767" attributes="0"/>
|
<Component id="zoomInButton" alignment="2" max="32767" attributes="0"/>
|
||||||
<Component id="zoomActualButton" alignment="2" max="32767" attributes="0"/>
|
<Component id="zoomActualButton" alignment="2" max="32767" attributes="0"/>
|
||||||
<Component id="fitZoomButton" alignment="2" max="32767" attributes="0"/>
|
<Component id="fitZoomButton" alignment="2" max="32767" attributes="0"/>
|
||||||
|
<Component id="jLabel2" alignment="2" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="zoomLabel" alignment="2" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace min="-2" pref="3" max="-2" attributes="0"/>
|
<EmptySpace min="-2" pref="3" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
@ -316,6 +322,20 @@
|
|||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="fitZoomButtonActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="fitZoomButtonActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||||
|
<ResourceString bundle="org/sleuthkit/autopsy/communications/Bundle.properties" key="VisualizationPanel.jLabel2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="zoomLabel">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||||
|
<ResourceString bundle="org/sleuthkit/autopsy/communications/Bundle.properties" key="VisualizationPanel.zoomLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
|
@ -43,6 +43,7 @@ import java.awt.event.MouseAdapter;
|
|||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseWheelEvent;
|
import java.awt.event.MouseWheelEvent;
|
||||||
import java.beans.PropertyVetoException;
|
import java.beans.PropertyVetoException;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import static java.util.Collections.singleton;
|
import static java.util.Collections.singleton;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
@ -138,41 +139,25 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
|
|
||||||
//install rubber band selection handler
|
//install rubber band selection handler
|
||||||
rubberband = new mxRubberband(graphComponent);
|
rubberband = new mxRubberband(graphComponent);
|
||||||
// new mxLayoutManager(graph) {
|
|
||||||
// final private mxOrganicLayout layout;
|
graph.getView().addListener(mxEvent.SCALE, (Object sender, mxEventObject evt) -> {
|
||||||
// private int counter;
|
zoomLabel.setText(DecimalFormat.getPercentInstance().format(graph.getScale()));
|
||||||
// {
|
});
|
||||||
// this.layout = new mxOrganicLayout(graph);
|
|
||||||
// this.layout.setMaxIterations(1);
|
graph.getView().addListener(mxEvent.SCALE_AND_TRANSLATE, (Object sender, mxEventObject evt) -> {
|
||||||
// }
|
zoomLabel.setText(DecimalFormat.getPercentInstance().format(graph.getScale()));
|
||||||
//
|
});
|
||||||
// @Override
|
final MouseAdapter mouseAdapter = new MouseAdapter() {
|
||||||
// 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;
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//right click handler
|
|
||||||
graphComponent.getGraphControl().addMouseListener(new MouseAdapter() {
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||||
super.mouseWheelMoved(e);
|
super.mouseWheelMoved(e);
|
||||||
if (e.getPreciseWheelRotation() > 0) {
|
if (e.getPreciseWheelRotation() > 0) {
|
||||||
graphComponent.zoomIn();
|
graphComponent.zoomTo(graph.getScale() / graphComponent.getZoomFactor(), true);
|
||||||
|
// graphComponent.zoomIn();
|
||||||
} else if (e.getPreciseWheelRotation() < 0) {
|
} else if (e.getPreciseWheelRotation() < 0) {
|
||||||
graphComponent.zoomOut();
|
graphComponent.zoomTo(graph.getScale() * graphComponent.getZoomFactor(), true);
|
||||||
|
// graphComponent.zoomOut();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,14 +177,14 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
jPopupMenu.add(new JMenuItem(new AbstractAction("Lock Account " + cellAt.getId(), unlockIcon) {
|
jPopupMenu.add(new JMenuItem(new AbstractAction("Lock Account " + cellAt.getId(), lockIcon) {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
graph.lockAccount((AccountDeviceInstanceKey) cellAt.getValue());
|
graph.lockAccount((AccountDeviceInstanceKey) cellAt.getValue());
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
jPopupMenu.add(new JMenuItem(new AbstractAction("UnLock Account " + cellAt.getId(), lockIcon) {
|
jPopupMenu.add(new JMenuItem(new AbstractAction("UnLock Account " + cellAt.getId(), unlockIcon) {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
graph.unlockAccount((AccountDeviceInstanceKey) cellAt.getValue());
|
graph.unlockAccount((AccountDeviceInstanceKey) cellAt.getValue());
|
||||||
@ -223,7 +208,10 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
//right click handler
|
||||||
|
graphComponent.getGraphControl().addMouseWheelListener(mouseAdapter);
|
||||||
|
graphComponent.getGraphControl().addMouseListener(mouseAdapter);
|
||||||
|
|
||||||
splitPane.setRightComponent(new MessageBrowser(vizEM, gacEM));
|
splitPane.setRightComponent(new MessageBrowser(vizEM, gacEM));
|
||||||
|
|
||||||
@ -372,6 +360,8 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
zoomInButton = new JButton();
|
zoomInButton = new JButton();
|
||||||
zoomActualButton = new JButton();
|
zoomActualButton = new JButton();
|
||||||
fitZoomButton = new JButton();
|
fitZoomButton = new JButton();
|
||||||
|
jLabel2 = new JLabel();
|
||||||
|
zoomLabel = new JLabel();
|
||||||
|
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
|
|
||||||
@ -515,6 +505,10 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jLabel2.setText(NbBundle.getMessage(VisualizationPanel.class, "VisualizationPanel.jLabel2.text")); // NOI18N
|
||||||
|
|
||||||
|
zoomLabel.setText(NbBundle.getMessage(VisualizationPanel.class, "VisualizationPanel.zoomLabel.text")); // NOI18N
|
||||||
|
|
||||||
GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
|
GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
|
||||||
jPanel2.setLayout(jPanel2Layout);
|
jPanel2.setLayout(jPanel2Layout);
|
||||||
jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(GroupLayout.LEADING)
|
jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(GroupLayout.LEADING)
|
||||||
@ -539,7 +533,11 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
.add(zoomActualButton, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
|
.add(zoomActualButton, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(LayoutStyle.RELATED)
|
.addPreferredGap(LayoutStyle.RELATED)
|
||||||
.add(fitZoomButton, GroupLayout.PREFERRED_SIZE, 32, GroupLayout.PREFERRED_SIZE)
|
.add(fitZoomButton, GroupLayout.PREFERRED_SIZE, 32, GroupLayout.PREFERRED_SIZE)
|
||||||
.addContainerGap(214, Short.MAX_VALUE))
|
.addPreferredGap(LayoutStyle.RELATED, 110, Short.MAX_VALUE)
|
||||||
|
.add(jLabel2)
|
||||||
|
.addPreferredGap(LayoutStyle.RELATED)
|
||||||
|
.add(zoomLabel)
|
||||||
|
.add(27, 27, 27))
|
||||||
);
|
);
|
||||||
jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(GroupLayout.LEADING)
|
jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(GroupLayout.LEADING)
|
||||||
.add(jPanel2Layout.createSequentialGroup()
|
.add(jPanel2Layout.createSequentialGroup()
|
||||||
@ -554,7 +552,9 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
.add(zoomOutButton)
|
.add(zoomOutButton)
|
||||||
.add(zoomInButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.add(zoomInButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.add(zoomActualButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.add(zoomActualButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.add(fitZoomButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
.add(fitZoomButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.add(jLabel2)
|
||||||
|
.add(zoomLabel))
|
||||||
.add(3, 3, 3))
|
.add(3, 3, 3))
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -610,17 +610,31 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fitGraph() {
|
private void fitGraph() {
|
||||||
final Object[] childVertices = graph.getChildVertices(graph.getDefaultParent());
|
|
||||||
mxRectangle boundsForCells = graph.getBoundsForCells(childVertices, true, true, true);
|
|
||||||
if (boundsForCells == null) {
|
|
||||||
boundsForCells = new mxRectangle();
|
|
||||||
}
|
|
||||||
mxPoint translate = graph.getView().getTranslate();
|
mxPoint translate = graph.getView().getTranslate();
|
||||||
if (translate == null) {
|
if (translate == null || Double.isNaN(translate.getX()) || Double.isNaN(translate.getY())) {
|
||||||
translate = new mxPoint();
|
translate = new mxPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mxRectangle boundsForCells = graph.getCellBounds(graph.getDefaultParent(), true, true, true);
|
||||||
|
if (boundsForCells == null||Double.isNaN( boundsForCells.getWidth()) || Double.isNaN(boundsForCells.getHeight())) {
|
||||||
|
boundsForCells = new mxRectangle(0,0,1,1);
|
||||||
|
}
|
||||||
graph.getView().setTranslate(new mxPoint(translate.getX() - boundsForCells.getX(), translate.getY() - boundsForCells.getY()));
|
graph.getView().setTranslate(new mxPoint(translate.getX() - boundsForCells.getX(), translate.getY() - boundsForCells.getY()));
|
||||||
|
|
||||||
|
boundsForCells = graph.getCellBounds(graph.getDefaultParent(), true, true, true);
|
||||||
|
if (boundsForCells == null||Double.isNaN( boundsForCells.getWidth()) || Double.isNaN(boundsForCells.getHeight())) {
|
||||||
|
boundsForCells = new mxRectangle(0,0,1,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Dimension size = graphComponent.getSize();
|
||||||
|
|
||||||
|
double widthFactor = size.getWidth() / boundsForCells.getWidth();
|
||||||
|
// widthFactor = boundsForCells.getWidth() / size.getWidth();
|
||||||
|
|
||||||
|
graphComponent.zoom(widthFactor);
|
||||||
|
|
||||||
|
// bounds = graph.getGraphBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void morph(mxIGraphLayout layout) {
|
private void morph(mxIGraphLayout layout) {
|
||||||
@ -655,6 +669,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
private JButton fitZoomButton;
|
private JButton fitZoomButton;
|
||||||
private JButton hierarchyLayoutButton;
|
private JButton hierarchyLayoutButton;
|
||||||
private JLabel jLabel1;
|
private JLabel jLabel1;
|
||||||
|
private JLabel jLabel2;
|
||||||
private JPanel jPanel1;
|
private JPanel jPanel1;
|
||||||
private JPanel jPanel2;
|
private JPanel jPanel2;
|
||||||
private JToolBar.Separator jSeparator1;
|
private JToolBar.Separator jSeparator1;
|
||||||
@ -666,6 +681,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider
|
|||||||
private JLabel statusLabel;
|
private JLabel statusLabel;
|
||||||
private JButton zoomActualButton;
|
private JButton zoomActualButton;
|
||||||
private JButton zoomInButton;
|
private JButton zoomInButton;
|
||||||
|
private JLabel zoomLabel;
|
||||||
private JButton zoomOutButton;
|
private JButton zoomOutButton;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
|
@ -93,6 +93,33 @@ 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;
|
||||||
|
// }
|
||||||
|
// };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -214,7 +241,12 @@ final class mxGraphImpl extends mxGraph {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean hasPinnedAccounts() {
|
boolean hasPinnedAccounts() {
|
||||||
return pinnedAccountDevices.isEmpty() == false; }
|
return pinnedAccountDevices.isEmpty() == false;
|
||||||
|
}
|
||||||
|
|
||||||
|
double getScale() {
|
||||||
|
return getView().getScale();
|
||||||
|
}
|
||||||
|
|
||||||
class SwingWorkerImpl extends SwingWorker<Void, Void> {
|
class SwingWorkerImpl extends SwingWorker<Void, Void> {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user