/*
* Title: japlot.jaxodraw
* Description: Graphical user interface for drawing Feynman diagrams
* @author Daniele Binosi
* @author Lukas Theussl
Copyright (C) 2003-2006, Daniele Binosi and Lukas Theussl
See the file LICENSE in the source distribution home directory
for a full copy of the GPL (GNU General Public License).
This file is part of japlot.jaxodraw.
japlot.jaxodraw is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
japlot.jaxodraw is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package japlot.jaxodraw;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.util.ResourceBundle;
import javax.swing.AbstractButton;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
/** Contains the entries of the edit menu. */
public class JaxoEditMenu extends JMenu implements ActionListener {
private JaxoMainPanel thePanel;
private ResourceBundle language =
ResourceBundle.getBundle(JaxoPrefs.getPref(JaxoPrefs.PREF_LANGUAGE));
private JMenuItem undoMI;
private JMenuItem clearMI;
private JMenuItem refreshMI;
private JMenuItem pasteMI;
private JMenuItem moveMI;
private JMenuItem resizeMI;
private JMenuItem copyMI;
private JMenuItem colorMI;
private JMenuItem editMI;
private JMenuItem deleteMI;
private JMenuItem backgroundMI;
private JMenuItem foregroundMI;
private JMenuItem groupMI;
private JMenuItem ungroupMI;
private JMenuItem zoomMI;
/** Constructs a new edit menu from the specified panel.
* @param mainPanel The parent JaxoMainPanel.
*/
public JaxoEditMenu(JaxoMainPanel mainPanel) {
super(ResourceBundle.getBundle(JaxoPrefs.getPref(
JaxoPrefs.PREF_LANGUAGE)).getString("Edit"));
this.thePanel = mainPanel;
undoMI = new JMenuItem(language.getString("Undo"));
this.add(undoMI);
undoMI.addActionListener(this);
undoMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U,
ActionEvent.ALT_MASK));
undoMI.setActionCommand("Undo");
clearMI = new JMenuItem(language.getString("Clear"));
this.add(clearMI);
clearMI.addActionListener(this);
clearMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,
ActionEvent.ALT_MASK));
clearMI.setActionCommand("Clear");
refreshMI = new JMenuItem(language.getString("Refresh"));
this.add(refreshMI);
refreshMI.addActionListener(this);
refreshMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
ActionEvent.ALT_MASK));
refreshMI.setActionCommand("Refresh");
addSeparator();
pasteMI = new JMenuItem(language.getString("Paste"));
this.add(pasteMI);
pasteMI.addActionListener(this);
pasteMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,
ActionEvent.ALT_MASK));
pasteMI.setActionCommand("Paste");
addSeparator();
moveMI = new JMenuItem(language.getString("Move"));
this.add(moveMI);
moveMI.addActionListener(this);
moveMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M,
ActionEvent.ALT_MASK));
moveMI.setActionCommand("Move");
resizeMI = new JMenuItem(language.getString("Resize"));
this.add(resizeMI);
resizeMI.addActionListener(this);
resizeMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,
ActionEvent.ALT_MASK));
resizeMI.setActionCommand("Resize");
copyMI = new JMenuItem(language.getString("Copy"));
this.add(copyMI);
copyMI.addActionListener(this);
copyMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,
ActionEvent.ALT_MASK));
copyMI.setActionCommand("Copy");
colorMI = new JMenuItem(language.getString("Color"));
this.add(colorMI);
colorMI.addActionListener(this);
colorMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L,
ActionEvent.ALT_MASK));
colorMI.setActionCommand("Color");
editMI = new JMenuItem(language.getString("Edit"));
this.add(editMI);
editMI.addActionListener(this);
editMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,
ActionEvent.ALT_MASK));
editMI.setActionCommand("Edit");
deleteMI = new JMenuItem(language.getString("Delete"));
this.add(deleteMI);
deleteMI.addActionListener(this);
deleteMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D,
ActionEvent.ALT_MASK));
deleteMI.setActionCommand("Delete");
addSeparator();
backgroundMI = new JMenuItem(language.getString("Background"));
this.add(backgroundMI);
backgroundMI.addActionListener(this);
backgroundMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B,
ActionEvent.ALT_MASK));
backgroundMI.setActionCommand("Background");
foregroundMI = new JMenuItem(language.getString("Foreground"));
this.add(foregroundMI);
foregroundMI.addActionListener(this);
foregroundMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F,
ActionEvent.ALT_MASK));
foregroundMI.setActionCommand("Foreground");
addSeparator();
groupMI = new JMenuItem(language.getString("group"));
this.add(groupMI);
groupMI.addActionListener(this);
groupMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G,
ActionEvent.ALT_MASK));
groupMI.setActionCommand("Group");
ungroupMI = new JMenuItem(language.getString("Ungroup"));
this.add(ungroupMI);
ungroupMI.addActionListener(this);
ungroupMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,
ActionEvent.ALT_MASK));
ungroupMI.setActionCommand("Ungroup");
addSeparator();
zoomMI = new JMenuItem(language.getString("Zoom"));
// this.add(zoomMI);
zoomMI.addActionListener(this);
zoomMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z,
ActionEvent.ALT_MASK));
zoomMI.setActionCommand("Zoom");
}
/** Specifies the action to be taken when an item
* from the menu has been selected.
* @param evt The event to be processed.
*/
public final void actionPerformed(ActionEvent evt) {
AbstractButton source = (AbstractButton) evt.getSource();
if (source.getActionCommand().equals("Undo")) {
thePanel.actionEvent(JaxoMainPanel.UNDO);
} else if (source.getActionCommand().equals("Clear")) {
thePanel.actionEvent(JaxoMainPanel.CLEAR);
} else if (source.getActionCommand().equals("Refresh")) {
thePanel.actionEvent(JaxoMainPanel.REFRESH);
} else if (source.getActionCommand().equals("Paste")) {
thePanel.actionEvent(JaxoMainPanel.PASTE);
} else if (source.getActionCommand().equals("Move")) {
thePanel.editEvent(JaxoMainPanel.MOVE);
} else if (source.getActionCommand().equals("Resize")) {
thePanel.editEvent(JaxoMainPanel.RESIZE);
} else if (source.getActionCommand().equals("Copy")) {
thePanel.editEvent(JaxoMainPanel.COPY);
} else if (source.getActionCommand().equals("Color")) {
thePanel.editEvent(JaxoMainPanel.COLOR);
} else if (source.getActionCommand().equals("Edit")) {
thePanel.editEvent(JaxoMainPanel.EDIT);
} else if (source.getActionCommand().equals("Delete")) {
thePanel.editEvent(JaxoMainPanel.DELETE);
} else if (source.getActionCommand().equals("Background")) {
thePanel.editEvent(JaxoMainPanel.BACKGROUND);
} else if (source.getActionCommand().equals("Foreground")) {
thePanel.editEvent(JaxoMainPanel.FOREGROUND);
} else if (source.getActionCommand().equals("Group")) {
thePanel.editEvent(JaxoMainPanel.GROUP);
} else if (source.getActionCommand().equals("Ungroup")) {
thePanel.editEvent(JaxoMainPanel.UNGROUP);
} else if (source.getActionCommand().equals("Zoom")) {
thePanel.editEvent(JaxoMainPanel.ZOOM);
}
}
/** Sets the text for the entries in the edit menu in different languages.
* @param languageString A string specifying the language to be set.
*/
public final void setLanguage(String languageString) {
language = ResourceBundle.getBundle(languageString);
super.setText(language.getString("Edit"));
undoMI.setText(language.getString("Undo"));
clearMI.setText(language.getString("Clear"));
refreshMI.setText(language.getString("Refresh"));
pasteMI.setText(language.getString("Paste"));
moveMI.setText(language.getString("Move"));
resizeMI.setText(language.getString("Resize"));
copyMI.setText(language.getString("Copy"));
colorMI.setText(language.getString("Color"));
editMI.setText(language.getString("Edit"));
deleteMI.setText(language.getString("Delete"));
backgroundMI.setText(language.getString("Background"));
foregroundMI.setText(language.getString("Foreground"));
groupMI.setText(language.getString("group"));
ungroupMI.setText(language.getString("Ungroup"));
zoomMI.setText(language.getString("Zoom"));
}
}
Ads help maintain this website.