Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
FeldrinH committed Mar 27, 2024
1 parent efece00 commit 669d2b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
8 changes: 1 addition & 7 deletions src/main/java/ee/ut/dendroloj/CallTreeLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

class CallTreeLayout {

static {
GraphGUI.initProperties();
}

public static final MetaTreeNode root = new MetaTreeNode();
private static TreeNode currentNode = root;

Expand All @@ -29,12 +25,10 @@ class CallTreeLayout {
public static final JSlider stepSlider;

static {
stepSlider = new JSlider();
stepSlider = new JSlider(0, 0, 0);
stepSlider.setEnabled(false);
stepSlider.setPaintTicks(true);
stepSlider.setMajorTickSpacing(1);
stepSlider.setMinimum(0);
stepSlider.setMaximum(0);
stepSlider.addChangeListener(event -> {
if (!internalSliderChange) {
setActiveStep(stepSlider.getValue());
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/ee/ut/dendroloj/Dendrologist.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
import java.awt.Color;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;

public final class Dendrologist {

static {
// Initialize global Swing and GraphStream properties as soon as possible
GraphGUI.initProperties();
}

private static boolean awake = false;

// Startup settings
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/ee/ut/dendroloj/GraphGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ class GraphGUI {
}

/**
* Initializes global Swing and GraphStream properties.
* This will be called automatically when the GUI is initialized.
* You should call this manually before creating Swing objects
* if you create Swing objects before GUI is initialized.
* Initializes global Swing and GraphStream properties. This will be called automatically when the GUI is initialized.
* To avoid issues this should also be called manually before any initialization code that might create Swing objects.
*/
public static void initProperties() {
// The actual initialization happens inside the static block above
Expand Down

0 comments on commit 669d2b1

Please sign in to comment.