Example usage for javax.swing JPopupMenu JPopupMenu

List of usage examples for javax.swing JPopupMenu JPopupMenu

Introduction

In this page you can find the example usage for javax.swing JPopupMenu JPopupMenu.

Prototype

public JPopupMenu(String label) 

Source Link

Document

Constructs a JPopupMenu with the specified title.

Usage

From source file:forge.screens.match.CMatchUI.java

@Override
public SpellAbility getAbilityToPlay(List<SpellAbility> abilities, ITriggerEvent triggerEvent) {
    if (triggerEvent == null) {
        if (abilities.isEmpty()) {
            return null;
        }/*from   w ww  .j  a  va  2s .co  m*/
        if (abilities.size() == 1) {
            return abilities.get(0);
        }
        return GuiChoose.oneOrNone("Choose ability to play", abilities);
    }

    if (abilities.isEmpty()) {
        return null;
    }
    if (abilities.size() == 1 && !abilities.get(0).promptIfOnlyPossibleAbility()) {
        if (abilities.get(0).canPlay()) {
            return abilities.get(0); //only return ability if it's playable, otherwise return null
        }
        return null;
    }

    //show menu if mouse was trigger for ability
    final JPopupMenu menu = new JPopupMenu("Abilities");

    boolean enabled;
    boolean hasEnabled = false;
    int shortcut = KeyEvent.VK_1; //use number keys as shortcuts for abilities 1-9
    for (final SpellAbility ab : abilities) {
        enabled = ab.canPlay();
        if (enabled) {
            hasEnabled = true;
        }
        GuiUtils.addMenuItem(menu, FSkin.encodeSymbols(ab.toString(), true),
                shortcut > 0 ? KeyStroke.getKeyStroke(shortcut, 0) : null, new Runnable() {
                    @Override
                    public void run() {
                        CPrompt.SINGLETON_INSTANCE.selectAbility(ab);
                    }
                }, enabled);
        if (shortcut > 0) {
            shortcut++;
            if (shortcut > KeyEvent.VK_9) {
                shortcut = 0; //stop adding shortcuts after 9
            }
        }
    }
    if (hasEnabled) { //only show menu if at least one ability can be played
        SwingUtilities.invokeLater(new Runnable() { //use invoke later to ensure first ability selected by default
            public void run() {
                MenuSelectionManager.defaultManager()
                        .setSelectedPath(new MenuElement[] { menu, menu.getSubElements()[0] });
            }
        });
        MouseEvent mouseEvent = ((MouseTriggerEvent) triggerEvent).getMouseEvent();
        menu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
    }

    return null; //delay ability until choice made
}

From source file:com.ivli.roim.controls.ChartControl.java

