/*
* 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.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.ResourceBundle;
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
/** Contains the entries of the options menu. */
public class JaxoOptionsMenu extends JMenu implements ActionListener {
private ResourceBundle language =
ResourceBundle.getBundle(JaxoPrefs.getPref(JaxoPrefs.PREF_LANGUAGE));
private JaxoMainPanel thePanel;
private JMenu languageM;
private JMenu vertexM, axesM;
private JMenuItem showtoolMI;
private JMenuItem showeditorMI;
private JMenuItem showbrowserMI;
private JMenuItem showStatusMI;
private JMenuItem antialiasOnMI;
private JMenuItem gridOnMI;
private JMenuItem arrowMI;
private JMenuItem lookAndFeelMI;
private JMenuItem preferencesMI;
private JMenu defaultM;
private JRadioButtonMenuItem englishBT;
private JRadioButtonMenuItem germanBT;
private JRadioButtonMenuItem frenchBT;
private JRadioButtonMenuItem spanishBT;
private JRadioButtonMenuItem italianBT;
private JRadioButtonMenuItem type1BT;
private JRadioButtonMenuItem type2BT;
private JRadioButtonMenuItem type3BT;
private JRadioButtonMenuItem type4BT;
private JRadioButtonMenuItem type5BT;
private JRadioButtonMenuItem type6BT;
private ButtonGroup languageGroup;
private ButtonGroup vertexGroup;
private ButtonGroup axesGroup;
private JRadioButtonMenuItem t11;
private JRadioButtonMenuItem t12;
private JRadioButtonMenuItem t21;
private JRadioButtonMenuItem t22;
private int keyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
private String[] defaults =
{
language.getString("None"), language.getString("Fermion_Line"),
language.getString("Fermion_Loop"), language.getString("Fermion_Arc"),
language.getString("Scalar_Line"), language.getString("Scalar_Loop"),
language.getString("Scalar_Arc"), language.getString("Ghost_Line"),
language.getString("Ghost_Loop"), language.getString("Ghost_Arc"),
language.getString("Photon_Line"), language.getString("Photon_Loop"),
language.getString("Photon_Arc"), language.getString("Gluon_Line"),
language.getString("Gluon_Loop"), language.getString("Gluon_Arc"),
language.getString("Box"), language.getString("Blob"),
language.getString("Vertex"), language.getString("Zigzag"),
language.getString("Text"), language.getString("LaTex"),
language.getString("Move"), language.getString("Resize"),
language.getString("Copy"), language.getString("Color"),
language.getString("Edit")
};
private String[] defactions =
{
"None", "Fermion_Line", "Fermion_Loop", "Fermion_Arc", "Scalar_Line",
"Scalar_Loop", "Scalar_Arc", "Ghost_Line", "Ghost_Loop", "Ghost_Arc",
"Photon_Line", "Photon_Loop", "Photon_Arc", "Gluon_Line", "Gluon_Loop",
"Gluon_Arc", "Box", "Blob", "Vertex", "Zigzag", "Text", "LaTex", "Move",
"Resize", "Copy", "Color", "Edit"
};
private int nofdef = 27;
private JMenuItem[] defMIs = new JMenuItem[nofdef];
/** Constructs a new options menu from the specified panel.
* @param mainPanel The parent JaxoMainPanel.
*/
public JaxoOptionsMenu(JaxoMainPanel mainPanel) {
super(ResourceBundle.getBundle(JaxoPrefs.getPref(
JaxoPrefs.PREF_LANGUAGE)).getString("Options"));
this.thePanel = mainPanel;
lookAndFeelMI = new JMenuItem(language.getString("Look_And_Feel"));
this.add(lookAndFeelMI);
lookAndFeelMI.addActionListener(this);
lookAndFeelMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L,
keyMask));
lookAndFeelMI.setActionCommand("Look_And_Feel");
languageM = new JMenu(language.getString("Language"));
languageM.addActionListener(this);
setupLanguageMenu();
this.add(languageM);
defaultM =
new JMenu(language.getString("Default") + ": "
+ defaults[JaxoPrefs.getIntPref(JaxoPrefs.PREF_DEFAULTACTION)]);
defaultM.addActionListener(this);
setupDefaultMenu();
this.add(defaultM);
addSeparator();
vertexM = new JMenu(language.getString("Vertex_types"));
vertexM.addActionListener(this);
setupVertexMenu();
this.add(vertexM);
axesM = new JMenu("Add pads");
axesM.addActionListener(this);
setupAxesMenu();
this.add(axesM);
addSeparator();
showtoolMI = new JMenuItem(language.getString("Show_Toolbar"));
if (JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_SHOWTOOL)) {
showtoolMI.setIcon(new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/checkmark.png")));
} else {
showtoolMI.setIcon(null);
}
this.add(showtoolMI);
showtoolMI.addActionListener(this);
showtoolMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, keyMask));
showtoolMI.setActionCommand("Show_Toolbar");
showeditorMI = new JMenuItem(language.getString("Show_Editor"));
if (JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_SHOWEDITOR)) {
showeditorMI.setIcon(new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/checkmark.png")));
} else {
showeditorMI.setIcon(null);
}
this.add(showeditorMI);
showeditorMI.addActionListener(this);
showeditorMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, keyMask));
showeditorMI.setActionCommand("Show_Editor");
showbrowserMI = new JMenuItem(language.getString("Show_Browser"));
if (JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_SHOWBROWSER)) {
showbrowserMI.setIcon(new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/checkmark.png")));
} else {
showbrowserMI.setIcon(null);
}
this.add(showbrowserMI);
showbrowserMI.addActionListener(this);
showbrowserMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, keyMask));
showbrowserMI.setActionCommand("Show_Browser");
showStatusMI = new JMenuItem(language.getString("Show_Statusbar"));
if (JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_SHOWSTATUS)) {
showStatusMI.setIcon(new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/checkmark.png")));
} else {
showStatusMI.setIcon(null);
}
this.add(showStatusMI);
showStatusMI.addActionListener(this);
showStatusMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F,
keyMask));
showStatusMI.setActionCommand("Show_Statusbar");
antialiasOnMI = new JMenuItem(language.getString("Antialias_on"));
if (JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_ANTIALIAS)) {
showStatusMI.setIcon(new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/checkmark.png")));
} else {
antialiasOnMI.setIcon(null);
}
this.add(antialiasOnMI);
antialiasOnMI.addActionListener(this);
antialiasOnMI.setActionCommand("Antialias_on");
arrowMI = new JMenuItem(language.getString("Arrow"));
if (JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_ARROW)) {
arrowMI.setIcon(new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/checkmark.png")));
} else {
arrowMI.setIcon(null);
}
this.add(arrowMI);
arrowMI.addActionListener(this);
arrowMI.setActionCommand("Arrow");
gridOnMI = new JMenuItem(language.getString("Grid_on"));
if (JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_GRIDONOFF)) {
gridOnMI.setIcon(new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/checkmark.png")));
} else {
gridOnMI.setIcon(null);
}
this.add(gridOnMI);
gridOnMI.addActionListener(this);
gridOnMI.setActionCommand("Grid_on");
addSeparator();
preferencesMI = new JMenuItem(language.getString("Preferences"));
this.add(preferencesMI);
preferencesMI.addActionListener(this);
preferencesMI.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,
keyMask));
preferencesMI.setActionCommand("Preferences");
}
private void setupAxesMenu() {
axesGroup = new ButtonGroup();
t11 =
new JRadioButtonMenuItem("pad 1x1");
t12 =
new JRadioButtonMenuItem("pad 1x2");
t21 =
new JRadioButtonMenuItem("pad 2x1");
t22 =
new JRadioButtonMenuItem("pad 2x2");
t11.addActionListener(this);
t11.setActionCommand("pad 1x1");
t12.addActionListener(this);
t12.setActionCommand("pad 1x2");
t21.addActionListener(this);
t21.setActionCommand("pad 2x1");
t22.addActionListener(this);
t22.setActionCommand("pad 2x2");
axesGroup.add(t11);
axesGroup.add(t12);
axesGroup.add(t21);
axesGroup.add(t22);
axesM.add(t11);
axesM.add(t12);
axesM.add(t21);
axesM.add(t22);
}
private void setupVertexMenu() {
vertexGroup = new ButtonGroup();
type1BT =
new JRadioButtonMenuItem(language.getString("Dot"),
new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/vertexsT1.png")),
true);
type1BT.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D,
ActionEvent.SHIFT_MASK));
type2BT =
new JRadioButtonMenuItem(language.getString("Circle_cross"),
new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/vertexsT2.png")));
type2BT.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,
ActionEvent.SHIFT_MASK));
type3BT =
new JRadioButtonMenuItem(language.getString("Square"),
new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/vertexsT3.png")));
type3BT.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
ActionEvent.SHIFT_MASK));
type4BT =
new JRadioButtonMenuItem(language.getString("Cross"),
new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/vertexsT4.png")));
type4BT.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,
ActionEvent.SHIFT_MASK));
type5BT =
new JRadioButtonMenuItem(language.getString("Triangle"),
new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/vertexsT5.png")));
type5BT.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T,
ActionEvent.SHIFT_MASK));
type6BT =
new JRadioButtonMenuItem(language.getString("Diamond"),
new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/vertexsT6.png")));
type6BT.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I,
ActionEvent.SHIFT_MASK));
type1BT.addActionListener(this);
type1BT.setActionCommand("Dot");
type2BT.addActionListener(this);
type2BT.setActionCommand("Circle_cross");
type3BT.addActionListener(this);
type3BT.setActionCommand("Square");
type4BT.addActionListener(this);
type4BT.setActionCommand("Cross");
type5BT.addActionListener(this);
type5BT.setActionCommand("Triangle");
type6BT.addActionListener(this);
type6BT.setActionCommand("Diamond");
vertexGroup.add(type1BT);
vertexGroup.add(type2BT);
vertexGroup.add(type3BT);
vertexGroup.add(type4BT);
vertexGroup.add(type5BT);
vertexGroup.add(type6BT);
vertexM.add(type1BT);
vertexM.add(type2BT);
vertexM.add(type3BT);
vertexM.add(type4BT);
vertexM.add(type5BT);
vertexM.add(type6BT);
}
private void setupLanguageMenu() {
languageGroup = new ButtonGroup();
englishBT = new JRadioButtonMenuItem(language.getString("English"));
englishBT.addActionListener(this);
englishBT.setActionCommand("English");
englishBT.setAccelerator(KeyStroke.getKeyStroke('e'));
languageGroup.add(englishBT);
germanBT = new JRadioButtonMenuItem(language.getString("German"));
germanBT.addActionListener(this);
germanBT.setActionCommand("German");
germanBT.setAccelerator(KeyStroke.getKeyStroke('g'));
languageGroup.add(germanBT);
frenchBT = new JRadioButtonMenuItem(language.getString("French"));
frenchBT.addActionListener(this);
frenchBT.setActionCommand("French");
frenchBT.setAccelerator(KeyStroke.getKeyStroke('f'));
languageGroup.add(frenchBT);
spanishBT = new JRadioButtonMenuItem(language.getString("Spanish"));
spanishBT.addActionListener(this);
spanishBT.setActionCommand("Spanish");
spanishBT.setAccelerator(KeyStroke.getKeyStroke('s'));
languageGroup.add(spanishBT);
italianBT = new JRadioButtonMenuItem(language.getString("Italian"));
italianBT.addActionListener(this);
italianBT.setActionCommand("Italian");
italianBT.setAccelerator(KeyStroke.getKeyStroke('i'));
languageGroup.add(italianBT);
languageM.add(englishBT);
languageM.add(germanBT);
languageM.add(frenchBT);
languageM.add(spanishBT);
languageM.add(italianBT);
if (JaxoPrefs.getPref(JaxoPrefs.PREF_LANGUAGE).equals("english")) {
englishBT.setSelected(true);
} else if (JaxoPrefs.getPref(JaxoPrefs.PREF_LANGUAGE).equals("german")) {
germanBT.setSelected(true);
} else if (JaxoPrefs.getPref(JaxoPrefs.PREF_LANGUAGE).equals("french")) {
frenchBT.setSelected(true);
} else if (JaxoPrefs.getPref(JaxoPrefs.PREF_LANGUAGE).equals("spanish")) {
spanishBT.setSelected(true);
} else if (JaxoPrefs.getPref(JaxoPrefs.PREF_LANGUAGE).equals("italian")) {
italianBT.setSelected(true);
}
}
private void setupDefaultMenu() {
for (int i = 0; i < nofdef; i++) {
defMIs[i] = new JMenuItem(defaults[i]);
defMIs[i].addActionListener(this);
defMIs[i].setActionCommand(defactions[i]);
defaultM.add(defMIs[i]);
}
}
/** 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("Describe")) {
describe();
} else if (source.getActionCommand().equals("Package")) {
latexPackage();
} else if (source.getActionCommand().equals("Look_And_Feel")) {
lookNFeel();
} else if (source.getActionCommand().equals("English")) {
thePanel.setLanguage("english");
} else if (source.getActionCommand().equals("German")) {
thePanel.setLanguage("german");
} else if (source.getActionCommand().equals("French")) {
thePanel.setLanguage("french");
} else if (source.getActionCommand().equals("Spanish")) {
thePanel.setLanguage("spanish");
} else if (source.getActionCommand().equals("Italian")) {
thePanel.setLanguage("italian");
} else if (source.getActionCommand().equals("Dot")) {
thePanel.setVertexType(JaxoMainPanel.VERTEXT1);
thePanel.getMbtPanel().getVertexButton().setIcon(new ImageIcon(
JaxoOptionsMenu.class.getClassLoader().getResource("japlot/jaxodraw/icons/vertexT1.png")));
thePanel.getMbtPanel().getVertexButton().doClick();
thePanel.getMbtPanel().updatePop(JaxoMainPanel.VERTEXT1);
} else if (source.getActionCommand().equals("Circle_cross")) {
thePanel.setVertexType(JaxoMainPanel.VERTEXT2);
thePanel.getMbtPanel().getVertexButton().setIcon(new ImageIcon(
JaxoOptionsMenu.class.getClassLoader().getResource("japlot/jaxodraw/icons/vertexT2.png")));
thePanel.getMbtPanel().getVertexButton().doClick();
thePanel.getMbtPanel().updatePop(JaxoMainPanel.VERTEXT2);
} else if (source.getActionCommand().equals("Square")) {
thePanel.setVertexType(JaxoMainPanel.VERTEXT3);
thePanel.getMbtPanel().getVertexButton().setIcon(new ImageIcon(
JaxoOptionsMenu.class.getClassLoader().getResource("japlot/jaxodraw/icons/vertexT3.png")));
thePanel.getMbtPanel().getVertexButton().doClick();
thePanel.getMbtPanel().updatePop(JaxoMainPanel.VERTEXT3);
} else if (source.getActionCommand().equals("Cross")) {
thePanel.setVertexType(JaxoMainPanel.VERTEXT4);
thePanel.getMbtPanel().getVertexButton().setIcon(new ImageIcon(
JaxoOptionsMenu.class.getClassLoader().getResource("japlot/jaxodraw/icons/vertexT4.png")));
thePanel.getMbtPanel().getVertexButton().doClick();
thePanel.getMbtPanel().updatePop(JaxoMainPanel.VERTEXT4);
} else if (source.getActionCommand().equals("Triangle")) {
thePanel.setVertexType(JaxoMainPanel.VERTEXT5);
thePanel.getMbtPanel().getVertexButton().setIcon(new ImageIcon(
JaxoOptionsMenu.class.getClassLoader().getResource("japlot/jaxodraw/icons/vertexT5.png")));
thePanel.getMbtPanel().getVertexButton().doClick();
thePanel.getMbtPanel().updatePop(JaxoMainPanel.VERTEXT5);
} else if (source.getActionCommand().equals("Diamond")) {
thePanel.setVertexType(JaxoMainPanel.VERTEXT6);
thePanel.getMbtPanel().getVertexButton().setIcon(new ImageIcon(
JaxoOptionsMenu.class.getClassLoader().getResource("japlot/jaxodraw/icons/vertexT6.png")));
thePanel.getMbtPanel().getVertexButton().doClick();
thePanel.getMbtPanel().updatePop(JaxoMainPanel.VERTEXT6);
} else if (source.getActionCommand().equals("pad 1x1")) {
thePanel.setAxes(1,1);
} else if (source.getActionCommand().equals("pad 1x2")) {
thePanel.setAxes(1,2);
} else if (source.getActionCommand().equals("pad 2x1")) {
thePanel.setAxes(2,1);
} else if (source.getActionCommand().equals("pad 2x2")) {
thePanel.setAxes(2,2);
} else if (source.getActionCommand().equals("Show_Toolbar")) {
if (!JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_SHOWTOOL)) {
showToolbar(true);
} else {
showToolbar(false);
}
} else if (source.getActionCommand().equals("Show_Editor")) {
if (!JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_SHOWEDITOR)) {
showEditorbar(true);
} else {
showEditorbar(false);
}
} else if (source.getActionCommand().equals("Show_Browser")) {
if (!JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_SHOWBROWSER)) {
showBrowserbar(true);
} else {
showBrowserbar(false);
}
} else if (source.getActionCommand().equals("Show_Statusbar")) {
if (!JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_SHOWSTATUS)) {
showStatusbar(true);
} else {
showStatusbar(false);
}
} else if (source.getActionCommand().equals("Antialias_on")) {
if (!JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_ANTIALIAS)) {
antialiasOn(true);
} else {
antialiasOn(false);
}
} else if (source.getActionCommand().equals("Arrow")) {
if (!JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_ARROW)) {
arrow(true);
} else {
arrow(false);
}
} else if (source.getActionCommand().equals("Grid_on")) {
if (!JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_GRIDONOFF)) {
gridOn(true);
} else {
gridOn(false);
}
} else if (source.getActionCommand().equals("Preferences")) {
JaxoPrefsPanel prefDialog = new JaxoPrefsPanel(thePanel);
prefDialog.pack();
prefDialog.setVisible(true);
} else {
for (int i = 0; i < nofdef; i++) {
if (source.getActionCommand().equals(defactions[i])) {
setDefault(i);
}
}
}
}
/** Pops up a dialog box that allows the user to change the
* Look and Feel of this japlot.jaxodraw session.
*/
public final void lookNFeel() {
JaxoLooknFeel laf = new JaxoLooknFeel();
laf.updateState();
SwingUtilities.updateComponentTreeUI(thePanel);
}
/** Sets the text for the entries in the options 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("Options"));
showtoolMI.setText(language.getString("Show_Toolbar"));
showStatusMI.setText(language.getString("Show_Statusbar"));
antialiasOnMI.setText(language.getString("Antialias_on"));
gridOnMI.setText(language.getString("Grid_on"));
arrowMI.setText(language.getString("Arrow"));
vertexM.setText(language.getString("Vertex_types"));
lookAndFeelMI.setText(language.getString("Look_And_Feel"));
languageM.setText(language.getString("Language"));
englishBT.setText(language.getString("English"));
germanBT.setText(language.getString("German"));
frenchBT.setText(language.getString("French"));
spanishBT.setText(language.getString("Spanish"));
italianBT.setText(language.getString("Italian"));
type1BT.setText(language.getString("Dot"));
type2BT.setText(language.getString("Circle_cross"));
type3BT.setText(language.getString("Square"));
type4BT.setText(language.getString("Cross"));
type5BT.setText(language.getString("Triangle"));
type6BT.setText(language.getString("Diamond"));
preferencesMI.setText(language.getString("Preferences"));
defaultM.setText(language.getString("Default") + ": "
+ language.getString(
defactions[JaxoPrefs.getIntPref(JaxoPrefs.PREF_DEFAULTACTION)]));
for (int i = 0; i < nofdef; i++) {
defMIs[i].setText(language.getString(defactions[i]));
}
}
/** Sets the Toolbar visible or not. If it is visible, a small Icon
* is displayed in the corresponding OptionsMenu item.
* @param show Boolean variable that determines whether to show
the Toolbar or not.
*/
public final void showToolbar(boolean show) {
if (show) {
showtoolMI.setIcon(new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/checkmark.png")));
thePanel.showToolbar(true);
} else {
showtoolMI.setIcon(null);
thePanel.showToolbar(false);
}
}
/** Sets the Editor visible or not. If it is visible, a small Icon
* is displayed in the corresponding OptionsMenu item.
* @param show Boolean variable that determines whether to show
the editor or not.
*/
public final void showEditorbar(boolean show) {
if (show) {
showeditorMI.setIcon(new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/checkmark.png")));
thePanel.showEditorbar(true);
} else {
showeditorMI.setIcon(null);
thePanel.showEditorbar(false);
}
}
/** Sets the Editor visible or not. If it is visible, a small Icon
* is displayed in the corresponding OptionsMenu item.
* @param show Boolean variable that determines whether to show
the editor or not.
*/
public final void showBrowserbar(boolean show) {
if (show) {
showbrowserMI.setIcon(new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/checkmark.png")));
thePanel.showBrowserbar(true);
} else {
showbrowserMI.setIcon(null);
thePanel.showBrowserbar(false);
}
}
/** Sets the Statusbar visible or not. If it is visible,
* a small Icon is displayed in the corresponding OptionsMenu item.
* @param show Boolean variable that determines whether to show
* the Statusbar or not.
*/
public final void showStatusbar(boolean show) {
if (show) {
showStatusMI.setIcon(new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/checkmark.png")));
thePanel.showStatusbar(true);
} else {
showStatusMI.setIcon(null);
thePanel.showStatusbar(false);
}
}
/** Switches antialiasing on or off. If it is on, a small Icon
* is displayed in the corresponding OptionsMenu item.
* @param on Boolean variable that determines whether
* antialiasing is on or off.
*/
public final void antialiasOn(boolean on) {
if (on) {
antialiasOnMI.setIcon(new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/checkmark.png")));
thePanel.antialiasOn(true);
} else {
antialiasOnMI.setIcon(null);
thePanel.antialiasOn(false);
}
}
/** Determines whether arrows should be drawn by default on lines,
* arcs and loops.
* @param on A boolean variable that determines whether
* arrows should be drawn by default on lines, arcs and loops.
*/
public final void arrow(boolean on) {
if (on) {
arrowMI.setIcon(new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/checkmark.png")));
thePanel.arrow(true);
} else {
arrowMI.setIcon(null);
thePanel.arrow(false);
}
}
/** Switches the grid on or off. If it is on, a small Icon
* is displayed in the corresponding OptionsMenu item.
* @param on Boolean variable that determines whether
* the grid is on or off.
*/
public final void gridOn(boolean on) {
if (on) {
gridOnMI.setIcon(new ImageIcon(JaxoOptionsMenu.class.getClassLoader()
.getResource("japlot/jaxodraw/icons/checkmark.png")));
thePanel.gridOn(true);
} else {
gridOnMI.setIcon(null);
thePanel.gridOn(false);
}
}
/** Allows to enter a short text that serves as a description of the current
* JaxoGraph. This text will appear in all export files.
*/
public final void describe() {
String describeText =
thePanel.getCanvas().getCanvasGraph().getDescription();
String msg1 =
language.getString(
"Please_enter_a_short_description_of_this_Graph.");
String msg2 =
language.getString(
"It_will_appear_as_a_comment_in_all_your_output_files.");
JTextField textField = new JTextField(describeText, 70);
Object[] array = {msg1, msg2, textField};
String btn1 = language.getString("OK");
String btn2 = language.getString("Cancel");
Object[] options = {btn1, btn2};
int n =
JOptionPane.showOptionDialog(null, array,
language.getString("Enter_description"),
JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null,
options, btn1);
if (n == JOptionPane.OK_OPTION) {
describeText = textField.getText();
}
thePanel.getCanvas().getCanvasGraph().setDescription(describeText);
}
/** Brings up a dialog that allows a custom Latex package
* to be included in the Latex output.
*/
public final void latexPackage() {
ArrayList packageList =
thePanel.getCanvas().getCanvasGraph().getPackageList();
JaxoLatexPackage latexPackage = new JaxoLatexPackage(packageList);
ArrayList newPackageList = latexPackage.getPackageList();
thePanel.getCanvas().getCanvasGraph().setPackageList(newPackageList);
}
/** Sets the radio button to the current vertex type in the pop-up menu.
* @param popvt Specifies the current vertex type.
*/
public final void setPopVT(int popvt) {
if (popvt == JaxoMainPanel.VERTEXT1) {
type1BT.setSelected(true);
} else if (popvt == JaxoMainPanel.VERTEXT2) {
type2BT.setSelected(true);
} else if (popvt == JaxoMainPanel.VERTEXT3) {
type3BT.setSelected(true);
} else if (popvt == JaxoMainPanel.VERTEXT4) {
type4BT.setSelected(true);
} else if (popvt == JaxoMainPanel.VERTEXT5) {
type5BT.setSelected(true);
} else if (popvt == JaxoMainPanel.VERTEXT6) {
type6BT.setSelected(true);
}
}
/** Sets the label of the default entry to the selected one.
* @param act Specifies the current default action.
*/
public final void setDefault(int act) {
defaultM.setText(language.getString("Default") + ": "
+ language.getString(defactions[act]));
if (act != JaxoPrefs.getIntPref(JaxoPrefs.PREF_DEFAULTACTION)) {
JaxoPrefs.setIntPref(JaxoPrefs.PREF_DEFAULTACTION, act);
}
}
}
Ads help maintain this website.