package genegui; import java.awt.*; import java.awt.event.*; import java.io.*; import javax.swing.*; import javax.swing.event.*; import affectors.Affector; import main.*; import parameters.*; /** ParameterViewer.java A corgial re-write of the ParInsepctor with a new name and some enhancements. @author WJS */ public class ParameterViewer extends JInternalFrame implements GuiInterface { /** */ private ParameterPanel FirstParameterPanel; /** */ private Font FieldFont = new Font("",Font.PLAIN,10); /** */ private float[] InitialLowerBounds; /** */ private float[] InitialStepSizes; /** */ private int[] InitialTypes; /** */ private float[] InitialUpperBounds; /** */ private float[] InitialValues; /** The MenuBar */ private JMenuBar MainMenu; /** The Main panel that stores all */ private JPanel MainPanel; /** The ParameterSet being viewed/edited */ private ParameterSet Parameters = new ParameterSet("fullstate"); /** THe panel for storing all ParameterPanels */ private JPanel ParametersPanel; /** Self Reference */ private ParameterViewer SaveThis = this; /** If set to true, simple display mode is used which just shows values */ private boolean SimpleDisplay = false; /** The MainGui object that this belongs to */ private MainGui TheMainGui; /** Simple constructor. @author WJS */ public ParameterViewer(MainGui theMainGui, String title, boolean simpleDisplay) { super(title,true,true,true,true); TheMainGui = theMainGui; SimpleDisplay = simpleDisplay; // Make main panel MainPanel = new JPanel(); MainPanel.setLayout(new BoxLayout(MainPanel,BoxLayout.Y_AXIS)); MainPanel.setBackground(Color.lightGray); setContentPane(MainPanel); // Make a panel for storing ParamaterPanels ParametersPanel = new JPanel(); // Initialize all the entries init(); pack(); setVisible(true); if (SimpleDisplay) setSize(220,400); else setSize(600,400); // Make a header panel ParameterHeaderPanel header = new ParameterHeaderPanel(); MainPanel.add(header,0); // Make a scroll panel for this list of all ParameterPanels JScrollPane scrollPane = new JScrollPane(ParametersPanel); MainPanel.add(scrollPane); // Make a JMenuBar MainMenu = new JMenuBar(); MainMenu.setBackground(Color.lightGray); JButton setAllButton = new JButton("Set All"); setAllButton.setOpaque(false); setAllButton.setFont(FieldFont); MainMenu.add(setAllButton); JButton resetAllButton = new JButton("Reset All"); resetAllButton.setOpaque(false); resetAllButton.setFont(FieldFont); MainMenu.add(resetAllButton); setJMenuBar(MainMenu); // Add an internal frame listener for capturing frame closing events addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent ife) { close(); } }); } /** Close up the JFrame properly, and disconnect from listener lists. @author WJS */ private void close() { dispose(); GeneNet.TheMainGui.removeInternalFrame(this); GeneNet.TheMainGui.removeGUIListener(this); } /** Initialize the display */ public void init() { // Make arrays for storing initial values so they may be reset. InitialLowerBounds = new float[Parameters.getNumParams()]; InitialUpperBounds = new float[Parameters.getNumParams()]; InitialValues = new float[Parameters.getNumParams()]; InitialStepSizes = new float[Parameters.getNumParams()]; InitialTypes = new int[Parameters.getNumParams()]; ParameterPanel pPanel; ParametersPanel.setLayout(new BoxLayout(ParametersPanel,BoxLayout.Y_AXIS)); for (int i=0;i