Skip to content

Commit

Permalink
Drop minimum supported Java version to 11
Browse files Browse the repository at this point in the history
  • Loading branch information
FeldrinH committed Sep 19, 2023
1 parent 4fac7aa commit a9ac773
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 16
java-version: 11
- uses: gradle/wrapper-validation-action@v1
- uses: gradle/gradle-build-action@v2
- run: ./gradlew check shadowJar
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
languageVersion.set(JavaLanguageVersion.of(11))
}
}

Expand Down
54 changes: 21 additions & 33 deletions src/main/java/ee/ut/dendroloj/GraphGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,27 @@ public static void init(double uiScale) {
Graph graph = new SingleGraph("DendroloJ");
graph.setAttribute("ui.quality");
graph.setAttribute("ui.antialias");
graph.setAttribute("ui.stylesheet", String.format(Locale.ROOT, """
edge {
size: %fpx;
text-size: %f;
text-alignment: center;
text-background-mode: plain;
text-background-color: rgba(255, 255, 255, 180);
text-padding: %f;
text-offset: 5, 0;
}
edge .returned {
fill-color: gray;
}
node {
size: %fpx;
text-size: %f;
text-alignment: at-right;
text-background-mode: plain;
text-background-color: rgba(255, 255, 255, 180);
text-padding: %f;
text-offset: 5, 0;
}
node.error {
fill-color: #fa4c29;
}
node:selected {
fill-color: #0096ff;
}
""", Math.sqrt(uiScale), uiScale * 12, uiScale + 1, Math.sqrt(uiScale) * 10, uiScale * 12, uiScale + 1));
graph.setAttribute("ui.stylesheet", String.format(Locale.ROOT,
"edge {" +
" size: %fpx; text-size: %f; text-alignment: center;" +
" text-background-mode: plain; text-background-color: rgba(255, 255, 255, 180);" +
" text-padding: %f; text-offset: 5, 0;" +
"}" +
"edge .returned {" +
" fill-color: gray;" +
"}" +
"node {" +
" size: %fpx; text-size: %f; text-alignment: at-right;" +
" text-background-mode: plain; text-background-color: rgba(255, 255, 255, 180);" +
" text-padding: %f; text-offset: 5, 0;" +
"}" +
"node.error {" +
" fill-color: #fa4c29;" +
"}" +
"node:selected {" +
" fill-color: #0096ff;" +
"}",
Math.sqrt(uiScale), uiScale * 12, uiScale + 1, Math.sqrt(uiScale) * 10, uiScale * 12, uiScale + 1));

JSlider stepSlider = new JSlider();
stepSlider.setPaintTicks(true);
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/ee/ut/dendroloj/SimpleTreeLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;


class SimpleTreeLayout {
Expand Down Expand Up @@ -83,11 +84,20 @@ private static void setActiveStep(int newActiveStep) {
activeStep = newActiveStep;
}

private record NodeMetaWrapper(CallTreeNode node, List<NodeMetaWrapper> children, double reservedWidth) {
private static class NodeMetaWrapper {
public final CallTreeNode node;
public final List<NodeMetaWrapper> children;
public final double reservedWidth;

public NodeMetaWrapper(CallTreeNode node, List<NodeMetaWrapper> children, double reservedWidth) {
this.node = node;
this.children = children;
this.reservedWidth = reservedWidth;
}
}

private static NodeMetaWrapper wrap(CallTreeNode node) {
List<NodeMetaWrapper> children = node.childStream().map(SimpleTreeLayout::wrap).toList();
List<NodeMetaWrapper> children = node.childStream().map(SimpleTreeLayout::wrap).collect(Collectors.toList());
double sum = children.stream().mapToDouble(c -> c.reservedWidth).sum();

return new NodeMetaWrapper(node, children, Math.max(1d, sum));
Expand Down Expand Up @@ -118,7 +128,7 @@ private static void updateGraph(NodeMetaWrapper meta, boolean hideNewElements, L
double reserve = meta.reservedWidth / meta.children.size();
double padding = reserve / 2;
for (int i = 0; i < meta.children.size(); i++) {
updateGraph(meta.children().get(i), hideNewElements, newElements,
updateGraph(meta.children.get(i), hideNewElements, newElements,
leftBoundary + padding + (reserve * i), y - layerHeight, layerHeight, current);
}

Expand Down
10 changes: 8 additions & 2 deletions src/test/java/OhtlikAsi.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import ee.ut.dendroloj.Grow;

public record OhtlikAsi(String tekst) {
public class OhtlikAsi {
public final String tekst;

public OhtlikAsi(String tekst) {
this.tekst = tekst;
}

@Grow
int fib(int n, OhtlikAsi a) {
if (n < 2) return n;
return fib(n - 2, a) + fib(n - 1, a);
}

// @Grow annotatsioon toString meetodil mida kutsutakse puu uuendamise ajal.
// @Grow annotatsioon toString meetodil mida kutsutakse puu uuendamise ajal
@Grow
@Override
public String toString() {
Expand Down

0 comments on commit a9ac773

Please sign in to comment.