Persistent data for paintable canvas

I am trying to store persistent data for a paintable canvas. Specifically a background image, but possibly the entire graphics object. Or perhaps I’m coming at it the wrong way…

I’m making an app that shows where various pieces of equipment are located on a map. What I’ve got so far is that the repaint method will check for a locally disk cached version of the image, and redownload it if necessary. Once it’s got the background image, it will go through a list of tags that define the locations of the various pieces of equipment and place markers on the map for each one.

Where it’s not quite working how I like is in the update rate. Clicking buttons to pan and zoom works fine (modifying parameters used to scale and translate the graphics object) but dragging the image to pan is a little laggy. I’d like to skip the disk operation (retrieving the cached image data) and possibly the equipment rendering operation. I don’t see any way to create a custom property with an arbitrary datatype; is this something I can do via scripting? In other words, is there any memory-based storage I can use for arbitrary data that is persistent between repaint events?

Sort of. You can add odd property types by adding a DynamicPropertyDescriptor to a component’s custom properties via getDynamicProps(). Which will allow you to specify any java class you like for the content. However, whatever you put in this property must be serializable, and you cannot keep it from being saved in the designer as part of the component. It would be especially bad to assign a custom python class instance, as you would set yourself up to have an unopenable window at some point. (Been there…)
More here.

1 Like