Implement Save/Load Functionality for Drawings #37

Open
opened 2026-03-27 23:18:14 +00:00 by thib8956 · 0 comments
Owner

Overview

Implement save and load functionality to persist and restore drawings.

Current State

  • Export to HTML and SVG exists (HTMLExporter, SVGExporter)
  • No serialization of full model state
  • No persistence

Implementation Plan

1. Serialization format

  • Use JSON for human-readable format
  • Or use Java Serialization for binary format
  • Store all shape data: type, position, size, attributes

2. Data structure

3. Save operation

  • Menu item: File > Save / Save As
  • Serialize SCollection to file
  • Use file chooser dialog
  • Default extension: .shapes or .json

4. Load operation

  • Menu item: File > Open
  • Deserialize from file
  • Replace current model contents
  • Clear selection
  • Reset view

5. Error handling

  • Invalid format: show error dialog
  • Missing shapes: log warning, continue
  • Version mismatch: migration or error

Files to create/modify

  • Create: persistence/ShapeSerializer.java
  • Create: persistence/ShapeDeserializer.java
  • Modify: App.java - add File menu items
  • Modify: SCollection.java - add serialization support if needed

Edge cases

  • Loading fails: keep current drawing, show error
  • Save to existing file: confirm overwrite
  • Empty drawing: save empty file (valid)
  • Forward compatibility: warn on newer versions
## Overview Implement save and load functionality to persist and restore drawings. ## Current State - Export to HTML and SVG exists (HTMLExporter, SVGExporter) - No serialization of full model state - No persistence ## Implementation Plan ### 1. Serialization format - Use JSON for human-readable format - Or use Java Serialization for binary format - Store all shape data: type, position, size, attributes ### 2. Data structure ### 3. Save operation - Menu item: File > Save / Save As - Serialize SCollection to file - Use file chooser dialog - Default extension: .shapes or .json ### 4. Load operation - Menu item: File > Open - Deserialize from file - Replace current model contents - Clear selection - Reset view ### 5. Error handling - Invalid format: show error dialog - Missing shapes: log warning, continue - Version mismatch: migration or error ## Files to create/modify - Create: persistence/ShapeSerializer.java - Create: persistence/ShapeDeserializer.java - Modify: App.java - add File menu items - Modify: SCollection.java - add serialization support if needed ## Edge cases - Loading fails: keep current drawing, show error - Save to existing file: confirm overwrite - Empty drawing: save empty file (valid) - Forward compatibility: warn on newer versions
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: thib8956/new-shapes#37