Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

inheriting from MATLAB graphics objects

I need to create subclass of the Patch object's class in MATLAB 2014b but MATLAB does not allow me to do so:

Class 'matlab.graphics.primitive.Patch' is Sealed and may not be used as a superclass.

Is there a hack around this?

like image 981
Sia Avatar asked Dec 04 '25 12:12

Sia


1 Answers

No - you can't subclass a class that is Sealed, and matlab.graphics.primitive.Patch is a built-in class, so you can't make a (hack) edit to unseal it.

The best you can do is to use an Adapter pattern - create your own class, storing a Patch as a private (and maybe hidden) property, and then wrap all its properties and ones of your own, implementing set and get methods that pass through the value to/from the underlying Patch. Do something similar for any methods of Patch that you need. You may also need to listen to property change events on the Patch and respond to them appropriately.

Then you can add your own methods as well, and/or modify the existing method and property behavior as required.

like image 66
Sam Roberts Avatar answered Dec 06 '25 06:12

Sam Roberts