@Override
 public void show() {
   Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
   mainFrame.setSize(screenSize.width - 100, screenSize.height - 100);
   mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
   mainFrame.setVisible(true);
 }
Exemple #2
0
  /**
   * This method starts the GUI.
   *
   * @throws CoapException Thrown, if the connection to obix via CoAP fails.
   */
  public void runGui() throws CoapException {
    this.lobby = obixChannel.getLobby(obixChannel.getLobbyUri());
    // Create and set up the window.
    mainFrame =
        new JFrame("ObixConnector at " + obixChannel.getBaseUri() + ": " + obixChannel.getPort());
    mainFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    mainFrame.setUndecorated(false);
    mainFrame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            close();
          }
        });

    Container contentPane = mainFrame.getContentPane();

    // Create and set up the content pane.
    this.addComponentToPane(contentPane);

    // Display the window.
    mainFrame.pack();
    executor.execute(updateThread);
    connector.addRunAndStopAble(updateThread);
    mainFrame.setVisible(true);
  }
  @Override
  public void showMenuCaja(CajaController cc, JFrame f, Usuario u) {

    usuario = u;

    System.out.println("SHOW CAJA");

    cajaController = cc;
    frame = f;

    PanelGeneral panelGeneral = new PanelGeneral(u);

    listenerCajaVolver = new ListenerCajaVolver(cc);
    listenerVerMovimientos = new ListenerVerMovimientos(cc);
    listenerVerOtrosMovimientos = new ListenerVerOtrosMovimientos(cc);

    panelCajaMenu.getBtnVolver().addActionListener(listenerCajaVolver);
    panelCajaMenu.getBtnVerMovs().addActionListener(listenerVerMovimientos);
    panelCajaMenu.getBtnVerUnDia().addActionListener(listenerVerOtrosMovimientos);

    frame.setTitle("Menu Caja");
    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    frame.getContentPane().removeAll();
    frame.getContentPane().add(panelGeneral, BorderLayout.PAGE_START);
    frame.getContentPane().add(panelCajaMenu, BorderLayout.WEST);
    frame.getContentPane().add(panelCaja, BorderLayout.LINE_END);
    frame.validate();
    frame.repaint();
  }
Exemple #4
0
  /** *********************************************************************** */
  private static void createAndShowGUI() {
    JFrame.setDefaultLookAndFeelDecorated(true); // give JFrame nice decorations
    JFrame frame = new JFrame("Java GUI"); // create the JFrame
    frame.setDefaultCloseOperation(
        JFrame.EXIT_ON_CLOSE); // set up the JFrame to end the program when it closes
    Container c = frame.getContentPane();
    c.setLayout(new BorderLayout());

    ColorBars drawingPanel = new ColorBars(); // set up the panel to draw in
    drawingPanel.setBackground(Color.BLACK); // the the background to black

    drawingPanel.btnDraw = new JButton("Click me"); // instantiate a swing button
    drawingPanel.btnDraw.addActionListener(drawingPanel); // register the panel with the button
    drawingPanel.btnClear = new JButton("Clear Screen");
    drawingPanel.btnClear.addActionListener(drawingPanel);

    Panel buttonPanel = new Panel(); // instantiate the panel for buttons
    buttonPanel.add(drawingPanel.btnDraw); // add the swing button the the button panel
    buttonPanel.add(drawingPanel.btnClear);

    c.add(
        drawingPanel,
        BorderLayout.CENTER); // add the drawing panel to the frame (take up the entire frame)
    c.add(buttonPanel, BorderLayout.SOUTH); // add the button panel to the bottom of the frame

    frame.setExtendedState(JFrame.MAXIMIZED_BOTH); // set the window to maximized
    frame.setSize(600, 400); // set the frame size (in case user un-maximizes
    frame.setVisible(true); // display the frame
  }
  public static void requestFocus(Project project, final boolean useRobot) {
    JFrame frame = WindowManager.getInstance().getFrame(project);

    // the only reliable way I found to bring it to the top
    boolean aot = frame.isAlwaysOnTop();
    frame.setAlwaysOnTop(true);
    frame.setAlwaysOnTop(aot);

    int frameState = frame.getExtendedState();
    if ((frameState & Frame.ICONIFIED) == Frame.ICONIFIED) {
      // restore the frame if it is minimized
      frame.setExtendedState(frameState ^ Frame.ICONIFIED);
    }
    frame.toFront();
    frame.requestFocus();
    if (useRobot && runningOnWindows7()) {
      try {
        // remember the last location of mouse
        final Point oldMouseLocation = MouseInfo.getPointerInfo().getLocation();

        // simulate a mouse click on title bar of window
        Robot robot = new Robot();
        robot.mouseMove(frame.getX(), frame.getY());
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

        // move mouse to old location
        robot.mouseMove((int) oldMouseLocation.getX(), (int) oldMouseLocation.getY());
      } catch (Exception ex) {
        // just ignore exception, or you can handle it as you want
      } finally {
        frame.setAlwaysOnTop(false);
      }
    }
  }
 public static void main(String[] args) {
   JFrame frame = new JFrame();
   frame.add(new VotingForm(null));
   frame.pack();
   frame.setExtendedState(Frame.MAXIMIZED_BOTH);
   frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   frame.setVisible(true);
 }
Exemple #7
0
 private static void createAndShowMain() {
   JFrame.setDefaultLookAndFeelDecorated(true);
   JFrame frame = new JFrame("RT Prune Algorithm Simulator");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setLocationRelativeTo(null);
   Main newContentPane = new Main(frame);
   newContentPane.setOpaque(true);
   frame.setContentPane(newContentPane);
   frame.pack();
   frame.setExtendedState(Frame.MAXIMIZED_BOTH);
   frame.setVisible(true);
 }
 // Initialize frame
 private void addFrame() {
   crimeDistEstimJFrame = new JFrame();
   crimeDistEstimJFrame.getContentPane().setBackground(SystemColor.control);
   crimeDistEstimJFrame.setBackground(UIManager.getColor("Button.disabledForeground"));
   crimeDistEstimJFrame.setTitle("Crime Distribution Estimator");
   crimeDistEstimJFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
   crimeDistEstimJFrame.setMinimumSize(new Dimension(800, 600));
   crimeDistEstimJFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   crimeDistEstimJFrame
       .getContentPane()
       .setLayout(new MigLayout("", "[][][][][]", "[477.00][-16.00][-30.00][86.00][][28.00][]"));
 }
