示例#1
0
  public MapEditor(LocalSettings localSettings) throws HeadlessException {
    setTitle(TITLE);
    setSize(WIDTH, HEIGHT);

    this.localSettings = localSettings;

    mainpane = new JDesktopPane();
    mainpane.setSize(WIDTH, HEIGHT);
    mainpane.setBackground(Color.GRAY);
    setContentPane(mainpane);

    LwjglApplicationConfiguration configuration = new LwjglApplicationConfiguration();
    configuration.width = WIDTH;
    configuration.height = HEIGHT;

    levelHolder = new LevelHolder();
    final LwjglCanvas lwjglCanvas = new LwjglCanvas(levelHolder, configuration);
    canvas = lwjglCanvas;
    levelHolderFrame = new JInternalFrame("EnJine2D Map", false, false, false, true);
    levelHolderFrame.setSize(WIDTH, HEIGHT);
    levelHolderFrame.setVisible(true);

    palette = new Palette("Palette", true, false, true, true);
    palette.setVisible(true);
    palette.setLevelHolder(levelHolder);
    levelHolder.setPalette(palette);

    getContentPane().add(palette);
    getContentPane().add(levelHolderFrame);

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            levelHolderFrame.getContentPane().add(lwjglCanvas.getCanvas());
            setVisible(true);
          }
        });

    loadSettings();

    levelHolderFrame.addComponentListener(this);
    palette.addComponentListener(this);

    addWindowListener(this);
  }
 protected void installDefaults() {
   if (desktop.getBackground() == null || desktop.getBackground() instanceof UIResource) {
     desktop.setBackground(UIManager.getColor("Desktop.background"));
   }
   LookAndFeel.installProperty(desktop, "opaque", Boolean.TRUE);
 }
示例#3
0
  public MainWindow() {
    JMenuItem showTextItem, showContentItem, showStatsItem;
    JMenuItem consoleWinItem, treeWinItem, traceWinItem;

    // our libgist execution thread
    opThread = new OpThread(this);
    Libgist.setBreakHandler(opThread);
    opThread.start();
    cmd = new LibgistCommand();

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

    // create toolbar and console window with text area

    getContentPane().removeAll();
    getContentPane().setLayout(new BorderLayout());
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    // desktop pane + console frame
    desktop = new JDesktopPane();
    desktop.setOpaque(true);
    desktop.setBackground(Color.lightGray);
    consoleFrame = new ConsoleWindow(200, desktop);
    desktop.add(consoleFrame, JLayeredPane.PALETTE_LAYER);

    // debugging actions for toolbar:
    // notify opThread of what to do when it hits a breakpoint
    stepAction =
        new AbstractAction("Step") {
          public void actionPerformed(ActionEvent e) {
            opThread.step();
          }
        };
    cancelAction =
        new AbstractAction("Cancel") {
          public void actionPerformed(ActionEvent e) {
            scriptWasCancelled = true; // don't call it after next line!
            opThread.cancel();
          }
        };
    nextAction =
        new AbstractAction("Next") {
          public void actionPerformed(ActionEvent e) {
            opThread.next();
          }
        };
    contAction =
        new AbstractAction("Continue") {
          public void actionPerformed(ActionEvent e) {
            opThread.cont();
          }
        };

    // opThread is currently executing a script and we want it to stop:
    // tell libgist directly to suspend execution once opThread is done
    // with the current operation
    stopAction =
        new AbstractAction("Stop") {
          public void actionPerformed(ActionEvent e) {
            Libgist.singleStep();
          }
        };

    // toolbar
    JToolBar toolbar = new JToolBar();
    toolbar.add(stepAction).setText("Step");
    toolbar.add(nextAction).setText("Next");
    toolbar.add(contAction).setText("Continue");
    toolbar.add(stopAction).setText("Stop");
    toolbar.add(cancelAction).setText("Cancel");

    panel.add(toolbar, BorderLayout.NORTH);
    panel.add(desktop, BorderLayout.CENTER);
    getContentPane().add(panel);

    createFileMenu();
    createOpsMenu();
    createDebugMenu();
    createTreeStatsMenu();
    createAnalysisMenu();
    createWindowsMenu();

    setGuiState(INITSTATE); // nothing opened yet

    // addWindowListener(this); // So we do the right thing on window closing.
  }