MATLAB Object-Oriented Programming

(Joyce) #1

Interface Properties and Methods


The graph class specifies the following properties, which the subclasses must define:



  • Primitive — Handle of the graphics object used to implement the specialized graph.
    The class user has no need to access these objects directly so this property has
    protected SetAccess and GetAccess.

  • AxesHandle — Handle of the axes used for the graph. The specialized graph objects
    can set axes object properties. This property has protected SetAccess and
    GetAccess.

  • Data — All subclasses of the GraphInterface class must store data. The type of data
    varies and each subclass defines the storage mechanism. Subclass users can change
    the data values so this property has public access rights.


The GraphInterface class names three abstract methods that subclasses must
implement. The GraphInterface class also suggests in comments that each subclass
constructor must accept the plot data and property name/property value pairs for all class
properties.



  • Subclass constructor — Accept data and P/V pairs and return an object.

  • draw — Used to create a drawing primitive and render a graph of the data according
    to the type of graph implemented by the subclass.

  • zoom — Implementation of a zoom method by changing the axes CameraViewAngle
    property. The interface suggests the use of the camzoom function for consistency
    among subclasses. The zoom buttons created by the addButtons static method use
    this method as a callback.

  • updateGraph — Method called by the set.Data method to update the plotted data
    whenever the Data property changes.


Interface Guides Class Design


The package of classes that derive from the GraphInterface abstract class implement
the following behaviors:



  • Creating an instance of a specialized GraphInterface object (subclass object)
    without rendering the plot

  • Specifying any or none of the object properties when you create a specialized
    GraphInterface object

  • Changing any object property automatically updates the currently displayed plot


Define an Interface Superclass
Free download pdf