// Create a simple JToolBar with some buttons.
  protected JToolBar createToolBar() {
    JToolBar bar = new JToolBar();

    // Add simple actions for opening & saving.
    bar.add(getOpenAction()).setText("");
    bar.add(getSaveAction()).setText("");
    bar.addSeparator();

    // Add cut/copy/paste buttons.
    bar.add(textComp.getActionMap().get(DefaultEditorKit.cutAction)).setText("");
    bar.add(textComp.getActionMap().get(DefaultEditorKit.copyAction)).setText("");
    bar.add(textComp.getActionMap().get(DefaultEditorKit.pasteAction)).setText("");
    return bar;
  }
  /** Initialisation */
  private void initComponents() {
    setBackground(new java.awt.Color(114, 159, 255));
    addWindowListener(
        new java.awt.event.WindowAdapter() {
          public void windowClosing(java.awt.event.WindowEvent evt) {
            closeDialog();
          }
        });
    getContentPane().setLayout(new java.awt.BorderLayout());

    JPanel actionPanel = new JPanel();
    actionPanel.setLayout(new java.awt.GridLayout(1, 0));
    detailedArea.setEditable(false);
    detailedArea.setVisible(true);
    detailedArea.setSize(500, 300);
    detailedArea.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11));
    StringWriter opDetail = new StringWriter();
    actionPrint(new PrintWriter(opDetail));
    detailedArea.setText(new String(opDetail.getBuffer()));
    JScrollPane scroll = new JScrollPane(detailedArea);
    actionPanel.add(scroll);
    getContentPane().add(actionPanel, "Center");

    northToolBar = new javax.swing.JToolBar();
    northToolBar.setLayout(new java.awt.FlowLayout());
    northToolBar.setFloatable(false);

    jbn_Print = new javax.swing.JButton();
    jbn_Print.setText("   Print   ");
    jbn_Print.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jbn_PrintActionPerformed();
          }
        });
    northToolBar.add(jbn_Print);

    jbn_OK = new javax.swing.JButton();
    jbn_OK.setText("   Close   ");
    jbn_OK.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jbn_OKActionPerformed();
          }
        });
    northToolBar.add(jbn_OK);

    getContentPane().add(northToolBar, "South");
  }
    /** Returns the tool bar for the panel. */
    protected JComponent getToolBar() {
      JToolBar tbarDir = new JToolBar();
      JButton btnNew = new JButton();
      // m_btnSave = new JButton("Save File");
      // i118n
      // btnNew.setText("New Label");
      btnNew.setText(Util.getAdmLabel("_adm_New_Label"));
      btnNew.setActionCommand("new");
      // m_btnSave.setActionCommand("save");

      ActionListener alTool =
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              doAction(e);
            }
          };

      btnNew.addActionListener(alTool);
      // m_btnSave.addActionListener(alTool);

      tbarDir.setFloatable(false);
      tbarDir.add(btnNew);
      /*tbarDir.add(new JLabel("        "));
      tbarDir.add(m_btnSave);*/

      return tbarDir;
    }
Example #4
0
 private JToolBar initToolbar() {
   JToolBar toolbar = new JToolBar();
   toolbar.setFloatable(false);
   fRun = createRunButton();
   toolbar.add(fRun);
   return toolbar;
 }
Example #5
0
 /** Simple convenience routine for adding a button/icon to a Toolbar */
 public static JButton addTool(JToolBar toolBar, String name) {
   JButton b;
   b = new JButton(new ImageIcon("images/" + name + ".gif", name));
   toolBar.add(b);
   b.setToolTipText(name);
   b.setMargin(new Insets(0, 0, 0, 0));
   b.getAccessibleContext().setAccessibleName(name);
   return b;
 }
Example #6
0
 private JToolBar buildToolBar() {
   // build tool bar
   JToolBar toolBar = new JToolBar("Toolbar");
   toolBar.add(makeToolbarButton("stock_new.png", "New file", "New"));
   toolBar.add(makeToolbarButton("stock_open.png", "Open file", "Open"));
   toolBar.add(makeToolbarButton("stock_save.png", "Save file", "Save"));
   // run button is special
   runButton = makeToolbarButton("Play24.gif", "Run Program", "Run");
   toolBar.add(runButton);
   toolBar.add(makeToolbarButton("stock_text_left.png", "Pretty Print", "Pretty"));
   toolBar.addSeparator();
   toolBar.add(new JButton(copyAction));
   toolBar.add(new JButton(cutAction));
   toolBar.add(new JButton(pasteAction));
   return toolBar;
 }
 /** Adds the controls to the toolbar. */
 protected void arrangeToolBar() {
   toolBar.add(loadProgramButton);
   toolBar.addSeparator(separatorDimension);
   toolBar.add(singleStepButton);
   toolBar.add(stepOverButton);
   toolBar.add(ffwdButton);
   toolBar.add(stopButton);
   toolBar.add(rewindButton);
   toolBar.addSeparator(separatorDimension);
   toolBar.add(scriptButton);
   toolBar.add(breakButton);
   toolBar.addSeparator(separatorDimension);
   toolBar.add(speedSlider);
   toolBar.add(animationCombo);
   toolBar.add(additionalDisplayCombo);
   toolBar.add(formatCombo);
 }
