[Biojava-l] viewsequence is unchangeable?

Kalle Näslund kalle.naslund at genpat.uu.se
Fri Sep 17 10:14:38 EDT 2004


Maximilian Haussler wrote:

> Hi everyone,
>
> why is ViewSequence an implementation of the Unchangeable interface? 
> Isn't a view (among others) meant for adding features to an otherwise 
> unchangeable sequence?

Exactly what a view is for, is a question you can argue a lot about i 
guess =). But, just from reading the javadocs of the class, it seems 
this one, is to be used to add data "on top" of another sequence. One 
example would indeed be to use it to add Features to an otherwise 
Unchangeable Sequence.

> I have a class derived from the view, but I don't get it to notify the 
> GUI when changes occur, as I don't find the getChangeSupport() in 
> ViewSequence...

ViewSequence extends Unchangeable, this is a minimal implementation of 
the Changeable Interface, that basicly just refuses any changes. The 
getChangeSupport() method belongs to the AbstractChangeable class. Most 
classes extend AbstractChangeable, so that is why you are used to always 
having getchangeSupport() around.

As ViewSequence will never change, it will never emit any change events, 
and that is what the SWING gui widgets listen for, as a trigger to 
redraw, just as you say.

I think that the correct way to fix this problem, is to have 
ViewSequence to emit change events, i guess alter it to extend 
AbstractChangeable, and then listen for Changes to the underlying 
sequence, and take appropriate action when change events are caught, 
aswell as emitting ChangeEvents when Features are added to the view itself.

> [Well, simply adding standard java change support instead of this 
> overly complicated biojava system would also do the trick... :-) ]

The biojava Changeability thingy, isnt realy that much more complex, 
atleast not from the view of the programmer, that just wants to make his 
class implement Changeable , and the added complexity has its uses. I 
wont claim that the  current BJ way is the greatest way though =)

So, my suggestion would be to make your own ViewSequene class, that does 
listen for changes on the underlying Sequence, aswell as emiting 
changes. You would start by taking the ViewSequence class, make it 
extend AbstractChangeable instead of Unchanging, then add a 
ChangeListener to the underlying Sequence, and hammer togheter some code 
that does the right thing[tm] when the listener notices the underlying 
sequence have changed ( most likely, check if the change affects the 
features in the view, if so, take some action) and then have a change 
forwarder that also forwards the changes.

Im not sure i have the time at hand, or the mental capability right now, 
to fix this for you, but if you try something like this, and get into 
problems, feel free to mail the ml again, and i will try to help as much 
as i can.

mvh Kalle Näslund

> Thanks
> Max
>
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l at biojava.org
> http://biojava.org/mailman/listinfo/biojava-l





More information about the Biojava-l mailing list