Beispiel #1
0
 /** Returns the selected item in the next radio button group. */
 public String getNextRadioButton() {
   if (radioButtonGroups == null) return null;
   CheckboxGroup cg = (CheckboxGroup) (radioButtonGroups.elementAt(radioButtonIndex));
   radioButtonIndex++;
   Checkbox checkbox = cg.getSelectedCheckbox();
   String item = "null";
   if (checkbox != null) item = checkbox.getLabel();
   if (macro) {
     String label = (String) labels.get((Object) cg);
     item = Macro.getValue(macroOptions, label, item);
   }
   if (recorderOn) recordOption(cg, item);
   return item;
 }
Beispiel #2
0
  public void itemStateChanged(ItemEvent e) {
    Checkbox currentCheckbox = shapeActions.getSelectedCheckbox();
    boolean CheckboxState = currentCheckbox.getState();
    String currentAction = currentCheckbox.getLabel();
    if (CheckboxState) {
      myAction = currentAction;
    } else {
      myAction = "DRAW";
    }

    applet.repaint();
  }
  /** Récupère les preférences manquants et ferme la fenêtre */
  public void fermer() {
    // noms des joueurs
    String nom = txt_joueur0.getText();
    if (nom.compareTo("") == 0) noms[0] = "J1";
    else noms[0] = nom;
    nom = txt_joueur1.getText();
    if (nom.compareTo("") == 0) noms[1] = "J2";
    else noms[1] = nom;

    // nombre de vies
    nb_vies = new Integer(cbg_vies.getSelectedCheckbox().getLabel()).intValue();
    aleatoire = cb_aleatoire.getState();
    setVisible(false);
  } // fermer()
 /*------------------------------------------------------------------*/
 public void itemStateChanged(ItemEvent ie) {
   if (choice.getSelectedCheckbox().getLabel().equals("Gradient Magnitude")) {
     operation = Differentials_.GRADIENT_MAGNITUDE;
   } else if (choice.getSelectedCheckbox().getLabel().equals("Gradient Direction")) {
     operation = Differentials_.GRADIENT_DIRECTION;
   } else if (choice.getSelectedCheckbox().getLabel().equals("Laplacian")) {
     operation = Differentials_.LAPLACIAN;
   } else if (choice.getSelectedCheckbox().getLabel().equals("Largest Hessian")) {
     operation = Differentials_.LARGEST_HESSIAN;
   } else if (choice.getSelectedCheckbox().getLabel().equals("Smallest Hessian")) {
     operation = Differentials_.SMALLEST_HESSIAN;
   } else if (choice.getSelectedCheckbox().getLabel().equals("Hessian Orientation")) {
     operation = Differentials_.HESSIAN_ORIENTATION;
   } else {
     cancel = true;
     operation = Differentials_.LAPLACIAN;
     IJ.error("Unexpected checkbox ID");
     this.setVisible(false);
   }
   repaint();
 } /* end itemStateChanged */
  public void read() {
    try {
      // patient.dt=""+tdt.getText();
      patient.pid = Integer.parseInt(tpid.getText());
      patient.pfnm = tpfnm.getText();
      patient.pmnm = tpmnm.getText();
      patient.plnm = tplnm.getText();
      patient.gen = cbg.getSelectedCheckbox().getLabel();

      try {
        patient.age = Integer.parseInt(tage.getText());
        tage.setText("" + patient.age);

      } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Invalid age inputed.");
        patient.age = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid age:"));
        tage.setText("" + patient.age);
      }

      try {
        int wet = Integer.parseInt(twt.getText());
        twt.setText("" + wet);
      } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Invalid weight inputed.");
        int wet = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid weight:"));
        twt.setText("" + wet);
      }
      patient.wt = twt.getText();
      patient.addr = tadd.getText();
      this.ad = tadd.getText();
      System.out.println(tadd.getText());

      while (true) {
        patient.cno = tcno.getText();
        if (patient.cno.length() == 10) break;
        else {
          JOptionPane.showMessageDialog(null, "Invalid Phone No.");
          patient.cno = JOptionPane.showInputDialog("Please enter valid 10-digit Phone No.:");
          tcno.setText(patient.cno);
        }
      }
      patient.dnm = tdnm.getText();
      patient.sym = tsym.getText();
      System.out.println(tsym.getText());

      patient.dig = tdig.getText();
      try {
        patient.fee = Integer.parseInt(tfee.getText());
        tfee.setText("" + patient.fee);

      } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Invalid Fee inputed.");
        patient.fee = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid Fee:"));
        tfee.setText("" + patient.fee);
      }

      patient.bg = tbg.getText();
      patient.path = str;
    } catch (Exception e) {
    }
  }
