OOP - Sealed Superclasses

8 visualizaciones (últimos 30 días)
Peter Cook
Peter Cook el 30 de En. de 2018
Respondida: Tibor Auer el 29 de Jun. de 2021
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

Respuesta aceptada

Steven Lord
Steven Lord el 30 de En. de 2018
"Is there a list of [graphics] objects in The MathWorks documentation which are not "sealed?" "
No, there is no such list.
"I am trying to create a custom class to overload the MATLAB image object "
Can you say a little more about why you're trying to overload the image object? Perhaps you can already do what you want and you're just not aware of how to do it, or perhaps this could be worthy of an enhancement request?
  4 comentarios
Steven Lord
Steven Lord el 29 de Jun. de 2021
Since this question was asked, we added the capability to create your own chart classes. It may not meet all your needs, but take a look at this section of the documentation for more information.
Peter Cook
Peter Cook el 29 de Jun. de 2021
@Steven Lord It has been quite some time since I asked this, and I haven't tried out any new MATLAB features. For the application for which this question/capability was relevant we had a number of axes containing heatmap-like data, timeseries data, and depth-series data. The data sources were independent of one another but the axes limits (e.g. depth/time) were bound to one another so that manipulation of one resulted in the need to resample the underlying datasets and re-display them in a "timely" manner (no perceptible latency). The image processing toolbox and MATLAB image object (imagesc unusable due to data gaps) were quite useful in the development phase. Ultimately we wound up with some lightweight MATLAB classes (each window pane essentially implementing a virtual class that contains some sort of dataset, has as a classmember an axes handle, and a method for drawing itself) that subscribed to change events on the x/y axes and wrote a bunch of C MEX Files to do the image manipulation. That code has been in production for a while but if we ever revisit it, I will be sure to evaluate the custom chart classes.

Iniciar sesión para comentar.

Más respuestas (2)

Tibor Auer
Tibor Auer el 28 de Jun. de 2021
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 comentarios
Tibor Auer
Tibor Auer el 29 de Jun. de 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
Peter Cook el 29 de Jun. de 2021
@Tibor Auer I think your approach should work, but perhaps attempting to extend the builtin MATLAB graph class isn't wholly appropriate in this case because it looks like what you actually want is to modify hggraphics/plotting objects. MATLAB's graph object is used to describe/manipulate data that is defined by 2-tuples of vertices and edges (and other metadata). Maybe that's what you are actually doing here and I misunderstand your code sample.
Martin said a class should be "open for extension, but closed for modification" but that doesn't mean TMW has to listen to him :)

Iniciar sesión para comentar.


Tibor Auer
Tibor Auer el 29 de Jun. de 2021
@Peter Cook, There might be some misunderstanding. "Line of graph" is not about plotting but transforming: Line graph - Wikipedia

Categorías

Más información sobre Construct and Work with Object Arrays en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by