Ejemplo n.º 1
0
  public void init(String str, int age) {
    setSize(400, 80);
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setTitle("View a cat.");
    Label label1 = new Label("Cat name:");
    Label label2 = new Label("Cat age:");

    jPanel.setLayout(new GridLayout(3, 2));

    jPanel.add(label1);
    jPanel.add(nameTextField = new TextField(str));
    jPanel.add(label2);
    jPanel.add(ageTextField = new TextField(age + ""));
    jPanel.add(record = new Button("Record"));

    String nameString = nameTextField.getText();
    String ageString = ageTextField.getText();
    nameTextField.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            list[0] = nameString;
            list[1] = ageString;
          }
        });
    add(jPanel);
    setVisible(true);
  }
Ejemplo n.º 2
0
  void init(String[] names1, float[][][] pch1, int psfflag1) {
    setLayout(null);
    names = names1;
    pch = pch1;
    psfflag = psfflag1;
    ncurves = pch.length;
    nparams = 11;
    xpts = pch[0].length;
    ypts = pch[0][0].length;

    checkarray = new Checkbox[ncurves];
    include = new boolean[ncurves];
    namearray = new TextField[ncurves + 1];
    int1array = new TextField[ncurves + 1];
    intensity1 = new double[ncurves + 1];
    e1array = new TextField[ncurves + 1];
    n1array = new TextField[ncurves + 1];
    bright1 = new double[ncurves + 1];
    number1 = new double[ncurves + 1];
    int2array = new TextField[ncurves + 1];
    intensity2 = new double[ncurves + 1];
    e2array = new TextField[ncurves + 1];
    n2array = new TextField[ncurves + 1];
    bright2 = new double[ncurves + 1];
    number2 = new double[ncurves + 1];
    eccarray = new TextField[ncurves + 1];
    brightcc = new double[ncurves + 1];
    eminccarray = new TextField[ncurves + 1];
    brightmincc = new double[ncurves + 1];
    c2array = new TextField[ncurves + 1];
    c2 = new double[ncurves + 1];
    nmeas = new int[ncurves + 1];
    avg = new float[xpts][ypts];
    indices = new int[ncurves];
    beta = 0.05;

    getintbright();
    for (int i = 0; i < ncurves; i++) {
      include[i] = true;
      indices[i] = i;
    }
    updateavg();

    int starty = 60;
    int startx = 10;
    int yinc = 25;
    for (int i = 0; i <= ncurves; i++) {
      if (i != ncurves) {
        checkarray[i] = new Checkbox("", include[i]);
        checkarray[i].setBounds(startx, starty + i * yinc, 20, 20);
        checkarray[i].addItemListener(this);
        add(checkarray[i]);
      }

      namearray[i] = new TextField(names[i]);
      namearray[i].setBounds(startx + 30, starty + i * yinc, 200, 20);
      add(namearray[i]);

      int1array[i] = new TextField("" + (float) intensity1[i]);
      int1array[i].setBounds(startx + 30 + 210, starty + i * yinc, 40, 20);
      add(int1array[i]);

      e1array[i] = new TextField("" + (float) bright1[i]);
      e1array[i].setBounds(startx + 30 + 210 + 50, starty + i * yinc, 40, 20);
      add(e1array[i]);

      n1array[i] = new TextField("" + (float) number1[i]);
      n1array[i].setBounds(startx + 30 + 210 + 50 + 50, starty + i * yinc, 40, 20);
      add(n1array[i]);

      int2array[i] = new TextField("" + (float) intensity2[i]);
      int2array[i].setBounds(startx + 30 + 210 + 50 + 50 + 50, starty + i * yinc, 40, 20);
      add(int2array[i]);

      e2array[i] = new TextField("" + (float) bright2[i]);
      e2array[i].setBounds(startx + 30 + 210 + 50 + 50 + 50 + 50, starty + i * yinc, 40, 20);
      add(e2array[i]);

      n2array[i] = new TextField("" + (float) number2[i]);
      n2array[i].setBounds(startx + 30 + 210 + 50 + 50 + 50 + 50 + 50, starty + i * yinc, 40, 20);
      add(n2array[i]);

      eccarray[i] = new TextField("" + (float) brightcc[i]);
      eccarray[i].setBounds(
          startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50, starty + i * yinc, 40, 20);
      add(eccarray[i]);

      eminccarray[i] = new TextField("" + (float) brightmincc[i]);
      eminccarray[i].setBounds(
          startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50 + 50, starty + i * yinc, 40, 20);
      add(eminccarray[i]);

      c2[i] = 0.0;
      c2array[i] = new TextField("" + (float) c2[i]);
      c2array[i].setBounds(
          startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50 + 50 + 50, starty + i * yinc, 80, 20);
      add(c2array[i]);
    }

    namelabel = new Label("Filename");
    namelabel.setBounds(startx + 30, starty - 25, 100, 20);
    add(namelabel);

    intlabel = new Label("<Ig>");
    intlabel.setBounds(startx + 30 + 210, starty - 25, 40, 20);
    add(intlabel);

    brightlabel = new Label("<eg>");
    brightlabel.setBounds(startx + 30 + 210 + 50, starty - 25, 40, 20);
    add(brightlabel);

    nlabel = new Label("<Ng>");
    nlabel.setBounds(startx + 30 + 210 + 50 + 50, starty - 25, 40, 20);
    add(nlabel);

    int2label = new Label("<Ir>");
    int2label.setBounds(startx + 30 + 210 + 50 + 50 + 50, starty - 25, 40, 20);
    add(int2label);

    bright2label = new Label("<er>");
    bright2label.setBounds(startx + 30 + 210 + 50 + 50 + 50 + 50, starty - 25, 40, 20);
    add(bright2label);

    n2label = new Label("<Nr>");
    n2label.setBounds(startx + 30 + 210 + 50 + 50 + 50 + 50 + 50, starty - 25, 40, 20);
    add(n2label);

    brightcclabel = new Label("<ecc>");
    brightcclabel.setBounds(startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50, starty - 25, 40, 20);
    add(brightcclabel);

    brightccminlabel = new Label("min");
    brightccminlabel.setBounds(
        startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50 + 50, starty - 25, 40, 20);
    add(brightccminlabel);

    c2label = new Label("chi^2");
    c2label.setBounds(
        startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50 + 50 + 50, starty - 25, 80, 20);
    add(c2label);

    int buttonsx = startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50 + 50 + 50 + 90;

    fitavgbutton = new Button("Fit Avg");
    fitavgbutton.setBounds(buttonsx, starty - 25, 100, 40);
    fitavgbutton.addActionListener(this);
    add(fitavgbutton);

    fitglobalbutton = new Button("Fit Global");
    fitglobalbutton.setBounds(buttonsx, starty - 25 + 50, 100, 40);
    fitglobalbutton.addActionListener(this);
    add(fitglobalbutton);

    clearparamsbutton = new Button("Reset Fit Params");
    clearparamsbutton.setBounds(buttonsx, starty - 25 + 50 + 50, 100, 40);
    clearparamsbutton.addActionListener(this);
    add(clearparamsbutton);

    checkc2 = false;

    fitclass = new NLLSfit(this, 0.0001, 50, 0.1);
    globalfitclass = new NLLSglobalfit(this, 0.0001, 50, 0.1);
    pchfunc = new pch2D((int) ((double) xpts * 1.5), (int) ((double) ypts * 1.5), psfflag);
    avgfit = new float[xpts][ypts];
    fit = new float[ncurves][xpts][ypts];

    xvals = new float[ncurves][xpts][ypts];
    for (int i = 0; i < ncurves; i++) {
      for (int j = 0; j < xpts; j++) {
        for (int k = 0; k < ypts; k++) {
          xvals[i][j][k] = (float) k;
          fit[i][j][k] = 1.0f;
        }
      }
    }

    globalc2label = new Label("Global chi^2 = " + (float) 0.0);
    globalc2label.setBounds(buttonsx, starty - 25 + 50 + 50 + 50, 140, 20);
    add(globalc2label);

    dispcurvelabel = new Label("Display Fit #");
    dispcurvelabel.setBounds(buttonsx, starty - 25 + 50 + 50 + 50 + 30, 70, 20);
    add(dispcurvelabel);

    dispcurvechoice = new Choice();
    for (int i = 0; i < ncurves; i++) {
      dispcurvechoice.add("" + (i + 1));
    }
    dispcurve = 0;
    dispcurvechoice.select(0);
    dispcurvechoice.setBounds(buttonsx + 80, starty - 25 + 50 + 50 + 50 + 30, 40, 20);
    dispcurvechoice.addItemListener(this);
    add(dispcurvechoice);

    betalabel = new Label("Bleedthrough f");
    betalabel.setBounds(buttonsx, starty - 25 + 50 + 50 + 50 + 30 + 30, 100, 20);
    add(betalabel);
    betaval = new TextField("" + (float) beta);
    betaval.setBounds(buttonsx + 110, starty - 25 + 50 + 50 + 50 + 30 + 30, 40, 20);
    betaval.addActionListener(this);
    add(betaval);

    beta = Double.parseDouble(betaval.getText());
    updatebeta();

    undobutton = new Button("Undo Global Fit");
    undobutton.setBounds(buttonsx, starty - 25 + 50 + 50 + 50 + 30 + 30 + 50, 100, 40);
    undobutton.addActionListener(this);
    add(undobutton);

    geterrorsbutton = new Button("Get Errors");
    geterrorsbutton.setBounds(buttonsx, starty - 25 + 50 + 50 + 50 + 30 + 30 + 50 + 50, 100, 40);
    geterrorsbutton.addActionListener(this);
    add(geterrorsbutton);

    copylabel = new Label("copyright 2009 Jay Unruh ([email protected]) non-profit use only");
    copylabel.setBounds(10, 790, 400, 20);
    add(copylabel);

    n_b_label = new Label("N and B Analysis");
    n_b_label.setBounds(250, 10, 100, 20);
    add(n_b_label);

    pwavg = new PlotWindow3D("Avg", "kg", "kr", "Frequency", avg, 0);
    pwavg.setLogAxes(false, false, true);
    pwavg.draw();
    pwavg.addPoints(avgfit, true, 0);
    float[] temp = pwavg.getLimits();
    temp[4] = 1.0f;
    pwavg.setLimits(temp);

    float[][] temppch = new float[xpts][ypts];
    for (int i = 0; i < xpts; i++) {
      System.arraycopy(pch[dispcurve][i], 0, temppch[i], 0, ypts);
    }
    pwfit = new PlotWindow3D("Selected Curve", "kg", "kr", "Frequency", temppch, 0);
    pwfit.setLogAxes(false, false, true);
    pwfit.draw();
    pwfit.addPoints(fit[dispcurve], true, 0);
    float[] temp2 = pwfit.getLimits();
    temp2[4] = 1.0f;
    pwfit.setLimits(temp2);

    resetparams();
    repaint();
  }