Example #8
0
  /** 程式的GUI畫面配置,並登入按鈕、選項監聽。 */
  private void GUI() {
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu fileMenu = new JMenu("File");
    menuBar.add(fileMenu);

    JMenuItem file_newMenuItem = new JMenuItem("New");
    file_newMenuItem.setIcon(
        new ImageIcon(
            DocumentEditGUI.class.getResource("/javax/swing/plaf/metal/icons/ocean/file.gif")));
    file_newMenuItem.addActionListener(new SystemFileNew());
    fileMenu.add(file_newMenuItem);

    JMenuItem file_openMenuItem = new JMenuItem("Open File...");
    file_openMenuItem.setIcon(
        new ImageIcon(
            DocumentEditGUI.class.getResource(
                "/com/sun/java/swing/plaf/windows/icons/TreeOpen.gif")));
    file_openMenuItem.addActionListener(new SystemFileOpen());
    fileMenu.add(file_openMenuItem);

    JMenu file_saveMenu = new JMenu("Save");
    fileMenu.add(file_saveMenu);

    JMenuItem file_save_saveMenuItem = new JMenuItem("Save");
    file_save_saveMenuItem.setIcon(
        new ImageIcon(
            DocumentEditGUI.class.getResource(
                "/com/sun/java/swing/plaf/windows/icons/FloppyDrive.gif")));
    file_save_saveMenuItem.addActionListener(new SystemFileSave());
    file_save_saveMenuItem.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
    file_saveMenu.add(file_save_saveMenuItem);

    JMenuItem file_save_save_asMenuItem = new JMenuItem("Save as");
    file_save_save_asMenuItem.addActionListener(new SystemFileSaveAS());
    file_saveMenu.add(file_save_save_asMenuItem);

    JMenuItem file_save_save_allMenuItem = new JMenuItem("Save all");
    file_save_save_allMenuItem.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));
    file_save_save_allMenuItem.addActionListener(new SystemFileSaveAll());
    file_saveMenu.add(file_save_save_allMenuItem);

    JMenu file_closeMenu = new JMenu("Close");
    fileMenu.add(file_closeMenu);

    JMenuItem file_close_closeMenuItem = new JMenuItem("Close File");
    file_close_closeMenuItem.addActionListener(new SystemFileClose());
    file_closeMenu.add(file_close_closeMenuItem);

    JMenuItem file_close_close_all_fileMenuItem = new JMenuItem("Close all File");
    file_close_close_all_fileMenuItem.addActionListener(new SystemFileCloseAll());
    file_closeMenu.add(file_close_close_all_fileMenuItem);

    JMenuItem file_exitMenuItem = new JMenuItem("Exit");
    file_exitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK));
    file_exitMenuItem.addActionListener(new SystemExit());
    fileMenu.add(file_exitMenuItem);

    JMenu editMenu = new JMenu("Edit");
    menuBar.add(editMenu);

    replace_searchMenuItem.addActionListener(replace_search);
    replace_searchMenuItem.setAccelerator(
        KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK));
    editMenu.add(replace_searchMenuItem);

    SystemEditCut_Copy_Paste cut_copy_paste = new SystemEditCut_Copy_Paste();
    cutMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK));
    cutMenuItem.addActionListener(cut_copy_paste);
    editMenu.add(cutMenuItem);
    copyMenutem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK));

    copyMenutem.addActionListener(cut_copy_paste);
    editMenu.add(copyMenutem);
    pasteMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK));

    pasteMenuItem.addActionListener(cut_copy_paste);
    editMenu.add(pasteMenuItem);

    JMenuItem pathMenuItem = new JMenuItem("Default AutoSave-Path");
    pathMenuItem.addActionListener(new SystemEditSetPath());
    editMenu.add(pathMenuItem);

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

    JMenuItem HelpMenuItem = new JMenuItem("Help");
    HelpMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            JOptionPane.showMessageDialog(null, help, "Help!", JOptionPane.INFORMATION_MESSAGE);
          }
        });
    helpMenu.add(HelpMenuItem);

    JMenuItem AboutNewMenuItem = new JMenuItem("About");
    AboutNewMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(null, about, "About...", JOptionPane.INFORMATION_MESSAGE);
          }
        });
    helpMenu.add(AboutNewMenuItem);

    JToolBar toolBar = new JToolBar();
    getContentPane().add(toolBar, BorderLayout.NORTH);

    scrollPane.setViewportView(td);
    JButton newFileButton = new JButton("New");
    newFileButton.setIcon(
        new ImageIcon(
            DocumentEditGUI.class.getResource("/javax/swing/plaf/metal/icons/ocean/file.gif")));
    newFileButton.setToolTipText("New File.");
    newFileButton.addActionListener(new SystemFileNew());
    toolBar.add(newFileButton);

    JButton openFileButton = new JButton("Open");
    openFileButton.setIcon(
        new ImageIcon(
            DocumentEditGUI.class.getResource(
                "/javax/swing/plaf/metal/icons/ocean/directory.gif")));
    openFileButton.setToolTipText("Open File.");
    openFileButton.addActionListener(new SystemFileOpen());
    toolBar.add(openFileButton);

    JButton save_asFileButton = new JButton("Save as");
    save_asFileButton.setToolTipText("Save as File.");
    save_asFileButton.addActionListener(new SystemFileSaveAS());
    toolBar.add(save_asFileButton);

    JButton saveFileButton = new JButton("Save");
    saveFileButton.setIcon(
        new ImageIcon(
            DocumentEditGUI.class.getResource("/javax/swing/plaf/metal/icons/ocean/floppy.gif")));
    saveFileButton.setToolTipText("Savet his File.");
    saveFileButton.addActionListener(new SystemFileSave());
    toolBar.add(saveFileButton);

    JButton save_allFileButton = new JButton("Save all");
    save_allFileButton.setToolTipText("Save all File.");
    save_allFileButton.addActionListener(new SystemFileSaveAll());
    toolBar.add(save_allFileButton);

    JButton closeButton = new JButton("Close");
    closeButton.setToolTipText("Close this file.");
    closeButton.addActionListener(new SystemFileClose());
    toolBar.add(closeButton);

    JButton close_allButton = new JButton("Close all");
    close_allButton.setToolTipText("Close al File.");
    close_allButton.addActionListener(new SystemFileCloseAll());
    toolBar.add(close_allButton);
  }
Example #9
0
  private void configureDisplay() {
    content = new MapContent();
    mapPane = new JMapPane(content);
    mapPane.setEnabled(true);
    content.setTitle("GIS APPLICATION");
    mapPane.setToolTipText("Map Area");
    this.setMapContent(content);

    // Create Buttons

    printBtn = new JButton("Print");

    refreshBtn = new JButton("Reset");
    refreshBtn.setToolTipText("Reset layout of window");

    queryBtn = new JButton("Query");

    // Main Panel
    mainPanel = new JPanel();
    Container contentPane = this.getContentPane();

    contentPane.setLayout(new BorderLayout());
    contentPane.add(mainPanel, BorderLayout.SOUTH);

    this.setTitle("GIS Application");
    this.enableToolBar(true);
    this.enableStatusBar(true);
    this.enableLayerTable(true);

    JToolBar toolbar = this.getToolBar();
    toolbar.addSeparator();
    toolbar.add(refreshBtn);
    toolbar.addSeparator();
    // toolbar.add(printBtn);
    toolbar.add(queryBtn);

    //		JButton distance = new JButton("Distance");
    //        toolbar.add(distance);
    //        distance.addActionListener(new ActionListener() {
    //
    //            public void actionPerformed(ActionEvent e) {
    //                distanceflag = true;
    //                distance_and_scalefalg = true;
    //                dis = 0.0;
    //                numberofpoint = 0;
    //                final JFrame ftemp = new JFrame("Distance");
    //                final JLabel flabel = new JLabel();
    //                String step = "To mesuare Distance between two points: \n (1)-Press Mouse Left
    // button on start point. \n (2)-Press Mouse Left button on destination point. \n (3)-For new
    // session press mouse right button.";
    //                JOptionPane.showMessageDialog(null, step);
    //                getMapPane().setCursorTool(
    //                        new CursorTool() {
    //
    //                            private int x1,px1,py1,y1,lx1,ly1,x2,y2,px2,py2;
    //							private double tempdistance;
    //							private int tnumberofpixel;
    //							private int lineincentimeter;
    //							private double scale;
    //
    //							@Override
    //                            public void onMouseClicked(MapMouseEvent ev) {
    //                                if (SwingUtilities.isLeftMouseButton(ev)) {
    //                                    if (distanceflag == true) {
    //                                        distanceflag = false;
    //                                        x1 = ev.getMapPosition().getX();
    //                                        px1 = ev.getX();
    //                                        py1 = ev.getY();
    //                                        y1 = ev.getMapPosition().getY();
    //                                        lx1 = ev.getXOnScreen();
    //                                        ly1 = ev.getYOnScreen();
    //                                    } else {
    //                                        String str;
    //                                        //JFrame ftemp=new JFrame("Distance");
    //                                        ftemp.setVisible(false);
    //                                        Graphics g = getGraphics();
    //                                        //Graphics scaleg=scalepanel.getGraphics();
    //
    //                                        g.drawLine(lx1, ly1, ev.getXOnScreen(),
    // ev.getYOnScreen());
    //                                        lx1 = ev.getXOnScreen();
    //                                        ly1 = ev.getYOnScreen();
    //                                        x2 = ev.getMapPosition().getX();
    //                                        y2 = ev.getMapPosition().getY();
    //                                        px2 = ev.getX();
    //                                        py2 = ev.getY();
    //                                        dis = dis + Math.sqrt(Math.pow(x1 - x2, 2) +
    // Math.pow(y1 - y2, 2));
    ////                                        tempdistance=dis;
    //                                        numberofpoint += Math.sqrt(Math.pow(px1 - px2, 2) +
    // Math.pow(py1 - py2, 2));
    //                                        System.out.println("numberofpoint = " +
    // numberofpoint);
    //                                        if (distance_and_scalefalg == true) {
    //                                            distance_and_scalefalg = false;
    //                                            tempdistance = dis;
    //                                            tnumberofpixel = numberofpoint;
    //                                            lineincentimeter = tnumberofpixel / 28;
    //                                            scale = tempdistance / lineincentimeter;
    //                                        }
    ////
    //                                        System.out.println("lineincentimeter = " +
    // lineincentimeter);
    //                                        x1 = ev.getMapPosition().getX();
    //                                        y1 = ev.getMapPosition().getY();
    //                                        px1 = ev.getX();
    //                                        py1 = ev.getY();
    //                                        System.out.println("x1=" + x1 + "  " + "y1=" + y1);
    //                                        System.out.println("x2=" + x2 + "  " + "y2=" + y2);
    //                                        System.out.println("distance=" + dis + " Meters");
    //                                        scalevalue.setVisible(true);
    //                                        scalevalue.setText("Scale :  1 cm = " + scale + "
    // Meters");
    //                                        toolbar.add(scalevalue, BorderLayout.EAST);
    //                                        flabel.setText("Distance = " + dis + " Meters");
    //                                        JPanel fpanel = new JPanel(new FlowLayout());
    //                                        JButton meterbtn = new JButton("Meters");
    //                                        JButton kmbtn = new JButton("KiloMeters");
    //                                        JButton milebtn = new JButton("Miles");
    //                                        JButton yardbtn = new JButton("Yards");
    //                                        meterbtn.addActionListener(new ActionListener() {
    //
    //                                            public void actionPerformed(ActionEvent e) {
    //                                                flabel.setText("Distance = " + dis + "
    // Meters");
    //                                                scalevalue.setText("Scale :  1 cm = " + scale
    // + " Meters");
    //                                            }
    //                                        });
    //
    //                                        kmbtn.addActionListener(new ActionListener() {
    //
    //                                            public void actionPerformed(ActionEvent e) {
    //                                                flabel.setText("Distance = " + dis / 1000 + "
    // KiloMeters");
    //                                                scalevalue.setText("Scale :  1 cm = " + scale
    // / 1000 + " Km");
    //                                            }
    //                                        });
    //
    //                                        milebtn.addActionListener(new ActionListener() {
    //
    //                                            public void actionPerformed(ActionEvent e) {
    //                                                flabel.setText("Distance = " + dis * 0.00062 +
    // " Miles");
    //                                                scalevalue.setText("Scale :  1 cm = " + scale
    // * 0.00062 + " Miles");
    //                                            }
    //                                        });
    //
    //
    //                                        yardbtn.addActionListener(new ActionListener() {
    //
    //                                            public void actionPerformed(ActionEvent e) {
    //                                                flabel.setText("Distance = " + dis * 1.094 + "
    // Yards");
    //                                                scalevalue.setText("Scale :  1 cm = " + scale
    // * 1.094 + " Yards");
    //                                            }
    //                                        });
    //
    //                                        fpanel.add(meterbtn);
    //                                        fpanel.add(kmbtn);
    //                                        fpanel.add(milebtn);
    //                                        fpanel.add(yardbtn);
    //                                        ftemp.add(flabel, BorderLayout.CENTER);
    //                                        ftemp.add(fpanel, BorderLayout.SOUTH);
    //                                        ftemp.setSize(400, 200);
    //                                        ftemp.setVisible(true);
    //
    //                                    }
    //                                } else {
    //                                    distanceflag = true;
    //                                    distance_and_scalefalg = true;
    //                                    scalevalue.setVisible(false);
    //                                    dis = 0.0;
    //                                    numberofpoint = 0;
    //                                    setMapContext(context);
    //                                    repaint();
    //                                }
    //                            }
    //                        });
    //            }
    //        });
    this.setJMenuBar(new CustomMenuBar(mapPane));
    this.setExtendedState(MAXIMIZED_BOTH);
    this.setMinimumSize(new Dimension(800, 800));

    this.setIconImage(java.awt.Toolkit.getDefaultToolkit().createImage("res\\img\\icon.png"));
    this.setVisible(true);
  }
