gt:         if (plotCanvas instanceof Plot3DCanvas) {
context: package org.math.plot.components;
  
  import java.awt.event.*;
  import java.io.*;
  import java.security.*;
  
  import javax.swing.*;
  import javax.swing.filechooser.FileFilter;
  
  import org.math.plot.*;
  import org.math.plot.canvas.*;
  
  /**
   * BSD License
   * 
   * @author Yann RICHET
   */
  public class PlotToolBar extends JToolBar {
  
      // TODO redesign icons...
      private static final long serialVersionUID = 1L;
      protected ButtonGroup buttonGroup;
      protected JToggleButton buttonCenter;
      //protected JToggleButton buttonEdit;
      protected JToggleButton buttonZoom;
      protected JToggleButton buttonRotate;
      //protected JToggleButton buttonViewCoords;
      protected JButton buttonSetScales;
      protected JButton buttonDatas;
      protected JButton buttonSavePNGFile;
      protected JButton buttonReset;
  //    protected JButton buttonAdjustBounds;
      private boolean denySaveSecurity;
      private JFileChooser pngFileChooser;
      /** the currently selected PlotPanel */
      private PlotCanvas plotCanvas;
      private PlotPanel plotPanel;
  
      public PlotToolBar(PlotPanel pp) {
          plotPanel = pp;
          plotCanvas = pp.plotCanvas;
  
          try {
              pngFileChooser = new JFileChooser();
              pngFileChooser.setFileFilter(new FileFilter() {
  
                  public boolean accept(File f) {
                      return f.isDirectory() || f.getName().endsWith(".png");
                  }
  
                  public String getDescription() {
                      return "Portable Network Graphic file";
                  }
              });
          } catch (AccessControlException ace) {
              denySaveSecurity = true;
          }
  
          buttonGroup = new ButtonGroup();
  
          buttonCenter = new JToggleButton(new ImageIcon(PlotPanel.class.getResource("icons/center.png")));
          buttonCenter.setToolTipText("Center axis");
          buttonCenter.setSelected(plotCanvas.ActionMode == PlotCanvas.TRANSLATION);
  
          buttonZoom = new JToggleButton(new ImageIcon(PlotPanel.class.getResource("icons/zoom.png")));
          buttonZoom.setToolTipText("Zoom");
          buttonZoom.setSelected(plotCanvas.ActionMode == PlotCanvas.ZOOM);
  
          //buttonEdit = new JToggleButton(new ImageIcon(PlotPanel.class.getResource("icons/edit.png")));
          //buttonEdit.setToolTipText("Edit mode");
  
          //buttonViewCoords = new JToggleButton(new ImageIcon(PlotPanel.class.getResource("icons/position.png")));
          //buttonViewCoords.setToolTipText("Highlight coordinates / Highlight plot");
  
          buttonSetScales = new JButton(new ImageIcon(PlotPanel.class.getResource("icons/scale.png")));
          buttonSetScales.setToolTipText("Edit axis scales");
  
          buttonDatas = new JButton(new ImageIcon(PlotPanel.class.getResource("icons/data.png")));
          buttonDatas.setToolTipText("Get data");
  
          buttonSavePNGFile = new JButton(new ImageIcon(PlotPanel.class.getResource("icons/topngfile.png")));
          buttonSavePNGFile.setToolTipText("Save graphics in a .PNG File");
  
          buttonReset = new JButton(new ImageIcon(PlotPanel.class.getResource("icons/back.png")));
          buttonReset.setToolTipText("Reset zoom & axis");
  
  //        buttonAdjustBounds = new JButton(new ImageIcon(PlotPanel.class.getResource(plotCanvas.getAdjustBounds() ? "icons/adjustbounds.png" : "icons/noadjustbounds.png")));
  //        buttonAdjustBounds.setToolTipText("Auto-update/fix bounds");
           
  
          /*buttonEdit.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
          plotCanvas.ActionMode = PlotCanvas.EDIT;
          }
          });*/
  
          buttonZoom.setSelected(true);
          buttonZoom.addActionListener(new ActionListener() {
  
              public void actionPerformed(ActionEvent e) {
                  plotCanvas.ActionMode = PlotCanvas.ZOOM;
              }
          });
  
          buttonCenter.addActionListener(new ActionListener() {
  
              public void actionPerformed(ActionEvent e) {
                  plotCanvas.ActionMode = PlotCanvas.TRANSLATION;
              }
          });
  
          /*buttonViewCoords.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
          plotCanvas.setNoteCoords(buttonViewCoords.isSelected());
          }
          });*/
  
          buttonSetScales.addActionListener(new ActionListener() {
  
              public void actionPerformed(ActionEvent e) {
                  plotCanvas.displayScalesFrame();
              }
          });
  
          buttonDatas.addActionListener(new ActionListener() {
  
              public void actionPerformed(ActionEvent e) {
                  plotCanvas.displayDataFrame();
              }
          });
  
          buttonSavePNGFile.addActionListener(new ActionListener() {
  
              public void actionPerformed(ActionEvent e) {
                  choosePNGFile();
              }
          });
  
          buttonReset.addActionListener(new ActionListener() {
  
              public void actionPerformed(ActionEvent e) {
                  plotCanvas.resetBase();
              }
          });
  
  //        buttonAdjustBounds.addActionListener(new ActionListener() {
  //
  //            public void actionPerformed(ActionEvent e) {
  //                plotCanvas.setAdjustBounds(!plotCanvas.getAdjustBounds());
  //                ajustBoundsChanged();
  //            }
  //        });
  
          buttonGroup.add(buttonCenter);
          buttonGroup.add(buttonZoom);
          //buttonGroup.add(buttonEdit);
  
          add(buttonCenter, null);
          add(buttonZoom, null);
          add(buttonReset, null);
          //add(buttonViewCoords, null);
          add(buttonSetScales, null);
  //        if (adjustBoundsVisible) {
  //            add(buttonAdjustBounds, null);
  //        }
          //add(buttonEdit, null);
          add(buttonSavePNGFile, null);
          add(buttonDatas, null);
          
          //show or hide legend
          final JCheckBox showHideLengend = new JCheckBox("show/hide legend", true);
          ItemListener itemListener = new ItemListener(){
          	public void itemStateChanged(ItemEvent e) {
          		Object obj=e.getItem(); 
          		if(obj.equals(showHideLengend)){ 
          			if(showHideLengend.isSelected()){ 
          				plotCanvas.linkedLegendPanel.setVisible(true);
          				//System.out.println("ok"); 
          			}else{ 
          				plotCanvas.linkedLegendPanel.setVisible(false);
          				//System.out.println("sdf");
          			} 
          		} 
          	}
          };
          
          showHideLengend.setSelected(true);
          showHideLengend.addItemListener(itemListener);
          
          add(showHideLengend,null);
          
          if (!denySaveSecurity) {
              pngFileChooser.addActionListener(new ActionListener() {
  
                  public void actionPerformed(ActionEvent e) {
                      saveGraphicFile();
                  }
              });
          } else {
              buttonSavePNGFile.setEnabled(false);
          }
  
          //buttonEdit.setEnabled(plotCanvas.getEditable());
  
          //buttonViewCoords.setEnabled(plotCanvas.getNotable());
  
          // allow mixed (2D/3D) plots managed by one toolbar
  