/**
   * Method declaration
   *
   * @param s
   */
  private void addToRecent(String s) {

    for (int i = 0; i < iMaxRecent; i++) {
      if (s.equals(sRecent[i])) {
        return;
      }
    }

    if (sRecent[iRecent] != null) {
      mRecent.remove(iRecent);
    }

    sRecent[iRecent] = s;

    if (s.length() > 43) {
      s = s.substring(0, 40) + "...";
    }

    MenuItem item = new MenuItem(s);

    item.setActionCommand("#" + iRecent);
    item.addActionListener(this);
    mRecent.insert(item, iRecent);

    iRecent = (iRecent + 1) % iMaxRecent;
  }
示例#2
0
文件: Gray.java 项目: zqyhellen/graph
    public void setMenu()
    {
        Menu fileMenu = new Menu("File");
        openItem = new MenuItem("Open");
        openItem.addActionListener(this);
        fileMenu.add(openItem);

        exitItem = new MenuItem("Exit");
        exitItem.addActionListener(this);
        fileMenu.add(exitItem);        
        
        Menu processMenu = new Menu("PictureTreatment");
        grayItem = new MenuItem("gray level treatment");
        grayItem.addActionListener(this);
        processMenu.add(grayItem);
        
        processMenu.addSeparator();        
        contrastItem = new MenuItem("contrast level treatment");
        contrastItem.addActionListener(this);
        processMenu.add(contrastItem);        
            
        MenuBar menuBar = new MenuBar();
        menuBar.add(fileMenu);
        menuBar.add(processMenu);
        setMenuBar(menuBar);      
    }
  /**
   * Method declaration
   *
   * @param f
   * @param m
   */
  void addMenuItems(Menu f, String m[]) {

    for (int i = 0; i < m.length; i++) {
      MenuItem item = new MenuItem(m[i].substring(1));
      char c = m[i].charAt(0);

      if (c != '-') {
        item.setShortcut(new MenuShortcut(c));
      }

      item.addActionListener(this);
      f.add(item);
    }
  }
示例#4
0
  public void setMenu() {
    // 菜单界面
    Menu fileMenu = new Menu("文件");
    openItem = new MenuItem("打开");
    openItem.addActionListener(this);
    fileMenu.add(openItem);

    exitItem = new MenuItem("退出");
    exitItem.addActionListener(this);
    fileMenu.add(exitItem);

    Menu affineMenu = new Menu("内置变换");
    rotateItem = new MenuItem("内置旋转");
    rotateItem.addActionListener(this);
    affineMenu.add(rotateItem);

    affineMenu.addSeparator();
    scaleItem = new MenuItem("内置缩放");
    scaleItem.addActionListener(this);
    affineMenu.add(scaleItem);

    affineMenu.addSeparator();
    shearItem = new MenuItem("内置错切");
    shearItem.addActionListener(this);
    affineMenu.add(shearItem);

    affineMenu.addSeparator();
    transItem = new MenuItem("内置平移");
    transItem.addActionListener(this);
    affineMenu.add(transItem);

    Menu affin2Menu = new Menu("仿射变换");
    rotItem = new MenuItem("旋转算法");
    rotItem.addActionListener(this);
    affin2Menu.add(rotItem);

    affin2Menu.addSeparator();
    mirItem = new MenuItem("镜象算法");
    mirItem.addActionListener(this);
    affin2Menu.add(mirItem);

    affin2Menu.addSeparator();
    shrItem = new MenuItem("错切算法");
    shrItem.addActionListener(this);
    affin2Menu.add(shrItem);

    affin2Menu.addSeparator();
    trnItem = new MenuItem("平移算法");
    trnItem.addActionListener(this);
    affin2Menu.add(trnItem);

    Menu interpMenu = new Menu("图像插值");
    nearItem = new MenuItem("最邻近插值");
    nearItem.addActionListener(this);
    interpMenu.add(nearItem);

    interpMenu.addSeparator();
    linrItem = new MenuItem("双线性插值");
    linrItem.addActionListener(this);
    interpMenu.add(linrItem);

    interpMenu.addSeparator();
    cubicItem = new MenuItem("三次卷积插值");
    cubicItem.addActionListener(this);
    interpMenu.add(cubicItem);

    MenuBar menuBar = new MenuBar();
    menuBar.add(fileMenu);
    menuBar.add(affineMenu);
    menuBar.add(affin2Menu);
    menuBar.add(interpMenu);
    setMenuBar(menuBar);
  }