Example #1
0
  /*.................................................................................................................*/
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("setToDefaults")) {
      setDefaultTNTCommandsSearchOptions();
      searchField.setText(searchArguments);
      bootstrapSearchField.setText(bootstrapSearchArguments);
      harvestOnlyStrictConsensusBox.setState(harvestOnlyStrictConsensus);
      resamplingAllConsensusTreesBox.setState(!resamplingAllConsensusTrees);
      bootStrapRepsField.setValue(bootstrapreps);

    } else if (e.getActionCommand().equalsIgnoreCase("setToDefaultsOtherOptions")) {
      setDefaultTNTCommandsOtherOptions();
      otherOptionsField.setText(otherOptions);
      convertGapsBox.setState(convertGapsToMissing);
    } else if (e.getActionCommand().equalsIgnoreCase("browseSearchScript")
        && searchScriptPathField != null) {
      MesquiteString directoryName = new MesquiteString();
      MesquiteString fileName = new MesquiteString();
      String path =
          MesquiteFile.openFileDialog("Choose Search Script File", directoryName, fileName);
      if (StringUtil.notEmpty(path)) searchScriptPathField.setText(path);
    } else if (e.getActionCommand().equalsIgnoreCase("browseBootSearchScript")
        && bootSearchScriptPathField != null) {

      MesquiteString directoryName = new MesquiteString();
      MesquiteString fileName = new MesquiteString();
      String path =
          MesquiteFile.openFileDialog(
              "Choose Resampling Search Script File", directoryName, fileName);
      if (StringUtil.notEmpty(path)) bootSearchScriptPathField.setText(path);
    }
  }
Example #2
0
  public void goTo(int where) {
    try {
      if (where < 1) {
        return;
      }
      if (where > db.getRecordCount()) {
        return;
      }
      db.gotoRecord(where);
      crl.setText("Record " + db.getCurrentRecordNumber());
      delCB.setState(db.deleted());

      Field f;
      LogicalField lf;
      Checkbox c;
      TextField t;

      int i;

      for (i = 1; i <= db.getFieldCount(); i++) {
        f = db.getField(i);
        if (f.isMemoField()) {
        } else if (f.getType() == 'L') {
          lf = (LogicalField) f;
          c = (Checkbox) fldObjects.elementAt(i - 1);
          c.setState(lf.getBoolean());
        } else {
          t = (TextField) fldObjects.elementAt(i - 1);
          t.setText(f.get().trim());
        }
      }

      Next.setEnabled(!(db.getCurrentRecordNumber() == db.getRecordCount()));
      nextRecord.setEnabled(!(db.getCurrentRecordNumber() == db.getRecordCount()));

      Prev.setEnabled(!(db.getCurrentRecordNumber() == 1));
      prevRecord.setEnabled(!(db.getCurrentRecordNumber() == 1));

      firstRecord.setEnabled(db.getRecordCount() > 0);
      lastRecord.setEnabled(db.getRecordCount() > 0);

      SBrecpos.setValues(db.getCurrentRecordNumber(), 1, 0, db.getRecordCount());
    } // try
    catch (Exception e1) {
      System.out.println(e1);
      System.exit(2);
    }
  }
Example #3
0
  /**
   * Creates a new connection to the specified host of specified type. <br>
   * <br>
   * type: Type of connection to create <br>
   * destination: Host to connect to (in "host:port" or "host" syntax)
   */
  public Connection(java.net.InetAddress host, int port, PluginContext ctx)
      throws MessagingNetworkException, java.io.IOException {
    if (TRAKTOR_USED) {
      if (traktorConnectionDown) throw new IOException("network is down");

      traktor = new Frame("" + host + ":" + port + " - Traktor");
      final Checkbox c = new Checkbox("break this & ALL future connections");
      c.setState(traktorConnectionDown);
      c.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              traktorConnectionDown = c.getState();
              try {
                if (traktorConnectionDown) closeSocket();
              } catch (Exception ex) {
              }
            }
          });
      traktor.add(c);
      traktor.setSize(100, 50);
      traktor.setLocation(230, 450);
      traktor.setVisible(true);
    } else {
      traktor = null;
    }
  }
Example #4
0
 /**
  * Adds a group of checkboxs using a grid layout.
  *
  * @param rows the number of rows
  * @param columns the number of columns
  * @param labels the labels
  * @param defaultValues the initial states
  * @param headings the column headings Example:
  *     http://imagej.nih.gov/ij/plugins/multi-column-dialog/index.html
  */
 public void addCheckboxGroup(
     int rows, int columns, String[] labels, boolean[] defaultValues, String[] headings) {
   Panel panel = new Panel();
   int nRows = headings != null ? rows + 1 : rows;
   panel.setLayout(new GridLayout(nRows, columns, 6, 0));
   int startCBIndex = cbIndex;
   if (checkbox == null) checkbox = new Vector(12);
   if (headings != null) {
     Font font = new Font("SansSerif", Font.BOLD, 12);
     for (int i = 0; i < columns; i++) {
       if (i > headings.length - 1 || headings[i] == null) panel.add(new Label(""));
       else {
         Label label = new Label(headings[i]);
         label.setFont(font);
         panel.add(label);
       }
     }
   }
   int i1 = 0;
   int[] index = new int[labels.length];
   for (int row = 0; row < rows; row++) {
     for (int col = 0; col < columns; col++) {
       int i2 = col * rows + row;
       if (i2 >= labels.length) break;
       index[i1] = i2;
       String label = labels[i1];
       if (label == null || label.length() == 0) {
         Label lbl = new Label("");
         panel.add(lbl);
         i1++;
         continue;
       }
       if (label.indexOf('_') != -1) label = label.replace('_', ' ');
       Checkbox cb = new Checkbox(label);
       checkbox.addElement(cb);
       cb.setState(defaultValues[i1]);
       cb.addItemListener(this);
       if (Recorder.record || macro) saveLabel(cb, labels[i1]);
       if (IJ.isLinux()) {
         Panel panel2 = new Panel();
         panel2.setLayout(new BorderLayout());
         panel2.add("West", cb);
         panel.add(panel2);
       } else panel.add(cb);
       i1++;
     }
   }
   c.gridx = 0;
   c.gridy = y;
   c.gridwidth = 2;
   c.anchor = GridBagConstraints.WEST;
   c.insets = getInsets(10, 0, 0, 0);
   grid.setConstraints(panel, c);
   add(panel);
   y++;
 }
    // GL
    public synchronized void itemStateChanged(ItemEvent e) {
      if (e.getSource() == hsb) isRGB = false;
      if (e.getSource() == rgb) isRGB = true;

      if (e.getSource() == hsb || e.getSource() == rgb) {
        flag = true;
        originalB.setEnabled(false);
        filteredB.setEnabled(false);

        minHue = minSat = minBri = 0;
        maxHue = maxSat = maxBri = 255;

        bandPassH.setState(true);
        bandPassS.setState(true);
        bandPassB.setState(true);
      }
      reset(imp, ip);
      ip = setup(imp);
      apply(imp, ip);
      updateNames();
      notify();
    }
Example #6
0
 public void addRec() {
   try {
     setFields();
     db.write();
     goTo(db.getRecordCount());
     delCB.setState(false);
     trl.setText(" of " + db.getRecordCount());
   } // try
   catch (Exception e1) {
     System.out.println(e1);
     System.exit(1);
   }
   Update.setEnabled(true);
   updateRecord.setEnabled(true);
 }
Example #7
0
 protected void setStates() {
   try {
     snapH.setState(maker.sketch.snapToHorz);
     snapV.setState(maker.sketch.snapToVert);
     drawCurves.setState(maker.sketch.drawCurves);
     invertCurve.setState(maker.sketch.invertCurve);
     strokeColor.setColor(new Color(TruchetMaker.darkStroke));
     fillColor.setColor(new Color(TruchetMaker.darkFill));
     showSketchLines.setState(maker.sketch.drawSnapGrid);
     showStateOverlay.setState(maker.getCurrentLayout().overlayVisible());
   } catch (Exception e) {
     System.out.println("couldn't set tool states");
   }
 }
