fixed initial scaling on small native display graph

This commit is contained in:
ghidravore 2021-12-13 16:42:03 -05:00
parent 9e73231814
commit 32c054d243

View File

@ -1079,7 +1079,7 @@ public class DefaultGraphDisplay implements GraphDisplay {
.elements(vertices)
.maxFactor(.05)
.buttonSupplier(JRadioButton::new)
.paintFunction(v -> graphDisplayOptions.getVertexColor(v))
.paintFunction(v -> Color.BLACK)
.build();
vertexFilters.addItemListener(item -> {
@ -1097,7 +1097,7 @@ public class DefaultGraphDisplay implements GraphDisplay {
.elements(edges)
.maxFactor(.01)
.buttonSupplier(JRadioButton::new)
.paintFunction(e -> graphDisplayOptions.getEdgeColor(e))
.paintFunction(e -> Color.BLACK)
.build();
edgeFilters.addItemListener(item -> {
@ -1115,8 +1115,16 @@ public class DefaultGraphDisplay implements GraphDisplay {
*/
private void configureViewerPreferredSize() {
int vertexCount = graph.vertexSet().size();
// attempt to set a reasonable size for the layout based on the number of vertices
Dimension viewSize = viewer.getPreferredSize();
// set the layoutModel's initials size to a minimal value. Not sure this should be necessary
// but it makes the initial scaling look better for small graphs. Otherwise it seems
// to use a very large area to layout the graph, resulting in tiny nodes that are spaced
// very far apart. This might just be a work around for a bug in some of the layout
// algorithms that don't seem to properly compute a good layout size.
viewer.getVisualizationModel().getLayoutModel().setSize(1, 1);
if (vertexCount < 100) {
viewer.getVisualizationModel()
.getLayoutModel()