Example #10
0
  public SceneLayoutApp() {
    super();
    new Pair();
    final JFrame frame = new JFrame("Scene Layout");

    final JPanel panel = new JPanel(new BorderLayout());
    frame.setContentPane(panel);
    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setMaximumSize(screenSize);
    frame.setSize(screenSize);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JMenuBar mb = new JMenuBar();
    frame.setJMenuBar(mb);

    final JMenu jMenu = new JMenu("File");
    mb.add(jMenu);
    mb.add(new JMenu("Edit"));
    mb.add(new JMenu("Help"));
    JMenu menu = new JMenu("Look and Feel");

    //
    // Get all the available look and feel that we are going to use for
    // creating the JMenuItem and assign the action listener to handle
    // the selection of menu item to change the look and feel.
    //
    UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
    for (int i = 0; i < lookAndFeelInfos.length; i++) {
      final UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i];
      JMenuItem item = new JMenuItem(lookAndFeelInfo.getName());
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                //
                // Set the look and feel for the frame and update the UI
                // to use a new selected look and feel.
                //
                UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
                SwingUtilities.updateComponentTreeUI(frame);
              } catch (ClassNotFoundException e1) {
                e1.printStackTrace();
              } catch (InstantiationException e1) {
                e1.printStackTrace();
              } catch (IllegalAccessException e1) {
                e1.printStackTrace();
              } catch (UnsupportedLookAndFeelException e1) {
                e1.printStackTrace();
              }
            }
          });
      menu.add(item);
    }

    mb.add(menu);
    jMenu.add(new JMenuItem(new scene.action.QuitAction()));

    panel.add(new JScrollPane(desktopPane), BorderLayout.CENTER);
    final JToolBar bar = new JToolBar();

    panel.add(bar, BorderLayout.NORTH);

    final JComboBox comboNewWindow =
        new JComboBox(
            new String[] {"320:180", "320:240", "640:360", "640:480", "1280:720", "1920:1080"});

    comboNewWindow.addActionListener(new CreateSceneWindowAction());

    comboNewWindow.setBorder(BorderFactory.createTitledBorder("Create New Window"));
    bar.add(comboNewWindow);
    bar.add(
        new AbstractAction("Progress Bars") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new ProgressBarAnimator();
          }
        });
    bar.add(
        new AbstractAction("Sliders") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new SliderBarAnimator();
          }
        });

    final JCheckBox permaViz = new JCheckBox();
    permaViz.setText("Show the dump window");
    permaViz.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    dumpWindow = new JInternalFrame("perma dump window");
    dumpWindow.setContentPane(new JScrollPane(permText));

    permaViz.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dumpWindow.setVisible(permaViz.isSelected());
          }
        });

    comboNewWindow.setMaximumSize(comboNewWindow.getPreferredSize());

    permaViz.setSelected(false);
    bar.add(new CreateWebViewV1Action());
    bar.add(new CreateWebViewV2Action());
    bar.add(permaViz);
    desktopPane.add(dumpWindow);
    dumpWindow.setSize(400, 400);
    dumpWindow.setResizable(true);
    dumpWindow.setClosable(false);
    dumpWindow.setIconifiable(false);
    final JMenuBar m = new JMenuBar();
    final JMenu cmenu = new JMenu("Create");
    m.add(cmenu);
    final JMenuItem menuItem =
        new JMenuItem(
            new AbstractAction("new") {
              @Override
              public void actionPerformed(ActionEvent e) {
                Runnable runnable =
                    new Runnable() {
                      public void run() {
                        Object[] in = (Object[]) XSTREAM.fromXML(permText.getText());

                        final JInternalFrame ff = new JInternalFrame();

                        final ScenePanel c = new ScenePanel();
                        ff.setContentPane(c);
                        desktopPane.add(ff);
                        final Dimension d = (Dimension) in[0];
                        c.setMaximumSize(d);
                        c.setPreferredSize(d);

                        ff.setSize(d.width + 50, d.height + 50);
                        ScenePanel.panes.put(c, (List<Pair<Point, ArrayList<URL>>>) in[1]);

                        c.invalidate();
                        c.repaint();

                        ff.pack();
                        ff.setClosable(true);

                        ff.setMaximizable(false);
                        ff.setIconifiable(false);
                        ff.setResizable(false);
                        ff.show();
                      }
                    };

                SwingUtilities.invokeLater(runnable);
              }
            });
    cmenu.add(menuItem);
    //        JMenuBar menuBar = new JMenuBar();

    //        getContentPane().add(menuBar);

    dumpWindow.setJMenuBar(m);
    frame.setVisible(true);
  }