@Override
public void mouseReleased(MouseEvent e) {
    if (SwingUtilities.isRightMouseButton(e)
            && (iMarker instanceof DomainMarker || iSeries instanceof XYSeries)) {
        JPopupMenu mnu = new JPopupMenu(
                java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle").getString("MNU_MARKER_OPERATIONS"));
        if (iSeries instanceof XYSeries) {
            mnu.add(MENUS.ADD.makeItem(this));
            mnu.add(MENUS.EXPORT_CSV.makeItem(this));
            mnu.add(MENUS.DELETE_ALL.makeItem(this));
        } else if (iMarker instanceof DomainMarker) {
            JMenu mi1 = new JMenu(MENUS.MOVE_TO_MIN.iText);
            mi1.add(MENUS.MOVE_TO_MIN.makeItem(this));
            //  mi1.add(MENUS.MOVE_TO_MIN_LEFT.makeItem(this));
            //  mi1.add(MENUS.MOVE_TO_MIN_RIGHT.makeItem(this));
            mnu.add(mi1);//from w ww .j  a  va 2s.c om
            JMenu mi2 = new JMenu(MENUS.MOVE_TO_MAX.iText);
            mi2.add(MENUS.MOVE_TO_MAX.makeItem(this));
            //  mi2.add(MENUS.MOVE_TO_MAX_LEFT.makeItem(this));
            //  mi2.add(MENUS.MOVE_TO_MAX_RIGHT.makeItem(this));

            mnu.add(mi2);
            mnu.add(MENUS.MOVE_TO_MEDIAN.makeItem(this));

            //if(!getDomainMarkersForSeries()){
            JMenu mi3 = new JMenu(
                    java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle").getString("MARKER_COMMAND.FIT"));
            mi3.add(MENUS.FIT_LEFT.makeItem(this));
            mi3.add(MENUS.FIT_RIGHT.makeItem(this));
            mnu.add(mi3);
            //}

            mnu.add(MENUS.DELETE.makeItem(this));
        }

        mnu.show(this, e.getX(), e.getY());
    } else {
        super.mouseReleased(e);
        dropSelection();
    }
}

From source file:canreg.client.gui.analysis.FrequenciesByYearInternalFrame.java

private void columnTableMousePressed(java.awt.event.MouseEvent evt) {
    if (evt.getButton() == java.awt.event.MouseEvent.BUTTON3) {
        JTable target = (JTable) evt.getSource();
        int columnNumber = target.getSelectedColumn();

        JPopupMenu jpm = new JPopupMenu("" + columnNumber);
        jpm.add(java.util.ResourceBundle
                .getBundle("canreg/client/gui/analysis/resources/FrequenciesByYearInternalFrame")
                .getString("COLUMN ")
                + tableColumnModel.getColumn(tableColumnModel.getColumnIndexAtX(evt.getX())).getHeaderValue());
        jpm.show(target, evt.getX(), evt.getY());
    }/*from   w w  w .ja v a2  s . c om*/
}

From source file:jatoo.app.App.java

private JPopupMenu getWindowPopup(final Point location) {

    ///*w w w .j  a  va 2 s .c om*/
    // hide

    final JMenuItem hideItem = new JMenuItem(getText("popup.hide"));
    hideItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            hide();
        }
    });

    //
    // send to back

    final JMenuItem sendToBackItem = new JMenuItem(getText("popup.send_to_back"));
    sendToBackItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            sendToBack();
        }
    });

    //
    // always on top

    final JCheckBoxMenuItem alwaysOnTopItem = new JCheckBoxMenuItem(getText("popup.always_on_top"),
            isAlwaysOnTop());
    alwaysOnTopItem.addItemListener(new ItemListener() {
        public void itemStateChanged(final ItemEvent e) {
            setAlwaysOnTop(alwaysOnTopItem.isSelected());
        }
    });

    //
    // transparency

    final JSlider transparencySlider = new JSlider(JSlider.VERTICAL, 0, 100, getTransparency());
    transparencySlider.setMajorTickSpacing(25);
    transparencySlider.setMinorTickSpacing(5);
    transparencySlider.setSnapToTicks(true);
    transparencySlider.setPaintTicks(true);
    transparencySlider.setPaintLabels(true);
    transparencySlider.addChangeListener(new ChangeListener() {
        public void stateChanged(final ChangeEvent e) {
            setTransparency(transparencySlider.getValue());
        }
    });

    final JMenu transparencyItem = new JMenu(getText("popup.transparency"));
    transparencyItem.add(transparencySlider);

    //
    // close

    final JMenuItem closeItem = new JMenuItem(getText("popup.close"), getIcon("close-016.png"));
    closeItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            System.exit(0);
        }
    });

    //
    // the popup

    JPopupMenu popup = new JPopupMenu(getTitle());

    popup.add(hideItem);
    popup.addSeparator();
    popup.add(sendToBackItem);
    popup.add(alwaysOnTopItem);
    popup.add(transparencyItem);
    popup.addSeparator();
    popup.add(closeItem);

    popup.setInvoker(popup);
    popup.setLocation(location);

    return popup;
}