Example #8
0
 /**
  * Adds a checkbox; does not make it recordable if isPreview is true. With isPreview true, the
  * checkbox can be referred to as previewCheckbox from hereon.
  */
 private void addCheckbox(String label, boolean defaultValue, boolean isPreview) {
   String label2 = label;
   if (label2.indexOf('_') != -1) label2 = label2.replace('_', ' ');
   if (checkbox == null) {
     checkbox = new Vector(4);
     c.insets = getInsets(15, 20, 0, 0);
   } else c.insets = getInsets(0, 20, 0, 0);
   c.gridx = 0;
   c.gridy = y;
   c.gridwidth = 2;
   c.anchor = GridBagConstraints.WEST;
   Checkbox cb = new Checkbox(label2);
   grid.setConstraints(cb, c);
   cb.setState(defaultValue);
   cb.addItemListener(this);
   cb.addKeyListener(this);
   add(cb);
   checkbox.addElement(cb);
   // ij.IJ.write("addCheckbox: "+ y+" "+cbIndex);
   if (!isPreview && (Recorder.record || macro)) // preview checkbox is not recordable
   saveLabel(cb, label);
   if (isPreview) previewCheckbox = cb;
   y++;
 }
  /** Create GUI elements */
  private void loadGUI() {
    setTitle("Wifi QRCode Generator");

    mainPanel = new JPanel();
    BoxLayout vBoxLayout = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
    mainPanel.setLayout(vBoxLayout);

    int LABEL_WIDTH = 100;
    int LABEL_HEIGHT = 30;

    int EDIT_WIDTH = 200;
    int EDIT_HEIGHT = 30;

    // guide label
    {
      // This layout simply makes label looks left-alignmented
      JPanel barPanel = new JPanel();
      BoxLayout barHLayout = new BoxLayout(barPanel, BoxLayout.X_AXIS);
      barPanel.setLayout(barHLayout);

      JLabel ssoGuideLabel = new JLabel("Enter your SSO and click button below to login");
      ssoGuideLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 15));
      barPanel.add(ssoGuideLabel);
      mainPanel.add(barPanel);
    }

    Font gFont = new Font(Font.SANS_SERIF, Font.PLAIN, 13);

    Config config = Config.instance();

    // email password remember password
    {
      JPanel userPanel = new JPanel();
      BoxLayout hBoxLayout = new BoxLayout(userPanel, BoxLayout.X_AXIS);
      userPanel.setLayout(hBoxLayout);
      JLabel emailLabel = new JLabel("Email:");
      Dimension labelDimension = new Dimension(LABEL_WIDTH, LABEL_HEIGHT);
      emailLabel.setMinimumSize(labelDimension);
      emailLabel.setPreferredSize(labelDimension);
      emailLabel.setMaximumSize(labelDimension);
      userPanel.add(emailLabel);
      userPanel.add(Box.createRigidArea(new Dimension(5, 0)));
      emailField = new TextField();
      emailField.setMinimumSize(new Dimension(EDIT_WIDTH, EDIT_HEIGHT));
      emailField.setMaximumSize(new Dimension(EDIT_WIDTH + 300, EDIT_HEIGHT));
      emailField.setFont(gFont);
      emailField.setText(config.getEmail());

      userPanel.add(emailField);

      mainPanel.add(userPanel);

      JPanel passwordPanel = new JPanel();
      BoxLayout hBoxLayout2 = new BoxLayout(passwordPanel, BoxLayout.X_AXIS);
      passwordPanel.setLayout(hBoxLayout2);
      JLabel passwordLabel = new JLabel("SSO Password:"******"Remember password", false);
      rememberPasswordCheckbox.setState(config.getRememberPassword());

      mainPanel.add(rememberPasswordCheckbox);
      mainPanel.add(Box.createHorizontalGlue());
    }

    JPanel centerPanel = new JPanel();
    BorderLayout bLayout = new BorderLayout();
    centerPanel.setLayout(bLayout);

    buttonGetPassword = new JButton(idleButtonText);
    Font font = new Font(Font.SERIF, Font.BOLD, 18);
    buttonGetPassword.setFont(font);
    buttonGetPassword.setMinimumSize(new Dimension(300, 50));
    buttonGetPassword.setPreferredSize(new Dimension(300, 50));
    buttonGetPassword.setMaximumSize(new Dimension(300, 50));

    centerPanel.add(buttonGetPassword, BorderLayout.CENTER);

    hintLabel = new JLabel("Enter your SSO and click button to start");
    hintLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 15));

    centerPanel.add(hintLabel, BorderLayout.SOUTH);
    mainPanel.add(centerPanel);

    wifiPasswordField = new TextField("Wifi password has not been generated");
    mainPanel.add(wifiPasswordField);

    JPanel qrCenterPanel = new JPanel();
    BorderLayout bLayout2 = new BorderLayout();
    qrCenterPanel.setLayout(bLayout2);
    qrCodeLabel = new JLabel("");
    qrCodeLabel.setMinimumSize(new Dimension(400, 400));
    qrCodeLabel.setPreferredSize(new Dimension(400, 400));
    qrCodeLabel.setMaximumSize(new Dimension(400, 400));
    qrCodeLabel.setHorizontalAlignment(JLabel.CENTER);
    qrCodeLabel.setVerticalAlignment(JLabel.CENTER);
    qrCodeLabel.setIcon(idleIcon);

    qrCenterPanel.add(qrCodeLabel, BorderLayout.CENTER);
    mainPanel.add(qrCenterPanel);

    // client download section
    {
      Font clientFont = new Font(Font.SANS_SERIF, Font.BOLD, 15);
      Dimension clientDimension = new Dimension(200, 30);
      JPanel clientPanel = new JPanel();
      BorderLayout cp_bLayout = new BorderLayout();
      clientPanel.setLayout(cp_bLayout);
      HyberLinkLabel androidLabel =
          new HyberLinkLabel(
              " [ Android Client ] ",
              "https://github.com/tangyanhan/ClrGstAutoLogin-/blob/master/ClrGstAutoConnect/bin/ClrGstAutoConnect.apk");
      androidLabel.setMinimumSize(clientDimension);
      androidLabel.setFont(clientFont);
      clientPanel.add(androidLabel, BorderLayout.WEST);

      HyberLinkLabel iosLabel = new HyberLinkLabel(" [ iOS Client ] ", "");
      iosLabel.setMinimumSize(clientDimension);
      iosLabel.setFont(clientFont);
      clientPanel.add(iosLabel, BorderLayout.EAST);

      mainPanel.add(clientPanel);
    }

    add(mainPanel);

    this.pack();
    this.setVisible(true);
    this.setLocation(300, 100);
    this.setSize(500, 730);

    buttonGetPassword.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {

            long elapsed = Calendar.getInstance().getTimeInMillis() - lastClickTime;

            // If we got the successfull password 5 minutes ago
            if (((elapsed / 1000) / 60) < 5) {
              hintLabel.setText("Take a rest! You have got the QR code already!");
              return;
            }

            fetchPassword();

            if (!Config.instance().getWifiPassword().isEmpty())
              lastClickTime = Calendar.getInstance().getTimeInMillis();
          }
        });
  }
