/** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user pressed the ok button
   if (e.getSource() == ok_button) {
     filter_include_list = include_panel.getServiceList();
     filter_exclude_list = exclude_panel.getServiceList();
     if (status_box.isSelected()) {
       filter_active = status_active.isSelected();
       filter_complete = status_complete.isSelected();
     } else {
       filter_active = false;
       filter_complete = false;
     }
     ok_pressed = true;
     dialog.dispose();
   }
   // Check if the user pressed the cancel button
   if (e.getSource() == cancel_button) {
     dialog.dispose();
   }
   // Check if the user changed the status filter option
   if (e.getSource() == status_box) {
     status_active.setEnabled(status_box.isSelected());
     status_complete.setEnabled(status_box.isSelected());
   }
 }
 public void hideDialog(JDialog dialog, Project project) {
   if (project == null) {
     dialog.dispose();
   } else {
     IdeFrameImpl frame = getFrame(project);
     if (frame.isActive()) {
       dialog.dispose();
     } else {
       queueForDisposal(dialog, project);
       dialog.setVisible(false);
     }
   }
 }
 private void proceedDialogDisposalQueue(Project project) {
   Set<JDialog> dialogs = myDialogsToDispose.get(project);
   if (dialogs == null) return;
   for (JDialog dialog : dialogs) {
     dialog.dispose();
   }
   myDialogsToDispose.put(project, null);
 }
Beispiel #4
0
    @Override
    public void dispose() {
      if (isShowing()) {
        hide();
      }

      if (myWindowListener != null) {
        myWindowListener.saveSize();
        removeWindowListener(myWindowListener);
        myWindowListener = null;
      }

      if (myComponentListener != null) {
        removeComponentListener(myComponentListener);
        myComponentListener = null;
      }

      if (myFocusTrackback != null
          && !(myFocusTrackback.isSheduledForRestore()
              || myFocusTrackback.isWillBeSheduledForRestore())) {
        myFocusTrackback.dispose();
        myFocusTrackback = null;
      }

      final BufferStrategy strategy = getBufferStrategy();
      if (strategy != null) {
        strategy.dispose();
      }
      super.dispose();

      if (rootPane != null) { // Workaround for bug in native code to hold rootPane
        try {
          Field field = rootPane.getClass().getDeclaredField("glassPane");
          field.setAccessible(true);
          field.set(rootPane, null);

          field = rootPane.getClass().getDeclaredField("contentPane");
          field.setAccessible(true);
          field.set(rootPane, null);
          rootPane = null;

          field = Window.class.getDeclaredField("windowListener");
          field.setAccessible(true);
          field.set(this, null);
        } catch (Exception ignored) {
        }
      }

      // http://bugs.sun.com/view_bug.do?bug_id=6614056
      try {
        final Field field = Dialog.class.getDeclaredField("modalDialogs");
        field.setAccessible(true);
        final List<?> list = (List<?>) field.get(null);
        list.remove(this);
      } catch (final Exception ignored) {
      }
    }
 public void testWaitForDialogWithActiveWindowAsTargetDialog() throws InterruptedException {
   JFrame frame = new JFrame();
   JDialog testDialog = new JDialog(frame, "testDialog");
   setFocusManager(testDialog);
   windowContext.propertyChange(new PropertyChangeEvent(this, "focusOwner", null, testDialog));
   windowContext.waitForDialogOpening("testDialog", 10);
   assertSame(testDialog, windowContext.activeWindow());
   testDialog.dispose();
   frame.dispose();
 }
 public void dispose() {
   f.dispose();
   f = null;
   dummy.dispose();
   dummy = null;
   if (modal_d != null) {
     modal_d.dispose();
     modal_d = null;
   }
 }
 public void testWaitForActiveDialogWhenDialogIsNotReady() throws InterruptedException {
   final JDialog testDialog = new JDialog(new JFrame(), "testDialog");
   setFocusManager(testDialog);
   new Thread(
           new Runnable() {
             public void run() {
               windowContext.propertyChange(
                   new PropertyChangeEvent(this, "focusOwner", null, testDialog));
             }
           })
       .start();
   windowContext.waitForDialogOpening("testDialog", 10);
   assertEquals(testDialog, windowContext.activeWindow());
   testDialog.dispose();
 }
Beispiel #8
0
  public static Map[] showOpenMapDialog(final JFrame owner) throws IOException {
    final JFileChooser ch = new JFileChooser();
    if (config.getFile("mapLastOpenDir") != null) {
      ch.setCurrentDirectory(config.getFile("mapLastOpenDir"));
    }
    ch.setDialogType(JFileChooser.OPEN_DIALOG);
    ch.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    if (ch.showOpenDialog(MainFrame.getInstance()) != JFileChooser.APPROVE_OPTION) {
      return null;
    }
    final File dir = ch.getSelectedFile();
    config.set("mapLastOpenDir", dir);
    final String[] maps = dir.list(FILTER_TILES);
    for (int i = 0; i < maps.length; ++i) {
      maps[i] = maps[i].substring(0, maps[i].length() - MapIO.EXT_TILE.length());
    }
    final JDialog dialog = new JDialog(owner, Lang.getMsg("gui.chooser"));
    dialog.setModal(true);
    dialog.setLocationRelativeTo(null);
    dialog.setLayout(new BorderLayout());

    final JList list = new JList(maps);
    final JButton btn = new JButton(Lang.getMsg("gui.chooser.Ok"));

    btn.addActionListener(
        new AbstractAction() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            if (list.getSelectedValue() != null) {
              dialog.setVisible(false);
            }
          }
        });

    dialog.add(new JScrollPane(list), BorderLayout.CENTER);
    dialog.add(btn, BorderLayout.SOUTH);
    dialog.pack();
    dialog.setVisible(true);
    dialog.dispose();

    Map[] loadedMaps = new Map[list.getSelectedIndices().length];
    for (int i = 0; i < list.getSelectedIndices().length; i++) {
      loadedMaps[i] = MapIO.loadMap(dir.getPath(), (String) list.getSelectedValues()[i]);
    }
    return loadedMaps;
  }
Beispiel #9
0
 @Override
 public void dispose() {
   super.dispose();
   uninstallSheet();
 }
 /** Destroy this object */
 public void destroy() {
   if (viewDialog != null) {
     viewDialog.dispose();
     viewDialog = null;
   }
 }