From source file:org.gvsig.remotesensing.scatterplot.chart.ScatterPlotDiagram.java

/**
 * Creates a popup menu for the panel./*w  ww .j a  v a  2s . c  om*/
 *
 * @param properties  include a menu item for the chart property editor.
 * @param save  include a menu item for saving the chart.
 * @param print  include a menu item for printing the chart.
 * @param zoom  include menu items for zooming.
 *
 * @return The popup menu.
 */
protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) {

    JPopupMenu result = new JPopupMenu("Chart:");
    boolean separator = false;

    JMenuItem newClassItem = new JMenuItem(PluginServices.getText(this, "new_class"));
    newClassItem.setActionCommand(NEW_CLASS_COMMAND);
    newClassItem.addActionListener(this);
    result.add(newClassItem);
    separator = true;

    if (properties) {
    }

    if (save) {
        if (separator) {
            result.addSeparator();
            separator = false;
        }
        JMenuItem saveItem = new JMenuItem(localizationResources.getString("Save_as..."));
        saveItem.setActionCommand(SAVE_COMMAND);
        saveItem.addActionListener(this);
        result.add(saveItem);
        separator = true;
    }

    if (print) {
        if (separator) {
            result.addSeparator();
            separator = false;
        }
        JMenuItem printItem = new JMenuItem(localizationResources.getString("Print..."));
        printItem.setActionCommand(PRINT_COMMAND);
        printItem.addActionListener(this);
        result.add(printItem);
        separator = true;
    }

    if (zoom) {
        if (separator) {
            result.addSeparator();
            separator = false;
        }
    }

    return result;

}

From source file:corelyzer.ui.CorelyzerApp.java

private JPopupMenu sectionListPopupMenu(final int[] rows) {
    // section popup
    JPopupMenu menu = new JPopupMenu("Sections");

    // Section/Image property
    JMenuItem propertiesMenuItem = new JMenuItem("Properties...");
    propertiesMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, MENU_MASK));
    propertiesMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            controller.sectionProperties(rows);
        }//from  ww w .j  av a  2  s  .  co m
    });

    JMenuItem splitMenuItem = new JMenuItem("Split...");
    if (rows.length > 1) {
        splitMenuItem.setEnabled(false);
    }
    splitMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            controller.sectionSplit();
        }
    });

    JMenuItem deleteMenuItem = new JMenuItem("Delete");
    deleteMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            onDeleteSelectedSections(rows);
        }
    });

    JMenuItem locateMenuItem = new JMenuItem("Locate");
    locateMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            onLocateSelectedSection();
        }
    });

    menu.add(locateMenuItem);
    menu.add(splitMenuItem);
    menu.add(propertiesMenuItem);
    menu.add(deleteMenuItem);

    return menu;
}

From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java

/**
 * Creates a popup menu for the panel./*from   w ww .  ja va  2  s . c  o m*/
 *
 * @param properties  include a menu item for the chart property editor.
 * @param save  include a menu item for saving the chart.
 * @param print  include a menu item for printing the chart.
 * @param zoom  include menu items for zooming.
 *
 * @return The popup menu.
 */
protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) {

    JPopupMenu result = new JPopupMenu("Chart:");
    boolean separator = false;

    if (properties) {
        JMenuItem propertiesItem = new JMenuItem(localizationResources.getString("Properties..."));
        propertiesItem.setActionCommand(PROPERTIES_ACTION_COMMAND);
        propertiesItem.addActionListener(this);
        result.add(propertiesItem);
        separator = true;
    }

    if (save) {
        if (separator) {
            result.addSeparator();
            separator = false;
        }
        JMenuItem saveItem = new JMenuItem(localizationResources.getString("Save_as..."));
        saveItem.setActionCommand(SAVE_ACTION_COMMAND);
        saveItem.addActionListener(this);
        result.add(saveItem);
        separator = true;
    }

    if (print) {
        if (separator) {
            result.addSeparator();
            separator = false;
        }
        JMenuItem printItem = new JMenuItem(localizationResources.getString("Print..."));
        printItem.setActionCommand(PRINT_ACTION_COMMAND);
        printItem.addActionListener(this);
        result.add(printItem);
        separator = true;
    }

    if (zoom) {
        if (separator) {
            result.addSeparator();
            separator = false;
        }

        JMenu zoomInMenu = new JMenu(localizationResources.getString("Zoom_In"));

        zoomInBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes"));
        zoomInBothMenuItem.setActionCommand(ZOOM_IN_BOTH_ACTION_COMMAND);
        zoomInBothMenuItem.addActionListener(this);
        zoomInMenu.add(zoomInBothMenuItem);

        zoomInMenu.addSeparator();

        zoomInHorizontalMenuItem = new JMenuItem(localizationResources.getString("Horizontal_Axis"));
        zoomInHorizontalMenuItem.setActionCommand(ZOOM_IN_HORIZONTAL_ACTION_COMMAND);
        zoomInHorizontalMenuItem.addActionListener(this);
        zoomInMenu.add(zoomInHorizontalMenuItem);

        zoomInVerticalMenuItem = new JMenuItem(localizationResources.getString("Vertical_Axis"));
        zoomInVerticalMenuItem.setActionCommand(ZOOM_IN_VERTICAL_ACTION_COMMAND);
        zoomInVerticalMenuItem.addActionListener(this);
        zoomInMenu.add(zoomInVerticalMenuItem);

        result.add(zoomInMenu);

        JMenu zoomOutMenu = new JMenu(localizationResources.getString("Zoom_Out"));

        zoomOutBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes"));
        zoomOutBothMenuItem.setActionCommand(ZOOM_OUT_BOTH_ACTION_COMMAND);
        zoomOutBothMenuItem.addActionListener(this);
        zoomOutMenu.add(zoomOutBothMenuItem);

        zoomOutMenu.addSeparator();

        zoomOutHorizontalMenuItem = new JMenuItem(localizationResources.getString("Horizontal_Axis"));
        zoomOutHorizontalMenuItem.setActionCommand(ZOOM_OUT_HORIZONTAL_ACTION_COMMAND);
        zoomOutHorizontalMenuItem.addActionListener(this);
        zoomOutMenu.add(zoomOutHorizontalMenuItem);

        zoomOutVerticalMenuItem = new JMenuItem(localizationResources.getString("Vertical_Axis"));
        zoomOutVerticalMenuItem.setActionCommand(ZOOM_OUT_VERTICAL_ACTION_COMMAND);
        zoomOutVerticalMenuItem.addActionListener(this);
        zoomOutMenu.add(zoomOutVerticalMenuItem);

        result.add(zoomOutMenu);

        JMenu autoRangeMenu = new JMenu(localizationResources.getString("Auto_Range"));

        autoRangeBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes"));
        autoRangeBothMenuItem.setActionCommand(AUTO_RANGE_BOTH_ACTION_COMMAND);
        autoRangeBothMenuItem.addActionListener(this);
        autoRangeMenu.add(autoRangeBothMenuItem);

        autoRangeMenu.addSeparator();
        autoRangeHorizontalMenuItem = new JMenuItem(localizationResources.getString("Horizontal_Axis"));
        autoRangeHorizontalMenuItem.setActionCommand(AUTO_RANGE_HORIZONTAL_ACTION_COMMAND);
        autoRangeHorizontalMenuItem.addActionListener(this);
        autoRangeMenu.add(autoRangeHorizontalMenuItem);

        autoRangeVerticalMenuItem = new JMenuItem(localizationResources.getString("Vertical_Axis"));
        autoRangeVerticalMenuItem.setActionCommand(AUTO_RANGE_VERTICAL_ACTION_COMMAND);
        autoRangeVerticalMenuItem.addActionListener(this);
        autoRangeMenu.add(autoRangeVerticalMenuItem);

        result.addSeparator();
        result.add(autoRangeMenu);

    }

    return result;

}