Example #10
0
  /** CONSTRUCTOR */
  public CruiseControl(boolean waitallowed) {
    super();

    this.waitallowed = waitallowed;

    timeformatter = DateFormat.getDateTimeInstance();
    timeformatter.setTimeZone(TimeZone.getTimeZone("UTC"));

    FlowLayout layout = new FlowLayout();
    this.setLayout(layout);

    l_time.setText("-- time --");
    add(l_time);

    final Checkbox c_wait = new Checkbox("wait (global scheduler)");
    c_wait.setState(true);
    c_wait.addItemListener(
        new ItemListener() {

          @Override
          public void itemStateChanged(ItemEvent e) {
            wait = c_wait.getState();
          }
        });
    if (!waitallowed) {
      c_wait.setEnabled(false);
      c_wait.setState(false);
      wait = false;
    }
    this.add(c_wait);

    final Checkbox c_update = new Checkbox("update");
    c_update.setState(true);
    c_update.addItemListener(
        new ItemListener() {

          @Override
          public void itemStateChanged(ItemEvent e) {
            update = c_update.getState();
            if (update) {
              c_wait.setState(true);
              wait = true;
            }
            // TODO @TSC What to do if update == false?
          }
        });
    this.add(c_update);

    JButton b = new JButton("go");
    b.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            synchronized (CruiseControl.this) {
              go = -1;
            }
          }
        });
    this.add(b);

    final JTextField tf = new JTextField(10);
    final Color normalColor = tf.getForeground();
    tf.getDocument()
        .addDocumentListener(
            new DocumentListener() {

              private void checkInput() {
                try {
                  Long.parseLong(tf.getText());
                  // parsed correctly
                  tf.setForeground(normalColor);
                } catch (NumberFormatException e) {
                  tf.setForeground(Color.RED);
                }
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                checkInput();
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                checkInput();
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                checkInput();
              }
            });
    this.add(tf);

    b = new JButton("go to time");
    b.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            synchronized (CruiseControl.this) {
              try {
                go = Long.parseLong(tf.getText());
              } catch (NumberFormatException e1) {
              }
              c_wait.setEnabled(true);
            }
          }
        });
    this.add(b);

    this.setPreferredSize(new Dimension(300, 200));
  }
  public void focusLost(FocusEvent e) {
    int id = 0;
    boolean res = false;
    JTextField t = (JTextField) e.getSource();
    if (t == tpid) {
      try {
        id = Integer.parseInt(tpid.getText());
        res = patient.psearch(id);
      } catch (Exception e1) {
      }

      if (res) {
        int no, ag = 0, fee = 0;
        String pfn = "",
            bg = "",
            pmn = "",
            dt1 = "",
            pln = "",
            add = "",
            sym = "",
            dn = "",
            dig = "",
            cn = "",
            gender = "",
            wgt = "";
        try {
          dt1 = patient.rs.getString(1);
          no = patient.rs.getInt(2);
          pfn = patient.rs.getString(3);
          pmn = patient.rs.getString(4);
          pln = patient.rs.getString(5);
          gender = patient.rs.getString(6);
          ag = patient.rs.getInt(7);
          wgt = patient.rs.getString(8);
          add = patient.rs.getString(9);
          cn = patient.rs.getString(10);
          dn = patient.rs.getString(11);
          sym = patient.rs.getString(12);
          dig = patient.rs.getString(13);
          fee = patient.rs.getInt(14);
          bg = patient.rs.getString(15);
          dir = patient.rs.getString(17);

          s = dir;
          repaint();
          j13 = new JLabel("OLD IMAGE");
          j13.setBounds(840, 5, 300, 300);
          JLabel j12 =
              new JLabel("OLD PHOTO") {
                public void paint(Graphics g) {
                  ImageIcon ic = new ImageIcon(s);
                  Image img = ic.getImage();
                  g.drawImage(img, 0, 0, 150, 150, this);
                }
              };

          //	q.flushAll()

          /*ImageIcon ic=new ImageIcon(dir);
          JLabel j12=new JLabel("",ic,JLabel.CENTER);*/
          j12.setBounds(670, 70, 300, 300);
          //	image.setBounds(700,300,100,100);

          q.add(j12);
          q.add(j13);
          repaint();
          System.out.println("8743t32874" + dir);
        } catch (Exception e2) {
        }
        if (gender.equals("Male")) cm.setState(true);
        else cf.setState(true);
        tdt.setText(dt1);
        tpfnm.setText(pfn);
        tpmnm.setText(pmn);
        tplnm.setText(pln);
        tage.setText("" + ag);
        tfee.setText("" + fee);
        tadd.setText(add);
        tdig.setText(dig);
        tdnm.setText(dn);
        tsym.setText(sym);
        tcno.setText(cn);
        twt.setText(wgt);
        tbg.setText(bg);

        // cm.setState(set1State());
        // cf.setSelectedCheckbox(gender);
        ba.setEnabled(false);
        bm.setEnabled(true);
        bd.setEnabled(true);
      } else {
        if (id == 0) {
          bl.setEnabled(true);
          ba.setEnabled(false);
        } else ba.setEnabled(true);
        bm.setEnabled(false);
        bd.setEnabled(false);
      }
    }
  }
  public patientAdd(String s) {
    super(s);
    image =
        new JLabel() {
          public void paint(Graphics g) {
            ImageIcon ic = new ImageIcon(str);
            Image img = ic.getImage();
            g.drawImage(img, 0, 0, 150, 150, this);
          }
        };

    image.setBounds(670, 270, 300, 300);
    bu = new JButton("UPLOAD");
    bu.setBounds(700, 230, 100, 20);
    bu.addActionListener(this);
    //	q.add(bu);

    ldt = new JLabel("Date");
    lpid = new JLabel("Patient ID");
    lpnm = new JLabel("Patient Name");
    lgen = new JLabel("Gender");
    lbg = new JLabel("Blood Group");
    lage = new JLabel("Age");
    lwt = new JLabel("Weight                                          Kg");
    ladd = new JLabel("Address");
    lcno = new JLabel("Cont. no.");
    ldnm = new JLabel("Doctor Name            Dr.");
    lsym = new JLabel("Symptoms");
    ldig = new JLabel("Diagnosis");
    lfee = new JLabel("Fee                            Rs.");
    cbg = new CheckboxGroup();
    cm = new Checkbox("Male", cbg, false);
    cm.addItemListener(this);
    cf = new Checkbox("Female", cbg, false);
    cf.setState(true);
    cf.addItemListener(this);
    tdt = new JTextField(15);
    tpid = new JTextField(6);
    tpid.addFocusListener(this);
    tpfnm = new JTextField("first");
    tpmnm = new JTextField("middle");
    tplnm = new JTextField("last");
    tage = new JTextField(4);
    tage.addFocusListener(this);
    tbg = new JTextField(6);
    twt = new JTextField(5);
    tadd = new TextArea(patient.addr);
    tcno = new JTextField(20);
    tdnm = new JTextField(20);
    tsym = new TextArea();

    tdig = new JTextField(20);
    tfee = new JTextField(6);
    tfee.addFocusListener(this);
    ba = new JButton("ADD");
    ba.addActionListener(this);
    bm = new JButton("CANCEL");
    bm.addActionListener(this);
    bd = new JButton("DELETE");
    bd.addActionListener(this);
    bl = new JButton("DISPLAY");
    bl.addActionListener(this);
    bs = new JButton("SEARCH");
    bs.addActionListener(this);
    JPanel p = new JPanel();
    p.add(ba);
    p.add(bm);
    //	p.add(bd);
    //	p.add(bl);
    //	p.add(bs);
    add(p, BorderLayout.SOUTH);
    q = new JPanel();
    q.setLayout(null);
    ldt.setBounds(1015, 20, 60, 20);
    q.add(ldt);
    tdt.setBounds(1060, 20, 170, 20);
    q.add(tdt);
    lpid.setBounds(70, 60, 80, 20);
    q.add(lpid);
    tpid.setBounds(200, 60, 60, 20);
    q.add(tpid);
    lpnm.setBounds(70, 100, 80, 20);
    q.add(lpnm);
    tpfnm.setBounds(200, 100, 100, 20);
    q.add(tpfnm);
    tpmnm.setBounds(320, 100, 100, 20);
    q.add(tpmnm);
    tplnm.setBounds(440, 100, 100, 20);
    q.add(tplnm);
    lgen.setBounds(70, 140, 60, 20);
    q.add(lgen);
    lbg.setBounds(370, 140, 80, 20);
    q.add(lbg);
    tbg.setBounds(470, 140, 60, 20);
    q.add(tbg);
    cm.setBounds(200, 140, 60, 20);
    cf.setBounds(280, 140, 60, 20);
    lage.setBounds(70, 180, 40, 20);
    q.add(lage);
    tage.setBounds(200, 180, 50, 20);
    q.add(tage);
    lwt.setBounds(370, 180, 200, 20);
    q.add(lwt);
    twt.setBounds(470, 180, 60, 20);
    q.add(twt);
    ladd.setBounds(70, 220, 60, 20);
    q.add(ladd);
    tadd.setBounds(200, 220, 350, 50);
    q.add(tadd);
    lcno.setBounds(70, 310, 60, 20);
    q.add(lcno);
    tcno.setBounds(200, 310, 120, 20);
    q.add(tcno);
    ldnm.setBounds(70, 350, 200, 20);
    q.add(ldnm);
    tdnm.setBounds(200, 350, 150, 20);
    q.add(tdnm);
    lsym.setBounds(70, 390, 100, 20);
    q.add(lsym);
    tsym.setBounds(200, 390, 300, 70);
    q.add(tsym);
    ldig.setBounds(70, 480, 60, 20);
    q.add(ldig);
    tdig.setBounds(200, 480, 100, 20);
    q.add(tdig);
    lfee.setBounds(70, 520, 200, 20);
    q.add(lfee);
    tfee.setBounds(200, 520, 40, 20);
    q.add(tfee);
    q.add(cm);
    q.add(cf);
    q.add(image);
    q.add(bu);
    add(q, BorderLayout.CENTER);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            try {
              patient.con.close();
              System.exit(0);
            } catch (Exception e8) {
            }
          }
        });
    System.out.println(tadd.getText());
    setSize(1330, 740);
    setVisible(true);
  }
