OOP - Sealed Superclasses
Ältere Kommentare anzeigen
I am trying to create a custom class to overload the MATLAB image object but am getting this error message:
Class 'matlab.graphics.primitive.Image' is Sealed and may not be used as a superclass
Is there a list of [graphics] objects in The MathWorks documentation which are not "sealed?"
Or should I start from the beginning with
classdef overloadedImage < handle
Akzeptierte Antwort
Weitere Antworten (2)
Tibor Auer
am 28 Jun. 2021
0 Stimmen
I have a similar issue with graph class, which is also Sealed. I would like to extend its funcionality by adding further methods and proprties.
4 Kommentare
Tibor Auer
am 28 Jun. 2021
Bearbeitet: Tibor Auer
am 28 Jun. 2021
I have found a hacky workaround; however, it may not work for all cases:
classdef superClass
properties (Access = protected)
subClassInstance
end
methods
function obj = extendedGraph(varargin)
obj.subClassInstance = subClass(varargin{:});
end
function val = getSubClassProperty(obj,prop)
val = obj.subClassInstance.(prop);
end
function val = execSubClassMethod(obj,hMethod,varargin)
val = hMethod(obj.subClassInstance,varargin{:});
end
end
You can extend this class definition with custom properties and methods.
Steven Lord
am 29 Jun. 2021
What types of methods and properties are you trying to add to the graph class?
Tibor Auer
am 29 Jun. 2021
The main extension is to add methods to calulate the line of the graph and some further methods supporting the calculation.
I have also added some customised plotting as a method, which also adapts to when the graph is a line of a graph.
Peter Cook
am 29 Jun. 2021
Tibor Auer
am 29 Jun. 2021
0 Stimmen
@Peter Cook, There might be some misunderstanding. "Line of graph" is not about plotting but transforming: Line graph - Wikipedia
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

