-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Everything working, added a graph (just need to fix the strange closi…
…ng bug)
- Loading branch information
1 parent
2550e59
commit ca62291
Showing
4 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import java.awt.Dimension; | ||
import java.util.ArrayList; | ||
|
||
import org.jfree.chart.ChartFactory; | ||
import org.jfree.chart.ChartPanel; | ||
import org.jfree.chart.JFreeChart; | ||
import org.jfree.chart.plot.PlotOrientation; | ||
import org.jfree.data.category.CategoryDataset; | ||
import org.jfree.data.category.DefaultCategoryDataset; | ||
import org.jfree.ui.ApplicationFrame; | ||
|
||
@SuppressWarnings("serial") | ||
public class GenerationsGraph extends ApplicationFrame { | ||
|
||
public GenerationsGraph(String title, ArrayList<Generation> generations) { | ||
super(title); | ||
JFreeChart lineChart = ChartFactory.createLineChart("Creature Progression", "Generation No.", "Score", | ||
createDataSet(generations), PlotOrientation.VERTICAL, true, true, false); | ||
|
||
ChartPanel chartPanel = new ChartPanel(lineChart); | ||
chartPanel.setPreferredSize(new Dimension(560, 367)); | ||
setContentPane(chartPanel); | ||
} | ||
|
||
private CategoryDataset createDataSet(ArrayList<Generation> generations) { | ||
DefaultCategoryDataset dataset = new DefaultCategoryDataset(); | ||
int i = 0; | ||
for(Generation g : generations){ | ||
dataset.addValue(g.getMeanScore(), "Mean", ""+i); | ||
dataset.addValue(g.getMinScore(), "Max", ""+i); | ||
dataset.addValue(g.getMaxScore(), "Min", ""+i); | ||
i++; | ||
} | ||
return dataset; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters