I would like to share an issue I am having and see if anyone has any ideas. Let me explain.
I have created a rather complex graph that updates dynamically during runtime as per the code snippet below.
within Main:
if(singleRun){
try{
FileInputStream fin = new FileInputStream("C:\\eclipse\\data\\so.gad");
ObjectInputStream ois = new ObjectInputStream(fin);
SO = (GAStatisticObject) ois.readObject();
ois.close();
}
catch(FileNotFoundException FNFE){System.out.println("file not found"); System.exit(1);}
catch(ClassNotFoundException CNFE){System.out.println("class not found");System.exit(1);}
catch(IOException IOE){System.out.println("error during data save: "); IOE.printStackTrace
();System.exit(1);}
GenotypeSimulator GS = new GenotypeSimulator(SO, populationSize); //statistic object, population size, enable immediately
GS.simulateEvolution();
}
basically, read data from and object file create a new simulation engine (which in turn creates the GUI and charts) and then start the simulation which basically reads the data file one data point at a time and updates the graphs. (code for simulator is below)
public void simulateEvolution(){
for(int x=0; x<genNumberSolutionFound; x++){
//System.out.println("updating data. GEN # = " + (x+1));
//if(x!=0){
try {Thread.sleep(1000);}
catch (InterruptedException e) {e.printStackTrace();}
//}
//data series 1
XYDataItem point1 = null;
if(x<genNumberSolutionFound-1){//parent vector is always 1 less in length then the rest
point1 = new XYDataItem(new Double(x+1), new Double(selectedFitnessAvg.get(x))); //parent select avg fitness
}
XYDataItem point2 = new XYDataItem(new Double(x+1), new Double(populationFitnessAvg.get(x))); //avg fitness
XYDataItem point3 = new XYDataItem(new Double(x+1), new Double(populationSmallestFitness.get(x))); //low fitness
XYDataItem point4 = new XYDataItem(new Double(x+1), new Double(populationLargestFitness.get(x))); //high fitness
//data series 2
XYDataItem point5 = new XYDataItem(new Double(x+1), new Double(cumulativeAllelDistributionVector.get(x))); //diversity
Vector<XYDataItem> DI = new Vector<XYDataItem>();
DI.add(point1); //parent avg fitness
DI.add(point2); //avg fitness
DI.add(point3); //low fitness
DI.add(point4); //high fitness
DI.add(point5); //average diversity
LGP.updateAllDataSeries(DI, new Integer(sizeOfPopulation*(x+1)));
BGP.updateDataSet(x+1, instantaneousAllelDistributionMatrix.get(x));
}
BGP.setGARunComplete();
}
(note I added a sleep timer just to make the update slow down a little)
THIS WORKS GREAT!
Now here is where the problem comes in. What I really want to do is I want to start the simulation from another JFrame when I click on a JButton instead of from my main function directly. So I created a new "execution control panel" and when you click on the start button, it executes exactly the same code previously displayed within its event handler.
However, all I get is a window that is mostly blank and no longer updates dynamically like before. I know the simulation is running fine because I still see the println to StdOut, but the GUI remains blank until the "evolveSolution()" method completes and then updates all at once.
Anyone have any idea why I am getting this different behavior when executing from another GUI?