Example #11
0
 /**
  * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR
  * call it in your code!
  *
  * @noinspection ALL
  */
 private void $$$setupUI$$$() {
   rootPanel = new JPanel();
   rootPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1));
   final JToolBar toolBar1 = new JToolBar();
   rootPanel.add(
       toolBar1,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           new Dimension(-1, 20),
           null,
           0,
           false));
   openSrcButton = new JButton();
   openSrcButton.setText("Open Src");
   openSrcButton.setToolTipText("Open source file");
   toolBar1.add(openSrcButton);
   openBinButton = new JButton();
   openBinButton.setEnabled(true);
   openBinButton.setText("Open Bin");
   openBinButton.setToolTipText("Open and disassemble binaries");
   toolBar1.add(openBinButton);
   saveSrcButton = new JButton();
   saveSrcButton.setEnabled(true);
   saveSrcButton.setText("Save Src");
   saveSrcButton.setToolTipText("Save sources");
   toolBar1.add(saveSrcButton);
   saveBinButton = new JButton();
   saveBinButton.setEnabled(true);
   saveBinButton.setText("Save Bin");
   saveBinButton.setToolTipText("Save assembled binary");
   toolBar1.add(saveBinButton);
   final JToolBar.Separator toolBar$Separator1 = new JToolBar.Separator();
   toolBar1.add(toolBar$Separator1);
   asmButton = new JButton();
   asmButton.setText("Asm");
   asmButton.setToolTipText("Assemble sources");
   toolBar1.add(asmButton);
   final JToolBar.Separator toolBar$Separator2 = new JToolBar.Separator();
   toolBar1.add(toolBar$Separator2);
   hardResetButton = new JButton();
   hardResetButton.setEnabled(true);
   hardResetButton.setText("Hard Reset");
   hardResetButton.setToolTipText("Hard Reset - zeroize memory and reupload binary");
   toolBar1.add(hardResetButton);
   resetButton = new JButton();
   resetButton.setEnabled(true);
   resetButton.setText("Reset");
   resetButton.setToolTipText("Reset CPU (registers to zero)");
   toolBar1.add(resetButton);
   execButton = new JButton();
   execButton.setEnabled(true);
   execButton.setText("Exec");
   execButton.setToolTipText("Run forever");
   toolBar1.add(execButton);
   pauseButton = new JButton();
   pauseButton.setEnabled(false);
   pauseButton.setText("Pause");
   pauseButton.setToolTipText("Pause execution");
   toolBar1.add(pauseButton);
   runButton = new JButton();
   runButton.setEnabled(true);
   runButton.setText("Run");
   runButton.setToolTipText("Run until breakpoint/reserved");
   toolBar1.add(runButton);
   stepButton = new JButton();
   stepButton.setEnabled(true);
   stepButton.setText("Step");
   stepButton.setToolTipText("Execute one instruction");
   toolBar1.add(stepButton);
   final JToolBar.Separator toolBar$Separator3 = new JToolBar.Separator();
   toolBar1.add(toolBar$Separator3);
   breakpointButton = new JButton();
   breakpointButton.setEnabled(true);
   breakpointButton.setText("Breakpoint");
   breakpointButton.setToolTipText("Toggle breakpoint on instruction address");
   toolBar1.add(breakpointButton);
   final JPanel panel1 = new JPanel();
   panel1.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1));
   rootPanel.add(
       panel1,
       new GridConstraints(
           1,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           null,
           null,
           null,
           0,
           false));
   final JLabel label1 = new JLabel();
   label1.setText("Source");
   panel1.add(
       label1,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label2 = new JLabel();
   label2.setText("Memory");
   panel1.add(
       label2,
       new GridConstraints(
           0,
           1,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label3 = new JLabel();
   label3.setText("Registers");
   panel1.add(
       label3,
       new GridConstraints(
           0,
           2,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   memoryScrollPane = new JScrollPane();
   panel1.add(
       memoryScrollPane,
       new GridConstraints(
           1,
           1,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           new Dimension(600, -1),
           null,
           0,
           false));
   memoryTable = new JTable();
   memoryScrollPane.setViewportView(memoryTable);
   final JScrollPane scrollPane1 = new JScrollPane();
   panel1.add(
       scrollPane1,
       new GridConstraints(
           1,
           2,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           new Dimension(100, -1),
           null,
           0,
           false));
   registersTable = new JTable();
   scrollPane1.setViewportView(registersTable);
   sourceScrollPane = new JScrollPane();
   panel1.add(
       sourceScrollPane,
       new GridConstraints(
           1,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           new Dimension(500, 400),
           null,
           0,
           false));
   sourceTextarea = new JTextArea();
   sourceTextarea.setFont(new Font("Courier New", sourceTextarea.getFont().getStyle(), 12));
   sourceTextarea.setText(
       "; Input your program here\n            set a, 1\n            add a, 1\n            ife a, 2\n                set a, 3\n:mainloop\n            ife [message + I], 0\n                set pc, end\n            set a, [message + I]\n            add a, 0xA100\n            set [0x8000 + I], a\n            add i, 1\n            set pc, mainloop\n:message    dat \"Hello, world!\", 0\n:end        set pc, end");
   sourceScrollPane.setViewportView(sourceTextarea);
   final JPanel panel2 = new JPanel();
   panel2.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1));
   panel2.setVisible(false);
   rootPanel.add(
       panel2,
       new GridConstraints(
           2,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           null,
           null,
           null,
           0,
           false));
   consoleTextarea = new JTextArea();
   consoleTextarea.setEditable(true);
   panel2.add(
       consoleTextarea,
       new GridConstraints(
           1,
           0,
           1,
           3,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           new Dimension(150, 200),
           null,
           0,
           false));
   final JLabel label4 = new JLabel();
   label4.setText("Console");
   panel2.add(
       label4,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   clearButton = new JButton();
   clearButton.setText("Clear");
   panel2.add(
       clearButton,
       new GridConstraints(
           0,
           1,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final Spacer spacer1 = new Spacer();
   panel2.add(
       spacer1,
       new GridConstraints(
           0,
           2,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           1,
           null,
           null,
           null,
           0,
           false));
 }
Example #12
0
  public static JToolBar getToolbar(String label, int size, boolean hasStrings) {
    JToolBar toolBar = new JToolBar();

    JButton buttonCut = new JButton(hasStrings ? "cut" : null, getIcon(size + "/edit-cut"));
    buttonCut.putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE);
    toolBar.add(buttonCut);
    JButton buttonCopy = new JButton(hasStrings ? "copy" : null, getIcon(size + "/edit-copy"));
    buttonCopy.putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE);
    buttonCopy.setEnabled(false);
    toolBar.add(buttonCopy);
    JButton buttonPaste = new JButton(getIcon(size + "/edit-paste"));
    toolBar.add(buttonPaste);
    JButton buttonSelectAll = new JButton(getIcon(size + "/edit-select-all"));
    toolBar.add(buttonSelectAll);
    JButton buttonDelete = new JButton(getIcon(size + "/edit-delete"));
    toolBar.add(buttonDelete);
    toolBar.addSeparator();

    // add an inner toolbar to check the painting of toolbar
    // gradient and drop shadows under different skins.
    JToolBar innerToolbar = new JToolBar(JToolBar.HORIZONTAL);
    innerToolbar.setFloatable(false);
    JToggleButton buttonFormatCenter = new JToggleButton(getIcon(size + "/format-justify-center"));
    buttonFormatCenter.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 5.0f);
    innerToolbar.add(buttonFormatCenter);
    JToggleButton buttonFormatLeft = new JToggleButton(getIcon(size + "/format-justify-left"));
    innerToolbar.add(buttonFormatLeft);
    JToggleButton buttonFormatRight = new JToggleButton(getIcon(size + "/format-justify-right"));
    innerToolbar.add(buttonFormatRight);
    JToggleButton buttonFormatFill = new JToggleButton(getIcon(size + "/format-justify-fill"));
    buttonFormatFill.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f);
    innerToolbar.add(buttonFormatFill);

    toolBar.add(innerToolbar);
    toolBar.addSeparator();

    if (size > 20) {
      JToolBar innerToolbar2 = new JToolBar(JToolBar.HORIZONTAL);
      innerToolbar2.setFloatable(false);

      JPanel innerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
      innerToolbar2.add(innerPanel, BorderLayout.CENTER);

      final JToggleButton buttonStyleBold = new JToggleButton(getIcon(size + "/format-text-bold"));
      Set<Side> rightSide = EnumSet.of(Side.RIGHT);
      buttonStyleBold.putClientProperty(SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide);
      buttonStyleBold.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 3.0f);

      final JToggleButton buttonStyleItalic =
          new JToggleButton(getIcon(size + "/format-text-italic"));
      buttonStyleItalic.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f);
      buttonStyleItalic.putClientProperty(
          SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide);

      final JToggleButton buttonStyleUnderline =
          new JToggleButton(getIcon(size + "/format-text-underline"));
      buttonStyleUnderline.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f);
      buttonStyleUnderline.putClientProperty(
          SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide);

      final JToggleButton buttonStyleStrikethrough =
          new JToggleButton(getIcon(size + "/format-text-strikethrough"));
      buttonStyleStrikethrough.putClientProperty(
          SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, EnumSet.of(Side.LEFT));
      buttonStyleStrikethrough.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 3.0f);
      buttonStyleBold.setSelected(true);

      innerPanel.add(buttonStyleBold);
      innerPanel.add(buttonStyleItalic);
      innerPanel.add(buttonStyleUnderline);
      innerPanel.add(buttonStyleStrikethrough);

      toolBar.add(innerToolbar2);
    }

    toolBar.add(Box.createGlue());
    JButton buttonExit = new JButton(getIcon(size + "/process-stop"));
    buttonExit.setToolTipText("Closes the test application");
    buttonExit.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
    toolBar.add(buttonExit);

    return toolBar;
  }