Beispiel #11
0
 @Override
 public void update() {
   prog.dispose();
 }
 public void hide(boolean dispose) {
   myDialog.setVisible(false);
   if (dispose) {
     myDialog.dispose();
   }
 }
Beispiel #13
0
  public static Map showNewMapDialog(final JFrame owner) {
    final JDialog dialog = new JDialog(owner, Lang.getMsg("gui.newmap"));
    dialog.getContentPane().setLayout(new BoxLayout(dialog.getContentPane(), BoxLayout.PAGE_AXIS));
    dialog.setResizable(false);
    dialog.setLocationRelativeTo(null);
    dialog.setModal(true);
    final JSpinner width = new JSpinner(new SpinnerNumberModel(100, 0, UNSIGNED_MAX, 1));
    final JSpinner height = new JSpinner(new SpinnerNumberModel(100, 0, UNSIGNED_MAX, 1));
    final JSpinner x = new JSpinner(new SpinnerNumberModel(0, -SIGNED_MAX, SIGNED_MAX, 1));
    final JSpinner y = new JSpinner(new SpinnerNumberModel(0, -SIGNED_MAX, SIGNED_MAX, 1));
    final JSpinner l = new JSpinner(new SpinnerNumberModel(0, -SIGNED_MAX, SIGNED_MAX, 1));
    final JTextField name = new JTextField(1);
    final JButton btn = new JButton(Lang.getMsg("gui.newmap.Ok"));
    saveDir = null;
    btn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            final JFileChooser ch =
                new JFileChooser(MapEditor.getConfig().getFile("mapLastOpenDir"));
            ch.setDialogType(JFileChooser.OPEN_DIALOG);
            ch.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

            if (ch.showOpenDialog(MainFrame.getInstance()) != JFileChooser.APPROVE_OPTION) {
              dialog.setVisible(false);
              return;
            }
            saveDir = ch.getSelectedFile();
            dialog.setVisible(false);
          }
        });

    dialog.add(new JLabel(Lang.getMsg("gui.newmap.Width")));
    dialog.add(width);
    dialog.add(new JLabel(Lang.getMsg("gui.newmap.Height")));
    dialog.add(height);
    dialog.add(new JLabel(Lang.getMsg("gui.newmap.X")));
    dialog.add(x);
    dialog.add(new JLabel(Lang.getMsg("gui.newmap.Y")));
    dialog.add(y);
    dialog.add(new JLabel(Lang.getMsg("gui.newmap.Z")));
    dialog.add(l);
    dialog.add(new JLabel(Lang.getMsg("gui.newmap.Name")));
    dialog.add(name);
    dialog.add(btn);
    dialog.doLayout();
    dialog.pack();
    dialog.setVisible(true);
    dialog.dispose();

    if (saveDir != null) {
      return new Map(
          name.getText(),
          saveDir.getPath(),
          (Integer) width.getValue(),
          (Integer) height.getValue(),
          (Integer) x.getValue(),
          (Integer) y.getValue(),
          (Integer) l.getValue());
    }
    return null;
  }
