// DEPRECATED package genegui; import java.awt.*; import java.awt.Frame; import affectors.Affector; import parameters.Parameter; import parameters.ParameterSet; //import mygraphs.XYGraph; import main.ModelRunner; // TODO Slated for destruction public class ParInspector extends java.awt.Frame implements java.awt.event.ActionListener, java.awt.event.ItemListener, Runnable { ParameterSet params = new ParameterSet("fullstate"); float [] originalValues; boolean [] changed; boolean [] set; boolean anyChanged=false; int index=-1; // These are used for finding the model values across a range of a parameter // int surfaceParam, surfaceParamNumSteps; // float surfaceParamStart, surfaceParamEnd; public void init() { originalValues = new float[params.getNumParams()]; changed = new boolean[params.getNumParams()]; set = new boolean[params.getNumParams()]; for(int i = 0; i < params.getNumParams(); i++) { parList.add(params.getName(i)); originalValues[i] = params.getValue(i); changed[i] = set[i] = false; } setLocation(500,50); setVisible(true); } public ParInspector() { initVCControls(); init(); } //{{DECLARE_CONTROLS java.awt.Label lMode; java.awt.Button bRevertAll; java.awt.Button bRevert; java.awt.TextField fValue; java.awt.Button bSet; java.awt.List parList; java.awt.Label lVal; java.awt.Panel panel1; java.awt.Label label1; java.awt.Button surfaceButton; java.awt.TextField startText; java.awt.TextField endText; java.awt.TextField stepsText; java.awt.Label label2; java.awt.Label label3; //}} //{{DECLARE_MENUS //}} class SymItem implements java.awt.event.ItemListener { public void itemStateChanged(java.awt.event.ItemEvent event) { Object object = event.getSource(); if (object == parList) parList_ItemStateChanged(event); } } void parList_ItemStateChanged(java.awt.event.ItemEvent event) { index = parList.getSelectedIndex(); lVal.setEnabled(true); fValue.setEnabled(true); fValue.setText(String.valueOf(params.getValue(index))); if(changed[index]) { bRevert.setEnabled(true); } else bRevert.setEnabled(false); if(anyChanged) { bRevertAll.setEnabled(true); } fValue.setEditable(true); bSet.setEnabled(true); fValue.selectAll(); fValue.requestFocus(); } public void itemStateChanged(java.awt.event.ItemEvent event) { Object object = event.getSource(); if(object == parList) { index = parList.getSelectedIndex(); lVal.setEnabled(true); fValue.setEnabled(true); fValue.setText(String.valueOf(params.getValue(index))); if(changed[index]) bRevert.setEnabled(true); else bRevert.setEnabled(false); if(anyChanged) bRevertAll.setEnabled(true); fValue.setEditable(true); bSet.setEnabled(true); fValue.selectAll(); fValue.requestFocus(); startText.setText(String.valueOf(params.getLowerBound(index))); endText.setText(String.valueOf(params.getUpperBound(index))); if(params.getVariationMode(index) == Parameter.LINEAR) lMode.setText("Linear range..."); else lMode.setText("Log range (e^x)..."); } } public void actionPerformed(java.awt.event.ActionEvent event) { Object object = event.getSource(); if (object == fValue) { float newval = (Float.valueOf(fValue.getText())).floatValue(); params.setValue(index, newval); changed[index] = true; anyChanged = true; bRevert.setEnabled(true); bRevertAll.setEnabled(true); } else if (object == bSet) { if(changed[index]) { Affector.setParamValue(params.getName(index), params.getValue(index)); } set[index] = true; bRevert.setEnabled(true); bRevertAll.setEnabled(true); } else if (object == bRevert) { params.setValue(index, originalValues[index]); if(set[index]) { Affector.setParamValue(params.getName(index), params.getValue(index)); } changed[index] = set[index] = false; fValue.setText(String.valueOf(params.getValue(index))); } else if (object == bRevertAll) { if(anyChanged) { for(int i = 0; i < params.getNumParams(); i++) { params.setValue(i, originalValues[i]); if(set[i]) { Affector.setParamValue(params.getName(i), params.getValue(i)); } changed[i] = set[i] = false; } anyChanged = false; } bRevert.setEnabled(false); bRevertAll.setEnabled(false); fValue.setText(String.valueOf(params.getValue(index))); } else if (object == surfaceButton) { // if(itsGeneNet == null) return; return; /* try { surfaceParam = Affector.findParam(params.getName(index)); surfaceParamStart = (Float.valueOf(startText.getText())).floatValue(); surfaceParamEnd = (Float.valueOf(endText.getText())).floatValue(); surfaceParamNumSteps = (Integer.valueOf(stepsText.getText())).intValue(); // Check the values for being in bounds if(surfaceParamNumSteps < 1 || surfaceParamStart < params.getLowerBound(index) || surfaceParamEnd > params.getUpperBound(index) || surfaceParamStart >= surfaceParamEnd) { System.out.println("Something's wrong with those params - surface finding not called"); return; } Thread thread = new Thread(this); thread.start(); } catch(Exception e) { System.out.println(e.toString()); } */ } } public void run() { // if(itsGeneNet == null) return; return; /* try { XYGraph graph = new XYGraph(100); int graphIndex = graph.addItem(params.getName(index), Color.black); graph.setYScale(0.000000001f); graph.setXScale(1.1f * surfaceParamEnd); graph.setAutoscale(true); ModelRunner runner = itsGeneNet.getModelRunner(); float cur_val = Affector.getParamValue(surfaceParam); float val = surfaceParamStart; float step_val = (surfaceParamEnd - surfaceParamStart) / (surfaceParamNumSteps - 1); for(int i = 0; i < surfaceParamNumSteps; i++, val += step_val) { Affector.setParamValue(surfaceParam, val); runner.startRun(); try { while(runner.running) { Thread.sleep(100); } } catch (InterruptedException e) {} graph.addPoint(graphIndex, val, runner.stop.getScore()); System.out.println("@ " + val + " = " + runner.stop.getScore()); } Affector.setParamValue(surfaceParam, cur_val); } catch(Exception e) { System.out.println("Problem finding surface: " + e.toString()); } */ } class SymMouse extends java.awt.event.MouseAdapter { public void mouseReleased(java.awt.event.MouseEvent event) { } } class SymMouseMotion extends java.awt.event.MouseMotionAdapter { public void mouseDragged(java.awt.event.MouseEvent event) { } } class SymWindow extends java.awt.event.WindowAdapter { public void windowClosing(java.awt.event.WindowEvent event) { Object object = event.getSource(); if (object == ParInspector.this) ParInspector_WindowClosing(event); } } void ParInspector_WindowClosing(java.awt.event.WindowEvent event) { setVisible(false); params = null; this.dispose(); } /* private void activateSlider() { float value=0; lSliderMin.setText(String.valueOf(params[index].lowerBound)); lSliderMax.setText(String.valueOf(params[index].upperBound)); if(params[index].variationMode == Parameter.LINEAR) { lMode.setText("Linear range..."); float range = params[index].upperBound - params[index].lowerBound; value = (params[index].value - params[index].lowerBound) / range; } else if(params[index].variationMode == Parameter.LOGARITHMIC) { lMode.setText("Log range (e^x)..."); float loExp = (float)Math.log((double)params[index].lowerBound); float hiExp = (float)Math.log((double)params[index].upperBound); float expRange = hiExp - loExp; value = ((float)Math.log(params[index].value) - loExp) / expRange; } try { valueSlider.setValue((int)(value*100)); } catch(java.beans.PropertyVetoException pve) {} lMode.setEnabled(true); lSliderMin.setEnabled(true); lSliderMax.setEnabled(true); valueSlider.setEnabled(true); } */ private void initVCControls() { //{{INIT_CONTROLS GridBagLayout gridBagLayout; gridBagLayout = new GridBagLayout(); setLayout(gridBagLayout); setVisible(false); setSize(251,259); setBackground(new Color(12632256)); lMode = new java.awt.Label(""); lMode.setBounds(80,137,114,22); lMode.setFont(new Font("Dialog", Font.PLAIN, 10)); GridBagConstraints gbc; gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.gridwidth = 3; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(0,0,0,0); gbc.ipadx = 100; ((GridBagLayout)getLayout()).setConstraints(lMode, gbc); add(lMode); bRevertAll = new java.awt.Button(); bRevertAll.setLabel("Revert All"); bRevertAll.setBounds(98,164,72,20); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 3; gbc.gridwidth = 3; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(5,0,5,5); ((GridBagLayout)getLayout()).setConstraints(bRevertAll, gbc); add(bRevertAll); bRevertAll.setEnabled(false); bRevert = new java.awt.Button(); bRevert.setLabel("Revert"); bRevert.setBounds(27,164,53,20); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 3; gbc.anchor = GridBagConstraints.EAST; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(5,5,5,0); ((GridBagLayout)getLayout()).setConstraints(bRevert, gbc); add(bRevert); bRevert.setEnabled(false); fValue = new java.awt.TextField(10); fValue.setEditable(false); fValue.setBounds(85,111,8,17); fValue.setFont(new Font("DialogInput", Font.PLAIN, 12)); fValue.setBackground(new Color(16777215)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(5,5,5,5); ((GridBagLayout)getLayout()).setConstraints(fValue, gbc); add(fValue); fValue.setEnabled(false); bSet = new java.awt.Button(); bSet.setLabel("Set"); bSet.setBounds(194,164,32,20); gbc = new GridBagConstraints(); gbc.gridx = 4; gbc.gridy = 3; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(5,0,5,5); ((GridBagLayout)getLayout()).setConstraints(bSet, gbc); add(bSet); bSet.setEnabled(false); parList = new java.awt.List(4); parList.setBounds(42,12,129,85); parList.setFont(new Font("Dialog", Font.PLAIN, 12)); parList.setBackground(new Color(16777215)); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 4; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(10,5,5,5); ((GridBagLayout)getLayout()).setConstraints(parList, gbc); add(parList); lVal = new java.awt.Label("Value",Label.RIGHT); lVal.setBounds(25,107,50,25); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(5,5,5,5); ((GridBagLayout)getLayout()).setConstraints(lVal, gbc); add(lVal); lVal.setEnabled(false); panel1 = new java.awt.Panel(); gridBagLayout = new GridBagLayout(); panel1.setLayout(gridBagLayout); panel1.setBounds(29,189,155,67); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 4; gbc.gridwidth = 4; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(0,0,0,0); ((GridBagLayout)getLayout()).setConstraints(panel1, gbc); add(panel1); label1 = new java.awt.Label("Start"); label1.setBounds(0,0,45,25); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(0,0,0,0); ((GridBagLayout)panel1.getLayout()).setConstraints(label1, gbc); panel1.add(label1); surfaceButton = new java.awt.Button(); surfaceButton.setLabel("Find Surface"); surfaceButton.setBounds(33,47,89,20); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 3; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(5,0,0,0); ((GridBagLayout)panel1.getLayout()).setConstraints(surfaceButton, gbc); panel1.add(surfaceButton); startText = new java.awt.TextField(); startText.setBounds(1,25,43,17); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(0,0,0,0); gbc.ipadx = 35; ((GridBagLayout)panel1.getLayout()).setConstraints(startText, gbc); panel1.add(startText); endText = new java.awt.TextField(); endText.setBounds(50,25,43,17); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(0,5,0,0); gbc.ipadx = 35; ((GridBagLayout)panel1.getLayout()).setConstraints(endText, gbc); panel1.add(endText); stepsText = new java.awt.TextField(); stepsText.setText("10"); stepsText.setBounds(98,25,57,17); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 1; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(0,5,0,0); gbc.ipadx = 35; ((GridBagLayout)panel1.getLayout()).setConstraints(stepsText, gbc); panel1.add(stepsText); label2 = new java.awt.Label("End"); label2.setBounds(50,0,37,25); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(0,0,0,0); ((GridBagLayout)panel1.getLayout()).setConstraints(label2, gbc); panel1.add(label2); label3 = new java.awt.Label("Steps"); label3.setBounds(102,0,49,25); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 0; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(0,5,0,0); ((GridBagLayout)panel1.getLayout()).setConstraints(label3, gbc); panel1.add(label3); setTitle("Parameters"); setResizable(false); //}} //{{INIT_MENUS //}} //{{REGISTER_LISTENERS parList.addActionListener(this); SymMouse aSymMouse = new SymMouse(); SymMouseMotion aSymMouseMotion = new SymMouseMotion(); SymWindow aSymWindow = new SymWindow(); this.addWindowListener(aSymWindow); fValue.addActionListener(this); SymItem lSymItem = new SymItem(); parList.addItemListener(this); bSet.addActionListener(this); bRevert.addActionListener(this); bRevertAll.addActionListener(this); surfaceButton.addActionListener(this); //}} } }