I developed a Java/JavaFX app that simulates the electrical field strenght of a cable as a 2D Heatmap (Image_Nr_1). The goal is for users to visually grasp the field distribution in their space.
Here's my current solution: I created a 2D array mirroring the canvas dimensions. Each cell holds an electrical field strength value, visualized by color. After the user draws a line (inputs: x_start, y_start, x_end, y_end, angle), I calculate local field values, add them to the global matrix, and update the canvas (Image_Nr_2). Unfortunately, the update causes significant lag.
Due to code complexity, bad design and inefficiency, I'm planning a rewrite. I'm considering switching to Python with Flet, using libraries like pandas and pycairo.
I thought of three ways of how I could improve the current algorythm design:
Option 1: Use pandas to operate similarly to my current method in the backend, however, create a local matrix for each device ( Image_Nr_3). This seems feasible, with SVG output facilitating device movement and being considerably smaller than JPEG/PNG in this case(as in theory only the min values of each color zone would need to be traced with a path fill or so). However, implementing multiple devices (Image_Nr_4) might be a challenge. This solution would work well when using Flet, as i could then add/remove a gesturedetector container for each new device added to the Canvas
Option 2: Stick with the matrix uptdating approach. Yet here would be the question of how can I selectively update only the changed part of the image in Flet, without replacing the entire image everytime a change has been made to the canvas?
Option 3: Combine both approaches — use a background image to display values for heat map in raster or (ideally) vector graphic format and provide individual gesturedetector containers, which would contain the black device line, for device manipulation. This requires addressing issues from both options.
I've been working on solving the above mentioned issues and have been experimenting with Flet and python. The first approach works, but not yet for overlapping heatmaps (as mentioned as the issue in the first approach). The second approach also partly works, but only by updating the entire image in the Flet Container.
Further, I have looked into libraries such as geopandas, as this is in theory exactly what I want -> would need to draw the polygons depending on the shape of the current heatmap.
I am seeking advice on the most efficient approach and potential solutions for handling multiple devices. Any insights are greatly appreciated!
Aucun commentaire:
Enregistrer un commentaire