Exemple #9
0
  /**
   * Initializes our GUI's window. Note that this does not initialize the components inside, or the
   * event handlers.
   */
  private void initWindow() {
    // CONSTRUCT OUR WINDOW
    window = new JFrame(name);

    // NOTE THAT THE WINDOW WILL BE RESIZED LATER
    window.setExtendedState(JFrame.MAXIMIZED_BOTH);
    window.setResizable(false);

    // THIS IS JUST A SIMPLE LITTLE GAME THAT DOESN'T
    // SAVE ANY DATA, SO WE'LL JUST KILL THE APP WHEN
    // THE USER PRESSES THE X
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
 @Override
 public void onGameStopped() {
   gdxFrame.setExtendedState(JFrame.ICONIFIED);
   //    	gdxFrame.setVisible(false);
   for (int i = 0; i < game.getAllTeams().size(); ++i) {
     game.getAllTeams().get(i).removeAllAgents();
   }
   game.getPlayerTeams().clear();
   settings.prepareForNewGame();
   logger.log(Level.INFO, "Reset settings");
   launcherInterface.setVisible(true);
   launcherInterface.revalidate();
   launcherInterface.repaint();
 }
Exemple #11
0
 public FramePrefsHandler(JFrame frame) {
   this.frame = frame;
   frame.pack(); // makes the frame displayable, so that maximizing works
   frame.setMinimumSize(frame.getSize());
   frame.setMaximizedBounds(
       GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
   frame.setBounds(Util.stringToRectangle(PREFS.get("WINDOW_BOUNDS", null), frame.getBounds()));
   int state =
       frame.getExtendedState()
           | (PREFS.getBoolean("WINDOW_MAXIMIZED", true) ? JFrame.MAXIMIZED_BOTH : 0);
   frame.setExtendedState(state);
   frame.addComponentListener(this);
   frame.addWindowStateListener(this);
 }
 public void showOutlineWindow() {
   JFrame frame = getPopupWindow();
   if (frame.isVisible()) {
     if (popupBound != null) {
       frame.setBounds(popupBound);
     }
     frame.setExtendedState(popupState);
     frame.toFront();
   } else {
     frame.setLocationRelativeTo(SwingUtilities.getRoot(this));
     frame.setVisible(true);
   }
   if (dirtyPopup) {
     popupOutline.setImage(graphOutline.getImage());
     popupOutline.updateImage();
     dirtyPopup = false;
   }
 }
Exemple #13
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frame = new JFrame();
    frame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowOpened(WindowEvent arg0) {
            // affichage de la boite de dialogue de chargement des données
            dialogLoadView dia = new dialogLoadView(frame, "Chargement des données", true);
            dia.setVisible(true);
          }
        });
    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    frame.setSize(800, 600);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(new BorderLayout(0, 0));

    panelEditView panelEditView_ = new panelEditView();
    panelEditView_.getListResult().setBounds(37, 95, 364, 435);
    frame.getContentPane().add(panelEditView_, BorderLayout.CENTER);

    JMenuBar menuBar = new JMenuBar();
    menuBar.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    menuBar.setBackground(Color.GRAY);
    frame.getContentPane().add(menuBar, BorderLayout.NORTH);

    JMenu menuFile = new JMenu("Fichier");
    menuFile.setBackground(Color.GRAY);
    menuBar.add(menuFile);

    JMenuItem mntmNewMenuItem = new JMenuItem("Fermer");
    mntmNewMenuItem.setBackground(Color.GRAY);
    menuFile.add(mntmNewMenuItem);

    // changement d'icon
    frame.setIconImage(
        new ImageIcon(MainApp.class.getResource("/images/logo-prevac-mini.png")).getImage());
    // augmentation de la taille de la fenetre

  }
  /** Method to pop the GUI in the middle of the screen */
  private void displayFrame(JFrame aFrame) {
    // first center the frame
    GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Point c = e.getCenterPoint();
    Rectangle bounds = e.getMaximumWindowBounds();

    int w = Math.max(bounds.width / 2, Math.min(aFrame.getWidth(), bounds.width));
    int h = Math.max(bounds.height / 2, Math.min(aFrame.getHeight(), bounds.height));
    int x = c.x - w / 2;
    int y = c.y - h / 2;
    aFrame.setBounds(x, y, w, h);
    if (w == bounds.width && h == bounds.height) {
      aFrame.setExtendedState(Frame.MAXIMIZED_BOTH);
    }

    aFrame.validate();

    // then show it
    aFrame.pack();
    aFrame.setVisible(true);
    aFrame.setResizable(true);
    aFrame.toFront();
  }
 public static void toFullScreen(
     JFrame window,
     GraphicsDevice gd,
     boolean tryAppleFullscreen,
     boolean tryExclusiveFullscreen) {
   if (appleEawtAvailable()
       && tryAppleFullscreen
       && appleOSVersion() >= 7
       && // lion and above
       javaVersion() >= 7) { // java 7 and above
     System.out.println("trying to apple fullscreen");
     enableAppleFullscreen(window);
     doAppleFullscreen(window);
   } else if (appleEawtAvailable()
       && // Snow Leopard and below OR apple java 6 and below TODO: test this on SL
       tryExclusiveFullscreen
       && gd.isFullScreenSupported()) {
     if (javaVersion() >= 7) setAutoRequestFocus(window, true);
     window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     window.setUndecorated(true);
     // window.setExtendedState(JFrame.MAXIMIZED_BOTH);
     gd.setFullScreenWindow(window);
     window.toFront();
     Rectangle r = gd.getDefaultConfiguration().getBounds();
     window.setBounds(r);
     // window.pack();
   } else { // Windows and Linux TODO: test this
     window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     window.setUndecorated(true);
     window.setSize(gd.getDisplayMode().getWidth(), gd.getDisplayMode().getHeight());
     window.setLocation(0, 0);
     window.setExtendedState(JFrame.MAXIMIZED_BOTH);
     window.toFront();
   }
   window.pack();
   window.setVisible(true);
 }
  public static void main(String[] args) {
    polygons = new ArrayList<Polygon>();
    rotateLine[0] = new Point3Df(-1.0f, -1.0f, -1.0f);
    rotateLine[1] = new Point3Df(1.0f, 1.0f, 1.0f);

    // Prepare all our OpenGL canvas
    GLProfile glp = GLProfile.getDefault();
    GLCapabilities caps = new GLCapabilities(glp);

    canvas[0] = new GLCanvas(caps);
    canvas[1] = new GLCanvas(caps);
    canvas[2] = new GLCanvas(caps);

    // Prepare the main frame for the application
    JFrame frame = new JFrame(appTitle);

    // The file chooser for opening and saving files
    final JFileChooser fc = new JFileChooser();

    // Since the app started, set the save file to null
    saveFile = null;

    // This is our scene, which contains our polygons and rendering functions
    scene[0] = new Scene(Scene.XZPlane);
    scene[1] = new Scene(Scene.YZPlane);
    scene[2] = new Scene(Scene.XYPlane);

    // This is our list model and JList that will allow us to select the
    // polygons we wish to transform
    listModel = new DefaultListModel();
    JList listPolys = new JList(listModel);
    listPolys.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    listPolys.setLayoutOrientation(JList.VERTICAL);
    listPolys.setVisibleRowCount(-1);
    JScrollPane listScrollerPolys = new JScrollPane(listPolys);
    refreshPolygons();

    // This listener waits for selections in the JList and updates the polygons
    // in the scene with "selected" markers
    listPolys
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              @Override
              public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting() == false) {
                  ListSelectionModel lsm = (ListSelectionModel) e.getSource();

                  int minIndex = lsm.getMinSelectionIndex();
                  int maxIndex = lsm.getMaxSelectionIndex();

                  for (Polygon p : polygons) {
                    p.setSelected(false);
                  }

                  for (int i = minIndex; i <= maxIndex; i++) {
                    if (lsm.isSelectedIndex(i)) {
                      ((Polygon) listPolys.getModel().getElementAt(i)).setSelected(true);
                    }
                  }

                  refreshCanvas();
                }
              }
            });

    JSplitPane oneTwo = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, canvas[0], canvas[1]);
    JSplitPane threeFour =
        new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, canvas[2], listScrollerPolys);

    oneTwo.setDividerLocation(0.50);
    threeFour.setDividerLocation(0.50);

    JSplitPane canvases = new JSplitPane(JSplitPane.VERTICAL_SPLIT, oneTwo, threeFour);

    canvases.setDividerLocation(0.50);

    // Main menu for this application
    JMenuBar menu = new JMenuBar();

    JMenu menuFile = new JMenu("File");
    JMenuItem menuOpen =
        new JMenuItem(
            new AbstractAction("Open") {
              @Override
              public void actionPerformed(ActionEvent e) {
                int returnVal = fc.showOpenDialog(frame);

                if (returnVal == JFileChooser.APPROVE_OPTION) {
                  saveFile = fc.getSelectedFile();

                  openPolygons();

                  refreshPolygons();

                  refreshCanvas();

                  frame.setTitle(appTitle + " - " + saveFile.getAbsolutePath());
                }
              }
            });

    JMenuItem menuImportPly =
        new JMenuItem(
            new AbstractAction("Import Ply") {
              @Override
              public void actionPerformed(ActionEvent e) {
                int returnVal = fc.showOpenDialog(frame);

                if (returnVal == JFileChooser.APPROVE_OPTION) {
                  importPly(fc.getSelectedFile());

                  refreshPolygons();

                  refreshCanvas();
                }
              }
            });

    JMenuItem menuSave =
        new JMenuItem(
            new AbstractAction("Save") {
              @Override
              public void actionPerformed(ActionEvent e) {
                if (saveFile != null) {
                  savePolygons();
                } else {
                  int returnVal = fc.showSaveDialog(frame);

                  if (returnVal == JFileChooser.APPROVE_OPTION) {
                    saveFile = fc.getSelectedFile();

                    savePolygons();

                    frame.setTitle(appTitle + " - " + saveFile.getAbsolutePath());
                  }
                }
              }
            });

    JMenuItem menuSaveAs =
        new JMenuItem(
            new AbstractAction("Save As") {
              @Override
              public void actionPerformed(ActionEvent e) {
                int returnVal = fc.showSaveDialog(frame);

                if (returnVal == JFileChooser.APPROVE_OPTION) {
                  saveFile = fc.getSelectedFile();

                  savePolygons();

                  frame.setTitle(appTitle + " - " + saveFile.getAbsolutePath());
                }
              }
            });

    JMenuItem menuExit =
        new JMenuItem(
            new AbstractAction("Exit") {
              @Override
              public void actionPerformed(ActionEvent e) {
                System.exit(0);
              }
            });

    menuFile.add(menuOpen);
    menuFile.add(menuImportPly);
    menuFile.add(menuSave);
    menuFile.add(menuSaveAs);
    menuFile.add(menuExit);

    JMenu menuTransform = new JMenu("Transform");
    JMenuItem menuTranslate =
        new JMenuItem(
            new AbstractAction("Translate") {
              @Override
              public void actionPerformed(ActionEvent e) {
                String vector =
                    (String) JOptionPane.showInputDialog(frame, "Input Translation Vector: x,y,z");

                String[] vectorParts = vector.split(",", 3);
                float x = Float.valueOf(vectorParts[0]);
                float y = Float.valueOf(vectorParts[1]);
                float z = Float.valueOf(vectorParts[2]);

                for (Polygon p : polygons) {
                  if (p.getSelected()) {
                    p.translate(new Point3Df(x, y, z));
                    rebound();
                  }
                }

                refreshCanvas();
              }
            });

    JMenuItem menuScale =
        new JMenuItem(
            new AbstractAction("Scale") {
              @Override
              public void actionPerformed(ActionEvent e) {
                String vector =
                    (String) JOptionPane.showInputDialog(frame, "Input Scale Factor: x,y,z");

                String[] vectorParts = vector.split(",", 3);
                float x = Float.valueOf(vectorParts[0]);
                float y = Float.valueOf(vectorParts[1]);
                float z = Float.valueOf(vectorParts[2]);

                for (Polygon p : polygons) {
                  if (p.getSelected()) {
                    p.scale(new Point3Df(x, y, z));
                    rebound();
                  }
                }

                refreshCanvas();
              }
            });

    JMenuItem menuRotateLine =
        new JMenuItem(
            new AbstractAction("Set Rotate Line") {
              @Override
              public void actionPerformed(ActionEvent e) {
                String vector =
                    (String) JOptionPane.showInputDialog(frame, "Input Line Point 0: x0,y0,z0");

                String[] vectorParts = vector.split(",", 3);
                float x0 = Float.valueOf(vectorParts[0]);
                float y0 = Float.valueOf(vectorParts[1]);
                float z0 = Float.valueOf(vectorParts[2]);

                vector =
                    (String) JOptionPane.showInputDialog(frame, "Input Line Point 1: x1,y1,z1");

                vectorParts = vector.split(",", 3);
                float x1 = Float.valueOf(vectorParts[0]);
                float y1 = Float.valueOf(vectorParts[1]);
                float z1 = Float.valueOf(vectorParts[2]);

                rotateLine[0] = new Point3Df(x0, y0, z0);
                rotateLine[1] = new Point3Df(x1, y1, z1);

                refreshCanvas();
              }
            });

    JMenuItem menuRotate =
        new JMenuItem(
            new AbstractAction("Rotate") {
              @Override
              public void actionPerformed(ActionEvent e) {
                String sangle =
                    (String) JOptionPane.showInputDialog(frame, "Input Rotation Angle in Degrees:");

                float angle = Float.valueOf(sangle);

                for (Polygon p : polygons) {
                  if (p.getSelected()) {
                    p.rotate(rotateLine[0], rotateLine[1], angle * (Math.PI / 180));
                    rebound();
                  }
                }

                refreshCanvas();
              }
            });

    menuTransform.add(menuTranslate);
    menuTransform.add(menuScale);
    menuTransform.add(menuRotateLine);
    menuTransform.add(menuRotate);

    JMenu menuAnimate = new JMenu("Animate");
    JMenuItem menuAnimateStart =
        new JMenuItem(
            new AbstractAction("Start") {
              @Override
              public void actionPerformed(ActionEvent e) {
                for (int i = 0; i < 3; i++) {
                  scene[i].setAnimation(true);
                  animator[i].start();
                }
              }
            });
    JMenuItem menuAnimateStop =
        new JMenuItem(
            new AbstractAction("Stop") {
              @Override
              public void actionPerformed(ActionEvent e) {
                for (int i = 0; i < 3; i++) {
                  scene[i].setAnimation(false);
                  animator[i].stop();
                }
              }
            });
    JMenuItem menuAnimateReset =
        new JMenuItem(
            new AbstractAction("Reset") {
              @Override
              public void actionPerformed(ActionEvent e) {
                for (int i = 0; i < 3; i++) {
                  scene[i].resetRotationAnimation();
                }

                refreshCanvas();
              }
            });

    menuAnimate.add(menuAnimateStart);
    menuAnimate.add(menuAnimateStop);
    menuAnimate.add(menuAnimateReset);

    menu.add(menuFile);
    menu.add(menuTransform);
    menu.add(menuAnimate);

    // Set the menu for the frame
    frame.setJMenuBar(menu);

    // Maximize the frame on startup
    frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);

    // Add our splitpane to the frame
    frame.getContentPane().add(canvases);
    frame.setVisible(true);

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    canvases.addComponentListener(
        new ComponentListener() {
          // We do this to keep the splitpane the same proportion
          public void componentResized(ComponentEvent e) {
            oneTwo.setDividerLocation(0.50);
            threeFour.setDividerLocation(0.50);
            canvases.setDividerLocation(0.50);
          }

          @Override
          public void componentMoved(ComponentEvent e) {}

          @Override
          public void componentShown(ComponentEvent e) {}

          @Override
          public void componentHidden(ComponentEvent e) {}
        });

    frame.addComponentListener(
        new ComponentListener() {
          // We do this to keep the splitpane the same proportion
          public void componentResized(ComponentEvent e) {
            canvases.setDividerLocation(0.50);
          }

          @Override
          public void componentMoved(ComponentEvent e) {}

          @Override
          public void componentShown(ComponentEvent e) {}

          @Override
          public void componentHidden(ComponentEvent e) {}
        });

    canvas[0].addGLEventListener(scene[0]);
    canvas[1].addGLEventListener(scene[1]);
    canvas[2].addGLEventListener(scene[2]);

    animator[0] = new Animator(canvas[0]);
    animator[1] = new Animator(canvas[1]);
    animator[2] = new Animator(canvas[2]);
  }
  public void build(ODatabaseDocumentTx db) {

    menu.build(db);
    toolbar.build(db);
    panelBottom.build();

    // toolWindowManager
    for (ToolWindow window : toolWindowManager.getToolWindows()) {
      window.setAvailable(true);
    }

    toolWindowManager
        .getContentManager()
        .addContentManagerListener(
            new ContentManagerListener() {

              @Override
              public void contentSelected(ContentManagerEvent arg0) {
                idMasterOpen = arg0.getContent().getId();
                if (masterOpen != null) {
                  masterOpen.requestDefaultSelected();
                }
              }

              @Override
              public void contentRemoved(ContentManagerEvent arg0) {
                if (arg0.getContent().getId().equals(idMasterOpen)) {
                  idMasterOpen = "";
                }
                if (toolWindowManager.getContentManager().getContentCount() == 0) {
                  App.getActions().get(LApp.SHOW_WELCOME).actionPerformed(null);
                }
              }

              @Override
              public void contentAdded(ContentManagerEvent arg0) {
                idMasterOpen = arg0.getContent().getId();
                masterOpen = mapMaster.get(idMasterOpen);
                System.out.println(idMasterOpen);
                if (toolWindowManager.getContentManager().getContentCount() > 1) {
                  try {
                    Content c =
                        toolWindowManager
                            .getContentManager()
                            .getContentByComponent(welcomeComponent);
                    toolWindowManager.getContentManager().removeContent(c);
                  } catch (Exception e) {
                    App.printErr(e);
                  }
                }
              }
            });

    // frame
    frame.setTitle(LWindow.TITLE);
    frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
    frame.setIconImage(App.getImage(LApp.iconApp16).getImage());
    frame.getContentPane().setLayout(new BorderLayout());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(menu.getMenuBar());

    // build tool window manager
    JPanel p = new JPanel();
    p.setLayout(new ExtendedTableLayout(new double[][] {{0, -1, 0}, {0, -1, 0}}));
    p.add((Component) toolWindowManager, "1,1,");

    frame.add(p, BorderLayout.CENTER);

    // frame.getContentPane().add(toolbar.getPanel(), BorderLayout.SOUTH);
    JPanel p2 = new JPanel(new BorderLayout());
    p2.add(new JSeparator(), BorderLayout.NORTH);
    p2.add(panelBottom.getPanel(), BorderLayout.CENTER);
    frame.getContentPane().add(p2, BorderLayout.SOUTH);
  }
  /**
   * ********************************************************* Constructor that creates game and
   * label array *********************************************************
   */
  public ZombielandGUI() {

    frame = new JFrame();

    // Build menuBar
    menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);

    // Build Game Menu
    gameMenu = new JMenu("Game");
    menuBar.add(gameMenu);

    exitMenuItem = new JMenuItem("Exit");
    exitMenuItem.addActionListener(buttonListener);
    gameMenu.add(exitMenuItem);

    // Build Help Menu
    helpMenu = new JMenu("Help");
    menuBar.add(helpMenu);

    aboutMenuItem = new JMenuItem("About");
    aboutMenuItem.addActionListener(buttonListener);
    helpMenu.add(aboutMenuItem);

    helpMenuItem = new JMenuItem("Help");
    helpMenuItem.addActionListener(buttonListener);
    helpMenu.add(helpMenuItem);

    gamePanel = new JPanel(new GridBagLayout());

    // Makes new game
    game = new ZombielandGame();
    mapCopy = new Building[16][16];

    gbc = new GridBagConstraints();

    // Adds ResourcePanel
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gamePanel.add(new ResourcePanel(), gbc);

    // Adds MapPanel
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gamePanel.add(new MapPanel(game), gbc);

    // Adds MaterialsPanel
    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gamePanel.add(new MaterialsPanel(), gbc);

    // Adds groupPanel
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gamePanel.add(new GroupPanel(), gbc);

    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    frame.add(gamePanel);
    frame.setVisible(true);
  }