Beispiel #6
0
 public void itemStateChanged(ItemEvent e) {
   msg = "currnet selection ";
   msg += cbg.getSelectedCheckbox().getLabel();
   l.setText(msg);
 }
  public void itemStateChanged(ItemEvent e) {

    // choice=MALE
    if (cbg.getSelectedCheckbox().getLabel().equals("Male")) {
      if (gross < 160000) tp.setText("0");
      else if (gross < 300000) {
        gross -= 160000;
        gross *= 0.1;
        gross += gross * 0.03;
        tp.setText(Double.toString(gross));
      } else if (gross < 500000) {
        gross -= 300000;
        gross *= 0.2;
        gross += 14000;
        gross += gross * 0.03;
        tp.setText(Double.toString(gross));
      } else {
        gross -= 500000;
        gross *= 0.3;
        gross += 54000;
        gross += gross * 0.03;
        tp.setText(Double.toString(gross));
      }

    }
    // choice=FEMALE
    else if (cbg.getSelectedCheckbox().getLabel().equals("Female")) {
      if (gross < 190000) tp.setText("0");
      else if (gross < 300000) {
        gross -= 190000;
        gross *= 0.1;
        gross += gross * 0.03;
        tp.setText(Double.toString(gross));
      } else if (gross < 500000) {
        gross -= 300000;
        gross *= 0.2;
        gross += 11000;
        gross += gross * 0.03;
        tp.setText(Double.toString(gross));
      } else {
        gross -= 500000;
        gross *= 0.3;
        gross += 51000;
        gross += gross * 0.03;
        tp.setText(Double.toString(gross));
      }
    }
    // Choice=Senior citizen
    else {
      if (gross < 240000) tp.setText("0");
      else if (gross < 300000) {
        gross -= 240000;
        gross *= 0.2;
        gross += gross * 0.03;
        tp.setText(Double.toString(gross));
      } else if (gross < 500000) {
        gross -= 300000;
        gross *= 0.2;
        gross += 6000;
        gross += gross * 0.03;
        tp.setText(Double.toString(gross));
      } else {
        gross -= 500000;
        gross *= 0.3;
        gross += 46000;
        gross += gross * 0.03;
        tp.setText(Double.toString(gross));
      }
    }
  }
  /*------------------------------------------------------------------*/
  differentialsDialog(Frame parentWindow, String title, boolean isModal, int operation) {
    super(parentWindow, title, isModal);
    setLayout(new GridLayout(0, 1));

    Checkbox gradientMagnitude = new Checkbox("Gradient Magnitude", choice, false);
    Checkbox gradientDirection = new Checkbox("Gradient Direction", choice, false);
    Checkbox laplacian = new Checkbox("Laplacian", choice, false);
    Checkbox largestHessian = new Checkbox("Largest Hessian", choice, false);
    Checkbox smallestHessian = new Checkbox("Smallest Hessian", choice, false);
    Checkbox hessianOrientation = new Checkbox("Hessian Orientation", choice, false);
    this.operation = operation;
    switch (operation) {
      case Differentials_.GRADIENT_MAGNITUDE:
        choice.setSelectedCheckbox(gradientMagnitude);
        break;
      case Differentials_.GRADIENT_DIRECTION:
        choice.setSelectedCheckbox(gradientDirection);
        break;
      case Differentials_.LAPLACIAN:
        choice.setSelectedCheckbox(laplacian);
        break;
      case Differentials_.LARGEST_HESSIAN:
        choice.setSelectedCheckbox(largestHessian);
        break;
      case Differentials_.SMALLEST_HESSIAN:
        choice.setSelectedCheckbox(smallestHessian);
        break;
      case Differentials_.HESSIAN_ORIENTATION:
        choice.setSelectedCheckbox(hessianOrientation);
        break;
      default:
        cancel = true;
        IJ.error("Unexpected operation ID");
        setVisible(false);
    }

    gradientMagnitude.addItemListener(this);
    gradientDirection.addItemListener(this);
    laplacian.addItemListener(this);
    largestHessian.addItemListener(this);
    smallestHessian.addItemListener(this);
    hessianOrientation.addItemListener(this);

    Label separation1 = new Label("");
    Label separation2 = new Label("");
    Label separation3 = new Label("");
    Label separation4 = new Label("");

    Panel buttonPanel = new Panel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
    Button cancelButton = new Button("Cancel");
    Button okButton = new Button("OK");
    cancelButton.addActionListener(this);
    okButton.addActionListener(this);
    buttonPanel.add(cancelButton);
    buttonPanel.add(okButton);

    add(separation1);
    add(gradientMagnitude);
    add(gradientDirection);
    add(separation2);
    add(laplacian);
    add(separation3);
    add(largestHessian);
    add(smallestHessian);
    add(hessianOrientation);
    add(separation4);
    add(buttonPanel);

    pack();
  } /* end differentialsDialog */
