SwingHelper.activateWindowClosingAndSystemExitButton(this);
final Simulator simulator = new Simulator();
initLookAndFeel();
final TrafficCanvas trafficCanvas = new TrafficCanvas(simulator, properties);
canvasPanel = new CanvasPanel(resourceBundle, trafficCanvas);
statusPanel = new StatusPanel(resourceBundle, simulator);
toolBar = new MovSimToolBar(statusPanel, trafficCanvas, resourceBundle);
addMenu(resourceBundle, simulator, trafficCanvas, properties);
add(canvasPanel, BorderLayout.CENTER);
add(toolBar, BorderLayout.NORTH);
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
canvasPanel.resized();
canvasPanel.repaint();
}
});
initFrameSize(properties);
if (projectMetaData.hasProjectName()) {
trafficCanvas.setupTrafficScenario(projectMetaData.getProjectName(),
projectMetaData.getPathToProjectFile());
} else {
System.out.println("try to load default");
final String path = "sim/buildingBlocks/";
URL project = App.class.getClassLoader().getResource(path+"onramp.xml");
URL projectPath = App.class.getClassLoader().getResource(path);
File file = new File(project.getFile()); // TODO use file, working in applet?
System.out.println("file exists = "+file.exists());
System.out.println("project = "+project.getFile());
trafficCanvas.setupTrafficScenario(file.getName(), projectPath.getFile());
}
statusPanel.reset();
trafficCanvas.start();
setVisible(true);
boolean isGame = Boolean.parseBoolean(properties.getProperty("isGame"));
if (isGame) {
HighscoreFrame.initialize(resourceBundle, simulator, properties);