Exemple #19
0
 void doMinimize() {
   if (owner != null) {
     owner.setExtendedState(Frame.ICONIFIED);
   }
 }
 @Override
 public void onGameStarted() {
   loadingDialog.setVisible(false);
   if (settings.isEnabledEnhancedGraphism()) gdxFrame.setExtendedState(JFrame.NORMAL);
   //        	gdxFrame.setVisible(true);
 }
Exemple #21
0
  /**
   * Plot the results produced by the testing methods in this class.
   *
   * @param results The results of one or more tests. They must all have the same type {@link TYPE}.
   *     If more than one result is to be plotted then only {@link TYPE#STDP} or {@link
   *     TYPE#STDP_1D} are supported, and it is assumed that they all have the same pre- and
   *     post-synaptic spike patterns.
   * @param singlePlot If plotting more than one TestResult then whether to show the results on a
   *     single plot (true) or separate plots (false).
   * @param timeResolution The time resolution which the simulation was run at.
   * @param logSpikesAndStateVariables Whether to include pre- and post-synaptic spikes and any
   *     state variables exposed by the synapse model in the plot. This is ignored if more than one
   *     result is to be plotted.
   * @param showInFrame Whether to display the result in a frame.
   */
  public static JFreeChart createChart(
      TestResults[] results,
      boolean singlePlot,
      int timeResolution,
      boolean logSpikesAndStateVariables,
      boolean showInFrame,
      String title) {
    JFreeChart resultsPlot = null;
    int resultsCount = results.length;

    // Make sure they're all the same type.
    for (int ri = 0; ri < results.length; ri++) {
      if (ri < resultsCount - 1
          && results[ri].getProperty("type") != results[ri + 1].getProperty("type")) {
        throw new IllegalArgumentException("All results must have the same type.");
      }
      if (resultsCount > 1
          && results[ri].getProperty("type") != TYPE.STDP
          && results[ri].getProperty("type") != TYPE.STDP_1D) {
        throw new IllegalArgumentException(
            "Multiple results can only be plotted for types STDP or STDP_1D.");
      }
    }

    TYPE type = (TYPE) results[0].getProperty("type");

    XYLineAndShapeRenderer xyRenderer;
    XYToolTipGenerator tooltipGen = new StandardXYToolTipGenerator();

    if (type == TYPE.STDP) {
      CombinedDomainXYPlot combinedPlot = new CombinedDomainXYPlot(new NumberAxis("t (s)"));

      if (singlePlot) { // Plot all result sets together.
        DefaultXYDataset efficacyData = new DefaultXYDataset();
        for (TestResults result : results) {
          String efficacyLabel =
              (resultsCount == 1) ? "Efficacy" : "" + result.getProperty("label");
          efficacyData.addSeries(efficacyLabel, result.getResult("Time", "Efficacy"));
        }
        xyRenderer = new XYLineAndShapeRenderer(true, false);
        xyRenderer.setBaseToolTipGenerator(tooltipGen);
        combinedPlot.add(new XYPlot(efficacyData, null, new NumberAxis("Efficacy"), xyRenderer), 4);
      } else { // Plot each result set separately.
        for (TestResults result : results) {
          DefaultXYDataset efficacyData = new DefaultXYDataset();
          String efficacyLabel =
              (resultsCount == 1) ? "Efficacy" : "" + result.getProperty("label");
          efficacyData.addSeries(efficacyLabel, result.getResult("Time", "Efficacy"));
          xyRenderer = new XYLineAndShapeRenderer(true, false);
          xyRenderer.setBaseToolTipGenerator(tooltipGen);
          combinedPlot.add(
              new XYPlot(efficacyData, null, new NumberAxis("Efficacy"), xyRenderer), 4);
        }
      }

      // Don't plot trace data for multiple tests.
      if (resultsCount == 1 && logSpikesAndStateVariables) {
        DefaultXYDataset traceData = new DefaultXYDataset();
        for (String label : results[0].getResultLabels()) {
          if (!label.startsWith("Time")
              && !label.startsWith("Efficacy")
              && !label.equals("Pre-synaptic spikes")
              && !label.equals("Post-synaptic spikes")) {
            traceData.addSeries(label, results[0].getResult("Time", label));
          }
        }
        xyRenderer = new XYLineAndShapeRenderer(true, false);
        xyRenderer.setBaseToolTipGenerator(tooltipGen);
        combinedPlot.add(new XYPlot(traceData, null, new NumberAxis("State"), xyRenderer), 3);

        DefaultXYDataset spikeData = new DefaultXYDataset();
        spikeData.addSeries(
            "Pre-synaptic spikes", results[0].getResult("Time", "Pre-synaptic spikes"));
        spikeData.addSeries(
            "Post-synaptic spikes", results[0].getResult("Time", "Post-synaptic spikes"));
        xyRenderer = new XYLineAndShapeRenderer(true, false);
        xyRenderer.setBaseToolTipGenerator(tooltipGen);
        combinedPlot.add(
            new XYPlot(spikeData, null, new NumberAxis("Pre/post potential"), xyRenderer), 3);
      }

      resultsPlot = new JFreeChart(title, null, combinedPlot, true);
      resultsPlot.setBackgroundPaint(Color.WHITE);
      resultsPlot.getPlot().setBackgroundPaint(Color.WHITE);
      ((XYPlot) resultsPlot.getPlot()).setRangeGridlinePaint(Color.LIGHT_GRAY);
      ((XYPlot) resultsPlot.getPlot()).setDomainGridlinePaint(Color.LIGHT_GRAY);

    } else if (type == TYPE.STDP_1D) {
      DecimalFormat timeFormatter = new DecimalFormat();
      timeFormatter.setMultiplier(1000);
      NumberAxis domainAxis = new NumberAxis("\u0394t (ms)");
      domainAxis.setNumberFormatOverride(timeFormatter);
      CombinedDomainXYPlot combinedPlot = new CombinedDomainXYPlot(domainAxis);

      if (singlePlot) { // Plot all result sets together.
        DefaultXYDataset efficacyData = new DefaultXYDataset();
        for (TestResults result : results) {
          String efficacyLabel =
              (resultsCount == 1) ? "Efficacy" : "" + result.getProperty("label");
          efficacyData.addSeries(efficacyLabel, result.getResult("Time delta", "Efficacy"));
        }
        xyRenderer = new XYLineAndShapeRenderer(true, false);
        xyRenderer.setBaseToolTipGenerator(tooltipGen);
        combinedPlot.add(new XYPlot(efficacyData, null, new NumberAxis("Efficacy"), xyRenderer), 4);
      } else { // Plot each result set separately.
        for (TestResults result : results) {
          DefaultXYDataset efficacyData = new DefaultXYDataset();
          String efficacyLabel =
              (resultsCount == 1) ? "Efficacy" : "" + result.getProperty("label");
          efficacyData.addSeries(efficacyLabel, result.getResult("Time delta", "Efficacy"));
          xyRenderer = new XYLineAndShapeRenderer(true, false);
          xyRenderer.setBaseToolTipGenerator(tooltipGen);
          combinedPlot.add(
              new XYPlot(efficacyData, null, new NumberAxis("Efficacy"), xyRenderer), 4);
        }
      }

      resultsPlot = new JFreeChart(title, null, combinedPlot, true);
      resultsPlot.setBackgroundPaint(Color.WHITE);
      resultsPlot.getPlot().setBackgroundPaint(Color.WHITE);
      ((XYPlot) resultsPlot.getPlot()).setRangeGridlinePaint(Color.LIGHT_GRAY);
      ((XYPlot) resultsPlot.getPlot()).setDomainGridlinePaint(Color.LIGHT_GRAY);
    } else if (type == TYPE.STDP_2D) {
      double[][] data = results[0].getResult("Time delta 1", "Time delta 2", "Efficacy");

      DefaultXYZDataset plotData = new DefaultXYZDataset();
      plotData.addSeries("Efficacy", data);

      // Set up paint scale, and convert domain axes from seconds to
      // milliseconds (XYBlockRenderer won't deal with fractional values
      // in the domain axes)
      double min = Double.MAX_VALUE, max = -min;
      double[] efficacy = data[2];
      for (int i = 0; i < data[0].length; i++) {
        if (efficacy[i] < min) min = efficacy[i];
        if (efficacy[i] > max) max = efficacy[i];

        data[0][i] = Math.round(data[0][i] * 1000);
        data[1][i] = Math.round(data[1][i] * 1000);
      }

      XYBlockRenderer renderer = new XYBlockRenderer();

      double range = Math.max(Math.abs(min), Math.abs(max));
      double rangeBase = 0;
      if (min < 0) min = -range;
      if (max > 0) max = range;
      // If the value range does not cross the zero point, don't use a zero-based range.
      if ((min > 0) || (max < 0)) {
        range = Math.abs(max - min);
        rangeBase = Math.min(Math.abs(min), Math.abs(max));
      }
      if (min >= max) {
        max = min + Double.MIN_VALUE * 10;
      }

      LookupPaintScale scale = new LookupPaintScale(min, max, Color.WHITE);
      if (min < 0) {
        for (int ci = 0; ci <= 255; ci++) {
          double v = -(ci / 255.0) * range - rangeBase;
          scale.add(v, new Color(0, ci, ci));
        }
      }
      if (max > 0) {
        for (int ci = 0; ci <= 255; ci++) {
          double v = (ci / 255.0) * range + rangeBase;
          scale.add(v, new Color(ci, ci, 0));
        }
      }
      renderer.setPaintScale(scale);
      renderer.setSeriesToolTipGenerator(0, new StandardXYZToolTipGenerator());
      int displayResolution =
          ((Integer) results[0].getProperty("display time resolution")).intValue();
      renderer.setBlockWidth(1000.0 / displayResolution);
      renderer.setBlockHeight(1000.0 / displayResolution);

      NumberAxis xAxis = new NumberAxis("\u0394t1 (ms)");
      NumberAxis yAxis = new NumberAxis("\u0394t2 (ms)");

      XYPlot plot = new XYPlot(plotData, xAxis, yAxis, renderer);
      plot.setDomainGridlinesVisible(false);

      resultsPlot = new JFreeChart(title, plot);
      resultsPlot.removeLegend();
      NumberAxis valueAxis = new NumberAxis();
      valueAxis.setLowerBound(scale.getLowerBound());
      valueAxis.setUpperBound(scale.getUpperBound());
      PaintScaleLegend legend = new PaintScaleLegend(scale, valueAxis);
      legend.setPosition(RectangleEdge.RIGHT);
      legend.setMargin(5, 5, 5, 5);
      resultsPlot.addSubtitle(legend);
    }

    if (showInFrame) {
      JFrame plotFrame = new JFrame(title);
      plotFrame.add(new ChartPanel(resultsPlot));
      plotFrame.setExtendedState(plotFrame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
      plotFrame.pack();
      plotFrame.setVisible(true);
    }

    return resultsPlot;
  }
 @SuppressWarnings("static-access")
 public void MaxFrame() {
   super.setExtendedState(super.MAXIMIZED_BOTH);
 }
Exemple #23
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frame = new JFrame();
    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    // icon
    frame.setIconImage(
        new ImageIcon(this.getClass().getResource("/Textures/logoico.png")).getImage());

    frame.addWindowFocusListener(
        new WindowFocusListener() {
          public void windowGainedFocus(WindowEvent arg0) {
            m_panelAnalyse.updateAnalyse();
          }

          public void windowLostFocus(WindowEvent arg0) {}
        });
    frame.addWindowListener(
        new WindowAdapter() {

          @Override
          public void windowClosing(WindowEvent e) {
            try {
              JOptionPane.showMessageDialog(null, "Fermeture");

              SqlLiteInterface.close();

            } catch (SQLException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
            }
          }
        });
    frame.setSize(1152, 864);
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JMenuBar menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);

    JMenu menuFichier = new JMenu("Fichier");
    menuBar.add(menuFichier);

    mQuitter = new JMenuItem("Quitter");
    mQuitter.addActionListener(this);
    mQuitter.setActionCommand("QUITTER");
    menuFichier.add(mQuitter);

    JMenu menuEdition = new JMenu("Edition");
    menuBar.add(menuEdition);

    JMenuItem mAddRir = new JMenuItem("Ajouter un RIR");
    mAddRir.setActionCommand("ADDRIR");
    mAddRir.addActionListener(this);
    menuEdition.add(mAddRir);

    mListRir = new JMenuItem("Lister l'ensemble des RIR");
    mListRir.setActionCommand("LISTRIR");
    mListRir.addActionListener(this);
    menuEdition.add(mListRir);

    menuRecherche = new JMenu("Recherche");
    menuBar.add(menuRecherche);

    mRechercheDrogue = new JMenuItem("Recherche (Drogue)");
    mRechercheDrogue.addActionListener(this);
    mRechercheDrogue.setActionCommand("RECHERCHE_DROGUE");
    menuRecherche.add(mRechercheDrogue);

    mRechercheQuartier = new JMenuItem("Recherche (Quartier)");
    mRechercheQuartier.addActionListener(this);
    mRechercheQuartier.setActionCommand("RECHERCHE_QUARTIER");
    menuRecherche.add(mRechercheQuartier);

    mRecherchePersonne = new JMenuItem("Recherche d'une Personne");
    mRecherchePersonne.addActionListener(this);
    mRecherchePersonne.setActionCommand("RECHERCHE_PERSONNE");
    menuRecherche.add(mRecherchePersonne);

    mRechercheMtp = new JMenuItem("Recherche d'un Moyen de Transport");
    mRechercheMtp.addActionListener(this);
    mRechercheMtp.setActionCommand("RECHERCHE_MTP");
    menuRecherche.add(mRechercheMtp);

    mRechercheContact = new JMenuItem("Recherche d'un num\u00E9ro de Contact");
    mRechercheContact.addActionListener(this);
    mRechercheContact.setActionCommand("RECHERCHE_CONTACT");
    menuRecherche.add(mRechercheContact);

    mRechercheInfo = new JMenuItem("Recherche dans le contenu de l'information (RIR)");
    mRechercheInfo.addActionListener(this);
    mRechercheInfo.setActionCommand("RECHERCHE_INFO");
    menuRecherche.add(mRechercheInfo);

    mMultipleRecherche = new JMenuItem("Recherche crois\u00E9e");
    mMultipleRecherche.addActionListener(this);
    mMultipleRecherche.setActionCommand("RECHERCHE_CROISEE");
    mMultipleRecherche.setBackground(UIManager.getColor("activeCaption"));
    menuRecherche.add(mMultipleRecherche);

    menuAide = new JMenu("Aide");
    menuBar.add(menuAide);

    mAbout = new JMenuItem("Au sujet de RirDrugsManager");
    mAbout.setActionCommand("ABOUT");
    mAbout.addActionListener(this);
    menuAide.add(mAbout);
    frame.getContentPane().setLayout(new BorderLayout(0, 64));

    panelLogo = new panelLogo();
    frame.getContentPane().add(panelLogo, BorderLayout.CENTER);

    m_panelAnalyse = new panelAnalyse();

    frame.getContentPane().add(m_panelAnalyse, BorderLayout.SOUTH);

    panelDev = new JPanel();
    FlowLayout flowLayout = (FlowLayout) panelDev.getLayout();
    flowLayout.setAlignment(FlowLayout.RIGHT);
    frame.getContentPane().add(panelDev, BorderLayout.NORTH);

    m_lDev = new JLabel("Developp\u00E9 par THONON C\u00E9dric");
    m_lDev.setFont(new Font("Tahoma", Font.PLAIN, 9));
    panelDev.add(m_lDev);

    // instance du sqlinterface
    sqlLite = new SqlLiteInterface();
    try {
      //	sqlLite.prepareSchemaSQLLITE();
      sqlLite.prepareSchemaMYSQL();

    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      JOptionPane.showMessageDialog(null, "Erreur de chargement de la class : " + e.getMessage());
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      JOptionPane.showMessageDialog(
          null, "Exception dans la requete de préparation du schema : " + e.getMessage());
    }
  }
  public BaseballController() {

    // Connect to Database

    try {
      dataBase = new DBWrapper();
    } catch (SQLException e) {
      e.printStackTrace();
    }

    screen = new JFrame("Math Baseball");
    screen.setExtendedState(Frame.MAXIMIZED_BOTH);
    screen.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    inputManager = new InputManager(screen);
    createGameActions();
    loginPanel = new BackGroundPanel();
    loginPanel.setPreferredSize(screen.getSize());
    loginPanel.setOpaque(false);
    loginPanel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;

    uNameField = new JTextField();
    TextPrompt uText = new TextPrompt("Username", uNameField, TextPrompt.Show.FOCUS_LOST);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 1;
    loginPanel.add(uNameField, constraints);

    pWordField = new JPasswordField();
    TextPrompt pText = new TextPrompt("Password", pWordField, TextPrompt.Show.FOCUS_LOST);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 2;
    loginPanel.add(pWordField, constraints);

    isTeacher = new JRadioButton("Teacher");
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 3;
    loginPanel.add(isTeacher, constraints);

    loginButton = createButton("loginButton", "To Login");
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 4;
    loginPanel.add(loginButton, constraints);

    registerButton = new JButton("Register");
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 5;
    constraints.anchor = GridBagConstraints.PAGE_END;
    loginPanel.add(registerButton, constraints);

    Container contentPane = screen.getContentPane();
    // make sure the content pane is transparent
    if (contentPane instanceof JComponent) {
      ((JComponent) contentPane).setOpaque(false);
    }
    // add components to the screen's content pane
    contentPane.add(loginPanel);
    screen.setVisible(true);
    screen.validate();
    // screen.repaint();
    // add listeners
    isTeacher.addActionListener(this);
    loginButton.addActionListener(this);
    registerButton.addActionListener(this);
  }