From source file:corelyzer.ui.CorelyzerApp.java

private void setupPopupMenu() {
    // session popup
    sessionPopupMenu = new JPopupMenu("Sessions");

    JMenuItem hideSession = new JMenuItem("Hide");
    hideSession.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            JMenuItem m = (JMenuItem) e.getSource();
            Session s = (Session) sessionList.getSelectedValue();
            String l = s.isShow() ? "Show" : "Hide";
            controller.setSessionVisible(!s.isShow());
            m.setText(l);//w w  w .ja  va2  s. c  o m
        }
    });
    sessionPopupMenu.add(hideSession);

    JMenuItem renameSession = new JMenuItem("Rename...");
    renameSession.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            controller.renameSession();
        }
    });
    sessionPopupMenu.add(renameSession);

    JMenuItem removeSession = new JMenuItem("Close");
    removeSession.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            Session s = (Session) sessionList.getSelectedValue();
            controller.removeSession(s);
        }
    });
    sessionPopupMenu.add(removeSession);

    // track popup
    trackPopupMenu = new JPopupMenu("Tracks");

    JMenuItem hide = new JMenuItem("Hide");
    hide.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            controller.setTrackVisible();
        }
    });
    trackPopupMenu.add(hide);

    JMenuItem rename = new JMenuItem("Rename...");
    rename.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            controller.renameTrack();
        }
    });
    trackPopupMenu.add(rename);

    trackPopupDeleteMenuItem = new JMenuItem("Delete");
    trackPopupDeleteMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.deleteTrack();
        }
    });
    trackPopupMenu.add(trackPopupDeleteMenuItem);

    // data popup
    dataPopupMenu = new JPopupMenu("Datasets");

    dataPopupGraphMenuItem = new JMenuItem("Graph...");
    dataPopupGraphMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.showGraphDialog();
        }
    });

    JMenuItem dataPopupDeleteMenuItem = new JMenuItem("Delete");
    dataPopupDeleteMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.deleteDataset();
        }
    });

    dataPopupMenu.add(dataPopupGraphMenuItem);
    dataPopupMenu.add(dataPopupDeleteMenuItem);
}

From source file:com.isti.traceview.common.TraceViewChartPanel.java

/**
 * Creates a popup menu for the panel./*  ww  w  .jav a 2s  .c om*/
 * 
 * @param properties
 *            include a menu item for the chart property editor.
 * @param save
 *            include a menu item for saving the chart.
 * @param print
 *            include a menu item for printing the chart.
 * @param zoom
 *            include menu items for zooming.
 * @return The popup menu.
 */
protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) {

    JPopupMenu result = new JPopupMenu("Chart:");
    boolean separator = false;

    if (properties) {
        JMenuItem propertiesItem = new JMenuItem(localizationResources.getString("Properties..."));
        propertiesItem.setActionCommand(PROPERTIES_COMMAND);
        propertiesItem.addActionListener(this);
        result.add(propertiesItem);
        separator = true;
    }

    if (save) {
        if (separator) {
            result.addSeparator();
            separator = false;
        }
        JMenuItem saveItem = new JMenuItem(localizationResources.getString("Save_as..."));
        saveItem.setActionCommand(SAVE_COMMAND);
        saveItem.addActionListener(this);
        result.add(saveItem);
        separator = true;
    }

    if (print) {
        if (separator) {
            result.addSeparator();
            separator = false;
        }
        JMenuItem printItem = new JMenuItem(localizationResources.getString("Print..."));
        printItem.setActionCommand(PRINT_COMMAND);
        printItem.addActionListener(this);
        result.add(printItem);
        separator = true;
    }

    if (zoom) {
        if (separator) {
            result.addSeparator();
            separator = false;
        }

        JMenu zoomInMenu = new JMenu(localizationResources.getString("Zoom_In"));

        this.zoomInBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes"));
        this.zoomInBothMenuItem.setActionCommand(ZOOM_IN_BOTH_COMMAND);
        this.zoomInBothMenuItem.addActionListener(this);
        zoomInMenu.add(this.zoomInBothMenuItem);

        zoomInMenu.addSeparator();

        this.zoomInDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis"));
        this.zoomInDomainMenuItem.setActionCommand(ZOOM_IN_DOMAIN_COMMAND);
        this.zoomInDomainMenuItem.addActionListener(this);
        zoomInMenu.add(this.zoomInDomainMenuItem);

        this.zoomInRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis"));
        this.zoomInRangeMenuItem.setActionCommand(ZOOM_IN_RANGE_COMMAND);
        this.zoomInRangeMenuItem.addActionListener(this);
        zoomInMenu.add(this.zoomInRangeMenuItem);

        result.add(zoomInMenu);

        JMenu zoomOutMenu = new JMenu(localizationResources.getString("Zoom_Out"));

        this.zoomOutBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes"));
        this.zoomOutBothMenuItem.setActionCommand(ZOOM_OUT_BOTH_COMMAND);
        this.zoomOutBothMenuItem.addActionListener(this);
        zoomOutMenu.add(this.zoomOutBothMenuItem);

        zoomOutMenu.addSeparator();

        this.zoomOutDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis"));
        this.zoomOutDomainMenuItem.setActionCommand(ZOOM_OUT_DOMAIN_COMMAND);
        this.zoomOutDomainMenuItem.addActionListener(this);
        zoomOutMenu.add(this.zoomOutDomainMenuItem);

        this.zoomOutRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis"));
        this.zoomOutRangeMenuItem.setActionCommand(ZOOM_OUT_RANGE_COMMAND);
        this.zoomOutRangeMenuItem.addActionListener(this);
        zoomOutMenu.add(this.zoomOutRangeMenuItem);

        result.add(zoomOutMenu);

        JMenu autoRangeMenu = new JMenu(localizationResources.getString("Auto_Range"));

        this.zoomResetBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes"));
        this.zoomResetBothMenuItem.setActionCommand(ZOOM_RESET_BOTH_COMMAND);
        this.zoomResetBothMenuItem.addActionListener(this);
        autoRangeMenu.add(this.zoomResetBothMenuItem);

        autoRangeMenu.addSeparator();
        this.zoomResetDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis"));
        this.zoomResetDomainMenuItem.setActionCommand(ZOOM_RESET_DOMAIN_COMMAND);
        this.zoomResetDomainMenuItem.addActionListener(this);
        autoRangeMenu.add(this.zoomResetDomainMenuItem);

        this.zoomResetRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis"));
        this.zoomResetRangeMenuItem.setActionCommand(ZOOM_RESET_RANGE_COMMAND);
        this.zoomResetRangeMenuItem.addActionListener(this);
        autoRangeMenu.add(this.zoomResetRangeMenuItem);

        result.addSeparator();
        result.add(autoRangeMenu);
    }

    return result;
}

From source file:org.rdv.viz.chart.ChartPanel.java

/**
 * Creates a popup menu for the panel.//from  w  w w.  j  a v  a  2s  .  c om
 *
 * @param properties  include a menu item for the chart property editor.
 * @param save  include a menu item for saving the chart.
 * @param print  include a menu item for printing the chart.
 * @param zoom  include menu items for zooming.
 *
 * @return The popup menu.
 */
protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) {

    JPopupMenu result = new JPopupMenu("Chart:");
    boolean separator = false;

    if (properties) {
        JMenuItem propertiesItem = new JMenuItem(localizationResources.getString("Properties..."));
        propertiesItem.setActionCommand(PROPERTIES_COMMAND);
        propertiesItem.addActionListener(this);
        result.add(propertiesItem);
        separator = true;
    }

    if (save) {
        if (separator) {
            result.addSeparator();
            separator = false;
        }
        JMenuItem saveItem = new JMenuItem(localizationResources.getString("Save_as..."));
        saveItem.setActionCommand(SAVE_COMMAND);
        saveItem.addActionListener(this);
        result.add(saveItem);
        separator = true;
    }

    if (print) {
        if (separator) {
            result.addSeparator();
            separator = false;
        }
        JMenuItem printItem = new JMenuItem(localizationResources.getString("Print..."));
        printItem.setActionCommand(PRINT_COMMAND);
        printItem.addActionListener(this);
        result.add(printItem);
        separator = true;
    }

    if (zoom) {
        if (separator) {
            result.addSeparator();
            separator = false;
        }

        JMenu zoomInMenu = new JMenu(localizationResources.getString("Zoom_In"));

        this.zoomInBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes"));
        this.zoomInBothMenuItem.setActionCommand(ZOOM_IN_BOTH_COMMAND);
        this.zoomInBothMenuItem.addActionListener(this);
        zoomInMenu.add(this.zoomInBothMenuItem);

        zoomInMenu.addSeparator();

        this.zoomInDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis"));
        this.zoomInDomainMenuItem.setActionCommand(ZOOM_IN_DOMAIN_COMMAND);
        this.zoomInDomainMenuItem.addActionListener(this);
        zoomInMenu.add(this.zoomInDomainMenuItem);

        this.zoomInRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis"));
        this.zoomInRangeMenuItem.setActionCommand(ZOOM_IN_RANGE_COMMAND);
        this.zoomInRangeMenuItem.addActionListener(this);
        zoomInMenu.add(this.zoomInRangeMenuItem);

        result.add(zoomInMenu);

        JMenu zoomOutMenu = new JMenu(localizationResources.getString("Zoom_Out"));

        this.zoomOutBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes"));
        this.zoomOutBothMenuItem.setActionCommand(ZOOM_OUT_BOTH_COMMAND);
        this.zoomOutBothMenuItem.addActionListener(this);
        zoomOutMenu.add(this.zoomOutBothMenuItem);

        zoomOutMenu.addSeparator();

        this.zoomOutDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis"));
        this.zoomOutDomainMenuItem.setActionCommand(ZOOM_OUT_DOMAIN_COMMAND);
        this.zoomOutDomainMenuItem.addActionListener(this);
        zoomOutMenu.add(this.zoomOutDomainMenuItem);

        this.zoomOutRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis"));
        this.zoomOutRangeMenuItem.setActionCommand(ZOOM_OUT_RANGE_COMMAND);
        this.zoomOutRangeMenuItem.addActionListener(this);
        zoomOutMenu.add(this.zoomOutRangeMenuItem);

        result.add(zoomOutMenu);

        JMenu autoRangeMenu = new JMenu(localizationResources.getString("Auto_Range"));

        this.zoomResetBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes"));
        this.zoomResetBothMenuItem.setActionCommand(ZOOM_RESET_BOTH_COMMAND);
        this.zoomResetBothMenuItem.addActionListener(this);
        autoRangeMenu.add(this.zoomResetBothMenuItem);

        autoRangeMenu.addSeparator();
        this.zoomResetDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis"));
        this.zoomResetDomainMenuItem.setActionCommand(ZOOM_RESET_DOMAIN_COMMAND);
        this.zoomResetDomainMenuItem.addActionListener(this);
        autoRangeMenu.add(this.zoomResetDomainMenuItem);

        this.zoomResetRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis"));
        this.zoomResetRangeMenuItem.setActionCommand(ZOOM_RESET_RANGE_COMMAND);
        this.zoomResetRangeMenuItem.addActionListener(this);
        autoRangeMenu.add(this.zoomResetRangeMenuItem);

        result.addSeparator();
        result.add(autoRangeMenu);

    }

    return result;

}