package gui.frames; import gui.menubar.MenuBar; import gui.panels.agenda.AgendaPane; import gui.panels.edit.EditPane; import gui.panels.table.Table; import gui.simulator.SimulatorPane; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Window; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import javax.swing.JFrame; import javax.swing.JPanel; import agenda.Agenda; @SuppressWarnings("serial") public class MainFrame extends JFrame{ public enum Views{EDITOR, SIMULATOR, AGENDA, TABLE}; private Agenda agenda; private JPanel currentPanel, simulatorpanel; private int length; private int terainwidth; private SimulatorPane.Terrains terrain; public MainFrame(){ this.agenda = new Agenda(); this.currentPanel = new EditPane(this.agenda); this.add(currentPanel); this.setResizable(true); this.setBounds(100,100,1440,900); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setUndecorated(false); this.setJMenuBar(new MenuBar(this)); this.setVisible(true); this.length = 100000; this.terainwidth = 10000; this.terrain = SimulatorPane.Terrains.UNDEFINED; this.getContentPane().setBackground( Color.WHITE ); if(System.getProperties().getProperty("os.name").equals("Mac OS X")) { try { Class c = Class.forName("com.apple.eawt.FullScreenUtilities"); Method m = c.getMethod("setWindowCanFullScreen", Window.class, Boolean.TYPE); m.invoke(c, this, true); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } public void changeView(Views view){ switch(view){ case EDITOR: this.updateView(new EditPane(this.agenda)); break; case AGENDA: this.updateView(new AgendaPane(this.agenda)); break; case SIMULATOR: if(simulatorpanel == null){ simulatorpanel = new SimulatorPane(this.agenda, this.length, this.terainwidth, this.terrain); this.updateView(simulatorpanel); }else{ this.updateView(simulatorpanel); } break; case TABLE: this.updateView(new Table(this.agenda)); break; } } public void setTerrain(SimulatorPane.Terrains terrain){ this.terrain = terrain; } public void setLength(int length){ this.length = length; } public void setTerainWidth(int width){ this.terainwidth = width; } public int getTerainWidth(){ return terainwidth; } public int getLength(){ return length; } public SimulatorPane.Terrains getTerrain(){ return terrain; } private void updateView(JPanel panel){ this.currentPanel = panel; this.setContentPane(this.currentPanel); this.revalidate(); } public Agenda getAgenda() { return agenda; } public void setAgenda(Agenda agenda) { this.agenda = agenda; updateView(currentPanel); } public JPanel getSimulatorpanel() { return simulatorpanel; } public void setSimulatorpanel(JPanel simulatorpanel) { this.simulatorpanel = simulatorpanel; } }