コード例 #1
0
 /*------------------------------------------------------------------*/
 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 */
コード例 #2
0
  /*------------------------------------------------------------------*/
  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 */