Ejemplo n.º 1
0
  @Override
  public JPopupMenu getComponentPopupMenu() {
    if (popupMenu == null) {
      popupMenu = new JPopupMenu(Messages.CHART_COLON);
      timeRangeMenu = new JMenu(Messages.PLOTTER_TIME_RANGE_MENU);
      timeRangeMenu.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_TIME_RANGE_MENU));
      popupMenu.add(timeRangeMenu);
      menuRBs = new JRadioButtonMenuItem[rangeNames.length];
      ButtonGroup rbGroup = new ButtonGroup();
      for (int i = 0; i < rangeNames.length; i++) {
        menuRBs[i] = new JRadioButtonMenuItem(rangeNames[i]);
        rbGroup.add(menuRBs[i]);
        menuRBs[i].addActionListener(this);
        if (viewRange == rangeValues[i]) {
          menuRBs[i].setSelected(true);
        }
        timeRangeMenu.add(menuRBs[i]);
      }

      popupMenu.addSeparator();

      saveAsMI = new JMenuItem(Messages.PLOTTER_SAVE_AS_MENU_ITEM);
      saveAsMI.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_SAVE_AS_MENU_ITEM));
      saveAsMI.addActionListener(this);
      popupMenu.add(saveAsMI);
    }
    return popupMenu;
  }
  public static void main(String[] args) {
    final JPopupMenu menu = new JPopupMenu();
    menu.setLayout(new GridLayout(0, 3, 5, 5));

    final MenuedButton button = new MenuedButton("Icons", menu);

    for (int i = 0; i < 9; i++) {
      // replace "print.gif" with your own image
      final JLabel label = new JLabel("" + i); // new ImageIcon("resources/images/print.gif") );
      label.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              button.getMainButton().setIcon(label.getIcon());
              menu.setVisible(false);
            }
          });
      menu.add(label);
    }

    JFrame frame = new JFrame("Button Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new JLabel("Click Arrow Button To Show Popup"), BorderLayout.NORTH);
    frame.getContentPane().add(button, BorderLayout.CENTER);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
Ejemplo n.º 3
0
  void initControls() {
    JMenuItem jmi;

    jmi = new JMenuItem("JImage Menu");
    jmi.setEnabled(false);
    popupMenu.add(jmi);

    jmi = new JMenuItem("Fit");
    jmi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            fit = true;
            repaint();
          }
        });
    popupMenu.add(jmi);

    JMenu scaleMenu = new JMenu("Set Scale");
    popupMenu.add(scaleMenu);
    int scales[] = new int[] {25, 50, 100, 200, 400, 800};

    for (int i = 0; i < scales.length; i++) {
      jmi = new JMenuItem(scales[i] + " %");
      jmi.addActionListener(new ScaleAction(scales[i]));
      scaleMenu.add(jmi);
    }

    MyListener l = new MyListener();
    addMouseMotionListener(l);
    addMouseListener(l);
    addMouseWheelListener(l);
    addKeyListener(l);
  }
  public void createPopupMenu() {
    menu = new JPopupMenu();
    for (int i = filenames.size() - 2, j = 0; i >= 0; i--, j++) {
      menu.add((String) filenames.elementAt(i));
      JMenuItem mi = (JMenuItem) menu.getComponent(j);
      mi.setFont(new Font("Arial", Font.PLAIN, 11));
      mi.addActionListener(this);
    }

    menu.pack();
    // setPopupLocation(200, 200);
  }
Ejemplo n.º 5
0
  private void setupMenu() {
    JMenuItem close = new JMenuItem("close");
    JMenuItem closeall = new JMenuItem("close all");
    JMenuItem save = new JMenuItem("save");

    close.addActionListener(this);
    closeall.addActionListener(this);
    save.addActionListener(this);

    contextMenu.add(close);
    contextMenu.add(closeall);
    contextMenu.add(save);
  }