Ejemplo n.º 3
0
  public GuiClient() {
    setLayout(new FlowLayout());

    /** ** We define the textfields and buttons****** */
    lbIP = new Label("Enter the IP address of the server: "); // Construct Label
    add(lbIP);

    tfIP = new TextField(110); // Construct TextField
    add(tfIP); // "super" Frame adds TextField
    tfIP.setText("10.16.31.163"); // Set a default value

    tfIP.addActionListener(this);
    // Hitting Enter on TextField fires ActionEvent
    // tfInput (TextField) registers this instance as ActionEvent listener

    lblInput = new Label("Enter a link below: ");
    add(lblInput);

    tfInput = new TextField(110);
    add(tfInput);
    tfInput.setText("http://vodlocker.com/budq9rt5wt0e");
    tfInput.addActionListener(this);

    lblOutput = new Label("The download link is below: ");
    add(lblOutput);

    tfOutput = new TextField(110);
    tfOutput.setEditable(false); // read-only
    add(tfOutput);

    /** ************Stream************** */
    Butstr = new Button("Stream"); // construct Button
    add(Butstr); // "super" Frame adds Button

    Butstr.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            streamvidlink(getvidlink());
            tfOutput.setText("The video is being streamed");
          }
        });

    /** ************Download************** */
    Butdow = new Button("Download");
    add(Butdow);

    Butdow.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            downvidlink(getvidlink());
            tfOutput.setText("The video is being downloaded");
          }
        });

    /** ************QR CODE************** */
    Butqr = new Button("Qr Code");
    add(Butqr);

    Butqr.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // we load the qrvidlink() function that saves the image locally
            qrvidlink();
            try {
              // we display the image that is saved
              Runtime.getRuntime().exec("display qrcode.png");
              tfOutput.setText("The Qr code will be generated");
            } catch (Exception ex) {
              System.out.println("Qr Code failed: " + ex);
            }
          }
        });

    setTitle("Client"); // "super" Frame sets title
    setSize(900, 400); // "super" Frame sets initial window size
    setVisible(true); // "super" Frame shows
  }