gt: 		label = new JLabel("0.05 eV");
context: /*
   *   Copyright (C) 2006  The Concord Consortium, Inc.,
   *   25 Love Lane, Concord, MA 01742
   *
   *   This program 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.
   *
   *   This program 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
   *
   * END LICENSE */
  
  package org.concord.mw2d.ui;
  
  import java.awt.BorderLayout;
  import java.awt.Color;
  import java.awt.Cursor;
  import java.awt.Dimension;
  import java.awt.FlowLayout;
  import java.awt.Font;
  import java.awt.Frame;
  import java.awt.Graphics;
  import java.awt.Graphics2D;
  import java.awt.Point;
  import java.awt.Rectangle;
  import java.awt.RenderingHints;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.event.MouseEvent;
  import java.awt.event.MouseListener;
  import java.awt.event.MouseMotionListener;
  import java.awt.event.WindowAdapter;
  import java.awt.event.WindowEvent;
  import java.awt.geom.AffineTransform;
  import java.awt.geom.Ellipse2D;
  import java.text.DecimalFormat;
  import java.util.Hashtable;
  
  import javax.swing.AbstractButton;
  import javax.swing.BorderFactory;
  import javax.swing.ButtonGroup;
  import javax.swing.ImageIcon;
  import javax.swing.JButton;
  import javax.swing.JComponent;
  import javax.swing.JDialog;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  import javax.swing.JSlider;
  import javax.swing.JToggleButton;
  import javax.swing.SwingConstants;
  import javax.swing.event.ChangeEvent;
  import javax.swing.event.ChangeListener;
  
  import org.concord.modeler.ModelerUtilities;
  import org.concord.modeler.ui.ColorComboBox;
  import org.concord.modeler.ui.ColorRectangle;
  import org.concord.modeler.ui.IconPool;
  import org.concord.mw2d.UserAction;
  
  public class GayBerneConfigure extends JPanel {
  
  	public final static String GB_COLOR = "GB color";
  	public final static double GB_LIMIT = 0.1;
  
  	public static double eeVsEs = 1.0;
  	public static double epsilon0 = 0.01;
  	public static int breadth = 20, length = 60;
  	public static double theta = 0.0;
  	public static Color color = Color.blue;
  
  	private JSlider slider1, slider2;
  	private JLabel eAnisotropy, epsilon0_label;
  	private EllipsePanel ellipsePanel;
  	private ColorComboBox colorComboBox;
  	private static Cursor rotateCursor1, rotateCursor2, rotateCursor3;
  
  	private final static Font littleFont = new Font(null, Font.PLAIN, 10);
  	private final static DecimalFormat scientificFormat = new DecimalFormat();
  
  	public JDialog showDialog(Frame owner) {
  
  		colorComboBox.setParent(owner);
  
  		final JDialog d = new JDialog(owner, "Customize Gay-Berne Particle", true);
  		d.setResizable(false);
  		d.setLocation(230, 200);
  		d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
  
  		JPanel p = new JPanel(new FlowLayout(FlowLayout.RIGHT));
  		d.getContentPane().add(p, BorderLayout.SOUTH);
  
  		String s = MDContainer.getInternationalText("Close");
  		JButton button = new JButton(s != null ? s : "Close");
  		button.addActionListener(new ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				d.removeAll();
  				d.dispose();
  			}
  		});
  		p.add(button);
  		s = MDContainer.getInternationalText("ResetButton");
  		button = new JButton(s != null ? s : "Reset");
  		button.addActionListener(new ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				reset();
  			}
  		});
  		p.add(button);
  
  		d.getContentPane().add(this, BorderLayout.CENTER);
  
  		d.pack();
  
  		d.addWindowListener(new WindowAdapter() {
  			public void windowClosing(WindowEvent e) {
  				d.removeAll();
  				d.dispose();
  			}
  		});
  
  		return d;
  
  	}
  
  	public GayBerneConfigure() {
  
  		super(new BorderLayout());
  
  		if (rotateCursor1 == null) {
  			rotateCursor1 = UserAction.createCursor("images/cursors/rotate1.gif", new Point(16, 17), "rotate");
  			rotateCursor2 = UserAction.createCursor("images/cursors/rotate2.gif", new Point(14, 11), "rotate");
  			rotateCursor3 = UserAction.createCursor("images/cursors/rotate3.gif", new Point(16, 17), "rotate");
  		}
  
  		ellipsePanel = new EllipsePanel();
  
  		JPanel panel = new JPanel(new BorderLayout());
  		panel.add(ellipsePanel, BorderLayout.CENTER);
  		panel.setBorder(BorderFactory.createTitledBorder("Geometric Anisotropy"));
  
  		JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
  		p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  
  		ButtonGroup bg = new ButtonGroup();
  		Dimension dim = ModelerUtilities.getSystemToolBarButtonSize();
  
  		AbstractButton rb = new JToggleButton(IconPool.getIcon("resize"));
  		rb.setToolTipText("Resize the particle");
  		rb.setPreferredSize(dim);
  		rb.setHorizontalAlignment(SwingConstants.CENTER);
  		rb.addActionListener(new ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				ellipsePanel.setState(EllipsePanel.RESIZE);
  				ellipsePanel.repaint();
  			}
  		});
  		rb.setSelected(true);
  		p.add(rb);
  		bg.add(rb);
  
  		rb = new JToggleButton(new ImageIcon(getClass().getResource("images/Rotate.gif")));
  		rb.setToolTipText("Assign an initial angle");
  		rb.setPreferredSize(dim);
  		rb.setHorizontalAlignment(SwingConstants.CENTER);
  		rb.addActionListener(new ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				ellipsePanel.setState(EllipsePanel.ROTATE);
  				ellipsePanel.repaint();
  			}
  		});
  		p.add(rb);
  		bg.add(rb);
  
  		colorComboBox = new ColorComboBox(this);
  		colorComboBox.setName(GB_COLOR);
  		colorComboBox.setPreferredSize(new Dimension(100, dim.height));
  		colorComboBox.setSelectedIndex(2);
  		colorComboBox.updateColor(new Runnable() {
  			public void run() {
  				color = colorComboBox.getMoreColor();
  				ellipsePanel.repaint();
  			}
  		});
  		colorComboBox.addActionListener(new ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				String actionName = colorComboBox.getName();
  				int id = 0;
  				if (actionName.equals(GB_COLOR)) {
  					id = ((Integer) colorComboBox.getSelectedItem()).intValue();
  				}
  				if (id == 6 || id == 100) {
  					color = colorComboBox.getMoreColor();
  				}
  				else {
  					color = ColorRectangle.COLORS[id];
  				}
  				ellipsePanel.repaint();
  			}
  		});
  		p.add(colorComboBox);
  
  		panel.add(p, BorderLayout.NORTH);
  
  		add(panel, BorderLayout.NORTH);
  
  		eAnisotropy = new JLabel("<html>&#949;<sub>e</sub>/&#949;<sub>s</sub></html>", SwingConstants.CENTER);
  
  		slider1 = new JSlider(JSlider.HORIZONTAL, -10, 10, 0);
  		slider1.setPreferredSize(new Dimension(100, 50));
  		slider1.setMajorTickSpacing(5);
  		slider1.setMinorTickSpacing(5);
  		slider1.setPaintTicks(true);
  		slider1.setPaintTrack(true);
  		slider1.setPaintLabels(true);
  		slider1.addChangeListener(new ChangeListener() {
  			public void stateChanged(ChangeEvent e) {
  				JSlider source = (JSlider) e.getSource();
  				if (!source.getValueIsAdjusting()) {
  					eeVsEs = source.getValue();
  					if (eeVsEs < 1.0 && eeVsEs > -1.0)
  						eeVsEs = 1.0;
  					eeVsEs = eeVsEs > 0 ? eeVsEs : -1.0 / eeVsEs;
  					eAnisotropy.setText("<html>&#949;<sub>e</sub>/&#949;<sub>s</sub> = "
  							+ scientificFormat.format(eeVsEs) + "</html>");
  				}
  			}
  		});
  		Hashtable<Integer, JLabel> tableOfLabels = new Hashtable<Integer, JLabel>();
  		JLabel label = new JLabel("10.0");
  		label.setFont(littleFont);
  		tableOfLabels.put(10, label);
  		label = new JLabel("5.0");
  		label.setFont(littleFont);
  		tableOfLabels.put(5, label);
  		label = new JLabel("1.0");
  		label.setFont(littleFont);
  		tableOfLabels.put(0, label);
  		label = new JLabel("0.2");
  		label.setFont(littleFont);
  		tableOfLabels.put(-5, label);
  		label = new JLabel("0.1");
  		label.setFont(littleFont);
  		tableOfLabels.put(-10, label);
  		slider1.setLabelTable(tableOfLabels);
  
  		panel = new JPanel(new BorderLayout(0, 20));
  		panel.add(slider1, BorderLayout.NORTH);
  
  		scientificFormat.applyPattern("##.###");
  		eAnisotropy.setText("<html>&#949;<sub>e</sub>/&#949;<sub>s</sub>  = " + scientificFormat.format((float) eeVsEs)
  				+ "</html>");
  		eAnisotropy.setBorder(BorderFactory.createTitledBorder("Slider Value"));
  		panel.add(eAnisotropy, BorderLayout.CENTER);
  
  		p = new JPanel(new BorderLayout());
  		p.setBorder(BorderFactory.createTitledBorder("Energetic Anisotropic Ratio"));
  		p.add(panel, BorderLayout.EAST);
  
  		label = new JLabel(new ImageIcon(getClass().getResource("images/EnergyAnisotropy.gif")));
  		label.setBorder(BorderFactory.createLoweredBevelBorder());
  		p.add(label, BorderLayout.WEST);
  
  		add(p, BorderLayout.CENTER);
  
  		panel = new JPanel(new BorderLayout(10, 10));
  		panel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
  
  		scientificFormat.applyPattern("#.###");
  		epsilon0_label = new JLabel("<html>&#949;<sub>0</sub> = " + scientificFormat.format(epsilon0) + "</html>");
  		epsilon0_label.setBorder(BorderFactory.createTitledBorder("Value"));
  		panel.add(epsilon0_label, BorderLayout.EAST);
  
  		slider2 = new JSlider(JSlider.HORIZONTAL, 0, 50, 10);
  		slider2.setBorder(BorderFactory.createTitledBorder("Potential Well Depth"));
  		slider2.setMajorTickSpacing(10);
  		slider2.setMinorTickSpacing(5);
  		slider2.setPaintTicks(true);
  		slider2.setPaintTrack(true);
  		slider2.setPaintLabels(true);
  		tableOfLabels = new Hashtable<Integer, JLabel>();
  		label = new JLabel("0.1 eV");
  		label.setFont(littleFont);
  		tableOfLabels.put(50, label);
  