PeakMeter[] meters;
AudioTrackRowHeader chanHead;
AudioTrack t;
int oldChannels, newChannels;
Axis chanRuler;
PeakMeter chanMeter;
newChannels = doc.getDisplayDescr().channels;
oldChannels = collChannelHeaders.size();
meters = channelMeters;
collChannelMeters = new ArrayList( meters.length );
for( int ch = 0; ch < meters.length; ch++ ) {
collChannelMeters.add( meters[ ch ]);
}
// first kick out editors whose tracks have been removed
for( int ch = 0; ch < oldChannels; ch++ ) {
chanHead = (AudioTrackRowHeader) collChannelHeaders.get( ch );
t = (AudioTrack) chanHead.getTrack();
if( !doc.audioTracks.contains( t )) {
chanHead = (AudioTrackRowHeader) collChannelHeaders.remove( ch );
chanMeter = (PeakMeter) collChannelMeters.remove( ch );
chanRuler = (Axis) collChannelRulers.remove( ch );
oldChannels--;
// XXX : dispose trnsEdit (e.g. free vectors, remove listeners!!)
flagsPanel.remove( chanHead );
metersPanel.remove( chanMeter );
rulersPanel.remove( chanRuler );
ch--;
chanHead.dispose();
chanMeter.dispose();
chanRuler.dispose();
}
}
// next look for newly added transmitters and create editors for them
newLp: for( int ch = 0; ch < newChannels; ch++ ) {
t = (AudioTrack) doc.audioTracks.get( ch );
for( int ch2 = 0; ch2 < oldChannels; ch2++ ) {
chanHead = (AudioTrackRowHeader) collChannelHeaders.get( ch );
if( chanHead.getTrack() == t ) continue newLp;
}
chanHead = new AudioTrackRowHeader( t, doc.tracks, doc.selectedTracks, doc.getUndoManager() );
collChannelHeaders.add( chanHead );
flagsPanel.add( chanHead, ch );
chanMeter = new PeakMeter();
collChannelMeters.add( chanMeter );
metersPanel.add( chanMeter, ch );
chanRuler = new Axis( Axis.VERTICAL, Axis.FIXEDBOUNDS );
collChannelRulers.add( chanRuler );