Skip to content

PAINTROID-761-3: Map and Transform Legacy Commands to Flutter Models - #173

Open
Amit-Matth wants to merge 5 commits into
Catrobat:developfrom
Amit-Matth:PAINTROID-761-model-transformer
Open

PAINTROID-761-3: Map and Transform Legacy Commands to Flutter Models#173
Amit-Matth wants to merge 5 commits into
Catrobat:developfrom
Amit-Matth:PAINTROID-761-model-transformer

Conversation

@Amit-Matth

Copy link
Copy Markdown
Contributor

This Pull Request is the third step of our 4-stage plan to add backward compatibility for legacy .catrobat files. It acts as the core translation layer, successfully mapping the raw binary models reconstructed in Stage 2 directly into modern Flutter commands and canvas states.

PAINTROID-761

New Features and Enhancements

  • Draw Command Transformation (LegacyModelTransformer): Implemented mapping logic for core drawing tools, translating LegacySerializablePath and path actions (Move, Line, Quad, Cubic, etc.) directly into Flutter Path objects.
  • Paint Mapping: Mapped legacy Paint attributes (color, stroke width, stroke cap, anti-aliasing) directly to modern Flutter Paint configurations.
  • Canvas State Command Transformation: Translated complex canvas coordinate and bounds transformations into their Flutter equivalents. Handled state operations including FlipCommand, RotateCommand, CropCommand, ResizeCommand, and ResetCommand.
  • Layer Management Translation: Built conversion logic to flatten and map legacy layer states into modern layer implementations (supporting operations like AddEmptyLayerCommand, SelectLayerCommand, RemoveLayerCommand, and LayerOpacityCommand).
  • Comprehensive Mapping Unit Testing: Added a complete suite of unit tests under test/unit/serialization/legacy_model_transformer_test.dart to verify the exact mapping parity across all translated commands. All tests are passing locally.

Backward Compatibility Roadmap

To make this feature easy to review and track, the work is organized into four sequential stages:

  1. Stage 1 (Completed - Foundational Binary Reader): The low-level KryoReader to parse bytes into basic Dart datatypes (ints, strings, doubles).
  2. Stage 2 (Completed - Registry & Model Parser): Setting up the class registry matching the native app's sequential registration IDs to reconstruct raw objects (like CommandManagerModel and ColorHistory).
  3. Stage 3 (This PR - Command Transformation): Converting those legacy Android commands (such as historical lines, shapes, and layer state changes) into their equivalent Flutter drawing commands via LegacyModelTransformer.
  4. Stage 4 (UI Performance & Fallbacks): Running the decoding logic on background isolates to keep the UI smooth during large file loads, and adding fallback renderers for legacy tools not yet supported by Flutter.

Refactorings and Bug Fixes

  • None (New feature architecture).

Checklist

Your checklist for this pull request

Please review the contributing guidelines and wiki pages of this repository.

  • Include the name of the Jira ticket in the PR’s title
  • Add the link to the ticket in Jira in the description of the PR
  • Include a summary of the changes plus the relevant context
  • Choose the proper base branch (develop)
  • Confirm that the changes follow the project’s coding guidelines (Wiki)
  • Verify that the changes generate no compiler or linter warnings
  • Perform a self-review of the changes
  • Verify to commit no other files than the intentionally changed ones
  • Include reasonable and readable tests verifying the added or changed behavior
  • Confirm that new and existing tests pass locally
  • Check that the commits’ message style matches the project’s guideline
  • Verify that your changes do not have any conflicts with the base branch
  • After the PR, verify that all CI checks have passed
  • Add new information to the Wiki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant