I extended the functionality of a line object using a class which takes a line handle as an input argument to its constructor. This class then creates a WindowMouseMotion
listener to detect a mouseover the line which highlights the line and displays a panel containing controls for setting some line/data properties. This is working well.
I am now trying to make this class detect and respond to the line being deleted by listening for the line's ObjectBeingDestroyed
event. My question is whether linking this class to the line object by storing the line's handle is the best solution or is it possible to extend the line class by inheriting from it? I have looked through the MATLAB documentation and searched online but can't find definitive information on inheriting from graphics classes.
It is possible to subclass the builtin handle graphics classes. There is an example at http://undocumentedmatlab.com/blog/udd-properties/ . It uses the specifically undocumented UDD mechanism. The MathWorks has stated on numerous occasions that UDD is for internal development and use only and unsupported. It is worth noting however that there are numerous examples of UDD subclassing in the m code that The MathWorks provides. Also IF they feel that there is a specific reason to keep something in UDD secret it is either built-in or pcoded. So I feel that if you find examples of how to do things in the source code provided by The MathWorks you should feel free to use them.
Got this response over at MATLAB Central Answers: "There is no documented way to inherit from (/subclass) handle graphic objects. I guess the rule is that if you cannot find it in the documentation it is not supported."
There is a suggestion that it may be possible to extend the new HG2 classes here but this is not official Mathworks information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With