Example #13
0
  void init() {
    int innerWidth = width - border * 2;

    /** Sketch */
    Panel sketchPanel = new Panel();
    sketchPanel.setLayout(new FlowLayout(FlowLayout.LEADING));
    sketchPanel.setBackground(new Color(panelBG));
    sketchPanel.setPreferredSize(new Dimension(innerWidth, 270));

    CheckboxGroup sketchToolsGroup = new CheckboxGroup();
    Checkbox lineTool = new Checkbox("Line", sketchToolsGroup, true);
    lineTool.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.sketch.setCurrentTool(Sketch.Tool.LINE);
          }
        });
    Checkbox polygonTool = new Checkbox("Polygon", sketchToolsGroup, false);
    polygonTool.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.sketch.setCurrentTool(Sketch.Tool.POLYGON);
          }
        });
    Checkbox selectTool = new Checkbox("Select", sketchToolsGroup, false);
    selectTool.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.sketch.setCurrentTool(Sketch.Tool.SELECT);
          }
        });
    Checkbox moveTool = new Checkbox("Move", sketchToolsGroup, false);
    moveTool.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.sketch.setCurrentTool(Sketch.Tool.MOVE);
          }
        });

    strokeColor = new ColorWell();
    strokeColor.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            maker.sketch.setStrokeColor(strokeColor.getColor().getRGB());
          }
        });
    fillColor = new ColorWell();
    fillColor.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            maker.sketch.setFillColor(fillColor.getColor().getRGB());
          }
        });

    snapH = new Checkbox("Snap Horizontal (H)");
    snapH.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.sketch.snapToHorz = snapH.getState();
          }
        });
    snapV = new Checkbox("Snap Vertical (V)");
    snapV.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.sketch.snapToVert = snapV.getState();
          }
        });
    drawCurves = new Checkbox("Draw Curves (C)");
    drawCurves.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.sketch.drawCurves = drawCurves.getState();
          }
        });
    invertCurve = new Checkbox("Invert Curve (I)");
    invertCurve.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.sketch.invertCurve = invertCurve.getState();
          }
        });

    Button clearSketch = new Button("Clear");
    clearSketch.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            maker.sketch.clear();
            maker.redraw();
          }
        });

    showSketchLines = new Checkbox("Grid Lines");
    showSketchLines.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.sketch.drawSnapGrid = showSketchLines.getState();
            maker.redraw();
          }
        });

    Button snapGridDecrement = new Button("Grid -");
    snapGridDecrement.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            maker.sketch.snapGridDecrement();
            maker.redraw();
          }
        });
    Button snapGridIncrement = new Button("Grid +");
    snapGridIncrement.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            maker.sketch.snapGridIncrement();
            maker.redraw();
          }
        });

    sketchPanel.add(new Label("Sketch"));
    sketchPanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    sketchPanel.add(new Label("Tools"));
    sketchPanel.add(lineTool);
    sketchPanel.add(polygonTool);
    sketchPanel.add(selectTool);
    sketchPanel.add(moveTool);
    sketchPanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    sketchPanel.add(new Label("Stroke"));
    sketchPanel.add(strokeColor);
    sketchPanel.add(new Label("Fill"));
    sketchPanel.add(fillColor);
    sketchPanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    sketchPanel.add(snapH);
    sketchPanel.add(snapV);
    sketchPanel.add(drawCurves);
    sketchPanel.add(invertCurve);
    sketchPanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    sketchPanel.add(clearSketch);
    sketchPanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    sketchPanel.add(snapGridDecrement);
    sketchPanel.add(snapGridIncrement);
    sketchPanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    sketchPanel.add(showSketchLines);

    /** Palette */
    Panel palettePanel = new Panel();
    palettePanel.setLayout(new FlowLayout(FlowLayout.LEADING));
    palettePanel.setBackground(new Color(panelBG));
    palettePanel.setPreferredSize(new Dimension(innerWidth, 110));

    Button addToPalette = new Button("Add Sketch Tile");
    addToPalette.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            maker.palette.saveTileToPalette();
            maker.redraw();
          }
        });

    Button editTile = new Button("Edit Tile");
    editTile.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            maker.palette.loadPaletteTileToSketch();
            maker.redraw();
          }
        });

    Button deleteTile = new Button("Delete Tile(s)");
    deleteTile.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            maker.palette.deletePaletteTile();
            maker.redraw();
          }
        });

    Button clearPalette = new Button("Remove All");
    clearPalette.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            maker.palette.clear();
            maker.redraw();
          }
        });

    palettePanel.add(new Label("Palette"));
    palettePanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    palettePanel.add(addToPalette);
    palettePanel.add(editTile);
    palettePanel.add(deleteTile);
    palettePanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    palettePanel.add(clearPalette);

    /** Grid */
    Panel gridPanel = new Panel();
    gridPanel.setLayout(new FlowLayout(FlowLayout.LEADING));
    gridPanel.setBackground(new Color(panelBG));
    gridPanel.setPreferredSize(new Dimension(innerWidth, 270));

    CheckboxGroup toolsGroup = new CheckboxGroup();
    Checkbox paintTool = new Checkbox("Paint", toolsGroup, true);
    paintTool.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.getCurrentLayout().currentTool = Layout.Tool.PAINT;
          }
        });
    Checkbox lockTool = new Checkbox("Lock", toolsGroup, false);
    lockTool.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.getCurrentLayout().currentTool = Layout.Tool.LOCK;
          }
        });
    Checkbox gridSelectTool = new Checkbox("Select", toolsGroup, false);
    gridSelectTool.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.getCurrentLayout().currentTool = Layout.Tool.SELECT;
          }
        });
    Checkbox gridMoveTool = new Checkbox("Move", toolsGroup, false);
    gridMoveTool.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.getCurrentLayout().currentTool = Layout.Tool.MOVE;
          }
        });

    final Choice layoutChoice = new Choice();
    layoutChoice.add("Seamless Progressive");
    layoutChoice.add("Seamless Random");
    layoutChoice.add("Pure Random");

    layoutChoice.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            String l = layoutChoice.getSelectedItem();
            if (l == "Seamless Progressive") {
              maker.getCurrentLayout().currentLayout = Layout.LayoutType.SEAM_PROG;
            } else if (l == "Seamless Random") {
              maker.getCurrentLayout().currentLayout = Layout.LayoutType.SEAM_RND;
            } else if (l == "Pure Random") {
              maker.getCurrentLayout().currentLayout = Layout.LayoutType.RND;
            }
          }
        });

    Scrollbar percentageFull = new Scrollbar(Scrollbar.HORIZONTAL, 100, 20, 0, 120);
    percentageFull.setPreferredSize(new Dimension(innerWidth / 2, 20));
    percentageFull.addAdjustmentListener(
        new AdjustmentListener() {
          @Override
          public void adjustmentValueChanged(AdjustmentEvent e) {
            float amount = (float) e.getValue() / 100;
            maker.getCurrentLayout().percentageFull = amount;
          }
        });

    final Checkbox transformI = new Checkbox("I", true);
    transformI.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.orientationsToUse.put(
                TruchetMaker.Orientation.I.toString(), transformI.getState());
          }
        });
    final Checkbox transform90 = new Checkbox("90", true);
    transform90.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.orientationsToUse.put(
                TruchetMaker.Orientation.R90.toString(), transform90.getState());
          }
        });
    final Checkbox transform180 = new Checkbox("180", true);
    transform180.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.orientationsToUse.put(
                TruchetMaker.Orientation.R180.toString(), transform180.getState());
          }
        });
    final Checkbox transform270 = new Checkbox("270", true);
    transform270.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.orientationsToUse.put(
                TruchetMaker.Orientation.R270.toString(), transform270.getState());
          }
        });
    final Checkbox transformH = new Checkbox("H", true);
    transformH.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.orientationsToUse.put(
                TruchetMaker.Orientation.MH.toString(), transformH.getState());
          }
        });
    final Checkbox transformV = new Checkbox("V", true);
    transformV.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.orientationsToUse.put(
                TruchetMaker.Orientation.MV.toString(), transformV.getState());
          }
        });

    Button doLayout = new Button("Do Layout");
    doLayout.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            for (Layout l : maker.layouts) {
              l.doLayout();
            }
          }
        });

    Button clearGrid = new Button("Clear");
    clearGrid.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            maker.getCurrentLayout().clear();
            maker.redraw();
          }
        });

    Button incrementGrid = new Button("Grid +");
    incrementGrid.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            maker.getCurrentLayout().incrementGridSize();
            maker.redraw();
          }
        });
    Button decrementGrid = new Button("Grid -");
    decrementGrid.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            maker.getCurrentLayout().decrementGridSize();
            maker.redraw();
          }
        });

    final Checkbox showGridLines = new Checkbox("Grid Lines");
    //		showGridLines.setState(maker.grid.drawGridLines); // not available at this point
    showGridLines.setState(true);
    showGridLines.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.getCurrentLayout().drawGridLines = showGridLines.getState();
            maker.redraw();
          }
        });

    showStateOverlay = new Checkbox("Show States");
    showStateOverlay.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            maker.getCurrentLayout().overlayVisible(showStateOverlay.getState());
            maker.redraw();
          }
        });

    gridPanel.add(new Label("Grid"));
    gridPanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    gridPanel.add(new Label("Tools"));
    gridPanel.add(paintTool);
    gridPanel.add(lockTool);
    gridPanel.add(gridSelectTool);
    gridPanel.add(gridMoveTool);
    gridPanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    gridPanel.add(new Label("Layout"));
    gridPanel.add(layoutChoice);
    gridPanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    gridPanel.add(new Label("Empty"));
    gridPanel.add(percentageFull);
    gridPanel.add(new Label("Full"));
    gridPanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    gridPanel.add(transformI);
    gridPanel.add(transform90);
    gridPanel.add(transform180);
    gridPanel.add(transform270);
    gridPanel.add(transformH);
    gridPanel.add(transformV);
    gridPanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    gridPanel.add(doLayout);
    gridPanel.add(clearGrid);
    gridPanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    gridPanel.add(decrementGrid);
    gridPanel.add(incrementGrid);
    gridPanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    gridPanel.add(showGridLines);
    gridPanel.add(showStateOverlay);

    add(sketchPanel);
    add(palettePanel);
    add(gridPanel);

    Panel layoutsPanel = new Panel();
    layoutsPanel.setLayout(new FlowLayout(FlowLayout.LEADING));
    layoutsPanel.setBackground(new Color(panelBG));
    layoutsPanel.setPreferredSize(new Dimension(innerWidth, 70));

    final Choice layouts = new Choice();
    layouts.setPreferredSize(new Dimension(100, 20));
    layouts.add("Grid 1");
    layouts.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            int i = layouts.getSelectedIndex();
            maker.setCurrentLayout(maker.layouts.get(i));
            maker.redraw();
          }
        });

    Button addLayout = new Button("Add Grid");
    addLayout.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            maker.addLayout();
            layouts.add("Grid " + maker.layouts.size());
            maker.redraw();
          }
        });
    Button removeLayout = new Button("Remove Grid");
    removeLayout.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            maker.removeLayout();
            layouts.removeAll();
            for (int i = 0; i < maker.layouts.size(); i++) {
              layouts.add("Grid " + (i + 1));
              maker.redraw();
            }
          }
        });

    layoutsPanel.add(addLayout);
    layoutsPanel.add(removeLayout);
    layoutsPanel.add(Box.createRigidArea(new Dimension(innerWidth, 0)));
    layoutsPanel.add(layouts);
    add(layoutsPanel);

    addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {
            switch (e.getKeyCode()) {
              case KeyEvent.VK_C:
                maker.sketch.drawCurves = !maker.sketch.drawCurves;
                drawCurves.setState(maker.sketch.drawCurves);
                break;
              case KeyEvent.VK_I:
                maker.sketch.invertCurve = !maker.sketch.invertCurve;
                invertCurve.setState(maker.sketch.invertCurve);
                break;
              case KeyEvent.VK_H:
                maker.sketch.snapToHorz = !maker.sketch.snapToHorz;
                snapH.setState(maker.sketch.snapToHorz);
                break;
              case KeyEvent.VK_V:
                maker.sketch.snapToVert = !maker.sketch.snapToVert;
                snapV.setState(maker.sketch.snapToVert);
                break;
            }
          }

          @Override
          public void keyTyped(KeyEvent e) {
            // TODO Auto-generated method stub
          }

          @Override
          public void keyReleased(KeyEvent e) {
            // TODO Auto-generated method stub
          }
        });

    addWindowListener(
        new WindowListener() {

          @Override
          public void windowClosing(WindowEvent e) {
            //				dispose();
            //				System.exit(0);
          }

          @Override
          public void windowOpened(WindowEvent e) {
            // TODO Auto-generated method stub
          }

          @Override
          public void windowClosed(WindowEvent e) {
            // TODO Auto-generated method stub
          }

          @Override
          public void windowIconified(WindowEvent e) {
            // TODO Auto-generated method stub
          }

          @Override
          public void windowDeiconified(WindowEvent e) {
            // TODO Auto-generated method stub
          }

          @Override
          public void windowActivated(WindowEvent e) {
            // TODO Auto-generated method stub
          }

          @Override
          public void windowDeactivated(WindowEvent e) {
            // TODO Auto-generated method stub
          }
        });
  }