Beispiel #14
0
  public void actionPerformed(ActionEvent evt) {
    Graphics g = getGraphics();
    if (evt.getSource() == openItem) {
      JFileChooser chooser = new JFileChooser();
      common.chooseFile(chooser, "./images", 0); // 设置默认目录,过滤文件
      int r = chooser.showOpenDialog(null);

      if (r == JFileChooser.APPROVE_OPTION) {
        String name = chooser.getSelectedFile().getAbsolutePath();

        // 装载图像
        iImage = common.openImage(name, new MediaTracker(this));

        // 取载入图像的宽和高
        iw = iImage.getWidth(null);
        ih = iImage.getHeight(null);
        bImage = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = bImage.createGraphics();
        g2.drawImage(iImage, 0, 0, null);
        loadflag = true;
        repaint();
      }
    } else if (evt.getSource() == rotateItem) // 内置旋转
    {
      setTitle("第4章 图像几何变换 内置旋转 作者 孙燮华");
      common.draw(g, iImage, bImage, common.getParam("旋转角(度):", "30"), 0, 0);
    } else if (evt.getSource() == scaleItem) // 内置缩放
    {
      setTitle("第4章 图像几何变换 内置缩放 作者 孙燮华");
      // 参数选择面板
      Parameters pp = new Parameters("参数", "x方向:", "y方向:", "1.5", "1.5");
      setPanel(pp, "内置缩放");
      float x = pp.getPadx();
      float y = pp.getPady();
      common.draw(g, iImage, bImage, x, y, 1);
    } else if (evt.getSource() == shearItem) // 内置错切
    {
      setTitle("第4章 图像几何变换 内置错切 作者 孙燮华");
      Parameters pp = new Parameters("参数", "x方向:", "y方向:", "0.5", "0.5");
      setPanel(pp, "内置错切");
      float x = pp.getPadx();
      float y = pp.getPady();
      common.draw(g, iImage, bImage, x, y, 2);
    } else if (evt.getSource() == transItem) // 内置平移
    {
      setTitle("第4章 图像几何变换 内置平移 作者 孙燮华");
      Parameters pp = new Parameters("参数", "x方向:", "y方向:", "100", "50");
      setPanel(pp, "内置平移");
      float x = pp.getPadx();
      float y = pp.getPady();
      common.draw(g, iImage, bImage, x, y, 3);
    } else if (evt.getSource() == rotItem) // 旋转算法
    {
      setTitle("第4章 图像几何变换 旋转算法 作者 孙燮华");
      pix = common.grabber(iImage, iw, ih);

      // 旋转,输出图像宽高
      int owh = (int) (Math.sqrt(iw * iw + ih * ih + 0.5));
      opix = geom.imRotate(pix, common.getParam("旋转角(度):", "30"), iw, ih, owh);

      // 将数组中的象素产生一个图像
      MemoryImageSource memoryImage =
          new MemoryImageSource(owh, owh, ColorModel.getRGBdefault(), opix, 0, owh);
      oImage = createImage(memoryImage);
      common.draw(g, iImage, oImage, iw, ih, owh, 4);
    } else if (evt.getSource() == mirItem) // 镜象算法(type:5)
    {
      setTitle("第4章 图像几何变换 镜象算法 作者 孙燮华");
      Parameters pp = new Parameters("选择镜象类型", "水平", "垂直");
      setPanel(pp, "镜象算法");

      pix = common.grabber(iImage, iw, ih);
      opix = geom.imMirror(pix, iw, ih, pp.getRadioState());
      ImageProducer ip = new MemoryImageSource(iw, ih, opix, 0, iw);
      oImage = createImage(ip);
      common.draw(g, iImage, oImage, iw, ih, 0, 5);
    } else if (evt.getSource() == shrItem) // 错切算法(type:6)
    {
      setTitle("第4章 图像几何变换 错切算法 作者 孙燮华");
      Parameters pp = new Parameters("参数", "x方向:", "y方向:", "0.5", "0.5");
      setPanel(pp, "错切算法");

      pix = common.grabber(iImage, iw, ih);

      float shx = pp.getPadx();
      float shy = pp.getPady();

      // 计算包围盒的宽和高
      int ow = (int) (iw + (ih - 1) * shx);
      int oh = (int) ((iw - 1) * shy + ih);

      if (shx > 0 && shy > 0) {
        opix = geom.imShear(pix, shx, shy, iw, ih, ow, oh);
        ImageProducer ip = new MemoryImageSource(ow, oh, opix, 0, ow);
        oImage = createImage(ip);
        common.draw(g, iImage, oImage, iw, ih, 0, 6);
      } else JOptionPane.showMessageDialog(null, "参数必须为正数!");
    } else if (evt.getSource() == trnItem) {
      setTitle("第4章 图像几何变换 平移算法 作者 孙燮华");
      Parameters pp = new Parameters("参数", "x方向:", "y方向:", "100", "50");
      setPanel(pp, "平移算法");
      pix = common.grabber(iImage, iw, ih);
      int tx = (int) pp.getPadx();
      int ty = (int) pp.getPady();

      if (tx > 0 && ty > 0) {
        int ow = iw + tx;
        int oh = ih + ty;
        opix = geom.imTrans(pix, tx, ty, iw, ih, ow, oh);
        ImageProducer ip = new MemoryImageSource(ow, oh, opix, 0, ow);
        oImage = createImage(ip);
        common.draw(g, iImage, oImage, iw, ih, 0, 7);
      } else JOptionPane.showMessageDialog(null, "参数必须为正数!");
    } else if (evt.getSource() == nearItem) {
      setTitle("第4章 图像几何变换 最邻近插值算法 作者 孙燮华");
      pix = common.grabber(iImage, iw, ih);

      float p =
          (Float.valueOf(JOptionPane.showInputDialog(null, "输入缩放参数(0.1-3.0)", "1.50")))
              .floatValue();
      int ow = (int) (p * iw); // 计算目标图宽高
      int oh = (int) (p * ih);
      opix = geom.nearNeighbor(pix, iw, ih, ow, oh, p);
      ImageProducer ip = new MemoryImageSource(ow, oh, opix, 0, ow);
      oImage = createImage(ip);
      common.draw(g, oImage, "最邻近插值", p);
    } else if (evt.getSource() == linrItem) {
      setTitle("第4章 图像几何变换 双线性插值算法 作者 孙燮华");
      pix = common.grabber(iImage, iw, ih);

      float p =
          (Float.valueOf(JOptionPane.showInputDialog(null, "输入缩放参数(0.1-3.0)", "1.50")))
              .floatValue();
      int ow = (int) (p * iw); // 计算目标图宽高
      int oh = (int) (p * ih);
      opix = geom.bilinear(pix, iw, ih, ow, oh, p);
      ImageProducer ip = new MemoryImageSource(ow, oh, opix, 0, ow);
      oImage = createImage(ip);
      common.draw(g, oImage, "双线性插值", p);
    } else if (evt.getSource() == cubicItem) {
      setTitle("第4章 图像几何变换 三次卷积插值算法 作者 孙燮华");
      pix = common.grabber(iImage, iw, ih);

      float p =
          (Float.valueOf(JOptionPane.showInputDialog(null, "输入缩放参数(1.1-3.0)", "1.50")))
              .floatValue();
      if (p < 1) {
        JOptionPane.showMessageDialog(null, "参数p必须大于1!");
        return;
      }
      int ow = (int) (p * iw); // 计算目标图宽高
      int oh = (int) (p * ih);
      opix = geom.scale(pix, iw, ih, ow, oh, p, p);
      ImageProducer ip = new MemoryImageSource(ow, oh, opix, 0, ow);
      oImage = createImage(ip);
      common.draw(g, oImage, "三次卷积插值", p);
    } else if (evt.getSource() == okButton) dialog.dispose();
    else if (evt.getSource() == exitItem) System.exit(0);
  }
 public void close() {
   JDialog dlg = (JDialog) parentContainer;
   dlg.setVisible(false);
   dlg.dispose();
 }