Ejemplo n.º 6
0
  public JConsole() {
    super();

    setBackground(new Color(70, 70, 70));
    setForeground(Color.WHITE);
    text = new MyJTextPane();

    text.setAutoscrolls(true);
    final Font lFont = new Font("Monospaced", Font.PLAIN, 15);
    text.setText("");
    text.setFont(lFont);
    text.setMargin(new Insets(5, 3, 5, 3));
    text.addKeyListener(new MyKeyListener());
    setViewportView(text);

    contextMenu = new JPopupMenu();
    final ActionListener lActionListener = new MyActionListener();
    contextMenu.add(new JMenuItem(CMD_CUT)).addActionListener(lActionListener);
    contextMenu.add(new JMenuItem(CMD_COPY)).addActionListener(lActionListener);
    contextMenu.add(new JMenuItem(CMD_PASTE)).addActionListener(lActionListener);
    text.addMouseListener(new MyMouseListener());

    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setForeground(attr, Color.BLACK);

    attr = new SimpleAttributeSet();
    StyleConstants.setForeground(attr, Color.WHITE);
    attrOut = attr;

    attr = new SimpleAttributeSet();
    StyleConstants.setForeground(attr, Color.RED);
    StyleConstants.setItalic(attr, true);
    StyleConstants.setBold(attr, true);
    attrError = attr;

    try {
      fromConsoleStream = new PipedOutputStream();
      in = new PipedInputStream((PipedOutputStream) fromConsoleStream);

      final PipedOutputStream lOutPipe = new PipedOutputStream();
      out = new PrintStream(lOutPipe);

      final PipedOutputStream lErrPipe = new PipedOutputStream();
      err = new PrintStream(lErrPipe);

    } catch (IOException e) {
      e.printStackTrace();
    }
    requestFocus();
  }
Ejemplo n.º 7
0
  public EditorConsolePane() {
    super();
    textArea = new JTextPane();
    textArea.setEditorKit(new HTMLEditorKit());
    textArea.setTransferHandler(new JTextPaneHTMLTransferHandler());
    String css = PreferencesUser.getInstance().getConsoleCSS();
    ((HTMLEditorKit) textArea.getEditorKit()).getStyleSheet().addRule(css);
    textArea.setEditable(false);

    setLayout(new BorderLayout());
    add(new JScrollPane(textArea), BorderLayout.CENTER);

    if (ENABLE_IO_REDIRECT) {
      Debug.log(3, "EditorConsolePane: starting redirection to message area");
      int npipes = 2;
      NUM_PIPES = npipes * ScriptRunner.scriptRunner.size();
      pin = new PipedInputStream[NUM_PIPES];
      reader = new Thread[NUM_PIPES];
      for (int i = 0; i < NUM_PIPES; i++) {
        pin[i] = new PipedInputStream();
      }

      int irunner = 0;
      for (IScriptRunner srunner : ScriptRunner.scriptRunner.values()) {
        Debug.log(3, "EditorConsolePane: redirection for %s", srunner.getName());
        if (srunner.doSomethingSpecial(
            "redirect", Arrays.copyOfRange(pin, irunner * npipes, irunner * npipes + 2))) {
          Debug.log(3, "EditorConsolePane: redirection success for %s", srunner.getName());
          quit = false; // signals the Threads that they should exit
          // TODO Hack to avoid repeated redirect of stdout/err
          ScriptRunner.systemRedirected = true;

          // Starting two seperate threads to read from the PipedInputStreams
          for (int i = irunner * npipes; i < irunner * npipes + npipes; i++) {
            reader[i] = new Thread(this);
            reader[i].setDaemon(true);
            reader[i].start();
          }
          irunner++;
        }
      }
    }

    // Create the popup menu.
    popup = new JPopupMenu();
    JMenuItem menuItem = new JMenuItem("Clear messages");
    // Add ActionListener that clears the textArea
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            textArea.setText("");
          }
        });
    popup.add(menuItem);

    // Add listener to components that can bring up popup menus.
    MouseListener popupListener = new PopupListener(popup);
    textArea.addMouseListener(popupListener);
  }
  public void showMenu() {
    if (LOCATION == BELOW) {
      setPopupLocation(main.getX() - main.getWidth(), main.getY() + getHeight());
    } else if (LOCATION == ABOVE) {
      setPopupLocation(main.getX() - main.getWidth(), main.getY() - menu.getHeight());
    }

    if (getPopperButtonLocation() == RIGHT) {
      if (getPopperButtonLocation() == RIGHT) {
        tempPopArrowDir = getPopperArrowDirection();
      }

      setPopperArrowDirection(DOWN);
    }

    menu.show(popper, getPopupX(), getPopupY());
  }