Example #13
0
  /** Construct the TV object - that is, the main GUI for the program */
  public TV(JFrame f, TD mod) {
    super();
    frm = f;
    theTD = mod;
    JButton b;

    // Build the GUI

    toolBar = new JToolBar();
    toolBar.setFloatable(false);
    toolBar.getAccessibleContext().setAccessibleName("File Toolbar");
    toolBar.addSeparator();
    b = addTool(toolBar, "Cut");
    b = addTool(toolBar, "Copy");
    b = addTool(toolBar, "Paste");
    toolBar.addSeparator();
    toolBar.putClientProperty("JToolBar.isRollover", Boolean.FALSE);

    // The Slider
    numSlider = new JSlider(JSlider.HORIZONTAL, 1, 40, 1);
    numSlider.setPaintTicks(true);
    numSlider.setPaintLabels(false);
    numSlider.setMajorTickSpacing(10);
    numSlider.setMinorTickSpacing(2);
    numSlider.setExtent(1);
    numSlider.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent ce) {
            // System.out.println("CHANGE: " + ce);
            setQNumber(((JSlider) (ce.getSource())).getValue());
          }
        });
    numSlider.setToolTipText("Slide to select question by number");
    toolBar.add(numSlider);

    // The Question# textfield
    toolBar.add(numTF = new JTextField("01"));
    numTF.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String num = ((JTextField) e.getSource()).getText();
            int n = Integer.parseInt(num.trim());
            setQNumber(n);
          }
        });
    numTF.setToolTipText("Type number to select question by number");

    // The First Button
    b = addTool(toolBar, "First");
    b.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setQNumber(1);
          }
        });

    // The Previous Button
    b = addTool(toolBar, "Previous");
    b.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (getQNumber() <= 1) return;
            setQNumber(getQNumber() - 1);
          }
        });

    // The Next Button
    b = addTool(toolBar, "Next");
    b.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (getQNumber() >= getNumQuestions()) return;
            setQNumber(getQNumber() + 1);
          }
        });

    // The "Last" Button
    b = addTool(toolBar, "Last");
    b.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setQNumber(getNumQuestions());
          }
        });

    add(BorderLayout.NORTH, toolBar);

    // Rest is a panel to hold the questions, one at a time.
    questionsPanel = new JPanel();
    questionsPanel.setLayout(myCardLayout = new CardLayout());

    add(BorderLayout.SOUTH, questionsPanel);

    fc = new FileDialog(frm);
    fc.setFilenameFilter(
        new FilenameFilter() {
          public boolean accept(File ff, String fname) {
            // System.out.println("accept("+fname+")");
            // XXX TODO list of extentions, from properties.
            return fname.endsWith(".xam");
          }
        });
    TV.centre(fc);
  }
Example #14
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.
  }
