Draw_Data: Implement new visualizers#3678
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces specialized visualization modes for binary and general trees within the Data Visualizer. It refactors the drawing logic into dedicated drawer classes and adds UI controls to switch between these modes. Feedback highlights a flaw in the binary tree validation logic that fails to check all branches, and an issue where TreeDepth is not reset, potentially causing layout errors during redraws. Additionally, the review points out unsafe non-null assertions in the tree drawers, the use of non-standard onMouseUp events for buttons, and the presence of unused dead code.
|
/gemini review |
|
I have reviewed the current state of the pull request. The implementation of the new visualizers is in place, and the requested OOP refactor is underway. Regarding your request for a final check on reviewer comments:
Since the PR is currently marked as a draft, please ensure all remaining refactoring tasks are completed and the code is fully tested before marking it as ready for final review. Let me know if you need any further assistance with specific parts of the implementation. |
martin-henz
left a comment
There was a problem hiding this comment.
Looks good now. All reviewer comments are addressed.
gemini bot confirmed that the reviewer comments are addressed.
Summary
This PR adds 2 new box-and-pointer visualizers for when the draw_data function is ran, so that now there are:
Type of Change
Added Functionality
Files Edited
src/features/dataVisualizer/[Documentation.md](http://documentation.md/)src/features/dataVisualizer/images/BINARY_TREE_IMAGE.pngsrc/features/dataVisualizer/images/GENERAL_TREE_IMAGE.pngsrc/features/dataVisualizer/images/ORIGINAL_VIEW_IMAGE.pngsrc/commons/sideContent/content/SideContentDataVisualizer.tsxsrc/features/dataVisualizer/dataVisualizer.tsxsrc/features/dataVisualizer/dataVisualizerTypes.tssrc/features/dataVisualizer/drawable/ArrayDrawable.tsxsrc/features/dataVisualizer/drawable/ArrowDrawable.tsxsrc/features/dataVisualizer/tree/ArrayTreeNode.tsxsrc/features/dataVisualizer/tree/BaseTreeNode.tssrc/features/dataVisualizer/tree/DrawableTreeNode.tsxsrc/features/dataVisualizer/tree/FunctionTreeNode.tsxsrc/features/dataVisualizer/tree/Tree.tsxsrc/commons/sagas/WorkspaceSaga/index.tssrc/features/dataVisualizer/Config.tsHow to Test
Run the following code in the Source Academy playground and open the Data Visualizer:
draw_data(list(1,2,3)): should only give error for “Render Binary Tree” mode.draw_data([1,2,3]): should only give errors for “Render Binary Tree” mode and “Render General Tree” mode.draw_data(list(1,list(2,null,null),list(3,null, null))): should not have any error, generates tree structures correctly in any of the 3 modes.The appropriate box-and-pointer diagram should be generated. Boxes belonging to the same node should be the same colour, while those from the neighbouring nodes should be in different colours. Examples are shown in the documentation file.
Checklist