Example #14
0
    public BandAdjuster() {

      super("Threshold Colour");
      if (instance != null) {
        instance.toFront();
        return;
      }
      imp = WindowManager.getCurrentImage();
      if (imp == null) {
        IJ.beep();
        IJ.showStatus("No image");
        return;
      }
      IJ.run("Select None");
      thread = new Thread(this, "BandAdjuster");
      WindowManager.addWindow(this);
      instance = this;
      IJ.register(PasteController.class);

      ij = IJ.getInstance();
      Font font = new Font("SansSerif", Font.PLAIN, 10);
      GridBagLayout gridbag = new GridBagLayout();
      GridBagConstraints c = new GridBagConstraints();
      setLayout(gridbag);

      int y = 0;
      c.gridx = 0;
      c.gridy = y;
      c.gridwidth = 1;
      c.weightx = 0;
      c.insets = new Insets(5, 0, 0, 0);
      labelh = new Label("Hue", Label.CENTER);
      add(labelh, c);

      c.gridx = 1;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = 0;
      c.insets = new Insets(7, 0, 0, 0);
      labelf = new Label("Filter type", Label.RIGHT);
      add(labelf, c);

      // plot
      c.gridx = 0;
      c.gridy = y;
      c.gridwidth = 1;
      c.fill = c.BOTH;
      c.anchor = c.CENTER;
      c.insets = new Insets(0, 5, 0, 0);
      add(plot, c);

      // checkboxes
      panelh = new Panel();
      filterTypeH = new CheckboxGroup();
      bandPassH = new Checkbox("Pass");
      bandPassH.setCheckboxGroup(filterTypeH);
      bandPassH.addItemListener(this);
      panelh.add(bandPassH);
      bandStopH = new Checkbox("Stop");
      bandStopH.setCheckboxGroup(filterTypeH);
      bandStopH.addItemListener(this);
      panelh.add(bandStopH);
      bandPassH.setState(true);
      c.gridx = 1;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(5, 0, 0, 0);
      add(panelh, c);

      // minHue slider
      minSlider = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 90 : 100;
      c.fill = c.HORIZONTAL;
      c.insets = new Insets(5, 5, 0, 0);

      add(minSlider, c);
      minSlider.addAdjustmentListener(this);
      minSlider.setUnitIncrement(1);

      // minHue slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 10 : 0;
      c.insets = new Insets(5, 0, 0, 0);
      label1 = new Label("       ", Label.LEFT);
      label1.setFont(font);
      add(label1, c);

      // maxHue sliderHue
      maxSlider = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y;
      c.gridwidth = 1;
      c.weightx = 100;
      c.insets = new Insets(5, 5, 0, 0);
      add(maxSlider, c);
      maxSlider.addAdjustmentListener(this);
      maxSlider.setUnitIncrement(1);

      // maxHue slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.gridy = y++;
      c.weightx = 0;
      c.insets = new Insets(5, 0, 0, 0);
      label2 = new Label("       ", Label.LEFT);
      label2.setFont(font);
      add(label2, c);

      // =====
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = 0;
      c.insets = new Insets(10, 0, 0, 0);
      labels = new Label("Saturation", Label.CENTER);
      add(labels, c);

      // plot
      c.gridx = 0;
      c.gridy = y;
      c.gridwidth = 1;
      c.fill = c.BOTH;
      c.anchor = c.CENTER;
      c.insets = new Insets(0, 5, 0, 0);
      add(splot, c);

      // checkboxes
      panels = new Panel();
      filterTypeS = new CheckboxGroup();
      bandPassS = new Checkbox("Pass");
      bandPassS.setCheckboxGroup(filterTypeS);
      bandPassS.addItemListener(this);
      panels.add(bandPassS);
      bandStopS = new Checkbox("Stop");
      bandStopS.setCheckboxGroup(filterTypeS);
      bandStopS.addItemListener(this);
      panels.add(bandStopS);
      bandPassS.setState(true);
      c.gridx = 1;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(5, 0, 0, 0);
      add(panels, c);

      // minSat slider
      minSlider2 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 90 : 100;
      c.fill = c.HORIZONTAL;
      c.insets = new Insets(5, 5, 0, 0);
      add(minSlider2, c);
      minSlider2.addAdjustmentListener(this);
      minSlider2.setUnitIncrement(1);

      // minSat slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 10 : 0;
      c.insets = new Insets(5, 0, 0, 0);
      label3 = new Label("       ", Label.LEFT);
      label3.setFont(font);
      add(label3, c);

      // maxSat slider
      maxSlider2 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = 100;
      c.insets = new Insets(5, 5, 0, 0);
      add(maxSlider2, c);
      maxSlider2.addAdjustmentListener(this);
      maxSlider2.setUnitIncrement(1);

      // maxSat slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.weightx = 0;
      c.insets = new Insets(5, 0, 0, 0);
      label4 = new Label("       ", Label.LEFT);
      label4.setFont(font);
      add(label4, c);

      // =====
      c.gridx = 0;
      c.gridwidth = 1;
      c.gridy = y++;
      c.weightx = 0;
      c.insets = new Insets(10, 0, 0, 0);
      labelb = new Label("Brightness", Label.CENTER);
      add(labelb, c);

      c.gridx = 0;
      c.gridwidth = 1;
      c.gridy = y;
      c.fill = c.BOTH;
      c.anchor = c.CENTER;
      c.insets = new Insets(0, 5, 0, 0);
      add(bplot, c);

      // checkboxes
      panelb = new Panel();
      filterTypeB = new CheckboxGroup();
      bandPassB = new Checkbox("Pass");
      bandPassB.setCheckboxGroup(filterTypeB);
      bandPassB.addItemListener(this);
      panelb.add(bandPassB);
      bandStopB = new Checkbox("Stop");
      bandStopB.setCheckboxGroup(filterTypeB);
      bandStopB.addItemListener(this);
      panelb.add(bandStopB);
      bandPassB.setState(true);
      c.gridx = 1;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(5, 0, 0, 0);
      add(panelb, c);

      // minBri slider
      minSlider3 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 90 : 100;
      c.fill = c.HORIZONTAL;
      c.insets = new Insets(5, 5, 0, 0);
      add(minSlider3, c);
      minSlider3.addAdjustmentListener(this);
      minSlider3.setUnitIncrement(1);

      // minBri slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 10 : 0;
      c.insets = new Insets(5, 0, 0, 0);
      label5 = new Label("       ", Label.LEFT);
      label5.setFont(font);
      add(label5, c);

      // maxBri slider
      maxSlider3 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = 100;
      c.insets = new Insets(5, 5, 0, 0);
      add(maxSlider3, c);
      maxSlider3.addAdjustmentListener(this);
      maxSlider3.setUnitIncrement(1);

      // maxBri slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.weightx = 0;
      c.insets = new Insets(5, 0, 0, 0);
      label6 = new Label("       ", Label.LEFT);
      label6.setFont(font);
      add(label6, c);

      // =====
      panelt = new Panel();
      threshold = new Checkbox("Threshold");
      threshold.addItemListener(this);
      panelt.add(threshold);

      invert = new Checkbox("Invert");
      invert.addItemListener(this);
      panelt.add(invert);

      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(0, 0, 0, 0);
      add(panelt, c);

      // buttons
      panel = new Panel();
      // panel.setLayout(new GridLayout(2, 2, 0, 0));
      originalB = new Button("Original");
      originalB.setEnabled(false);
      originalB.addActionListener(this);
      originalB.addKeyListener(ij);
      panel.add(originalB);

      filteredB = new Button("Filtered");
      filteredB.setEnabled(false);
      filteredB.addActionListener(this);
      filteredB.addKeyListener(ij);
      panel.add(filteredB);

      stackB = new Button("Stack");
      stackB.addActionListener(this);
      stackB.addKeyListener(ij);
      panel.add(stackB);

      helpB = new Button("Help");
      helpB.addActionListener(this);
      helpB.addKeyListener(ij);
      panel.add(helpB);

      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(0, 0, 0, 0);
      add(panel, c);

      panelMode = new Panel();

      sampleB = new Button("Sample");
      sampleB.addActionListener(this);
      sampleB.addKeyListener(ij);
      panelMode.add(sampleB);

      colourMode = new CheckboxGroup();
      hsb = new Checkbox("HSB");
      hsb.setCheckboxGroup(colourMode);
      hsb.addItemListener(this);
      panelMode.add(hsb);
      hsb.setState(true);
      rgb = new Checkbox("RGB");
      rgb.setCheckboxGroup(colourMode);
      rgb.addItemListener(this);
      panelMode.add(rgb);

      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(0, 0, 0, 0);
      add(panelMode, c);

      addKeyListener(ij); // ImageJ handles keyboard shortcuts
      pack();
      GUI.center(this);
      setVisible(true);

      ip = setup(imp);
      if (ip == null) {
        imp.unlock();
        IJ.beep();
        IJ.showStatus("RGB image cannot be thresholded");
        return;
      }
      thread.start();
    }
