Skip to content

Commit

Permalink
Change public configuration API
Browse files Browse the repository at this point in the history
  • Loading branch information
FeldrinH committed Sep 19, 2023
1 parent a9ac773 commit b867390
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
38 changes: 24 additions & 14 deletions src/main/java/ee/ut/dendroloj/Dendrologist.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,45 @@ public class Dendrologist {

private static boolean awake = false;

// Startup settings
private static double uiScale = 1.0;

// Runtime settings
protected static boolean showMethodNames = true;

private Dendrologist() {
}

/**
* Wakes up dendrologist with default configuration.
* Sets multiplier for size of UI elements (text, nodes, etc.).
* <p>
* Default: {@code 1.0}
*/
public static void wakeUp() {
init(1.0, true);
public static void setUIScale(double uiScale) {
Dendrologist.uiScale = uiScale;
}

/**
* Wakes up dendrologist with custom configuration.
*
* @param uiScale sets scaling multiplier for UI elements (text and nodes). default: 1.0
* @param showMethodNames if enabled shows method name for each method call. default: true
* Sets whether to show method names in call tree or not.
* <p>
* Default: {@code true}
*/
public static void wakeUp(double uiScale, boolean showMethodNames) {
init(uiScale, showMethodNames);
public static void setShowMethodNames(boolean showMethodNames) {
Dendrologist.showMethodNames = showMethodNames;
}

private static void init(double uiScale, boolean showMethodNames) {
if (awake) return;
/**
* Wakes up dendrologist.
*/
public static void wakeUp() {
init();
}

Dendrologist.showMethodNames = showMethodNames;
private static void init() {
if (awake) return;

initTracing();
initGraphics(uiScale);
initGraphics();

awake = true;
}
Expand All @@ -44,7 +54,7 @@ private static void initTracing() {
AgentTracer.init();
}

private static void initGraphics(double uiScale) {
private static void initGraphics() {
GraphGUI.init(uiScale);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/Katsed.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ static void juhuslikHargnemine(int n) {
}

public static void main(String[] args) {
Dendrologist.setUIScale(1.5);
Dendrologist.setShowMethodNames(false);

Dendrologist.wakeUp();

// fib(16);
Expand Down

0 comments on commit b867390

Please sign in to comment.