Example #15
0
  protected void createTools(JToolBar palette) {
    super.createTools(palette);

    Tool tool = new UndoableTool(new TextTool(this, new TextFigure()));
    palette.add(createToolButton(IMAGES + "TEXT", "Text Tool", tool));

    tool = new UndoableTool(new ConnectedTextTool(this, new TextFigure()));
    palette.add(createToolButton(IMAGES + "ATEXT", "Connected Text Tool", tool));

    tool = new URLTool(this);
    palette.add(createToolButton(IMAGES + "URL", "URL Tool", tool));

    tool = new UndoableTool(new CreationTool(this, new RectangleFigure()));
    palette.add(createToolButton(IMAGES + "RECT", "Rectangle Tool", tool));

    tool = new UndoableTool(new CreationTool(this, new RoundRectangleFigure()));
    palette.add(createToolButton(IMAGES + "RRECT", "Round Rectangle Tool", tool));

    tool = new UndoableTool(new CreationTool(this, new EllipseFigure()));
    palette.add(createToolButton(IMAGES + "ELLIPSE", "Ellipse Tool", tool));

    tool = new UndoableTool(new PolygonTool(this));
    palette.add(createToolButton(IMAGES + "POLYGON", "Polygon Tool", tool));

    tool = new UndoableTool(new CreationTool(this, new TriangleFigure()));
    palette.add(createToolButton(IMAGES + "TRIANGLE", "Triangle Tool", tool));

    tool = new UndoableTool(new CreationTool(this, new DiamondFigure()));
    palette.add(createToolButton(IMAGES + "DIAMOND", "Diamond Tool", tool));

    tool = new UndoableTool(new CreationTool(this, new LineFigure()));
    palette.add(createToolButton(IMAGES + "LINE", "Line Tool", tool));

    tool = new UndoableTool(new ConnectionTool(this, new LineConnection()));
    palette.add(createToolButton(IMAGES + "CONN", "Connection Tool", tool));

    tool = new UndoableTool(new ConnectionTool(this, new ElbowConnection()));
    palette.add(createToolButton(IMAGES + "OCONN", "Elbow Connection Tool", tool));

    tool = new UndoableTool(new ScribbleTool(this));
    palette.add(createToolButton(IMAGES + "SCRIBBL", "Scribble Tool", tool));

    tool = new UndoableTool(new BorderTool(this));
    palette.add(createToolButton(IMAGES + "BORDDEC", "Border Tool", tool));
  }
  /** Constructor to create the frame and its components */
  public CoreyTextEditor() {
    // Create a scroll pane
    area.setFont(new Font("Monospaced", Font.PLAIN, 12));
    JScrollPane scroll =
        new JScrollPane(
            area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    add(scroll, BorderLayout.CENTER);

    // Adds the system default look and feel

    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException
        | InstantiationException
        | UnsupportedLookAndFeelException
        | IllegalAccessException e) {
      e.printStackTrace();
    }

    // Create a menu bar
    JMenuBar JMB = new JMenuBar();
    setJMenuBar(JMB);
    JMenu file = new JMenu("File");
    JMenu edit = new JMenu("Edit");
    JMB.add(file);
    JMB.add(edit);

    // Finishing our menu bar
    file.add(New);
    file.add(Open);
    file.add(Save);
    file.add(SaveAs);
    file.addSeparator();
    file.add(Quit);

    edit.add(Cut);
    edit.add(Copy);
    edit.add(Paste);

    edit.getItem(0).setText("Cut");
    edit.getItem(0).setIcon(new ImageIcon("cut.gif"));
    edit.getItem(1).setText("Copy");
    edit.getItem(1).setIcon(new ImageIcon("copy.gif"));
    edit.getItem(2).setText("Paste");
    edit.getItem(2).setIcon(new ImageIcon("paste.gif"));

    // Time to make a toolbar!
    JToolBar tool = new JToolBar();
    add(tool, BorderLayout.NORTH);
    tool.add(New);
    tool.add(Open);
    tool.add(Save);
    tool.addSeparator();

    JButton cut = tool.add(Cut);
    JButton cop = tool.add(Copy);
    JButton pas = tool.add(Paste);

    cut.setText(null);
    cut.setIcon(new ImageIcon("cut.gif"));
    cop.setText(null);
    cop.setIcon(new ImageIcon("copy.gif"));
    pas.setText(null);
    pas.setIcon(new ImageIcon("paste.gif"));

    Save.setEnabled(false);
    SaveAs.setEnabled(false);

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    pack();

    /*
     KeyListener to change Save and SaveAs
    */
    KeyListener k1 =
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            changed = true;
            Save.setEnabled(true);
            SaveAs.setEnabled(true);
          }
        };
    area.addKeyListener(k1);
    setTitle(currentFile + " - CoreyTextEditor");
    setVisible(true);
  }
 /**
  * Creates the tools. By default only the selection tool is added. Override this method to add
  * additional tools. Call the inherited method to include the selection tool.
  *
  * @param palette the palette where the tools are added.
  */
 protected void createTools(JToolBar palette) {
   Tool tool = createSelectionTool();
   fDefaultToolButton = createToolButton(IMAGES + "SEL", "Selection Tool", tool);
   palette.add(fDefaultToolButton);
 }
  public static void main(String[] args) {
    System.setProperty("com.apple.mrj.application.apple.menu.about.name", "What's Wrong ...");
    changeUI(USE_SYSTEM_UI);

    final NLPCanvas canvas = new NLPCanvas();

    // create the filter pipeline
    EdgeTokenFilter edgeTokenFilter = new EdgeTokenFilter();
    EdgeLabelFilter edgeLabelFilter = new EdgeLabelFilter();
    TokenFilter tokenFilter = new TokenFilter();
    EdgeTypeFilter edgeTypeFilter = new EdgeTypeFilter();
    FilterPipeline filterPipeline =
        new FilterPipeline(tokenFilter, edgeTypeFilter, edgeLabelFilter, edgeTokenFilter);

    // set filter of canvas to be the pipeline
    canvas.setFilter(filterPipeline);

    int canvasWidth = 900;
    int canvasHeight = 300;
    int canvasX = 50;
    int canvasY = 50;
    int canvasBottom = canvasHeight + canvasY;

    final CorpusLoader gold = new CorpusLoader("Select Gold");
    final CorpusLoader guess = new CorpusLoader("Select Guess");
    gold.loadProperties(properties);
    guess.loadProperties(properties);

    // Menu
    JMenuBar menuBar = new JMenuBar();
    JMenu file = new JMenu("File");
    JMenuItem exportEps = new JMenuItem("Export EPS");
    final JFileChooser fc = new JFileChooser();
    exportEps.setAccelerator(KeyStroke.getKeyStroke('E', java.awt.event.InputEvent.ALT_MASK));
    exportEps.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int returnVal = fc.showSaveDialog(canvas);
            if (returnVal == JFileChooser.APPROVE_OPTION)
              try {
                canvas.exportToEPS(fc.getSelectedFile());
              } catch (IOException e1) {
                e1.printStackTrace();
              }
          }
        });
    file.add(exportEps);
    file.setMnemonic('F');

    JMenuItem quit = new JMenuItem("Quit");
    // quit.setMnemonic('Q');
    file.add(quit);
    quit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            System.exit(0);
          }
        });

    JMenu window = new JMenu("Window");

    menuBar.add(file);
    menuBar.add(window);

    // Toolbar
    JToolBar toolBar = new JToolBar("Blub");
    toolBar.add(new JButton("Test"));

    // dummy Frame
    // JFrame dummy = new JFrame();
    // dummy.setVisible(false);

    // canvas frame
    JFrame canvasFrame = new JFrame("What's Wrong With My NLP?");
    canvasFrame.setSize(canvasWidth, canvasHeight);
    canvasFrame.getContentPane().setLayout(new BorderLayout());
    canvasFrame.getContentPane().add(new JScrollPane(canvas), BorderLayout.CENTER);
    canvasFrame.setJMenuBar(menuBar);
    // canvasFrame.getContentPane().add(toolBar, BorderLayout.NORTH);
    canvasFrame.setLocation(canvasX, canvasY);
    canvasFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    // window.add(new WindowMenuItem(canvasFrame,"Canvas"));
    // desktop.add(canvasFrame);

    // file selection frame
    final ControllerDialog fileWindow = new ControllerDialog("File Selection", USE_SYSTEM_UI);
    fileWindow
        .getContentPane()
        .setLayout(new BoxLayout(fileWindow.getContentPane(), BoxLayout.Y_AXIS));
    fileWindow.getContentPane().add(gold);
    fileWindow.getContentPane().add(new JSeparator());
    fileWindow.getContentPane().add(guess);
    fileWindow.setLocation(canvasX + 20, canvasBottom + 20);
    fileWindow.pack();
    fileWindow.setVisible(USE_SYSTEM_UI);
    // fileWindow.toBack();
    window.add(new WindowMenuItem(fileWindow));
    // fileFrame.setResizable(false);
    // desktop.add(fileFrame);

    // filter frame
    ControllerDialog filterWindow = new ControllerDialog("Edge Filters", false);
    filterWindow
        .getContentPane()
        .setLayout(new BoxLayout(filterWindow.getContentPane(), BoxLayout.Y_AXIS));
    filterWindow.getContentPane().add(new EdgeTypeFilterPanel(canvas, edgeTypeFilter));
    filterWindow.getContentPane().add(new JSeparator());
    filterWindow
        .getContentPane()
        .add(new DependencyFilterPanel(canvas, edgeLabelFilter, edgeTokenFilter));
    filterWindow.pack();
    filterWindow.setLocation(canvasX + 250, canvasBottom + 15);
    filterWindow.setVisible(USE_SYSTEM_UI);
    window.add(new WindowMenuItem(filterWindow));

    // token filter frame
    ControllerDialog tokenFilterWindow = new ControllerDialog("Token Filters", false);
    tokenFilterWindow
        .getContentPane()
        .setLayout(new BoxLayout(tokenFilterWindow.getContentPane(), BoxLayout.Y_AXIS));
    tokenFilterWindow.getContentPane().add(new TokenFilterPanel(canvas, tokenFilter));
    tokenFilterWindow.pack();
    tokenFilterWindow.setLocation(canvasX + 360, canvasBottom + 230);
    tokenFilterWindow.setVisible(USE_SYSTEM_UI);
    window.add(new WindowMenuItem(tokenFilterWindow));

    // appearance
    ControllerDialog appearance = new ControllerDialog("Appearance", false);
    appearance
        .getContentPane()
        .setLayout(new BoxLayout(appearance.getContentPane(), BoxLayout.Y_AXIS));
    appearance.getContentPane().add(new AppearancePanel(canvas));
    appearance.pack();
    appearance.setLocation(canvasX + 500, canvasBottom + 25);
    appearance.setVisible(USE_SYSTEM_UI);
    window.add(new WindowMenuItem(appearance));

    // description
    ControllerDialog description = new ControllerDialog("Description", true);
    // description.getContentPane().setLayout(new BoxLayout(appearance.getContentPane(),
    // BoxLayout.Y_AXIS));
    JTextArea text = new JTextArea(15, 40);
    description.getContentPane().add(new JScrollPane(text));
    description.pack();
    description.setLocation(canvasX + 700, canvasBottom + 25);
    description.setVisible(USE_SYSTEM_UI);
    canvas.setTextArea(text);
    window.add(new WindowMenuItem(description));

    // navigator
    ControllerDialog navigatorWindow = new ControllerDialog("Search Corpus", USE_SYSTEM_UI);
    navigatorWindow
        .getContentPane()
        .setLayout(new BoxLayout(navigatorWindow.getContentPane(), BoxLayout.Y_AXIS));
    CorpusNavigator navigator = new CorpusNavigator(canvas, gold, guess, edgeTypeFilter);
    navigatorWindow.getContentPane().add(navigator);
    navigatorWindow.pack();
    navigatorWindow.setMinimumSize(navigatorWindow.getSize());
    navigatorWindow.setLocation(canvasX + 800, canvasBottom + 20);
    navigatorWindow.setVisible(USE_SYSTEM_UI);
    window.add(new WindowMenuItem(navigatorWindow, "Navigator"));

    // statusbar
    JPanel statusBar = new JPanel();
    JLabel status = new JLabel("What's Wrong With My NLP version " + VERSION);
    status.setForeground(Color.LIGHT_GRAY);
    statusBar.setLayout(new GridBagLayout());
    statusBar.setBorder(BorderFactory.createEmptyBorder(1, 10, 1, 10));
    statusBar.add(status);
    statusBar.add(navigator.getSpinnerPanel(), new SimpleGridBagConstraints(0, USE_SYSTEM_UI));
    statusBar.add(
        navigator.getSpinnerPanel(), new SimpleGridBagConstraints(1, 0, 1.0, 0.0, EAST, NONE));

    // final preparation of canvas
    canvasFrame.getContentPane().add(statusBar, BorderLayout.SOUTH);
    canvasFrame.setVisible(USE_SYSTEM_UI);
    canvasFrame.requestFocus();
    // canvasFrame.requestFocusInWindow();

    Runtime.getRuntime()
        .addShutdownHook(
            new Thread(
                new Runnable() {
                  public void run() {
                    gold.saveProperties(properties);
                    guess.saveProperties(properties);
                    try {
                      properties.store(
                          new FileOutputStream(System.getProperty("user.home") + "/.whatswrong"),
                          "Whats wrong with you NLP properties");
                    } catch (IOException e) {
                      e.printStackTrace();
                    }
                  }
                }));
  }
