import java.applet.*; import java.awt.*; import sansmodels.*; import graph.*; import graph.SpecialFunction; public class SANSSimulator extends Applet { TextField[] parameters, structParams; Label[] paramLabels, structLabels; TextField qminField, qmaxField, qpointsField; TextPopup outputText; TextField[] instrument; Label[] instrumentLabels; Checkbox smearedBox; Button showData; SANSResolution resolution = new SANSResolution(); Panel structPanel; Choice modelChoice, axisChoice, structureChoice; G2Dint graph; DataSet modelData, smearedData; Axis xaxis, yaxis; SANSModel model; StructureFactor structure; public void init() { Font font = new Font("TimesRoman",Font.PLAIN,12); graph = new G2Dint(); graph.drawzero = false; graph.drawgrid = true; graph.borderTop = 20; graph.borderRight = 50; graph.setDataBackground(Color.white); graph.setBackground(Color.white); setLayout( new BorderLayout() ); setBackground(Color.white); Label title = new Label("SANS data simulator", Label.CENTER); Panel panel = new Panel(); title.setFont(new Font("TimesRoman",Font.PLAIN,20)); add("North", title); add("Center", panel); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); panel.setLayout(gridbag); c.ipadx = 5; c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; gridbag.setConstraints(graph,c); panel.add(graph); showData = new Button("Show Data"); showData.setFont(font); c.fill = GridBagConstraints.HORIZONTAL; c.weightx=0.0; c.weighty=0.0; c.gridheight=1; c.anchor = GridBagConstraints.CENTER; gridbag.setConstraints(showData,c); panel.add(showData); c.fill = GridBagConstraints.NONE; c.weightx=0.0; c.weighty=0.0; c.gridheight=1; c.gridwidth=1; c.anchor = GridBagConstraints.CENTER; modelChoice = new Choice(); modelChoice.addItem("Sphere"); modelChoice.addItem("PolyHardSphere"); modelChoice.addItem("PolyRectSphere"); modelChoice.addItem("CoreShell"); modelChoice.addItem("PolyCoreShell"); modelChoice.addItem("PolyCoreShellRatio"); modelChoice.addItem("Cylinder"); modelChoice.addItem("HollowCylinder"); modelChoice.addItem("CoreShellCylinder"); modelChoice.addItem("Ellipsoid"); modelChoice.addItem("OblateCoreShell"); modelChoice.addItem("ProlateCoreShell"); modelChoice.addItem("TwoHomopolymerRPA"); modelChoice.addItem("DAB"); modelChoice.addItem("TeubnerStrey"); modelChoice.addItem("Lorentz"); modelChoice.addItem("PeakLorentz"); modelChoice.addItem("PeakGauss"); modelChoice.addItem("PowerLaw"); modelChoice.addItem("BE_RPA"); modelChoice.addItem("Flat"); modelChoice.addItem("CoreShellCylinderLam"); modelChoice.setFont(font); gridbag.setConstraints(modelChoice,c); panel.add(modelChoice); structureChoice = new Choice(); structureChoice.addItem("Flat"); structureChoice.addItem("HardSphere"); structureChoice.addItem("SquareWell"); structureChoice.addItem("HardDisk"); //structureChoice.addItem("MSA"); structureChoice.setFont(font); gridbag.setConstraints(structureChoice,c); panel.add(structureChoice); axisChoice = new Choice(); axisChoice.addItem("Lin-Lin"); axisChoice.addItem("Lin-Log"); axisChoice.addItem("Log-Lin"); axisChoice.addItem("Log-Log"); axisChoice.setFont(font); gridbag.setConstraints(axisChoice,c); panel.add(axisChoice); c.gridwidth = GridBagConstraints.REMAINDER; smearedBox = new Checkbox(); smearedBox.setLabel("Smear data?"); smearedBox.setFont(font); gridbag.setConstraints(smearedBox,c); panel.add(smearedBox); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTH; Panel paramPanel = new Panel(); GridBagLayout paramGridbag = new GridBagLayout(); GridBagConstraints paramc = new GridBagConstraints(); paramPanel.setLayout(paramGridbag); paramc.fill = GridBagConstraints.HORIZONTAL; paramc.weightx=0.0; paramc.weighty=0.0; paramc.gridheight=1; paramc.gridwidth=1; //initialize the values in the model fields model = new Sphere(); double[] paramValues = model.getParameters(); String[] paramText = model.getParametersText(); int numParams = model.getNumberOfParameters(); parameters = new TextField[11]; paramLabels = new Label[11]; for(int i=0;i<11;i++) { if (i