Beispiel #9
0
  public boolean action(Event event, Object what) {
    if (event.target instanceof Checkbox) {
      CheckboxGroup cbgrp = ((Checkbox) (event.target)).getCheckboxGroup();
      Checkbox selected = cbgrp.getCurrent();
      String label = selected.getLabel();

      int mode = GraphCanvas.CREATE_NODES;
      if (label.equals("Create Edges")) mode = GraphCanvas.CREATE_EDGES;
      else if (label.equals("Select Nodes")) mode = GraphCanvas.SELECT_NODES;
      else if (label.equals("Select Edges")) mode = GraphCanvas.SELECT_EDGES;
      else if (label.equals("Select Nodes or Edges")) mode = GraphCanvas.SELECT_BOTH;

      graphCanvas_.setMouseMode(mode);
    } else if (event.target instanceof CheckboxMenuItem) {
      String label = ((CheckboxMenuItem) (event.target)).getLabel();
      boolean state = ((CheckboxMenuItem) (event.target)).getState();

      if (label.equals("Scale Node Size")) graphCanvas_.scaleBounds(state);
      else if (label.equals("Show Controls  [s]")) {
        if (state) controls_.show();
        else controls_.hide();
        validate();
      } else if (label.equals("Directed")) graphCanvas_.setDirected(state);
      else if (label.equals("Use Node ID As Default Label")) {
        Node.setDefaultLabel(state);
        graphCanvas_.update(false);
      } else if (label.equals("High Quality Display"))
        graphCanvas_.setQuality(state == false ? 1 : 2);
    } else if (event.target instanceof MenuItem) {
      GraphAlgorithm alg;

      MenuItem menuitem = (MenuItem) event.target;

      alg = (GraphAlgorithm) algHashTable_.get(menuitem);
      if (alg != null) {
        applyAlgorithm_(alg);
      } else {
        String label = menuitem.getLabel();

        if (label.equals("Open Example Graph")) {
          URL src = null;
          try {
            src = new URL(context_, "example.gml");
            InputStream strm = src.openStream();
            GMLlexer lexer = new GMLlexer(strm);
            GMLfile_ = new GMLobject(lexer, null);
            GMLobject gmlgraph = GMLfile_.getGMLSubObject("graph", GMLobject.GMLlist, false);

            Graph newgraph = null;
            newgraph = new Graph(gmlgraph);
            graph_.copy(newgraph);
            graphCanvas_.update(true);

            filename_ = null;
            setTitle_();
          } catch (Exception e) {
            new MessageDialog(this, "Error", "Error loading example graph.", true);
          }
          ;

        } else if (label.equals("Open (GML)")) {
          String filename = null;

          FileDialog fd;
          try {
            fd = new FileDialog(this, "Open VGJ File (GML)", FileDialog.LOAD);
            fd.show();
          } catch (Throwable e) {
            MessageDialog dg =
                new MessageDialog(
                    this, "Error", "It appears your VM does not allow file loading.", true);
            return true;
          }
          filename = fd.getFile();
          if (filename == null) return true;
          filename = fd.getDirectory() + filename;

          loadFile(filename);
          return true;
        } else if (label.equals("Save (GML)") || label.equals("Save As (GML)")) {
          try {
            String filename;
            if (label.equals("Save As (GML)") || filename_ == null) {
              FileDialog fd;
              try {
                fd = new FileDialog(this, "Save VGJ File (GML)", FileDialog.SAVE);
                fd.show();
              } catch (Throwable e) {
                MessageDialog dg =
                    new MessageDialog(
                        this, "Error", "It appears your VM does not allow file saving.", true);
                return true;
              }

              filename = fd.getFile();
              if (filename == null) return true;

              // Work around JDK Windows bug.
              if (filename.endsWith(".*.*")) {
                String tmpstr = filename.substring(0, filename.length() - 4);
                filename = tmpstr;
              }
              filename = fd.getDirectory() + filename;
            } else filename = filename_;

            PrintStream ps = new PrintStream(new FileOutputStream(filename));
            if (GMLfile_ == null) {
              GMLfile_ = new GMLobject(null, GMLobject.GMLfile);
              GMLfile_.addObjectToEnd(new GMLobject("graph", GMLobject.GMLlist));
            }
            GMLobject gmlgraph = GMLfile_.getGMLSubObject("graph", GMLobject.GMLlist, false);
            graph_.setGMLvalues(gmlgraph);
            gmlgraph.prune();

            ps.println(GMLfile_.toString(0));
            ps.close();

            filename_ = filename;
            setTitle_();
          } catch (IOException e) {
            MessageDialog dg = new MessageDialog(this, "Error", e.getMessage(), true);
          }

        } else if (label.equals("Exit This Window")) Destroy();
        else if (label.startsWith("Exit Application")) System.exit(0);
        else if (label.equals("Delete Selected Items")) graphCanvas_.deleteSelected(true);
        else if (label.equals("Select All")) graphCanvas_.selectAll();
        else if (label.equals("Remove All Edge Bends")) graphCanvas_.removeEdgeBends();
        else if (label.equals("Remove All Groups")) graphCanvas_.removeGroups();
        else if (label.equals("Group Control")) {
          if (groupControl_ == null) groupControl_ = new GroupControl(this, graphCanvas_);
          else groupControl_.showMe();
        } else if (label.equals("Set New Node Properties")) graphCanvas_.setNodeProperties(true);
        else if (label.equals("Set Node Spacing")) {
          if (algPropDialog_ == null) algPropDialog_ = new AlgPropDialog(this, graphCanvas_);
          else algPropDialog_.showMe();
        } else if (label.equals("Set Font")) {
          if (fontPropDialog_ == null) fontPropDialog_ = new FontPropDialog(this, graphCanvas_);
          else fontPropDialog_.showMe();
        } else if (label.equals("Edit Text Representation (GML)")) {
          graphCanvas_.unselectItems();
          GraphEdit ge = new GraphEdit(graph_, graphCanvas_);
          ge.pack();
          ge.show();
        } else if (label.equals("PostScript Output")) {
          if (psDialog_ == null) psDialog_ = new PSdialog(this, graphCanvas_);
          else {
            psDialog_.pack();
            psDialog_.show();
          }
        }
      }
    } else if (event.target instanceof Button) {
      if (((String) what).equals("Scale / 2") // mod
          || ((String) what).equals("Zoom Out") // mod
      ) // mod
      {
        // scale_ /= 2.0;        // mod
        scale_ /= 1.2;
        graphCanvas_.setScale(scale_);

        scaleLabel_.setText("Scale: " + scale_);
      } else if (((String) what).equals("Scale * 2") // mod
          || ((String) what).equals("Zoom In") // mod
      ) // mod
      {
        // scale_ *= 2.0;       // mod
        scale_ *= 1.2;
        graphCanvas_.setScale(scale_);

        scaleLabel_.setText("Scale: " + scale_);
      } else if (((String) what).equals("Scale = 1")) {
        scale_ = 1.0;
        graphCanvas_.setScale(scale_);

        scaleLabel_.setText("Scale: " + scale_);
      } else if (((String) what).equals("Center")) {
        DDimension port_dim = viewingPanel_.getPortSize();
        DDimension cont_dim = viewingPanel_.getContentSize();

        double x = (cont_dim.width - port_dim.width) / 2.0;
        double y = (cont_dim.height - port_dim.height) / 2.0;

        viewingPanel_.scrollTo((int) x, (int) y);
        portScroller_.setOffset(x, y);
      } else if (((String) what).equals("Update")) {
        System.out.println("Update button pressed. " + myAction);
        if (myAction != null) {
          System.out.println("Performing action.");
          myAction.execute();
        }
      }
    }
    return true;
  }