pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Brown <gkbr...@mac.com>
Subject Re: Data, Components and Skins
Date Tue, 28 Sep 2010 11:52:42 GMT
> The MVC pattern in Pivot is well implemented and it is getting me thinking about options
for a musical score. My view of a score is that it is comprised of its data, a model object
graph and a graphic representation of the data in the graph. There may be a way to align these
aspects with the MVC pattern that Pivot uses?

This is exactly what I was talking about in my previous message.  :-)

> Presently, the model object graph has just enough objects arranged in a tree to allow
any type of score to be formed. The objects carry a lot of data that is put there by editing
tools and musical analysers. Possibly the graph could be an extended Component? There are
many ways to represent pure music data so having alternate skins (and styles) might be a way
to do that as well?

Data models in Pivot are often implemented as collections, Java Beans, or a combination thereof.
The Sequence interface is used to represent an ordered collection of values, and Dictionary
is used to represent an indexed collection. Classes that implement these interfaces generally
fire events to notify listeners about changes. Some classes fire events directly (such as
ArrayList) while others fire them indirectly via an outer class instance (such as TabPane.TabSequence).
Which approach to use is entirely up to you.

Again, I'm not an expert, but I imagine that a "score" could loosely be modeled as a collection
of "notes". So, you might be able to do something like:

public interface Note {

public class Score implements Sequence<Note> {

    public ListenerList<ScoreListener> getScoreListeners() {
        // return scoreListenerList;

public interface ScoreListener {
    // Define score events such as noteInserted(), notesRemoved(), etc.

If your model isn't too complex, you might actually be able to use an ArrayList rather than
creating your own Sequence. ArrayList implements the List interface, which already defines
a set of sequence-oriented events (in ListListener).

Anyways, hopefully this is enough to get you started. There are lots of examples of Sequence
implementations throughout the code, too (as well as Dictionary).

> I have resolved my requirements already but there may be a benefit to refactoring to
the MVC pattern Pivot uses?

There is - if you use Pivot's collection interfaces (specifically Sequence and Dictionary
or a class/interface that extends them), you can use BXML to declarative construct instances
of your model.


View raw message