public void mouseDragged(MouseEvent me) {

    int x = me.getX();
    int y = me.getY();
    vertSB.setValue(y);
    horzSB.setValue(x);
    repaint();
  }
示例#2
0
 // public void setPoint(T3d p){ point=p; set_values(); }
 private void set_values() {
   x_bar.setValue((int) view.camera.x / 100);
   y_bar.setValue((int) view.camera.y / 100);
   z_bar.setValue((int) view.camera.z / 100);
   x_text.setText("" + (int) view.camera.x / 100);
   y_text.setText("" + (int) view.camera.y / 100);
   z_text.setText("" + (int) view.camera.z / 100);
 }
示例#3
0
 public void mouseDragged(MouseEvent mme) {
   System.out.println("dragged");
   int x = mme.getX();
   int y = mme.getX();
   int z = mme.getX();
   s1.setValue(x);
   s2.setValue(y);
   s3.setValue(z);
 }
示例#4
0
  private void updateFromField() {
    try {
      double v = 0.0;

      if (integral) {
        v = (double) (Integer.parseInt(field.getText()));
      } else {
        v = (new Double(field.getText())).doubleValue();
      }

      if (v < min) {
        v = min;
        field.setText(ftoa(v));
      } else if (v > max) {
        v = max;
        field.setText(ftoa(v));
      }

      scroll.setValue(getSlideLoc(v));
      val = v;
      value_changed.notify(new Double(v));
    } catch (NumberFormatException nfe) {
      field.setText(ftoa(val));
    }
  }
示例#5
0
 void adjustMaxBri(int value) {
   maxBri = value;
   if (minBri > maxBri) {
     minBri = maxBri;
     minSlider3.setValue((int) minBri);
   }
 }
示例#6
0
 void adjustMaxSat(int value) {
   maxSat = value;
   if (minSat > maxSat) {
     minSat = maxSat;
     minSlider2.setValue((int) minSat);
   }
 }
示例#7
0
 void adjustMinBri(int value) {
   minBri = value;
   if (maxBri < minBri) {
     maxBri = minBri;
     maxSlider3.setValue((int) maxBri);
   }
 }
示例#8
0
 void adjustMinSat(int value) {
   minSat = value;
   if (maxSat < minSat) {
     maxSat = minSat;
     maxSlider2.setValue((int) maxSat);
   }
 }
示例#9
0
 void adjustMaxHue(int value) {
   maxHue = value;
   if (minHue > maxHue) {
     minHue = maxHue;
     minSlider.setValue((int) minHue);
   }
 }
示例#10
0
 void adjustMinHue(int value) {
   minHue = value;
   if (maxHue < minHue) {
     maxHue = minHue;
     maxSlider.setValue((int) maxHue);
   }
 }
示例#11
0
 void updateScrollBars() {
   minSlider.setValue((int) minHue);
   maxSlider.setValue((int) maxHue);
   minSlider2.setValue((int) minSat);
   maxSlider2.setValue((int) maxSat);
   minSlider3.setValue((int) minBri);
   maxSlider3.setValue((int) maxBri);
 }
示例#12
0
  public void setValue(double v, boolean propagate) {
    if (v < min) {
      v = min;
    } else if (v > max) {
      v = max;
    }

    scroll.setValue(getSlideLoc(v));
    field.setText(ftoa(v));
    val = v;

    if (propagate) {
      value_changed.notify(new Double(v));
    }
  }
示例#13
0
 public void textValueChanged(TextEvent e) {
   notifyListeners(e);
   if (slider == null) return;
   Object source = e.getSource();
   for (int i = 0; i < slider.size(); i++) {
     int index = sliderIndexes[i];
     if (source == numberField.elementAt(index)) {
       TextField tf = (TextField) numberField.elementAt(index);
       double value = Tools.parseDouble(tf.getText());
       if (!Double.isNaN(value)) {
         Scrollbar sb = (Scrollbar) slider.elementAt(i);
         sb.setValue((int) (value * sliderScales[i]));
       }
       // IJ.log(i+" "+tf.getText());
     }
   }
 }
