protected JToolBar createMainToolBar(boolean geneviewer, boolean organismpanel, final boolean layoutsaving,boolean mapping2pathway) {
        JToolBar toolBar = new JToolBar();
        toolBar.setFloatable(false);
        //toolBar.setBackground(Color.white);
        //toolBar.setForeground(Color.white);
        //toolBar.setMargin(new Insets(-5,-5,-5,-5));
        final JButton fileOperations = new JButton();
        toolBar.add(fileOperations);
        fileOperations.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/fileIcon.GIF")));
        fileOperations.setToolTipText("File Operations");
        fileOperations.setMaximumSize(new java.awt.Dimension(21, 21));
        fileOperations.setMinimumSize(new java.awt.Dimension(21, 21));
        fileOperations.setPreferredSize(new java.awt.Dimension(21, 21));
        fileOperations.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressedfileIcon.GIF")));
        fileOperations.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                showFilePopupMenu(fileOperations, layoutsaving);
            }
        });
        toolBar.addSeparator();

        ButtonGroup graphModeButtonGroup = new ButtonGroup();

        JToggleButton editingModeButton = new JToggleButton();
        toolBar.add(editingModeButton);
        graphModeButtonGroup.add(editingModeButton);
        editingModeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/editIcon.GIF")));
        editingModeButton.setToolTipText("Editing Tool");
        editingModeButton.setSelected(true);
        editingModeButton.setMaximumSize(new java.awt.Dimension(21, 21));
        editingModeButton.setMinimumSize(new java.awt.Dimension(21, 21));
        editingModeButton.setPreferredSize(new java.awt.Dimension(21, 21));
        editingModeButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressededitIcon.GIF")));
        editingModeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                graphViewer.setViewMode(DefaultYGraphViewerMetabolomics.GRAPH_MODE.EDIT);
            }
        });

        JToggleButton magnifyingModeButton = new JToggleButton();
        toolBar.add(magnifyingModeButton);
        graphModeButtonGroup.add(magnifyingModeButton);
        magnifyingModeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/magnifierIcon.GIF")));
        magnifyingModeButton.setToolTipText("Magnifying Tool");
        magnifyingModeButton.setMaximumSize(new java.awt.Dimension(21, 21));
        magnifyingModeButton.setMinimumSize(new java.awt.Dimension(21, 21));
        magnifyingModeButton.setPreferredSize(new java.awt.Dimension(21, 21));
        magnifyingModeButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressedmagnifierIcon.GIF")));
        magnifyingModeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                graphViewer.setViewMode(DefaultYGraphViewerMetabolomics.GRAPH_MODE.MAGNIFIER);
            }
        });

        JToggleButton panningModeButton = new JToggleButton();
        toolBar.add(panningModeButton);
        graphModeButtonGroup.add(panningModeButton);
        panningModeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/panIcon.GIF")));
        panningModeButton.setToolTipText("Panning Tool");
        panningModeButton.setMaximumSize(new java.awt.Dimension(21, 21));
        panningModeButton.setMinimumSize(new java.awt.Dimension(21, 21));
        panningModeButton.setPreferredSize(new java.awt.Dimension(21, 21));
        panningModeButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressedpanIcon.GIF")));
        panningModeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                graphViewer.setViewMode(DefaultYGraphViewerMetabolomics.GRAPH_MODE.PAN);
            }
        });

        JToggleButton interactiveZoomModeButton = new JToggleButton();
        toolBar.add(interactiveZoomModeButton);
        graphModeButtonGroup.add(interactiveZoomModeButton);
        interactiveZoomModeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/interactiveZoomIcon.GIF")));
        interactiveZoomModeButton.setToolTipText("Interactive Zooming Tool");
        interactiveZoomModeButton.setMaximumSize(new java.awt.Dimension(21, 21));
        interactiveZoomModeButton.setMinimumSize(new java.awt.Dimension(21, 21));
        interactiveZoomModeButton.setPreferredSize(new java.awt.Dimension(21, 21));
        interactiveZoomModeButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressedinteractiveZoomIcon.GIF")));
        interactiveZoomModeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                graphViewer.setViewMode(DefaultYGraphViewerMetabolomics.GRAPH_MODE.INTERACTIVE_ZOOM);
            }
        });

        JToggleButton areaZoomModeButton = new JToggleButton();
        toolBar.add(areaZoomModeButton);
        graphModeButtonGroup.add(areaZoomModeButton);
        areaZoomModeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/marqueeZoomIcon.GIF")));
        areaZoomModeButton.setToolTipText("Area Zooming Tool");
        areaZoomModeButton.setMaximumSize(new java.awt.Dimension(21, 21));
        areaZoomModeButton.setMinimumSize(new java.awt.Dimension(21, 21));
        areaZoomModeButton.setPreferredSize(new java.awt.Dimension(21, 21));
        areaZoomModeButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressedmarqueeZoomIcon.GIF")));
        areaZoomModeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                graphViewer.setViewMode(DefaultYGraphViewerMetabolomics.GRAPH_MODE.AREA_ZOOM);
            }
        });
        toolBar.addSeparator();

        if (graphViewer.ISDELETIONENABLED) {
            JButton deleteSelectionButton = new JButton();
            toolBar.add(deleteSelectionButton);
            deleteSelectionButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/deleteIcon.GIF")));
            deleteSelectionButton.setToolTipText("Delete Selection");
            deleteSelectionButton.setMaximumSize(new java.awt.Dimension(21, 21));
            deleteSelectionButton.setMinimumSize(new java.awt.Dimension(21, 21));
            deleteSelectionButton.setPreferredSize(new java.awt.Dimension(21, 21));
            deleteSelectionButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/presseddeleteIcon.GIF")));
            deleteSelectionButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    graphViewer.view.getGraph2D().removeSelection();
                    graphViewer.view.getGraph2D().updateViews();
                }
            });
        }


        JButton pointZoomInButton = new JButton();
        toolBar.add(pointZoomInButton);
        pointZoomInButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pointZoomInIcon.GIF")));
        pointZoomInButton.setToolTipText("Point Zoom In");
        pointZoomInButton.setMaximumSize(new java.awt.Dimension(21, 21));
        pointZoomInButton.setMinimumSize(new java.awt.Dimension(21, 21));
        pointZoomInButton.setPreferredSize(new java.awt.Dimension(21, 21));
        pointZoomInButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressedpointZoomInIcon.GIF")));
        pointZoomInButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                graphViewer.view.setZoom(graphViewer.view.getZoom() * 1.2);
                //optional code that adjusts the size of the
                //view's world rectangle. The world rectangle
                //defines the region of the canvas that is
                //accessible by using the scrollbars of the view.
                Rectangle box = graphViewer.view.getGraph2D().getBoundingBox();
                graphViewer.view.setWorldRect(box.x - 20, box.y - 20, box.width + 40, box.height + 40);

                graphViewer.view.updateView();
            }
        });

        JButton pointZoomOutButton = new JButton();
        toolBar.add(pointZoomOutButton);
        pointZoomOutButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pointZoomOutIcon.GIF")));
        pointZoomOutButton.setToolTipText("Point Zoom Out");
        pointZoomOutButton.setMaximumSize(new java.awt.Dimension(21, 21));
        pointZoomOutButton.setMinimumSize(new java.awt.Dimension(21, 21));
        pointZoomOutButton.setPreferredSize(new java.awt.Dimension(21, 21));
        pointZoomOutButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressedpointZoomOutIcon.GIF")));
        pointZoomOutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                graphViewer.view.setZoom(graphViewer.view.getZoom() * 0.8);
                //optional code that adjusts the size of the
                //view's world rectangle. The world rectangle
                //defines the region of the canvas that is
                //accessible by using the scrollbars of the view.
                Rectangle box = graphViewer.view.getGraph2D().getBoundingBox();
                graphViewer.view.setWorldRect(box.x - 20, box.y - 20, box.width + 40, box.height + 40);
                graphViewer.view.updateView();
            }
        });

        JButton fitToViewButton = new JButton();
        toolBar.add(fitToViewButton);
        fitToViewButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/zoomtofitIcon.GIF")));
        fitToViewButton.setToolTipText("Fit Content");
        fitToViewButton.setMaximumSize(new java.awt.Dimension(34, 21));
        fitToViewButton.setMinimumSize(new java.awt.Dimension(34, 21));
        fitToViewButton.setPreferredSize(new java.awt.Dimension(34, 21));
        fitToViewButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressedzoomtofitIcon.GIF")));
        fitToViewButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                graphViewer.view.fitContent();
                graphViewer.view.updateView();
            }
        });

        JButton normalSizedviewButton = new JButton();
        toolBar.add(normalSizedviewButton);
        normalSizedviewButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/zoomtoNormalIcon.GIF")));
        normalSizedviewButton.setToolTipText("Zoom to Normal Size");
        normalSizedviewButton.setMaximumSize(new java.awt.Dimension(34, 21));
        normalSizedviewButton.setMinimumSize(new java.awt.Dimension(34, 21));
        normalSizedviewButton.setPreferredSize(new java.awt.Dimension(34, 21));
        normalSizedviewButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressedzoomtoNormalIcon.GIF")));
        normalSizedviewButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                graphViewer.view.setZoom(1.0);
                //view.setWorldRect((int)view.getWorldRect().getWidth()/2, (int)view.getWorldRect().getHeight()/2, (int)view.getWorldRect().getWidth(), (int)view.getWorldRect().getHeight());
                graphViewer.view.updateView();
            }
        });

        final JButton showLayoutOptionsButton = new JButton();
        toolBar.add(showLayoutOptionsButton);
        showLayoutOptionsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/layoutChangeIcon.GIF")));
        showLayoutOptionsButton.setToolTipText("Choose Layout");
        showLayoutOptionsButton.setMaximumSize(new java.awt.Dimension(34, 21));
        showLayoutOptionsButton.setMinimumSize(new java.awt.Dimension(34, 21));
        showLayoutOptionsButton.setPreferredSize(new java.awt.Dimension(34, 21));
        showLayoutOptionsButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressedlayoutChangeIcon.GIF")));
        showLayoutOptionsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                showLayoutPopupMenu(showLayoutOptionsButton);
            }
        });

        final JToggleButton minimapButton = new JToggleButton();
        toolBar.add(minimapButton);
        minimapButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/minimapIcon.GIF")));
        minimapButton.setToolTipText("Display/Hide Minimap");
        minimapButton.setMaximumSize(new java.awt.Dimension(34, 21));
        minimapButton.setMinimumSize(new java.awt.Dimension(34, 21));
        minimapButton.setPreferredSize(new java.awt.Dimension(34, 21));
        minimapButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressedminimapIcon.GIF")));
        minimapButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                if (graphViewer != null && overviewSplitPane != null && overviewPane != null) {
                    if (minimapButton.isSelected()) {
                        overviewSplitPane.setLeftComponent(overviewPane);
                        overviewSplitPane.setDividerLocation(200);
                        overviewSplitPane.setEnabled(true);
                    } else {
                        overviewSplitPane.setLeftComponent(null);
                        overviewSplitPane.setDividerLocation(0);
                        overviewSplitPane.setEnabled(false);

                    }
                    repaint();
                }
            }
        });

        toolBar.addSeparator();

        geneViewerButton = new JToggleButton();
        toolBar.add(geneViewerButton);
        geneViewerButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/geneViewerIcon.GIF")));
        geneViewerButton.setToolTipText("Display/Hide Gene Viewer");
        geneViewerButton.setMaximumSize(new java.awt.Dimension(34, 21));
        geneViewerButton.setMinimumSize(new java.awt.Dimension(34, 21));
        geneViewerButton.setPreferredSize(new java.awt.Dimension(34, 21));
        geneViewerButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressedgeneViewerIcon.GIF")));
        geneViewerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                //if (view != null && splitPane != null && overviewPane !=null )
                {
                    if (geneViewerButton.isSelected()) {
                        geneViewerDisplayAction();

                    } else {
                        geneViewerHideAction();
                    }
                    repaint();
                }
            }
        });
        geneViewerButton.setEnabled(geneviewer);
        geneViewerButton.setVisible(geneviewer);

        organismBrowserButton = new JToggleButton();
        toolBar.add(organismBrowserButton);
        organismBrowserButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/organismPanelIcon.GIF")));
        organismBrowserButton.setToolTipText("Display/Hide Organism Panel");
        organismBrowserButton.setMaximumSize(new java.awt.Dimension(34, 21));
        organismBrowserButton.setMinimumSize(new java.awt.Dimension(34, 21));
        organismBrowserButton.setPreferredSize(new java.awt.Dimension(34, 21));
        organismBrowserButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressedOrganismPanelIcon.GIF")));
        organismBrowserButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                //if (view != null && splitPane != null && overviewPane !=null )
                {
                    if (organismBrowserButton.isSelected()) {
                        organismSplitPane.setRightComponent(organismPanel);
                        organismSplitPane.setDividerLocation(organismSplitPane.getWidth() - organismPanel.getPreferredSize().width);
                        organismSplitPane.setEnabled(true);
                    } else {
                        organismSplitPane.setRightComponent(null);
                        organismSplitPane.setDividerLocation(0);
                        organismSplitPane.setEnabled(false);
                    }
                    repaint();
                }
            }
        });
        organismBrowserButton.setEnabled(organismpanel);
        organismBrowserButton.setVisible(organismpanel);


        toolBar.addSeparator();

        final JButton hideCommonButton = new JButton();
        toolBar.add(hideCommonButton);
        hideCommonButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/commonmolIcon.GIF")));
        hideCommonButton.setToolTipText("Change Display Mode");
        hideCommonButton.setMaximumSize(new java.awt.Dimension(34, 21));
        hideCommonButton.setMinimumSize(new java.awt.Dimension(34, 21));
        hideCommonButton.setPreferredSize(new java.awt.Dimension(34, 21));
        hideCommonButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressedcommonmolIcon.GIF")));
        hideCommonButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JPopupMenu menu = getModesMenu();
                menu.show(hideCommonButton, 0, 15);
            }
        });

        if(mapping2pathway){
            final JButton mappingM2PButton = new JButton();
            toolBar.add(mappingM2PButton);
            mappingM2PButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/commonM2P.GIF")));//"/binevi/Resources/Images/commonM2P.GIF"
            mappingM2PButton.setToolTipText("Choose mapping pathway");
            mappingM2PButton.setMaximumSize(new java.awt.Dimension(34, 21));
            mappingM2PButton.setMinimumSize(new java.awt.Dimension(34, 21));
            mappingM2PButton.setPreferredSize(new java.awt.Dimension(34, 21));
            mappingM2PButton.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/binevi/Resources/Images/pressedcommonM2P.GIF")));//pressedcommonM2P
            mappingM2PButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    JPopupMenu menu = getMappingPWsMenu();
                    menu.show(mappingM2PButton, 0, 15);
                }
            });
            mappingM2PButton.setEnabled(true);
//            mappingM2PButton.setVisible(mapping2pathway);
        }


        return toolBar;
    }