Example #15
0
    void sample() {
      byte[] hsSource, ssSource, bsSource;
      // ImageProcessor ip2;
      // ip2 = imp.getProcessor();
      Rectangle myroi = ip.getRoi();
      int swidth = myroi.width;
      int sheight = myroi.height;
      int sy = myroi.y;
      int sx = myroi.x;
      if (swidth == width && sheight == height) {
        IJ.showMessage("Select a rectangular ROI");
        IJ.beep();
        return;
      }

      IJ.run("Select None");

      int snumPixels = swidth * sheight;

      hsSource = new byte[snumPixels];
      ssSource = new byte[snumPixels];
      bsSource = new byte[snumPixels];

      int[] pixs = new int[snumPixels];
      int[] bin = new int[256];

      int counter = 0, pi = 0, rangePassH = 0, rangeStopH = 0, rangePassL = 0, rangeStopL = 0, i, j;

      for (i = sy; i < sy + sheight; i++) {
        for (j = sx; j < sx + swidth; j++) {
          pixs[counter++] = ip.getPixel(j, i);
        }
      }

      // Get hsb or rgb from roi.
      ColorProcessor cp2 = new ColorProcessor(swidth, sheight, pixs);

      int iminhue = 256, imaxhue = -1, iminsat = 256, imaxsat = -1, iminbri = 256, imaxbri = -1;
      int iminred = 256, imaxred = -1, imingre = 256, imaxgre = -1, iminblu = 256, imaxblu = -1;

      if (isRGB) cp2.getRGB(hsSource, ssSource, bsSource);
      else cp2.getHSB(hsSource, ssSource, bsSource);

      for (i = 0; i < snumPixels; i++) {
        bin[hsSource[i] & 255] = 1;
        if ((hsSource[i] & 255) > imaxhue) imaxhue = (hsSource[i] & 255);
        if ((hsSource[i] & 255) < iminhue) iminhue = (hsSource[i] & 255);
        if ((ssSource[i] & 255) > imaxsat) imaxsat = (ssSource[i] & 255);
        if ((ssSource[i] & 255) < iminsat) iminsat = (ssSource[i] & 255);
        if ((bsSource[i] & 255) > imaxbri) imaxbri = (bsSource[i] & 255);
        if ((bsSource[i] & 255) < iminbri) iminbri = (bsSource[i] & 255);
        // IJ.showMessage("h:"+minhue+"H:"+maxhue+"s:"+minsat+"S:"+maxsat+"b:"+minbri+"B:"+maxbri);
      }

      if (!isRGB) { // get pass or stop filter whichever has a narrower range
        for (i = 0; i < 256; i++) {
          if (bin[i] > 0) {
            rangePassL = i;
            break;
          }
        }
        for (i = 255; i >= 0; i--) {
          if (bin[i] > 0) {
            rangePassH = i;
            break;
          }
        }
        for (i = 0; i < 256; i++) {
          if (bin[i] == 0) {
            rangeStopL = i;
            break;
          }
        }
        for (i = 255; i >= 0; i--) {
          if (bin[i] == 0) {
            rangeStopH = i;
            break;
          }
        }
        if ((rangePassH - rangePassL) < (rangeStopH - rangeStopL)) {
          bandPassH.setState(true);
          bandStopH.setState(false);
          iminhue = rangePassL;
          imaxhue = rangePassH;
        } else {
          bandPassH.setState(false);
          bandStopH.setState(true);
          iminhue = rangeStopL;
          imaxhue = rangeStopH;
        }
      } else {
        bandPassH.setState(true);
        bandStopH.setState(false);
      }

      adjustMinHue(iminhue);
      minSlider.setValue(iminhue);
      adjustMaxHue(imaxhue);
      maxSlider.setValue(imaxhue);
      adjustMinSat(iminsat);
      minSlider2.setValue(iminsat);
      adjustMaxSat(imaxsat);
      maxSlider2.setValue(imaxsat);
      adjustMinBri(iminbri);
      minSlider3.setValue(iminbri);
      adjustMaxBri(imaxbri);
      maxSlider3.setValue(imaxbri);
      originalB.setEnabled(true);
      // IJ.showStatus("done");
    }
