Skip to content

Commit b111d5d

Browse files
release: VisuStruct 1.2.1
Fix simulation branch selection (true/false by case name), reset rebuilds steps for new input on rerun, and save applies pending editor text with a more reliable macOS save dialog. Adds configurable play delay, diagram highlight improvements, and engine/path tests. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 2aa1ef0 commit b111d5d

20 files changed

Lines changed: 741 additions & 88 deletions

File tree

‎README.md‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ git clone https://github.com/code4teaching/VisuStruct.git
2222

2323
---
2424

25+
## Changes in 1.2.1 (summary)
26+
27+
- **Simulation:** correct **true/false** branch selection after swapped branches; **reset (Stop)** rebuilds the step list and accepts a **new input** on rerun.
28+
- **Save:** pending **element-editor** text is applied before save; more reliable save dialog on **macOS**.
29+
30+
Full notes: [`release-notes/v1.2.1.md`](release-notes/v1.2.1.md).
31+
2532
## Changes in 1.2.0 (summary)
2633

2734
- **Simulation (prep):** **Kotlin** in the Maven build; **`SimulationDocument`** and related types plus **XML decode** aligned with the existing diagram file format; **`Struktogramm.toSimulationDocument()`** exports the current editor state for a future **`step()`** engine (no simulation UI yet).
@@ -133,7 +140,7 @@ This release aligns **branding and technical identity** with **VisuStruct**. **`
133140
- **Java 17** target (build and run with JDK 17+).
134141
- **FlatLaf** light/dark themes; **JDOM2**; no legacy AppleJavaExtensions.
135142
- **Motif** look-and-feel removed; **Metal** and FlatLaf available.
136-
- Current fat JAR name follows **`pom.xml`** **`version`** (e.g. **`visustruct-1.2.0.jar`**).
143+
- Current fat JAR name follows **`pom.xml`** **`version`** (e.g. **`visustruct-1.2.1.jar`**).
137144

138145
---
139146

@@ -208,13 +215,13 @@ chmod +x mvnw
208215
Output (version from `pom.xml`):
209216

210217
```text
211-
target/visustruct-1.2.0.jar
218+
target/visustruct-1.2.1.jar
212219
```
213220

214221
## Run
215222

216223
```bash
217-
java -jar target/visustruct-1.2.0.jar
224+
java -jar target/visustruct-1.2.1.jar
218225
```
219226

220227
Double-click may work if `.jar` is associated with Java.

‎packaging/macos/build-lightweight-app.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
set -euo pipefail
55
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
66
ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
7-
VER="${PROJECT_VERSION:-1.2.0}"
7+
VER="${PROJECT_VERSION:-1.2.1}"
88
JAR_NAME="visustruct-${VER}.jar"
99
OUT="${ROOT}/dist/macos-app-light"
1010
APP="${OUT}/VisuStruct.app"

‎packaging/macos/build-macos-app.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Voraussetzung: JDK 17+ mit jpackage (im PATH oder JAVA_HOME).
55
set -euo pipefail
66
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
7-
VER="${PROJECT_VERSION:-1.2.0}"
7+
VER="${PROJECT_VERSION:-1.2.1}"
88
JAR="visustruct-${VER}.jar"
99
INPUT="${ROOT}/target"
1010
OUT="${ROOT}/dist/macos-app"

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>de.visustruct</groupId>
66
<artifactId>visustruct</artifactId>
7-
<version>1.2.0</version>
7+
<version>1.2.1</version>
88
<name>VisuStruct</name>
99

1010
<properties>

‎release-notes/v1.2.1.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# VisuStruct 1.2.1
2+
3+
Patch release **after** **1.2.0**.
4+
5+
## Simulation
6+
7+
- **Verzweigung:** Zweige mit Fallnamen `true` / `false` werden nach Namen gewählt (nicht nur nach XML-Reihenfolge) — z. B. nach „Zweige vertauschen“ und Speichern.
8+
- **Reset (Stopp):** Schrittliste wird wieder aus dem Diagramm aufgebaut; **neue Eingabe** bei erneutem Lauf (nicht mehr die erste Zahl).
9+
- **Modulo / Vergleich:** numerische `String`-Werte in Ausdrücken robuster.
10+
11+
## Speichern
12+
13+
- **Element-Editor:** ausstehender Text wird vor **Speichern** ins Diagramm übernommen (wie vor Simulation).
14+
- **macOS:** Speicherdialog beim ersten Speichern zuverlässiger (`invokeLater`); fehlende Zielordner werden angelegt.
15+
16+
## Build
17+
18+
- Maven: **`de.visustruct:visustruct:1.2.1`**
19+
- Fat JAR: **`visustruct-1.2.1.jar`** (`./mvnw package` → `target/`)

‎src/main/java/de/visustruct/control/Controlling.java‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,34 @@ public Struktogramm neuesStruktogramm(){
212212

213213
public void speichern(boolean neuenSpeicherpfadAuswaehlenLassen){
214214
Struktogramm str = gibAktuellesStruktogramm();
215-
216-
if(str != null){
217-
GlobalSettings.setzeSpeicherpfad(str.speichern(neuenSpeicherpfadAuswaehlenLassen,GlobalSettings.getZuletztGenutzterSpeicherpfad()));//Struktogramm wird gespeichert (zuletztGenutzterSpeicherpfad wird dabei übergeben, damit der JFileChooser, sofern er genutzt wird, dort startet) und der neue Speicherpfad wird gesichert
215+
if (str == null) {
216+
return;
217+
}
218+
flushPendingDiagramEdits();
219+
Runnable saveTask = () -> {
220+
GlobalSettings.setzeSpeicherpfad(str.speichern(neuenSpeicherpfadAuswaehlenLassen,
221+
GlobalSettings.getZuletztGenutzterSpeicherpfad()));
218222
String p = str.gibAktuellenSpeicherpfad();
219223
if (!p.isEmpty()) {
220224
GlobalSettings.rememberRecentStruktogrammPath(p);
221225
}
222226
GlobalSettings.saveSettings();
223227
titelleisteAktualisieren();
224228
gui.rebuildMenuBar();
229+
};
230+
// macOS: Speicherdialog nach Modal (z. B. Tab umbenennen) erst im nächsten EDT-Takt
231+
if (neuenSpeicherpfadAuswaehlenLassen || str.gibAktuellenSpeicherpfad().isEmpty()) {
232+
SwingUtilities.invokeLater(saveTask);
233+
} else {
234+
saveTask.run();
225235
}
226236
}
227237

238+
/** Editor-Text ins Diagramm übernehmen (wie vor Simulation), damit Speichern den sichtbaren Stand schreibt. */
239+
private void flushPendingDiagramEdits() {
240+
gui.gibElementEditorPanel().applyPendingTextToDiagram();
241+
}
242+
228243
public void laden(){
229244

230245
String pfad = Struktogramm.oeffnenDialog(GlobalSettings.getZuletztGenutzterSpeicherpfad(), gui);//Parameter ist der Startordner für den OpenDialog
@@ -371,6 +386,7 @@ public void actionPerformed(ActionEvent e) {
371386
break;
372387

373388
case quellcodeErzeugen:
389+
flushPendingDiagramEdits();
374390
new CodeErzeuger(gui, I18n.tr("menu.file.generateCode"), true, gibAktuellesStruktogramm());
375391
break;
376392

@@ -623,7 +639,7 @@ private void enterSimulation() {
623639
if (gui.gibTabbedpane().getTabCount() <= 0) {
624640
return;
625641
}
626-
gui.gibElementEditorPanel().applyPendingTextToDiagram();
642+
flushPendingDiagramEdits();
627643
Struktogramm str = gibAktuellesStruktogramm();
628644
if (str == null) {
629645
return;

‎src/main/java/de/visustruct/control/GlobalSettings.java‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ private static Font createPreferredDiagramSansFont(int size) {
121121
/** Textpaket für neu eingefügte Elemente (siehe {@link ElementBeschriftungPresets}). */
122122
private static int elementBeschriftungPresetIndex = ElementBeschriftungPresets.PRESET_ENGLISH_JAVA;
123123

124+
/** Erlaubte Pausen (Sekunden) zwischen zwei Schritten bei Simulations-Wiedergabe. */
125+
public static final double[] SIMULATION_PLAY_DELAY_SECONDS = { 0.2, 0.5, 0.75, 1.0, 1.5, 2.0 };
126+
127+
private static final double DEFAULT_SIMULATION_PLAY_DELAY_SEC = 0.5;
128+
129+
private static double simulationPlayDelaySec = DEFAULT_SIMULATION_PLAY_DELAY_SEC;
130+
124131
/**
125132
* Extended-Modifier-Maske für Menü-Kurzbefehle (Strg bzw. ⌘), z. B. für
126133
* {@link javax.swing.KeyStroke#getKeyStroke(int, int)} und {@code KeyEvent#getModifiersEx()}.
@@ -345,6 +352,15 @@ private static void applySettingsFromProperties(Properties pr) {
345352
uiLanguageFromPropertiesFile = true;
346353
}
347354

355+
s = pr.getProperty("simulationplaydelay");
356+
if (s != null && !s.isBlank()) {
357+
try {
358+
setSimulationPlayDelaySec(Double.parseDouble(s.trim()));
359+
} catch (NumberFormatException ignored) {
360+
simulationPlayDelaySec = DEFAULT_SIMULATION_PLAY_DELAY_SEC;
361+
}
362+
}
363+
348364
recentDiagramPaths.clear();
349365
for (int i = 0; i < MAX_RECENT_DIAGRAM_FILES; i++) {
350366
s = pr.getProperty("recentdiagram" + i);
@@ -396,6 +412,8 @@ public static void saveSettings(){
396412

397413
properties.setProperty("uilanguage", uiLanguageTag);
398414

415+
properties.setProperty("simulationplaydelay", Double.toString(simulationPlayDelaySec));
416+
399417
for (int i = 0; i < MAX_RECENT_DIAGRAM_FILES; i++) {
400418
if (i < recentDiagramPaths.size()) {
401419
properties.setProperty("recentdiagram" + i, recentDiagramPaths.get(i));
@@ -661,4 +679,31 @@ public static boolean isUiGerman() {
661679
public static boolean isUiPortuguesePortugal() {
662680
return "pt_PT".equals(uiLanguageTag);
663681
}
682+
683+
public static double getSimulationPlayDelaySec() {
684+
return simulationPlayDelaySec;
685+
}
686+
687+
public static int getSimulationPlayDelayMs() {
688+
return Math.max(50, (int) Math.round(simulationPlayDelaySec * 1000.0));
689+
}
690+
691+
public static void setSimulationPlayDelaySec(double seconds) {
692+
for (double opt : SIMULATION_PLAY_DELAY_SECONDS) {
693+
if (Math.abs(opt - seconds) < 1e-9) {
694+
simulationPlayDelaySec = opt;
695+
return;
696+
}
697+
}
698+
simulationPlayDelaySec = DEFAULT_SIMULATION_PLAY_DELAY_SEC;
699+
}
700+
701+
public static int getSimulationPlayDelayIndex() {
702+
for (int i = 0; i < SIMULATION_PLAY_DELAY_SECONDS.length; i++) {
703+
if (Math.abs(SIMULATION_PLAY_DELAY_SECONDS[i] - simulationPlayDelaySec) < 1e-9) {
704+
return i;
705+
}
706+
}
707+
return 1;
708+
}
664709
}

‎src/main/java/de/visustruct/control/Struktogramm.java‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,14 @@ public StruktogrammElementListe gibListe(){
230230
* oder {@code null} bei ungültigem Pfad.
231231
*/
232232
public StruktogrammElement elementFuerSimulationPfadSuchen(List<Integer> path) {
233+
return elementFuerSimulationPfadSuchenExakt(path);
234+
}
235+
236+
/**
237+
* Liefert das Element zum exakten Pfad oder zum längsten gültigen Präfix
238+
* (falls der Engine-Pfad einen Schleifen-Inhalts-Marker o. Ä. enthält).
239+
*/
240+
public StruktogrammElement elementFuerSimulationPfadSuchenExakt(List<Integer> path) {
233241
if (path == null || path.isEmpty()) {
234242
return null;
235243
}
@@ -251,6 +259,10 @@ public StruktogrammElement elementFuerSimulationPfadSuchen(List<Integer> path) {
251259
}
252260
list = fa.gibListe(col);
253261
} else if (el instanceof Schleife sch) {
262+
// Wie SimulationEngine.buildSteps(..., pathPrefix + 0): nach Schleifenindex folgt 0 = Inhalt.
263+
if (pi < path.size()) {
264+
pi++;
265+
}
254266
list = sch.gibListe();
255267
} else {
256268
return null;
@@ -259,6 +271,19 @@ public StruktogrammElement elementFuerSimulationPfadSuchen(List<Integer> path) {
259271
return null;
260272
}
261273

274+
private StruktogrammElement elementFuerSimulationPfadSuchenMitFallback(List<Integer> path) {
275+
if (path == null || path.isEmpty()) {
276+
return null;
277+
}
278+
for (int len = path.size(); len > 0; len--) {
279+
StruktogrammElement el = elementFuerSimulationPfadSuchenExakt(path.subList(0, len));
280+
if (el != null) {
281+
return el;
282+
}
283+
}
284+
return null;
285+
}
286+
262287
/** Hebt höchstens ein Element im Diagramm hervor (Simulationsmodus). {@code null} oder leer = aus. */
263288
public void setzeSimulationSpotlightPfad(List<Integer> path) {
264289
if (simulationSpotlightElement != null) {
@@ -269,7 +294,7 @@ public void setzeSimulationSpotlightPfad(List<Integer> path) {
269294
zeichne();
270295
return;
271296
}
272-
StruktogrammElement el = elementFuerSimulationPfadSuchen(path);
297+
StruktogrammElement el = elementFuerSimulationPfadSuchenMitFallback(path);
273298
if (el != null) {
274299
el.setzeSimulationSpotlight(true);
275300
simulationSpotlightElement = el;
@@ -1271,10 +1296,15 @@ private void xmlAbspeichernOhneFileChooser(String pfad){
12711296
return;
12721297
}
12731298
try {
1299+
File ziel = new File(pfad);
1300+
File eltern = ziel.getParentFile();
1301+
if (eltern != null && !eltern.isDirectory() && !eltern.mkdirs()) {
1302+
throw new IOException("Verzeichnis konnte nicht angelegt werden: " + eltern.getAbsolutePath());
1303+
}
12741304
Document myDocument = xmlErstellen();
12751305
XMLOutputter outputter = new XMLOutputter();
12761306
outputter.setFormat(Format.getPrettyFormat());
1277-
try (Writer writer = new OutputStreamWriter(new FileOutputStream(pfad), StandardCharsets.UTF_8)) {
1307+
try (Writer writer = new OutputStreamWriter(new FileOutputStream(ziel), StandardCharsets.UTF_8)) {
12781308
outputter.output(myDocument, writer);
12791309
}
12801310
tabbedpane.titelFuerStruktogrammBearbeitetMarkieren(this, false);

‎src/main/java/de/visustruct/struktogrammelemente/StruktogrammElement.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,11 @@ protected void eigenenBereichZeichnen(){
368368
g.fillRect(gibX(), gibY(), gibBreite(), gibHoehe());
369369
g.setColor(CanvasStyle.getElementBorder());
370370
g.drawRect(gibX(), gibY(), gibBreite(), gibHoehe());
371-
if (markiert) {
371+
if (simulationSpotlight) {
372+
g.setStroke(new BasicStroke(CanvasStyle.SELECTION_LINE_WIDTH));
373+
g.setColor(CanvasStyle.getSelectionStroke());
374+
g.drawRect(gibX(), gibY(), gibBreite(), gibHoehe());
375+
} else if (markiert) {
372376
g.setStroke(new BasicStroke(CanvasStyle.SELECTION_LINE_WIDTH));
373377
g.setColor(CanvasStyle.getSelectionStroke());
374378
g.drawRect(gibX(), gibY(), gibBreite(), gibHoehe());

0 commit comments

Comments
 (0)