private void eventScheduler(){

        for ( int i = 0; i < kernels.size(); i++ ) {
            kernels.get(i).updateKernel();
        }
        
        nextEventCounter--;
        //only move kernels every 10 points, performance reasons????
        //should this be randomized as well???
        if(nextEventCounter%kernelMovePointFrequency == 0){
            //move kernels
            for ( int i = 0; i < kernels.size(); i++ ) {
                kernels.get(i).move();
                //overlapControl();
            }
        }


        if(eventFrequencyOption.getValue() == 0){
            return;
        }

        String type ="";
        String message ="";
        boolean eventFinished = false;
        switch(nextEventChoice){
            case 0:
                if(numActiveKernels > 1 && numActiveKernels > numClusterOption.getValue() - numClusterRangeOption.getValue()){
                    message = mergeKernels(nextEventCounter);
                    type = "Merge";
                }
                if(mergeClusterA==null && mergeClusterB==null && message.startsWith("Clusters merging")){
                	eventFinished = true;
                }                
            break;
            case 1:
                if(nextEventCounter<=0){
                    if(numActiveKernels < numClusterOption.getValue() + numClusterRangeOption.getValue()){
                        type = "Split";
                        message = splitKernel();
                    }
                    eventFinished = true;
                }
            break;
            case 2:
                if(nextEventCounter<=0){
                	if(numActiveKernels > 1 && numActiveKernels > numClusterOption.getValue() - numClusterRangeOption.getValue()){
                        message = fadeOut();
                        type = "Delete";
                    }
                	eventFinished = true;
                }
            break;
            case 3:
                if(nextEventCounter<=0){
                	if(numActiveKernels < numClusterOption.getValue() + numClusterRangeOption.getValue()){
	                    message = fadeIn();
	                    type = "Create";
                	}
                	eventFinished = true;          	
                }
            break;

        }
        if (eventFinished){
                nextEventCounter = (int)(eventFrequencyOption.getValue()+(instanceRandom.nextBoolean()?-1:1)*eventFrequencyOption.getValue()*eventFrequencyRange*instanceRandom.nextDouble());
                nextEventChoice = getNextEvent();
                //System.out.println("Next event choice: "+nextEventChoice);
        }
        if(!message.isEmpty()){
        	message+=" (numKernels = "+numActiveKernels+" at "+numGeneratedInstances+")";
        	if(!type.equals("Merge") || message.startsWith("Clusters merging"))
        		fireClusterChange(numGeneratedInstances, type, message);
        }
    }
private void eventScheduler ( ) { for ( int i = 0 ; i < kernels . size ( ) ; i ++ ) { kernels . get ( i ) . updateKernel ( ) ; } nextEventCounter -- ; if ( nextEventCounter % kernelMovePointFrequency == 0 ) { for ( int i = 0 ; i < kernels . size ( ) ; i ++ ) { kernels . get ( i ) . move ( ) ; } } if ( eventFrequencyOption . getValue ( ) == 0 ) { return ; } String type = "" ; String message = "" ; boolean eventFinished = false ; switch ( nextEventChoice ) { case 0 : if ( numActiveKernels > 1 && numActiveKernels > numClusterOption . getValue ( ) - numClusterRangeOption . getValue ( ) ) { message = mergeKernels ( nextEventCounter ) ; type = "Merge" ; } if ( mergeClusterA == null && mergeClusterB == null && message . startsWith ( "Clusters merging" ) ) { eventFinished = true ; } break ; case 1 : if ( nextEventCounter <= 0 ) { if ( numActiveKernels < numClusterOption . getValue ( ) + numClusterRangeOption . getValue ( ) ) { type = "Split" ; message = splitKernel ( ) ; } eventFinished = true ; } break ; case 2 : if ( nextEventCounter <= 0 ) { if ( numActiveKernels > 1 && numActiveKernels > numClusterOption . getValue ( ) - numClusterRangeOption . getValue ( ) ) { message = fadeOut ( ) ; type = "Delete" ; } eventFinished = true ; } break ; case 3 : if ( nextEventCounter <= 0 ) { if ( numActiveKernels < numClusterOption . getValue ( ) + numClusterRangeOption . getValue ( ) ) { message = fadeIn ( ) ; type = "Create" ; } eventFinished = true ; } break ; } if ( eventFinished ) { nextEventCounter = ( int ) ( eventFrequencyOption . getValue ( ) + ( instanceRandom . nextBoolean ( ) ? - 1 : 1 ) * eventFrequencyOption . getValue ( ) * eventFrequencyRange * instanceRandom . nextDouble ( ) ) ; nextEventChoice = getNextEvent ( ) ; } if ( ! message . isEmpty ( ) ) { message += " (numKernels = " + numActiveKernels + " at " + numGeneratedInstances + ")" ; if ( ! type . equals ( "Merge" ) || message . startsWith ( "Clusters merging" ) ) fireClusterChange ( numGeneratedInstances , type , message ) ; } }
************************** EVENTS *****************************************