Ejemplo n.º 9
0
  /**
   * Mouse Listener methods.
   *
   * <p>spv
   */
  public void mouseTriggered(MouseEvent me) {
    if (me.isPopupTrigger()) {
      actionJumpToError.setEnabled(parseError != null && parseError.hasLineNumbers());
      ((GUIMultiModel) handler.getGUIPlugin()).doEnables();

      contextPopup.show(me.getComponent(), me.getX(), me.getY());
    }
  }
Ejemplo n.º 10
0
  public UpdateAssetGUI() {
    try {
      PluginMgrClient.init();
      mclient = new MasterMgrClient();
      queue = new QueueMgrClient();
      plug = PluginMgrClient.getInstance();
      log = LogMgr.getInstance();

      pAssetManager = new TreeMap<String, AssetInfo>();

      project = "lr";
      charList = new TreeMap<String, String>();
      setsList = new TreeMap<String, String>();
      propsList = new TreeMap<String, String>();

      potentialUpdates = new TreeSet<String>();
      pSubstituteFields = new TreeMap<String, LinkedList<JBooleanField>>();

      /* load the look-and-feel */
      {
        try {
          SynthLookAndFeel synth = new SynthLookAndFeel();
          synth.load(
              LookAndFeelLoader.class.getResourceAsStream("synth.xml"), LookAndFeelLoader.class);
          UIManager.setLookAndFeel(synth);
        } catch (java.text.ParseException ex) {
          log.log(
              LogMgr.Kind.Ops,
              LogMgr.Level.Severe,
              "Unable to parse the look-and-feel XML file (synth.xml):\n" + "  " + ex.getMessage());
          System.exit(1);
        } catch (UnsupportedLookAndFeelException ex) {
          log.log(
              LogMgr.Kind.Ops,
              LogMgr.Level.Severe,
              "Unable to load the Pipeline look-and-feel:\n" + "  " + ex.getMessage());
          System.exit(1);
        }
      }

      /* application wide UI settings */
      {
        JPopupMenu.setDefaultLightWeightPopupEnabled(false);
        ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
      }
    } catch (PipelineException ex) {
      ex.printStackTrace();
    } // end try/catch
  } // end constructor
Ejemplo n.º 11
0
  /** Code completion. */
  private void complete() {
    if (selected()) return;

    // find first character
    final int caret = editor.pos(), startPos = editor.completionStart();
    final String prefix = string(substring(editor.text(), startPos, caret));
    if (prefix.isEmpty()) return;

    // find insertion candidates
    final TreeMap<String, String> tmp = new TreeMap<>();
    for (final Entry<String, String> entry : REPLACE.entrySet()) {
      final String key = entry.getKey();
      if (key.startsWith(prefix)) tmp.put(key, entry.getValue());
    }

    if (tmp.size() == 1) {
      // insert single candidate
      complete(tmp.values().iterator().next(), startPos);
    } else if (!tmp.isEmpty()) {
      // show popup menu
      final JPopupMenu pm = new JPopupMenu();
      final ActionListener al =
          new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent ae) {
              complete(ae.getActionCommand().replaceAll("^.*?\\] ", ""), startPos);
            }
          };

      for (final Entry<String, String> entry : tmp.entrySet()) {
        final JMenuItem mi = new JMenuItem("[" + entry.getKey() + "] " + entry.getValue());
        pm.add(mi);
        mi.addActionListener(al);
      }
      pm.addSeparator();
      final JMenuItem mi = new JMenuItem(Text.INPUT + Text.COLS + prefix);
      mi.setEnabled(false);
      pm.add(mi);

      final int[] cursor = rend.cursor();
      pm.show(this, cursor[0], cursor[1]);

      // highlight first entry
      final MenuElement[] me = {pm, (JMenuItem) pm.getComponent(0)};
      MenuSelectionManager.defaultManager().setSelectedPath(me);
    }
  }