Beispiel #16
0
 @Override
 public void actionPerformed(ActionEvent arg0) {
   window.dispose();
 }
 /**
  * Disposes of the virtual entry dialog that is opened as a prompt when the user may want to edit
  * a virtual entry.
  */
 public void shutVirtualEntryDialog() {
   if (virtualEntryDialog != null) {
     virtualEntryDialog.setVisible(false);
     virtualEntryDialog.dispose();
   }
 }
Beispiel #18
0
 /** Overwrite dispose to stop the progress bar */
 public void dispose() {
   progressBar.stop();
   if (dialog != null) {
     dialog.dispose();
   }
 }
 /** Hide tracker */
 public final void hide() {
   dialog.dispose();
 }
  private void plotDataOnGraphics(
      Graphics g,
      final MainWindow mainWindow,
      final int w,
      final int h,
      final HiC hic,
      final JPanel hiCPanel) {
    // Print the panel on created graphics.
    if (w == mainWindow.getWidth() && h == mainWindow.getHeight()) {
      hiCPanel.printAll(g);
    } else {
      JDialog waitDialog = new JDialog();
      JPanel panel1 = new JPanel();
      panel1.add(new JLabel("  Creating and saving " + w + " by " + h + " image  "));
      // panel1.setPreferredSize(new Dimension(250,50));
      waitDialog.add(panel1);
      waitDialog.setTitle("Please wait...");
      waitDialog.pack();
      waitDialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

      waitDialog.setLocation(100, 100);
      waitDialog.setVisible(true);
      mainWindow.setVisible(false);

      Dimension minSize = mainWindow.getMinimumSize();
      Dimension prefSize = mainWindow.getPreferredSize();

      hic.centerBP(0, 0);
      mainWindow.setMinimumSize(new Dimension(w, h));
      mainWindow.setPreferredSize(new Dimension(w, h));
      mainWindow.pack();

      mainWindow.setState(Frame.ICONIFIED);
      mainWindow.setState(Frame.NORMAL);
      mainWindow.setVisible(true);
      mainWindow.setVisible(false);

      final Runnable painter =
          new Runnable() {
            public void run() {
              hiCPanel.paintImmediately(0, 0, w, h);
            }
          };

      Thread thread =
          new Thread(painter) {
            public void run() {
              try {
                SwingUtilities.invokeAndWait(painter);
              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          };

      thread.start();
      hiCPanel.printAll(g);
      mainWindow.setPreferredSize(prefSize);
      mainWindow.setMinimumSize(minSize);
      mainWindow.setSize(new Dimension(w, h));
      waitDialog.setVisible(false);
      waitDialog.dispose();
      mainWindow.setVisible(true);
    }
  }