Skip to content

Commit

Permalink
Fix #2350
Browse files Browse the repository at this point in the history
  • Loading branch information
mbastian committed Dec 30, 2022
1 parent 8ae43a4 commit 6d4ef9c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
Expand Up @@ -207,6 +207,9 @@ public void saveProperties(Layout layout) {
}

public void loadProperties(Layout layout) {
// In case some properties are only locally defined (like cooling in ForceAtlas)
layout.resetPropertiesValues();

List<LayoutPropertyKey> layoutValues = new ArrayList<>();
for (LayoutPropertyKey val : savedProperties.keySet()) {
if (val.layoutClassName.equals(layout.getClass().getName())) {
Expand Down
@@ -0,0 +1,20 @@
package org.gephi.layout;

import org.gephi.layout.utils.MockLayout;
import org.gephi.layout.utils.MockLayoutBuilder;
import org.gephi.layout.utils.Utils;
import org.junit.Assert;
import org.junit.Test;

public class LayoutModelImplTest {

@Test
public void testLocalPropertyReset() throws Exception {
LayoutModelImpl layoutModel = Utils.newLayoutModel();
MockLayout layout = new MockLayoutBuilder().buildLayout();
Assert.assertNotEquals(42.0, layout.getLocalProperty(), 0.0);
layoutModel.setSelectedLayout(layout);

Assert.assertEquals(42.0, layout.getLocalProperty(), 0.0);
}
}
Expand Up @@ -15,6 +15,7 @@ public class MockLayout implements Layout {
private final MockLayoutBuilder builder;
private double angle;
private Column column;
private double localProperty = 0.0;

public MockLayout(MockLayoutBuilder builder) {
this.builder = builder;
Expand Down Expand Up @@ -70,7 +71,11 @@ public LayoutProperty[] getProperties() {

@Override
public void resetPropertiesValues() {
localProperty = 42.0;
}

public double getLocalProperty() {
return localProperty;
}

@Override
Expand Down

0 comments on commit 6d4ef9c

Please sign in to comment.