Ejemplo n.º 12
0
  /** Creates the debug process, which is a GUI window that displays XML traffic. */
  private void createDebug() {
    frame =
        new JFrame(
            "Smack Debug Window -- " + connection.getServiceName() + ":" + connection.getPort());

    // Add listener for window closing event
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent evt) {
            rootWindowClosing(evt);
          }
        });

    // We'll arrange the UI into four tabs. The first tab contains all data, the second
    // client generated XML, the third server generated XML, and the fourth is packet
    // data from the server as seen by Smack.
    JTabbedPane tabbedPane = new JTabbedPane();

    JPanel allPane = new JPanel();
    allPane.setLayout(new GridLayout(3, 1));
    tabbedPane.add("All", allPane);

    // Create UI elements for client generated XML traffic.
    final JTextArea sentText1 = new JTextArea();
    final JTextArea sentText2 = new JTextArea();
    sentText1.setEditable(false);
    sentText2.setEditable(false);
    sentText1.setForeground(new Color(112, 3, 3));
    sentText2.setForeground(new Color(112, 3, 3));
    allPane.add(new JScrollPane(sentText1));
    tabbedPane.add("Sent", new JScrollPane(sentText2));

    // Add pop-up menu.
    JPopupMenu menu = new JPopupMenu();
    JMenuItem menuItem1 = new JMenuItem("Copy");
    menuItem1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Get the clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            // Set the sent text as the new content of the clipboard
            clipboard.setContents(new StringSelection(sentText1.getText()), null);
          }
        });

    JMenuItem menuItem2 = new JMenuItem("Clear");
    menuItem2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            sentText1.setText("");
            sentText2.setText("");
          }
        });

    // Add listener to the text area so the popup menu can come up.
    MouseListener popupListener = new PopupListener(menu);
    sentText1.addMouseListener(popupListener);
    sentText2.addMouseListener(popupListener);
    menu.add(menuItem1);
    menu.add(menuItem2);

    // Create UI elements for server generated XML traffic.
    final JTextArea receivedText1 = new JTextArea();
    final JTextArea receivedText2 = new JTextArea();
    receivedText1.setEditable(false);
    receivedText2.setEditable(false);
    receivedText1.setForeground(new Color(6, 76, 133));
    receivedText2.setForeground(new Color(6, 76, 133));
    allPane.add(new JScrollPane(receivedText1));
    tabbedPane.add("Received", new JScrollPane(receivedText2));

    // Add pop-up menu.
    menu = new JPopupMenu();
    menuItem1 = new JMenuItem("Copy");
    menuItem1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Get the clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            // Set the sent text as the new content of the clipboard
            clipboard.setContents(new StringSelection(receivedText1.getText()), null);
          }
        });

    menuItem2 = new JMenuItem("Clear");
    menuItem2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            receivedText1.setText("");
            receivedText2.setText("");
          }
        });

    // Add listener to the text area so the popup menu can come up.
    popupListener = new PopupListener(menu);
    receivedText1.addMouseListener(popupListener);
    receivedText2.addMouseListener(popupListener);
    menu.add(menuItem1);
    menu.add(menuItem2);

    // Create UI elements for interpreted XML traffic.
    final JTextArea interpretedText1 = new JTextArea();
    final JTextArea interpretedText2 = new JTextArea();
    interpretedText1.setEditable(false);
    interpretedText2.setEditable(false);
    interpretedText1.setForeground(new Color(1, 94, 35));
    interpretedText2.setForeground(new Color(1, 94, 35));
    allPane.add(new JScrollPane(interpretedText1));
    tabbedPane.add("Interpreted", new JScrollPane(interpretedText2));

    // Add pop-up menu.
    menu = new JPopupMenu();
    menuItem1 = new JMenuItem("Copy");
    menuItem1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Get the clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            // Set the sent text as the new content of the clipboard
            clipboard.setContents(new StringSelection(interpretedText1.getText()), null);
          }
        });

    menuItem2 = new JMenuItem("Clear");
    menuItem2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            interpretedText1.setText("");
            interpretedText2.setText("");
          }
        });

    // Add listener to the text area so the popup menu can come up.
    popupListener = new PopupListener(menu);
    interpretedText1.addMouseListener(popupListener);
    interpretedText2.addMouseListener(popupListener);
    menu.add(menuItem1);
    menu.add(menuItem2);

    frame.getContentPane().add(tabbedPane);

    frame.setSize(550, 400);
    frame.setVisible(true);

    // Create a special Reader that wraps the main Reader and logs data to the GUI.
    ObservableReader debugReader = new ObservableReader(reader);
    readerListener =
        new ReaderListener() {
          public void read(String str) {
            int index = str.lastIndexOf(">");
            if (index != -1) {
              receivedText1.append(str.substring(0, index + 1));
              receivedText2.append(str.substring(0, index + 1));
              receivedText1.append(NEWLINE);
              receivedText2.append(NEWLINE);
              if (str.length() > index) {
                receivedText1.append(str.substring(index + 1));
                receivedText2.append(str.substring(index + 1));
              }
            } else {
              receivedText1.append(str);
              receivedText2.append(str);
            }
          }
        };
    debugReader.addReaderListener(readerListener);

    // Create a special Writer that wraps the main Writer and logs data to the GUI.
    ObservableWriter debugWriter = new ObservableWriter(writer);
    writerListener =
        new WriterListener() {
          public void write(String str) {
            sentText1.append(str);
            sentText2.append(str);
            if (str.endsWith(">")) {
              sentText1.append(NEWLINE);
              sentText2.append(NEWLINE);
            }
          }
        };
    debugWriter.addWriterListener(writerListener);

    // Assign the reader/writer objects to use the debug versions. The packet reader
    // and writer will use the debug versions when they are created.
    reader = debugReader;
    writer = debugWriter;

    // Create a thread that will listen for all incoming packets and write them to
    // the GUI. This is what we call "interpreted" packet data, since it's the packet
    // data as Smack sees it and not as it's coming in as raw XML.
    listener =
        new PacketListener() {
          public void processPacket(Packet packet) {
            interpretedText1.append(packet.toXML());
            interpretedText2.append(packet.toXML());
            interpretedText1.append(NEWLINE);
            interpretedText2.append(NEWLINE);
          }
        };
  }
