// maintain a set of chunks sorted using dist from targetChunk
MinHeap chunks = new MinHeap(dist);
chunks.addAll(featFile.chunks);
MaxHeap chunks2 = new MaxHeap(500);
NumberFormat fmt = NumberFormat.getInstance();
fmt.setMaximumFractionDigits(3);
double currTime = 0;
while(chunks.size() > 0)
{
dist.setTarget(currChunk);
chunks.rebuildHeap();
currChunk = (FeatChunk)chunks.deleteMin();
// turn currChunk into an EDL chunk
EDLChunk nc = new EDLChunk(currChunk, currTime);
chunks2.add(nc);
currTime += currChunk.length;
progress.setValue(progress.getValue()+1);
}
double currTime2 = 0;
Random rand = new Random();
int pointer;
int pointer2;
int clumpWidth;
int moveWidth;
while(currTime2<=outFileLength)
{
pointer = rand.nextInt((int)chunks2.size());
clumpWidth = rand.nextInt(maxClumpWidth)+1;
moveWidth = rand.nextInt(13)+13;
int pointersSize = 2+rand.nextInt(3);
int pointers[] = new int[pointersSize];
pointers[0]=pointer;
for ( int pi = 1; pi<pointersSize; pi++) {
pointers[pi] = pointers[0]+rand.nextInt(moveWidth);
};
for (int i = 0; i<rand.nextInt(maxClumpWidth)+1; i++) {
pointer = pointers[rand.nextInt(pointersSize)];
for (int i2 = 0; i2<rand.nextInt(maxClumpWidth)+1; i2++)
{
pointer2 = pointers[rand.nextInt(pointersSize)] + rand.nextInt(clumpWidth+1);
if (pointer2>(chunks2.size()-1))
{
pointer2 = chunks2.size()-1;
}
EDLChunk currChunk2 = (EDLChunk)chunks2.get(pointer2);
EDLChunk nc = new EDLChunk(currChunk2.srcFile, currChunk2.startTime, currChunk2.length, currTime2);
outFile.chunks.add(nc);
currTime2 += nc.length;
}
}