20,741
edits
| Line 235: | Line 235: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
As can be seen, each "Model" needs to derive from the "LayerModel" class. At the moment, the only method that needs to be implemented is the "init" method, which is invoked once the Layer is re-initialized. In this case, the init() method merely runs findNavaidsWithinRange(50); and then populates the model by appending each navaid to the MVC model in the top-level "LayerModel". Afterwards, the "notifyView" method is invoked to update the view (this will probably change pretty soon, once a real MVC controller abstraction is added). | As can be seen, each "Model" needs to derive from the "LayerModel" class. At the moment, the only method that needs to be implemented is the "init" method, which is invoked once the Layer is re-initialized. | ||
In this case, the init() method merely clears the internal vector using the "me.clear()" call, runs findNavaidsWithinRange(50); and then populates the model by appending each navaid to the MVC model in the top-level "LayerModel". Afterwards, the "notifyView" method is invoked to update the view (this will probably change pretty soon, once a real MVC controller abstraction is added). | |||
Note that the model merely stores the data - only the draw* callback will try to access it, i.e. the lat/lon/id fields. | Note that the model merely stores the data - only the draw* callback will try to access it, i.e. the lat/lon/id fields. | ||