Ejemplo n.º 13
0
 public void setPopupMenu(JPopupMenu menu) {
   this.menu = menu;
   menu.addPopupMenuListener(padapter);
 }
Ejemplo n.º 14
0
  /**
   * Helper method that initializes the items for the context menu. This menu will include cut,
   * copy, paste, undo/redo, and find/replace functionality.
   */
  private void initContextMenu() {

    contextPopup = new JPopupMenu();
    // Edit menu stuff
    contextPopup.add(GUIPrism.getClipboardPlugin().getUndoAction());
    contextPopup.add(GUIPrism.getClipboardPlugin().getRedoAction());
    contextPopup.add(new JSeparator());
    contextPopup.add(GUIPrism.getClipboardPlugin().getCutAction());
    contextPopup.add(GUIPrism.getClipboardPlugin().getCopyAction());
    contextPopup.add(GUIPrism.getClipboardPlugin().getPasteAction());
    contextPopup.add(GUIPrism.getClipboardPlugin().getDeleteAction());
    contextPopup.add(new JSeparator());
    contextPopup.add(GUIPrism.getClipboardPlugin().getSelectAllAction());
    contextPopup.add(new JSeparator());
    // Model menu stuff
    contextPopup.add(((GUIMultiModel) handler.getGUIPlugin()).getParseModel());
    contextPopup.add(((GUIMultiModel) handler.getGUIPlugin()).getBuildModel());
    contextPopup.add(new JSeparator());
    contextPopup.add(((GUIMultiModel) handler.getGUIPlugin()).getExportMenu());
    contextPopup.add(((GUIMultiModel) handler.getGUIPlugin()).getViewMenu());
    contextPopup.add(((GUIMultiModel) handler.getGUIPlugin()).getComputeMenu());
    // contextPopup.add(actionJumpToError);
    // contextPopup.add(actionSearch);

    if (editor.getContentType().equals("text/prism")) {

      JMenu insertMenu = new JMenu("Insert elements");
      JMenu insertModelTypeMenu = new JMenu("Model type");
      insertMenu.add(insertModelTypeMenu);
      JMenu insertModule = new JMenu("Module");
      insertMenu.add(insertModule);
      JMenu insertVariable = new JMenu("Variable");
      insertMenu.add(insertVariable);

      insertModelTypeMenu.add(insertDTMC);
      insertModelTypeMenu.add(insertCTMC);
      insertModelTypeMenu.add(insertMDP);
      // contextPopup.add(new JSeparator());
      // contextPopup.add(insertMenu);
    }
  }
Ejemplo n.º 15
0
 static {
   // The following is required to use Swing menus with the heavyweight canvas used by World Wind.
   ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
   JPopupMenu.setDefaultLightWeightPopupEnabled(false);
 }
Ejemplo n.º 16
0
 private void maybeShowPopup(MouseEvent e) {
   if (e.isPopupTrigger()) {
     popup.show(e.getComponent(), e.getX(), e.getY());
   }
 }
Ejemplo n.º 17
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);
  }