示例#14
0
  /** Création de l'intérieur de la fenêtre */
  private void initConteneur() {
    // le fond
    fond = getToolkit().getImage("./images/preference/bomber_fond.gif");
    tracker = new MediaTracker(this);
    tracker.addImage(fond, 0);
    try {
      tracker.waitForID(0);
    } catch (Exception a) {
      System.out.println("Erreur lors chargement de l'image: initConteneur() Preference");
      a.printStackTrace();
    }

    // le layout manager
    GridBagLayout layout = new GridBagLayout();
    setLayout(layout);
    GridBagConstraints c = new GridBagConstraints();
    c.weightx = 10;
    c.weighty = 10;
    c.ipadx = 10;
    c.ipady = 10;
    c.fill = GridBagConstraints.BOTH;

    // label "Joueurs:"
    Label lbl_joueurs = new Label("Joueurs:");
    lbl_joueurs.setAlignment(Label.CENTER);
    lbl_joueurs.setFont(new Font("SansSerif", Font.BOLD, 16));
    lbl_joueurs.setBackground(Color.black);
    lbl_joueurs.setForeground(Color.red);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 6;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 10, 10);
    c.anchor = GridBagConstraints.SOUTH;
    layout.setConstraints(lbl_joueurs, c);
    add(lbl_joueurs);

    // choix de couleur du joueur ayant l'identifiant 0
    choix_couleur0 = new Choice();
    choix_couleur0.addItem("rouge");
    choix_couleur0.addItem("bleu");
    choix_couleur0.addItemListener(this);
    choix_couleur0.setBackground(Color.red);
    choix_couleur0.setForeground(Color.black);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.insets = new Insets(10, 10, 5, 20);
    c.anchor = GridBagConstraints.EAST;
    layout.setConstraints(choix_couleur0, c);
    add(choix_couleur0);

    // nom du joueur ayant l'identifiant 0
    txt_joueur0 = new TextField(noms[0]);
    c.gridx = 2;
    c.gridy = 1;
    c.gridwidth = 4;
    c.gridheight = 1;
    c.insets = new Insets(10, 10, 5, 20);
    c.anchor = GridBagConstraints.WEST;
    layout.setConstraints(txt_joueur0, c);
    add(txt_joueur0);

    // choix de couleur du joueur ayant l'identifiant 1
    choix_couleur1 = new Choice();
    choix_couleur1.addItem("bleu");
    choix_couleur1.addItem("rouge");
    choix_couleur1.addItemListener(this);
    choix_couleur1.setBackground(Color.blue);
    choix_couleur1.setForeground(Color.black);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.insets = new Insets(10, 10, 20, 20);
    c.anchor = GridBagConstraints.EAST;
    layout.setConstraints(choix_couleur1, c);
    add(choix_couleur1);

    // nom du joueur ayant l'identifiant 1
    txt_joueur1 = new TextField(noms[1]);
    c.gridx = 2;
    c.gridy = 2;
    c.gridwidth = 4;
    c.gridheight = 1;
    c.insets = new Insets(10, 10, 30, 20);
    c.anchor = GridBagConstraints.WEST;
    layout.setConstraints(txt_joueur1, c);
    add(txt_joueur1);

    // label "Nombre De Vies:"
    Label lbl_nbvies = new Label("Nombre De Vies:");
    lbl_nbvies.setAlignment(Label.CENTER);
    lbl_nbvies.setFont(new Font("SansSerif", Font.BOLD, 14));
    lbl_nbvies.setBackground(Color.black);
    lbl_nbvies.setForeground(Color.yellow);
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 5, 10);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(lbl_nbvies, c);
    add(lbl_nbvies);
    // un choix possible
    cbg_vies = new CheckboxGroup();
    Checkbox cb;
    for (int i = 1; i <= 5; i++) {
      if (i == nb_vies) cb = new Checkbox("" + i, cbg_vies, true);
      else cb = new Checkbox("" + i, cbg_vies, false);
      c.gridx = i;
      c.gridy = 4;
      c.gridwidth = 1;
      c.gridheight = 1;
      c.insets = new Insets(20, 10, 5, 10);
      c.anchor = GridBagConstraints.CENTER;
      layout.setConstraints(cb, c);
      add(cb);
    } // for

    // label "Nombre	De Victoires:"
    lbl_victoires = new Label();
    lbl_victoires.setAlignment(Label.CENTER);
    lbl_victoires.setFont(new Font("SansSerif", Font.BOLD, 14));
    lbl_victoires.setText("Nombre De Victoires: " + nb_victoires);
    lbl_victoires.setBackground(Color.black);
    lbl_victoires.setForeground(Color.green);
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 5, 10);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(lbl_victoires, c);
    add(lbl_victoires);

    // choix du nombre de victoires entre un 1 et 9
    sb_victoires = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, 10);
    sb_victoires.setUnitIncrement(1);
    sb_victoires.setBlockIncrement(2);
    sb_victoires.addAdjustmentListener(this);
    sb_victoires.setValue(nb_victoires);
    c.gridx = 1;
    c.gridy = 6;
    c.gridwidth = 5;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 5, 10);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(sb_victoires, c);
    add(sb_victoires);

    // tirage aléatoire des niveaux
    cb_aleatoire = new Checkbox("Niveaux Aléatoires", aleatoire);
    cb_aleatoire.setFont(new Font("SansSerif", Font.BOLD, 14));
    cb_aleatoire.setBackground(Color.black);
    cb_aleatoire.setForeground(Color.magenta);
    c.gridx = 0;
    c.gridy = 8;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(20, 12, 5, 10);
    c.anchor = GridBagConstraints.EAST;
    layout.setConstraints(cb_aleatoire, c);
    add(cb_aleatoire);

    // label "FPS:" nombre de frames par seconde
    lbl_fps = new Label();
    lbl_fps.setAlignment(Label.CENTER);
    lbl_fps.setFont(new Font("SansSerif", Font.BOLD, 14));
    lbl_fps.setText("FPS: " + fps);
    lbl_fps.setBackground(Color.black);
    lbl_fps.setForeground(Color.orange);
    c.gridx = 0;
    c.gridy = 10;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 5, 10);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(lbl_fps, c);
    add(lbl_fps);

    // choix du nombre de frames par seconde
    sb_fps = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, 51);
    sb_fps.setUnitIncrement(1);
    sb_fps.setBlockIncrement(10);
    sb_fps.addAdjustmentListener(this);
    sb_fps.setValue(fps);
    c.gridx = 1;
    c.gridy = 10;
    c.gridwidth = 5;
    c.gridheight = 1;
    c.insets = new Insets(20, 10, 5, 10);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(sb_fps, c);
    add(sb_fps);

    // bouton de confirmation
    button_ok = new Button("Ok");
    c.gridx = 0;
    c.gridy = 12;
    c.gridwidth = 6;
    c.gridheight = 1;
    c.insets = new Insets(20, 5, 20, 5);
    c.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(button_ok, c);
    add(button_ok);
    button_ok.addActionListener(this);
  } // initConteneur()
示例#15
0
 private void set_values() {
   d_bar.setValue((int) (view.d_percent * 100.0));
   d_text.setText("d%= " + view.d_percent);
 }
示例#16
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");
    }