Example #19
0
  /**
   * Constructs a simple frame with the specified world and orientation.
   *
   * @param world the world view.
   * @param ao the axes orientation.
   */
  public RSFFrame(World world, AxesOrientation ao) {
    super(new PlotPanel());
    if (world == null) world = new World();
    if (ao == null) ao = AxesOrientation.XRIGHT_YOUT_ZDOWN;
    _world = world;
    _view = new OrbitView(_world);
    _view.setAxesOrientation(ao);
    _canvas = new ViewCanvas();
    _canvas.setView(_view);
    _canvas.setBackground(Color.WHITE);

    _points = new ArrayList<PointGroup>();
    _lines = new ArrayList<LineGroup>();

    _d = null;
    _tpx = null;
    _tpy = null;
    _ipg = null;

    _etc = null;
    _coord = null;

    ModeManager mm = new ModeManager();
    mm.add(_canvas);
    OrbitViewMode ovm = new OrbitViewMode(mm);
    SelectDragMode sdm = new SelectDragMode(mm);

    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);

    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('F');
    Action exitAction =
        new AbstractAction("Exit") {
          public void actionPerformed(ActionEvent event) {
            System.exit(0);
          }
        };

    Action cubeAction =
        new AbstractAction("Add Cube") {
          public void actionPerformed(ActionEvent event) {
            String filename = chooseFile(".");
            if (filename != null) addRSFCube(filename);
          }
        };

    Action lineAction =
        new AbstractAction("Add Line") {
          public void actionPerformed(ActionEvent event) {
            String filename = chooseFile(".");
            if (filename != null) addRSFLine(filename);
          }
        };

    Action pointAction =
        new AbstractAction("Add Points") {
          public void actionPerformed(ActionEvent event) {
            String filename = chooseFile(".");
            if (filename != null) addRSFPoint(filename);
          }
        };

    Action loadViewAction =
        new AbstractAction("Load Viewpoint") {
          public void actionPerformed(ActionEvent event) {
            String filename = chooseFile(".");
            if (filename != null) loadView(filename);
          }
        };

    Action saveViewAction =
        new AbstractAction("Save Viewpoint") {
          public void actionPerformed(ActionEvent event) {
            JFileChooser chooser = new JFileChooser(new File("."));
            int returnVal = chooser.showSaveDialog(new JFrame());
            String filename = null;
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              filename = chooser.getSelectedFile().getPath();
              saveView(filename);
            }
          }
        };

    Action saveFrameAction =
        new AbstractAction("Save to PNG") {
          public void actionPerformed(ActionEvent event) {
            JFileChooser chooser = new JFileChooser(new File("."));
            int returnVal = chooser.showSaveDialog(new JFrame());
            String filename = null;
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              filename = chooser.getSelectedFile().getPath();
              saveFrametoPNG(filename);
            }
          }
        };

    JMenuItem cubeItem = fileMenu.add(cubeAction);
    cubeItem.setMnemonic('C');

    JMenuItem lineItem = fileMenu.add(lineAction);
    lineItem.setMnemonic('L');

    JMenuItem pointItem = fileMenu.add(pointAction);
    pointItem.setMnemonic('P');

    JMenuItem saveViewItem = fileMenu.add(saveViewAction);
    saveViewItem.setMnemonic('V');

    JMenuItem loadViewItem = fileMenu.add(loadViewAction);
    loadViewItem.setMnemonic('I');

    JMenuItem saveFrameItem = fileMenu.add(saveFrameAction);
    saveFrameItem.setMnemonic('S');

    JMenuItem exitItem = fileMenu.add(exitAction);
    exitItem.setMnemonic('X');

    JMenu colorMenu = new JMenu("Color");

    Action jetAction =
        new AbstractAction("Jet") {
          public void actionPerformed(ActionEvent event) {
            _color = ColorList.JET;
            setColorMap();
          }
        };

    Action prismAction =
        new AbstractAction("Prism") {
          public void actionPerformed(ActionEvent event) {
            _color = ColorList.PRISM;
            setColorMap();
          }
        };

    Action grayAction =
        new AbstractAction("Gray") {
          public void actionPerformed(ActionEvent event) {
            _color = ColorList.GRAY;
            setColorMap();
          }
        };

    Action rwbAction =
        new AbstractAction("Red-White-Blue") {
          public void actionPerformed(ActionEvent event) {
            _color = ColorList.RWB;
            setColorMap();
          }
        };

    colorMenu.add(jetAction);
    colorMenu.add(prismAction);
    colorMenu.add(grayAction);
    colorMenu.add(rwbAction);

    JMenu clipMenu = new JMenu("% Clip");
    Action clipUp =
        new AbstractAction("Set max pclip") {
          public void actionPerformed(ActionEvent event) {
            String value =
                JOptionPane.showInputDialog(new JFrame(), "Percentile Clip Max (0-100.0):", _pmax);
            try {
              _pmax = Float.parseFloat(value);
              if (_pmax > 100.0f) _pmax = 100.0f;
              if (_pmax < _pmin) _pmax = _pmin + 1.0f;
              System.out.printf("pclip: (%f,%f) \n", _pmin, _pmax);
              _ipg.setPercentiles(_pmin, _pmax);

            } catch (Exception e) {
              System.out.println(e);
            }
          }
        };
    Action clipDown =
        new AbstractAction("Set min pclip") {
          public void actionPerformed(ActionEvent event) {
            String value =
                JOptionPane.showInputDialog(
                    new JFrame(), String.format("Percentile Clip Min (0-%f):", _pmax), _pmin);
            try {
              _pmin = Float.parseFloat(value);
              if (_pmin < 0.0f) _pmin = 0.0f;
              if (_pmin > _pmax) _pmin = _pmax - 1.0f;
              System.out.printf("pclip: (%f,%f) \n", _pmin, _pmax);
              _ipg.setPercentiles(_pmin, _pmax);

            } catch (Exception e) {
              System.out.println(e);
            }
          }
        };

    clipMenu.add(clipUp);
    clipMenu.add(clipDown);

    JMenu modeMenu = new JMenu("Mode");
    modeMenu.setMnemonic('M');
    JMenuItem ovmItem = new JMenuItem(ovm);
    modeMenu.add(ovmItem);
    JMenuItem sdmItem = new JMenuItem(sdm);
    modeMenu.add(sdmItem);

    JMenu tensorMenu = new JMenu("Tensor");

    Action tenLoadAction =
        new AbstractAction("Load Tensors") {
          public void actionPerformed(ActionEvent event) {
            String filename = chooseFile(".");
            if (filename != null) loadTensors(filename);
          }
        };

    Action tenCoordLoadAction =
        new AbstractAction("Load Tensor Coordinates") {
          public void actionPerformed(ActionEvent event) {
            String filename = chooseFile(".");
            if (filename != null) loadTensorCoords(filename);
          }
        };

    Action showTenAction =
        new AbstractAction("Show Tensors at Coordinates") {
          public void actionPerformed(ActionEvent event) {

            String filename;
            int sel;

            if (_ipg == null) {
              sel =
                  JOptionPane.showConfirmDialog(
                      null,
                      "An RSF Cube (Image) needs to be loaded. " + " Would you like to load one?",
                      "Notice",
                      JOptionPane.OK_CANCEL_OPTION,
                      JOptionPane.QUESTION_MESSAGE);
              if (sel == JOptionPane.OK_OPTION) {
                filename = chooseFile(".");
                if (filename != null) addRSFCube(filename);
              } else {
                JOptionPane.showConfirmDialog(
                    null,
                    "Cannot load tensors because an RFC cube was not loaded.",
                    "Error",
                    JOptionPane.DEFAULT_OPTION,
                    JOptionPane.ERROR_MESSAGE);
                return;
              }
            }
            if (_coord == null) {
              sel =
                  JOptionPane.showConfirmDialog(
                      null,
                      "The tensors coordinates need to be loaded. "
                          + " Would you like to load them?",
                      "Notice",
                      JOptionPane.OK_CANCEL_OPTION,
                      JOptionPane.QUESTION_MESSAGE);
              if (sel == JOptionPane.OK_OPTION) {
                filename = chooseFile(".");
                if (filename != null) loadCoord(filename);
              } else {
                JOptionPane.showConfirmDialog(
                    null,
                    "Error loading coordinates.",
                    "Error",
                    JOptionPane.DEFAULT_OPTION,
                    JOptionPane.ERROR_MESSAGE);
                return;
              }
            }
            if (_etc == null) {
              sel =
                  JOptionPane.showConfirmDialog(
                      null,
                      "The tensors at coordinates need to be loaded. "
                          + " Would you like to load them?",
                      "Notice",
                      JOptionPane.OK_CANCEL_OPTION,
                      JOptionPane.QUESTION_MESSAGE);
              if (sel == JOptionPane.OK_OPTION) {
                filename = chooseFile(".");
                if (filename != null) loadTensorCoords(filename);
                return;
              } else {
                JOptionPane.showConfirmDialog(
                    null,
                    "Cannot show tensors because the tensors at coordinates" + " were not loaded.",
                    "Error",
                    JOptionPane.DEFAULT_OPTION,
                    JOptionPane.ERROR_MESSAGE);
                return;
              }
            }
            /*
            if(_d == null) {
            	sel = JOptionPane.showConfirmDialog(null,
            						"The tensors need to be loaded. "
            						+ " Would you like to load them?",
            						"Notice",
            						JOptionPane.OK_CANCEL_OPTION,
            						JOptionPane.QUESTION_MESSAGE);
            	if(sel == JOptionPane.OK_OPTION) {
            		filename = chooseFile(".");
            		if (filename != null) loadTensors(filename);
            	} else {
            		JOptionPane.showConfirmDialog(null,
            				"Cannot show tensors because the tensors were not loaded.",
            				"Error",
            				JOptionPane.DEFAULT_OPTION,
            				JOptionPane.ERROR_MESSAGE);
            		return;
            	}
            }
            if(_etg == null) {
            	sel = JOptionPane.showConfirmDialog(null,
            						"The tensor coordinates need to be loaded. "
            						+ " Would you like to load them?",
            						"Notice",
            						JOptionPane.OK_CANCEL_OPTION,
            						JOptionPane.QUESTION_MESSAGE);
            	if(sel == JOptionPane.OK_OPTION) {
            		filename = chooseFile(".");
            		if (filename != null) loadTensorCoords(filename);
            		return;
            	} else {
            		JOptionPane.showConfirmDialog(null,
            				"Cannot show tensors because the tensor coordinates"
            				+ " were not loaded.",
            				"Error",
            				JOptionPane.DEFAULT_OPTION,
            				JOptionPane.ERROR_MESSAGE);
            		return;
            	}
            }
            */
            _world.addChild(_etg);
          }
        };

    Action hideTenAction =
        new AbstractAction("Hide Tensors at Coordinates") {
          public void actionPerformed(ActionEvent event) {
            if (_etg != null) _world.removeChild(_etg);
          }
        };

    Action showTenPanAction =
        new AbstractAction("Show Tensor Panels") {
          public void actionPerformed(ActionEvent event) {

            String filename;
            int sel;
            if (_ipg == null) {
              sel =
                  JOptionPane.showConfirmDialog(
                      null,
                      "An RSF Cube (Image) needs to be loaded. " + " Would you like to load one?",
                      "Notice",
                      JOptionPane.OK_CANCEL_OPTION,
                      JOptionPane.QUESTION_MESSAGE);
              if (sel == JOptionPane.OK_OPTION) {
                filename = chooseFile(".");
                if (filename != null) addRSFCube(filename);
              } else {
                JOptionPane.showConfirmDialog(
                    null,
                    "Cannot load tensors because an RFC cube was not loaded.",
                    "Error",
                    JOptionPane.DEFAULT_OPTION,
                    JOptionPane.ERROR_MESSAGE);
                return;
              }
            }

            if (_d == null) {
              sel =
                  JOptionPane.showConfirmDialog(
                      null,
                      "The tensors need to be loaded. " + " Would you like to load them?",
                      "Notice",
                      JOptionPane.OK_CANCEL_OPTION,
                      JOptionPane.QUESTION_MESSAGE);
              if (sel == JOptionPane.OK_OPTION) {
                filename = chooseFile(".");
                if (filename != null) loadTensors(filename);
                addRSFTensorEllipsoids();
              } else {
                JOptionPane.showConfirmDialog(
                    null,
                    "Cannot show tensors because the tensors were not loaded.",
                    "Error",
                    JOptionPane.DEFAULT_OPTION,
                    JOptionPane.ERROR_MESSAGE);
                return;
              }
            } else if (_tpx == null || _tpy == null) {
              addRSFTensorEllipsoids();
            } else {
              ImagePanel ipx = _ipg.getImagePanel(Axis.X);
              ImagePanel ipy = _ipg.getImagePanel(Axis.Y);
              ipx.getFrame().addChild(_tpx);
              ipy.getFrame().addChild(_tpy);
            }
          }
        };

    Action hideTenPanAction =
        new AbstractAction("Hide Tensor Panels") {
          public void actionPerformed(ActionEvent event) {
            if (_tpx != null) {
              ImagePanel ipx = _ipg.getImagePanel(Axis.X);
              ipx.getFrame().removeChild(_tpx);
            }
            if (_tpy != null) {
              ImagePanel ipy = _ipg.getImagePanel(Axis.Y);
              ipy.getFrame().removeChild(_tpy);
            }
          }
        };

    JMenuItem tensorItem0 = tensorMenu.add(tenLoadAction);
    tensorItem0.setMnemonic('L');

    JMenuItem tensorItem2 = tensorMenu.add(tenCoordLoadAction);
    tensorItem2.setMnemonic('C');

    JMenuItem tensorItem1 = tensorMenu.add(showTenPanAction);
    tensorItem1.setMnemonic('T');

    JMenuItem tensorItem5 = tensorMenu.add(hideTenPanAction);
    tensorItem5.setMnemonic('R');

    JMenuItem tensorItem4 = tensorMenu.add(showTenAction);
    tensorItem4.setMnemonic('S');

    JMenuItem tensorItem3 = tensorMenu.add(hideTenAction);
    tensorItem3.setMnemonic('H');

    JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu);
    menuBar.add(modeMenu);
    menuBar.add(tensorMenu);
    menuBar.add(colorMenu);
    menuBar.add(clipMenu);

    JToolBar toolBar = new JToolBar(SwingConstants.VERTICAL);
    toolBar.setRollover(true);
    JToggleButton ovmButton = new ModeToggleButton(ovm);
    toolBar.add(ovmButton);
    JToggleButton sdmButton = new ModeToggleButton(sdm);
    toolBar.add(sdmButton);

    _cb = new ColorBar();
    _cb.setWidthMinimum(45);
    _cb.setFont(_cb.getFont().deriveFont(18.f));
    // _ipg.addColorMapListener(_cb);

    ovm.setActive(true);

    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setSize(new Dimension(SIZE, SIZE));
    this.add(_canvas, BorderLayout.CENTER);
    this.add(toolBar, BorderLayout.WEST);
    this.add(_cb, BorderLayout.EAST);
    this.setJMenuBar(menuBar);
    this.setVisible(true);
  }