Example #16
0
  /** Ensures that the options dialog has no mutually exclusive options. */
  private void verifyOptions(Object src) {
    // record GUI state

    boolean autoscaleEnabled = autoscaleBox.isEnabled();
    boolean colorModeEnabled = colorModeChoice.isEnabled();
    boolean concatenateEnabled = concatenateBox.isEnabled();
    boolean cropEnabled = cropBox.isEnabled();
    boolean groupFilesEnabled = groupFilesBox.isEnabled();
    boolean ungroupFilesEnabled = ungroupFilesBox.isEnabled();
    boolean openAllSeriesEnabled = openAllSeriesBox.isEnabled();
    // boolean recordEnabled = recordBox.isEnabled();
    boolean showMetadataEnabled = showMetadataBox.isEnabled();
    boolean showOMEXMLEnabled = showOMEXMLBox.isEnabled();
    boolean specifyRangesEnabled = specifyRangesBox.isEnabled();
    boolean splitZEnabled = splitZBox.isEnabled();
    boolean splitTEnabled = splitTBox.isEnabled();
    boolean splitCEnabled = splitCBox.isEnabled();
    // boolean stackFormatEnabled = stackFormatChoice.isEnabled();
    boolean stackOrderEnabled = stackOrderChoice.isEnabled();
    boolean swapDimsEnabled = swapDimsBox.isEnabled();
    boolean virtualEnabled = virtualBox.isEnabled();

    boolean isAutoscale = autoscaleBox.getState();
    String colorModeValue = colorModeChoice.getSelectedItem();
    boolean isConcatenate = concatenateBox.getState();
    boolean isCrop = cropBox.getState();
    boolean isGroupFiles = groupFilesBox.getState();
    boolean isUngroupFiles = ungroupFilesBox.getState();
    boolean isOpenAllSeries = openAllSeriesBox.getState();
    // boolean isRecord = recordBox.getState();
    boolean isShowMetadata = showMetadataBox.getState();
    boolean isShowOMEXML = showOMEXMLBox.getState();
    boolean isSpecifyRanges = specifyRangesBox.getState();
    boolean isSplitZ = splitZBox.getState();
    boolean isSplitT = splitTBox.getState();
    boolean isSplitC = splitCBox.getState();
    String stackFormatValue = stackFormatChoice.getSelectedItem();
    boolean isStackNone = stackFormatValue.equals(ImporterOptions.VIEW_NONE);
    boolean isStackStandard = stackFormatValue.equals(ImporterOptions.VIEW_STANDARD);
    boolean isStackHyperstack = stackFormatValue.equals(ImporterOptions.VIEW_HYPERSTACK);
    boolean isStackBrowser = stackFormatValue.equals(ImporterOptions.VIEW_BROWSER);
    boolean isStackImage5D = stackFormatValue.equals(ImporterOptions.VIEW_IMAGE_5D);
    boolean isStackView5D = stackFormatValue.equals(ImporterOptions.VIEW_VIEW_5D);
    String stackOrderValue = stackOrderChoice.getSelectedItem();
    boolean isSwap = swapDimsBox.getState();
    boolean isVirtual = virtualBox.getState();

    // toggle availability of each option based on state of earlier options

    // NB: The order the options are examined here defines their order of
    // precedence. This ordering is necessary because it affects which
    // component states are capable of graying out other components.

    // For example, we want to disable autoscaleBox when virtualBox is checked,
    // so the virtualBox logic must appear before the autoscaleBox logic.

    // To make it more intuitive for the user, the order of precedence should
    // match the component layout from left to right, top to bottom, according
    // to subsection.

    // == Stack viewing ==

    // stackOrderChoice
    stackOrderEnabled = isStackStandard;
    if (src == stackFormatChoice) {
      if (isStackHyperstack || isStackBrowser || isStackImage5D) {
        stackOrderValue = ImporterOptions.ORDER_XYCZT;
      } else if (isStackView5D) stackOrderValue = ImporterOptions.ORDER_XYZCT;
      else stackOrderValue = ImporterOptions.ORDER_DEFAULT;
    }

    // == Metadata viewing ==

    // showMetadataBox
    showMetadataEnabled = !isStackNone;
    if (!showMetadataEnabled) isShowMetadata = true;

    // showOMEXMLBox
    // NB: no other options affect showOMEXMLBox

    // == Dataset organization ==

    // groupFilesBox
    if (src == stackFormatChoice && isStackBrowser) {
      isGroupFiles = true;
    } else if (!options.isLocal()) {
      isGroupFiles = false;
      groupFilesEnabled = false;
    }

    // ungroupFilesBox

    if (options.isOMERO()) {
      isUngroupFiles = false;
      ungroupFilesEnabled = false;
    }

    // swapDimsBox
    // NB: no other options affect swapDimsBox

    // openAllSeriesBox
    // NB: no other options affect openAllSeriesBox

    // concatenateBox
    // NB: no other options affect concatenateBox

    // == Memory management ==

    // virtualBox
    virtualEnabled = !isStackNone && !isStackImage5D && !isStackView5D && !isConcatenate;
    if (!virtualEnabled) isVirtual = false;
    else if (src == stackFormatChoice && isStackBrowser) isVirtual = true;

    // recordBox
    // recordEnabled = isVirtual;
    // if (!recordEnabled) isRecord = false;

    // specifyRangesBox
    specifyRangesEnabled = !isStackNone && !isVirtual;
    if (!specifyRangesEnabled) isSpecifyRanges = false;

    // cropBox
    cropEnabled = !isStackNone && !isVirtual;
    if (!cropEnabled) isCrop = false;

    // == Color options ==

    // colorModeChoice
    colorModeEnabled = !isStackImage5D && !isStackView5D && !isStackStandard;
    if (!colorModeEnabled) colorModeValue = ImporterOptions.COLOR_MODE_DEFAULT;

    // autoscaleBox
    autoscaleEnabled = !isVirtual;
    if (!autoscaleEnabled) isAutoscale = false;

    // == Split into separate windows ==

    boolean splitEnabled = !isStackNone && !isStackBrowser && !isStackImage5D && !isStackView5D;
    // TODO: Make splitting work with Data Browser.

    // splitCBox
    splitCEnabled = splitEnabled;
    if (!splitCEnabled) isSplitC = false;

    // splitZBox
    splitZEnabled = splitEnabled;
    if (!splitZEnabled) isSplitZ = false;

    // splitTBox
    splitTEnabled = splitEnabled;
    if (!splitTEnabled) isSplitT = false;

    // update state of each option, in case anything changed

    autoscaleBox.setEnabled(autoscaleEnabled);
    colorModeChoice.setEnabled(colorModeEnabled);
    concatenateBox.setEnabled(concatenateEnabled);
    cropBox.setEnabled(cropEnabled);
    groupFilesBox.setEnabled(groupFilesEnabled);
    ungroupFilesBox.setEnabled(ungroupFilesEnabled);
    openAllSeriesBox.setEnabled(openAllSeriesEnabled);
    // recordBox.setEnabled(recordEnabled);
    showMetadataBox.setEnabled(showMetadataEnabled);
    showOMEXMLBox.setEnabled(showOMEXMLEnabled);
    specifyRangesBox.setEnabled(specifyRangesEnabled);
    splitZBox.setEnabled(splitZEnabled);
    splitTBox.setEnabled(splitTEnabled);
    splitCBox.setEnabled(splitCEnabled);
    // stackFormatChoice.setEnabled(stackFormatEnabled);
    stackOrderChoice.setEnabled(stackOrderEnabled);
    swapDimsBox.setEnabled(swapDimsEnabled);
    virtualBox.setEnabled(virtualEnabled);

    autoscaleBox.setState(isAutoscale);
    colorModeChoice.select(colorModeValue);
    concatenateBox.setState(isConcatenate);
    cropBox.setState(isCrop);
    groupFilesBox.setState(isGroupFiles);
    ungroupFilesBox.setState(isUngroupFiles);
    openAllSeriesBox.setState(isOpenAllSeries);
    // recordBox.setState(isRecord);
    showMetadataBox.setState(isShowMetadata);
    showOMEXMLBox.setState(isShowOMEXML);
    specifyRangesBox.setState(isSpecifyRanges);
    splitZBox.setState(isSplitZ);
    splitTBox.setState(isSplitT);
    splitCBox.setState(isSplitC);
    // stackFormatChoice.select(stackFormatValue);
    stackOrderChoice.select(stackOrderValue);
    swapDimsBox.setState(isSwap);
    virtualBox.setState(isVirtual);

    if (IS_GLITCHED) {
      // HACK - work around a Mac OS X bug where GUI components do not update

      // list of affected components
      Component[] c = {
        autoscaleBox,
        colorModeChoice,
        concatenateBox,
        cropBox,
        groupFilesBox,
        ungroupFilesBox,
        openAllSeriesBox,
        // recordBox,
        showMetadataBox,
        showOMEXMLBox,
        specifyRangesBox,
        splitZBox,
        splitTBox,
        splitCBox,
        stackFormatChoice,
        stackOrderChoice,
        swapDimsBox,
        virtualBox
      };

      // identify currently focused component
      Component focused = null;
      for (int i = 0; i < c.length; i++) {
        if (c[i].isFocusOwner()) focused = c[i];
      }

      // temporarily disable focus events
      for (int i = 0; i < c.length; i++) c[i].removeFocusListener(this);

      // cycle through focus on all components
      for (int i = 0; i < c.length; i++) c[i].requestFocusInWindow();

      // clear the focus globally
      KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
      kfm.clearGlobalFocusOwner();
      sleep(100); // doesn't work if this value is too small

      // refocus the originally focused component
      if (focused != null) focused.requestFocusInWindow();

      // reenable focus events
      for (int i = 0; i < c.length; i++) c[i].addFocusListener(this);
    }
  }
Example #17
-1
  public void clearFields() {
    Field f;

    Checkbox c;
    TextField t;

    int i;

    for (i = 1; i <= db.getFieldCount(); i++) {
      try {
        f = db.getField(i);
        if (f.isMemoField()) {
          f.put("");
        } else if (f.getType() == 'L') {
          c = (Checkbox) fldObjects.elementAt(i - 1);
          c.setState(false);
        } else {
          t = (TextField) fldObjects.elementAt(i - 1);
          t.setText("");
        }
      } catch (Exception e1) {
        System.out.println(e1);
        System.exit(3);
      }
    }
  }