Exemple #25
0
  /**
   * The main function of the game. Something fun starts here. :)
   *
   * @param args passed command line arguments.
   */
  public static void main(String[] args) {

    if (!Resource.getInstance().initialize()) {
      JOptionPane.showMessageDialog(
          null, "Resource loading fail.", "Cannot open game", JOptionPane.ERROR_MESSAGE);
      return;
    }
    if (!LevelFileManager.getInstance().initialize()) {
      JOptionPane.showMessageDialog(
          null, "Level files loading fail.", "Cannot open game", JOptionPane.ERROR_MESSAGE);
      return;
    }

    // Create JFrame
    JFrame frame = new JFrame(Constants.PROGRAM_NAME);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // frame.setResizable(false);
    frame.setMinimumSize(Constants.MINIMUM_WINDOW_SIZE);
    frame
        .getContentPane()
        .addComponentListener(
            new ComponentListener() {

              @Override
              public void componentShown(ComponentEvent arg0) {}

              @Override
              public void componentResized(ComponentEvent arg0) {
                DrawManager.getInstance()
                    .setCanvasSize(
                        frame.getContentPane().getWidth(), frame.getContentPane().getHeight());
              }

              @Override
              public void componentMoved(ComponentEvent arg0) {}

              @Override
              public void componentHidden(ComponentEvent arg0) {}
            });

    if (Constants.IS_FULLSCREEN) {
      frame.setUndecorated(true);
      frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    } else {
      frame.getContentPane().setPreferredSize(Constants.DEFAULT_SCREEN_SIZE);
      frame.pack();
    }

    InputManager.setListenerTo(frame);

    frame.getContentPane().setBackground(ColorSwatch.BACKGROUND);
    frame.setVisible(true);

    // Add canvas to the frame
    DrawManager.getInstance().addCanvasInto(frame);
    DrawManager.getInstance()
        .setCanvasSize(frame.getContentPane().getWidth(), frame.getContentPane().getHeight());

    // Set initial scene

    SceneManager.getInstance().setNextScene(new scene.mainmenu.MainMenuScene(true));
    // SceneManager.getInstance().setNextScene(new stage.GameStage(GameStageType.PLAY));

    // Game looper
    final long maximumWaitTime = 1000000000 / Constants.MAX_FRAME_PER_SECOND;
    long updateTime;
    Resource.getInstance().themeSong.loop();
    while (true) {
      // Perform a game update (including game logic and painting)
      updateTime = System.nanoTime();
      SceneManager.getInstance().update();
      updateTime = System.nanoTime() - updateTime;

      if (updateTime < maximumWaitTime) {
        FPSCollector.add(Constants.MAX_FRAME_PER_SECOND);
      } else {
        FPSCollector.add(Math.round(1000000000 / updateTime));
      }

      // Perform sleeping to limit maximum FPS
      if (updateTime < maximumWaitTime) {
        try {
          Thread.sleep((maximumWaitTime - updateTime) / 1000000);
        } catch (InterruptedException e) {
          Thread.interrupted();
          e.printStackTrace();
        }
      }
    }
  }
  public GraphArrayWindow(
      AllCommandsExecutor allCommandsExecutor,
      SimulationConstructionSet sim,
      GUIEnablerAndDisabler guiEnablerAndDisabler,
      ConfigurationList configurationList,
      GraphGroupList graphGroupList,
      String graphGroupName,
      GraphConfigurationList graphConfigurationList,
      SelectedVariableHolder selectedVariableHolder,
      DataBuffer dataBuffer,
      StandardGUIActions mainGUIActions,
      int screenID,
      Point windowLocation,
      Dimension windowSize,
      boolean maximizeWindow) {
    this.configurationList = configurationList;
    this.graphGroupList = graphGroupList;
    this.graphConfigurationList = graphConfigurationList;

    GraphicsConfiguration configurationToUse = null;
    GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices();
    for (int j = 0; j < devices.length; j++) {
      // GraphicsDevice graphicsDevice = devices[j];
      if (devices[j].toString().indexOf("screen=" + screenID) >= 0)
        configurationToUse = devices[j].getDefaultConfiguration();
    }

    String windowName;

    if (graphGroupName != null) {
      windowName = "Graph Window: " + graphGroupName;
      this.name = graphGroupName;
    } else {
      windowName = "Graph Window";
      this.name = "Unnamed";
    }

    frame = new JFrame(windowName, configurationToUse);
    frame.setName(windowName);
    myGraphArrayPanel = new GraphArrayPanel(selectedVariableHolder, dataBuffer, frame);

    windowGUIActions = new StandardGUIActions();

    SaveGraphConfigurationDialogConstructor saveGraphConfigurationDialogConstructor =
        new SaveGraphConfigurationDialogGenerator(guiEnablerAndDisabler, frame, myGraphArrayPanel);

    LoadGraphGroupDialogConstructor loadGraphGroupDialogConstructor =
        new LoadGraphGroupDialogGenerator(
            sim, sim.getStandardSimulationGUI(), this, frame, myGraphArrayPanel);

    PrintGraphsDialogConstructor printGraphsDialogConstructor =
        new PrintGraphsDialogGenerator(myGraphArrayPanel);

    ExportGraphsToFileConstructor exportGraphsToFileConstructor;
    if (USE_CSV_INSTEAD_OF_MATLAB) {
      exportGraphsToFileConstructor =
          new CsvExportGraphsToFileGenerator(
              sim, frame, myGraphArrayPanel, sim.getStandardSimulationGUI());
    } else {
      exportGraphsToFileConstructor =
          new MatlabExportGraphsToFileGenerator(
              sim, frame, myGraphArrayPanel, sim.getStandardSimulationGUI());
    }

    windowGUIActions.createGraphWindowActions(
        mainGUIActions,
        myGraphArrayPanel,
        saveGraphConfigurationDialogConstructor,
        loadGraphGroupDialogConstructor,
        printGraphsDialogConstructor,
        exportGraphsToFileConstructor);
    JPanel buttonPanel = windowGUIActions.createGraphWindowButtons();
    JMenuBar menuBar = windowGUIActions.createGraphWindowMenus();

    frame.setJMenuBar(menuBar);

    frame.getContentPane().add(buttonPanel, "South");

    JPanel graphArrayAndButtonPanel = new JPanel(new java.awt.BorderLayout());
    graphArrayAndButtonPanel.add("Center", myGraphArrayPanel);

    JPanel graphButtonPanel = myGraphArrayPanel.createGraphButtonPanel();
    graphArrayAndButtonPanel.add("South", graphButtonPanel);

    frame.getContentPane().add(graphArrayAndButtonPanel);

    this.selectGraphGroup(graphGroupName);

    if (windowLocation != null) frame.setLocation(windowLocation);

    frame.pack();

    if (maximizeWindow) {
      frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    } else if (windowSize != null) frame.setSize(windowSize);

    frame.setVisible(true);
  }