コード例 #1
0
ファイル: PaintApplet.java プロジェクト: acpanna/coding
  public void mouseReleased(MouseEvent evt) {
    Graphics g = canvas.getGraphics();
    g.setColor(color);
    g.setPaintMode();
    end = evt.getPoint();

    if (type == 0) {
      g.drawRect(start.x, start.y, end.x - start.x, end.y - start.y);

      if (filled.getState() == true) g.fillRect(start.x, start.y, end.x - start.x, end.y - start.y);

      status.setText("2. Ecke des Rechtecks festgelegt");
    } else if (type == 1) {
      int radius;

      radius = (int) Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));

      g.drawOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius);

      if (filled.getState() == true)
        g.fillOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius);

      status.setText("Radius des Kreises festgelegt");
    } else if (type == 2) {
      g.drawOval(start.x, start.y, end.x - start.x, end.y - start.y);

      if (filled.getState() == true) g.fillOval(start.x, start.y, end.x - start.x, end.y - start.y);

      status.setText("Radius der Ellipse festgelegt");
    }
  }
コード例 #2
0
ファイル: PaintApplet.java プロジェクト: acpanna/coding
  public void itemStateChanged(ItemEvent evt) {
    if (evt.getSource() == farbe) {
      status.setText("Farbe " + farben[farbe.getSelectedIndex()] + " ausgewaehlt");

      switch (farbe.getSelectedIndex()) {
        case 0:
          color = Color.blue;
          break;
        case 1:
          color = Color.yellow;
          break;
        case 2:
          color = Color.green;
          break;
        case 3:
          color = Color.red;
          break;
        case 4:
          color = Color.black;
          break;
        case 5:
          color = Color.white;
      }
    } else if (evt.getSource() == filled) {
      if (filled.getState() == true) status.setText("Ausgefuellt zeichnen");
      else status.setText("Rahmen zeichnen");
    }
  }
コード例 #3
0
  public void launch() {
    setLocation(350, 200);
    setLayout(new GridLayout(5, 1));

    ItemMonitor im = new ItemMonitor();
    // checkbox
    checkbox.setLabel("test");
    checkbox.addItemListener(im);
    add(checkbox);

    for (int i = 0; i < 3; i++) {
      cb[i] = new Checkbox("item " + i);
      cb[i].addItemListener(im);
      add(cb[i]);

      if (checkbox.getState() == true) {
        cb[i].setEnabled(true);
      } else {
        cb[i].setEnabled(false);
      }

      if (i == 2) {
        cb[i].setState(true);
      }
    }

    // label
    lb = new Label();
    add(lb);

    pack();
    setVisible(true);
  }
コード例 #4
0
  public void itemStateChanged(ItemEvent E) {
    // The 'log chat' checkbox
    if (E.getSource() == logChat) {
      server.logChats = logChat.getState();

      // Loop through all of the chat rooms, and set the logging
      // state to be the same as the value of the checkbox
      for (int count = 0; count < server.chatRooms.size(); count++) {
        babylonChatRoom tmp = (babylonChatRoom) server.chatRooms.elementAt(count);
        try {
          tmp.setLogging(server.logChats);
        } catch (IOException e) {
          server.serverOutput(
              server.strings.get(thisClass, "togglelogerror") + " " + tmp.name + "\n");
        }
      }
    }

    // The user list
    if (E.getSource() == userList) {
      // If anything is selected, enable the 'disconnect user'
      // button, otherwise disable it
      synchronized (userList) {
        disconnect.setEnabled(userList.getSelectedItem() != null);
      }
    }
  }
コード例 #5
0
ファイル: GrandFinale.java プロジェクト: simon816/CS118
 public static void maybeDrawGraph(GrandFinale.Graph nodeGraph, IRobot r) {
   if (!enable.getState()) {
     return;
   }
   if (c++ % 20 == 0) { // Because it's expensive to do this every tick
     drawGraph(nodeGraph, r);
   }
 }
コード例 #6
0
ファイル: GenericDialog.java プロジェクト: aschain/ImageJA
 private void recordCheckboxOption(Checkbox cb) {
   String label = (String) labels.get((Object) cb);
   if (label != null) {
     if (cb.getState()) // checked
     Recorder.recordOption(label);
     else if (Recorder.getCommandOptions() == null) Recorder.recordOption(" ");
   }
 }
コード例 #7
0
ファイル: DictAWTView.java プロジェクト: amake/jdictserver
 private void loop() {
   while (true) {
     try {
       Thread.sleep(delay);
     } catch (InterruptedException e) {
     }
     if (mode.getState()) {
       lookup();
     }
   }
 }
コード例 #8
0
ファイル: Canvas.java プロジェクト: graywv/OST-Java
  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();
  }
コード例 #9
0
ファイル: GenericDialog.java プロジェクト: aschain/ImageJA
 /** Returns the state of the next checkbox. */
 public boolean getNextBoolean() {
   if (checkbox == null) return false;
   Checkbox cb = (Checkbox) (checkbox.elementAt(cbIndex));
   if (recorderOn) recordCheckboxOption(cb);
   boolean state = cb.getState();
   if (macro) {
     String label = (String) labels.get((Object) cb);
     String key = Macro.trimKey(label);
     state = isMatch(macroOptions, key + " ");
   }
   cbIndex++;
   return state;
 }
コード例 #10
0
  /** 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()
コード例 #11
0
  private void clickOpciones() {

    JPanel myPanel = new JPanel();
    //		myPanel.setFont(new Font("Serif",Font.PLAIN,20));
    Checkbox cbMovimientosPosibles = new Checkbox("Mostrar movimientos posibles", false);
    cbMovimientosPosibles.setFont(new Font("Serif", Font.PLAIN, 20));
    myPanel.add(cbMovimientosPosibles);

    UIManager.put("OptionPane.buttonFont", new FontUIResource(new Font("Serif", Font.PLAIN, 20)));
    int result =
        JOptionPane.showConfirmDialog(null, myPanel, "Opciones", JOptionPane.OK_CANCEL_OPTION);
    if (result == JOptionPane.OK_OPTION) {
      mostrarPosibles = cbMovimientosPosibles.getState();
    }
  }
コード例 #12
0
ファイル: dbfShow.java プロジェクト: akerigan/staxer
  public void updateRec() {

    try {
      setFields();
      db.update();
      boolean b = delCB.getState();
      if (db.deleted() && !b) {
        db.undelete();
      } else if (!db.deleted() && b) {
        db.delete();
      }
    } // try
    catch (Exception e1) {
      System.out.println(e1);
      System.exit(1);
    }
  }
コード例 #13
0
  void displayWifiPassword() {
    Config config = Config.instance();
    config.setEmail(emailField.getText());
    config.setRememberPassword(rememberPasswordCheckbox.getState());
    config.setPassword(passField.getText());

    config.updateConfig();

    if (Config.instance().getQRImage() == null || Config.instance().getWifiPassword().isEmpty()) {
      if (Config.instance().getWifiPassword().isEmpty()) {
        wifiPasswordField.setText("");
      }

      hintLabel.setText("QRCode has not been generated");
      qrCodeLabel.setIcon(idleIcon);
      return;
    }

    try {

      wifiPasswordField.setText(Config.instance().getWifiPassword());

      BufferedImage qrImage = Config.instance().getQRImage();

      int width = qrCodeLabel.getWidth();
      int height = qrCodeLabel.getHeight();

      // make a square image
      int length = width < height ? width : height;

      ImageIcon imgIcon = new ImageIcon();
      imgIcon.setImage(qrImage.getScaledInstance(length, length, Image.SCALE_AREA_AVERAGING));

      hintLabel.setText("Scan QRCode with mobile client to login clear-guest!");
      wifiPasswordField.setText(Config.instance().getWifiPassword());
      qrCodeLabel.setIcon(imgIcon);
    } catch (Exception e) {
      JOptionPane.showMessageDialog(
          mainPanel,
          "Failed to generate QR Image, please try again",
          "QRCode Generation Failed",
          JOptionPane.ERROR_MESSAGE);
      e.printStackTrace();
    }
  }
コード例 #14
0
ファイル: GrandFinale.java プロジェクト: simon816/CS118
 public static void printRoute(List<GrandFinale.Node> route) {
   if (!enable.getState()) {
     return;
   }
   MazeGridPanel panel = getPanel();
   Graphics g = panel.getGraphics();
   Font fOld = g.getFont();
   g.setFont(new Font("Arial", Font.BOLD, fOld.getSize()));
   for (int i = 0; i < route.size(); i++) {
     Point p = route.get(i).getPoint();
     try {
       mFill.invoke(panel, p.x, p.y, g, Color.red);
     } catch (Exception e) {
     }
     p = offset(panel, p, 3, 1);
     g.setColor(Color.black);
     g.drawString(String.valueOf(i), p.x, p.y);
   }
 }
コード例 #15
0
ファイル: TransCreator.java プロジェクト: asanian/GenNet
 /**
  * Diff�rentes actions men�es suivant le choix de l'utilisateur
  *
  * @param e evenement d�clench� par le clic sur ok ou annuler
  */
 public void actionPerformed(ActionEvent e) {
   Object source = e.getSource();
   if (source == ok) {
     if (plus.getState() == true) {
       sign = 1;
     } else {
       sign = 0;
     }
     threshold = tf.getText();
     try {
       thresholdVal = Integer.parseInt(threshold);
       if (thresholdVal < 0) {
         JOptionPane.showMessageDialog(
             this.mf,
             "Threshold must be a positive integer",
             "Error",
             JOptionPane.WARNING_MESSAGE);
         this.setVisible(true);
       } else {
         gz.draw();
         gz.creatTrans(thresholdVal, sign);
         auto.modif(true);
         this.dispose();
       }
     } catch (NumberFormatException ex) {
       JOptionPane.showMessageDialog(
           this.mf, "Threshold must be a positive integer.", "Error", JOptionPane.WARNING_MESSAGE);
       this.setVisible(true);
     }
   } else if (source == cancel) {
     gz.draw();
     bar.displayInfo(mf.frameName);
     bar.can = true;
     this.dispose();
   }
   gz.menu.majMenus();
 }
コード例 #16
0
ファイル: dbfShow.java プロジェクト: akerigan/staxer
  public void setFields() {
    Field f;
    LogicalField lf;
    Checkbox c;
    TextField t;

    int i;
    try {
      for (i = 1; i <= db.getFieldCount(); i++) {
        f = db.getField(i);
        if (f.isMemoField() || f.isPictureField()) {
        } else if (f.isLogicalField()) {
          lf = (LogicalField) f;
          c = (Checkbox) fldObjects.elementAt(i - 1);
          lf.put(c.getState());
        } else {
          t = (TextField) fldObjects.elementAt(i - 1);
          f.put(t.getText());
        }
      }
    } catch (Exception e1) {
      System.out.println(e1);
    }
  }
コード例 #17
0
  boolean showOptions() {

    MesquiteInteger buttonPressed = new MesquiteInteger(1);
    ExtensibleDialog queryDialog =
        new ExtensibleDialog(containerOfModule(), "Reinterpret Node Labels", buttonPressed);
    queryDialog.addLargeOrSmallTextLabel(
        "Some programs write information as node labels; e.g. MrBayes writes posterior probabilities as if they were the names of clades (= node labels)."
            + "\nHere you can reintepret such information.");
    // name for information (e.g., "posteriorProbability", "bootstrapFrequency")
    queryDialog.addLabel(
        "Name for information? (e.g., \"posteriorProbability\", \"bootstrapFrequency\")",
        Label.LEFT);
    TextField nameField = queryDialog.addTextField(name, 30);

    queryDialog.addHorizontalLine(2);

    // where to attach
    queryDialog.addLabel("Applies to branch or node?", Label.LEFT);
    String[] where =
        new String[] {
          "Information applies to branch (e.g., posterior probability, bootstrap frequency)",
          "Information applies to node (e.g., clade name)"
        };
    RadioButtons whereButtons = queryDialog.addRadioButtons(where, 0);
    queryDialog.addLabel(
        "(This determines how the information will behave when the tree is rerooted.)", Label.LEFT);
    queryDialog.addHorizontalLine(2);

    // how to treat
    queryDialog.addLabel("Number or text?", Label.LEFT);
    String[] what =
        new String[] {
          "Treat as number (e.g., posterior probability)", "Treat as text (e.g., clade name)"
        };
    RadioButtons whatButtons = queryDialog.addRadioButtons(what, 0);
    queryDialog.addHorizontalLine(2);

    // delete internal node labels after reinterpreting?
    Checkbox delete =
        queryDialog.addCheckBox("Delete internal node labels after reinterpreting?", deleteAfter);
    queryDialog.addHorizontalLine(2);

    queryDialog.completeAndShowDialog(true);

    boolean ok = (queryDialog.query() == 0);

    if (ok) {
      if (StringUtil.blank(nameField.getText())) {
        ok = false;
        alert("A name must be entered for the information");
      } else {
        name = nameField.getText();
        nameRef = NameReference.getNameReference(name);
        appliesToBranch = whereButtons.getValue() == 0;
        isNumber = whatButtons.getValue() == 0;
        deleteAfter = delete.getState();
      }
    }

    queryDialog.dispose();
    return ok;
  }
コード例 #18
0
ファイル: GrandFinale.java プロジェクト: simon816/CS118
 public static void drawGraph(GrandFinale.Graph g, IRobot r) {
   if (!enable.getState()) {
     return;
   }
   drawChain(g, g.getNodeAt(r.getMaze().getStart()), new ArrayList<>());
 }
コード例 #19
0
 public boolean shouldScale() {
   return scaleCheckbox.getState();
 }
コード例 #20
0
ファイル: Channels.java プロジェクト: hellotod/HadoopLung
 public void itemStateChanged(ItemEvent e) {
   ImagePlus imp = WindowManager.getCurrentImage();
   if (imp == null) return;
   if (!imp.isComposite()) {
     int channels = imp.getNChannels();
     if (channels == 1 && imp.getStackSize() <= 4) channels = imp.getStackSize();
     if (imp.getBitDepth() == 24 || (channels > 1 && channels < CompositeImage.MAX_CHANNELS)) {
       GenericDialog gd = new GenericDialog(imp.getTitle());
       gd.addMessage("Convert to multi-channel composite image?");
       gd.showDialog();
       if (gd.wasCanceled()) return;
       else IJ.doCommand("Make Composite");
     } else {
       IJ.error(
           "Channels",
           "A composite image is required (e.g., "
               + moreLabel
               + " Open HeLa Cells),\nor create one using "
               + moreLabel
               + " Make Composite.");
       return;
     }
   }
   if (!imp.isComposite()) return;
   CompositeImage ci = (CompositeImage) imp;
   Object source = e.getSource();
   if (source == choice) {
     int index = ((Choice) source).getSelectedIndex();
     switch (index) {
       case 0:
         ci.setMode(IJ.COMPOSITE);
         break;
       case 1:
         ci.setMode(IJ.COLOR);
         break;
       case 2:
         ci.setMode(IJ.GRAYSCALE);
         break;
     }
     ci.updateAndDraw();
     if (Recorder.record) {
       String mode = null;
       switch (index) {
         case 0:
           mode = "composite";
           break;
         case 1:
           mode = "color";
           break;
         case 2:
           mode = "grayscale";
           break;
       }
       Recorder.record("Stack.setDisplayMode", mode);
     }
   } else if (source instanceof Checkbox) {
     for (int i = 0; i < checkbox.length; i++) {
       Checkbox cb = (Checkbox) source;
       if (cb == checkbox[i]) {
         if (ci.getMode() == IJ.COMPOSITE) {
           boolean[] active = ci.getActiveChannels();
           active[i] = cb.getState();
           if (Recorder.record) {
             String str = "";
             for (int c = 0; c < ci.getNChannels(); c++) str += active[c] ? "1" : "0";
             Recorder.record("Stack.setActiveChannels", str);
             Recorder.record("//Stack.toggleChannel", imp.getChannel());
           }
         } else {
           imp.setPosition(i + 1, imp.getSlice(), imp.getFrame());
           if (Recorder.record) Recorder.record("Stack.setChannel", i + 1);
         }
         ci.updateAndDraw();
         return;
       }
     }
   }
 }
コード例 #21
0
ファイル: Evaluator.java プロジェクト: tomka/fiji
 /**
  * Every time one of the options is changed, this method is called. The parser settings are
  * adjusted to the GUI settings, the expression is parsed again, and the results updated.
  */
 private void optionsChanged() {
   myParser.setImplicitMul(implicitCheckbox.getState());
   myParser.setAllowUndeclared(undeclaredCheckbox.getState());
   parseExpression();
   updateResult();
 }
コード例 #22
0
ファイル: MainDialog.java プロジェクト: IDR/bioformats
  /** 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);
    }
  }
コード例 #23
0
ファイル: GenericDialog.java プロジェクト: aschain/ImageJA
 /** Returns 'true' if this dialog has a "Preview" checkbox and it is enabled. */
 public boolean isPreviewActive() {
   return previewCheckbox != null && previewCheckbox.getState();
 }
コード例 #24
0
    void apply(ImagePlus imp, ImageProcessor ip) {
      // this.setCursor(wait);
      // IJ.showStatus("Bandpassing slice "+previousSlice);
      java.awt.Color col;

      if (invert.getState()) col = Toolbar.getForegroundColor();
      else col = Toolbar.getBackgroundColor();

      ip.setColor(col);

      int fill = ip.BLACK;
      int keep = 0;

      if (bandPassH.getState() && bandPassS.getState() && bandPassB.getState()) { // PPP All pass
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue < minHue) || (hue > maxHue))
              || ((sat < minSat) || (sat > maxSat))
              || ((bri < minBri) || (bri > maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      } else if (!bandPassH.getState()
          && !bandPassS.getState()
          && !bandPassB.getState()) { // SSS All stop
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue >= minHue) && (hue <= maxHue))
              || ((sat >= minSat) && (sat <= maxSat))
              || ((bri >= minBri) && (bri <= maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      } else if (bandPassH.getState() && bandPassS.getState() && !bandPassB.getState()) { // PPS
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue < minHue) || (hue > maxHue))
              || ((sat < minSat) || (sat > maxSat))
              || ((bri >= minBri) && (bri <= maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      } else if (!bandPassH.getState() && !bandPassS.getState() && bandPassB.getState()) { // SSP
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue >= minHue) && (hue <= maxHue))
              || ((sat >= minSat) && (sat <= maxSat))
              || ((bri < minBri) || (bri > maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      } else if (bandPassH.getState() && !bandPassS.getState() && !bandPassB.getState()) { // PSS
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue < minHue) || (hue > maxHue))
              || ((sat >= minSat) && (sat <= maxSat))
              || ((bri >= minBri) && (bri <= maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      } else if (!bandPassH.getState() && bandPassS.getState() && bandPassB.getState()) { // SPP
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue >= minHue) && (hue <= maxHue))
              || ((sat < minSat) || (sat > maxSat))
              || ((bri < minBri) || (bri > maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      } else if (!bandPassH.getState() && bandPassS.getState() && !bandPassB.getState()) { // SPS
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue >= minHue) && (hue <= maxHue))
              || ((sat < minSat) || (sat > maxSat))
              || ((bri >= minBri) && (bri <= maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      } else if (bandPassH.getState() && !bandPassS.getState() && bandPassB.getState()) { // PSP
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue < minHue) || (hue > maxHue))
              || ((sat >= minSat) && (sat <= maxSat))
              || ((bri < minBri) || (bri > maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      }

      ip.fill(fillMask);

      if (threshold.getState()) {
        ip.invert();
        for (int j = 0; j < numPixels; j++) {
          if (fillMask[j] == fill) fillMask[j] = keep;
          else fillMask[j] = fill;
        }
        ip.fill(fillMask);
        ip.invert();
      }
    }
コード例 #25
0
  public boolean queryOptions() {
    if (!okToInteractWithUser(
        CAN_PROCEED_ANYWAY,
        "Querying Options")) // Debugg.println needs to check that options set well enough to
                             // proceed anyway
    return true;
    boolean closeWizard = false;

    if ((MesquiteTrunk.isMacOSXBeforeSnowLeopard()) && MesquiteDialog.currentWizard == null) {
      CommandRecord cRec = null;
      cRec = MesquiteThread.getCurrentCommandRecordDefIfNull(null);
      if (cRec != null) {
        cRec.requestEstablishWizard(true);
        closeWizard = true;
      }
    }

    MesquiteInteger buttonPressed = new MesquiteInteger(1);

    queryOptionsDialog =
        new ExtensibleDialog(
            containerOfModule(),
            "TNT Options & Locations",
            buttonPressed); // MesquiteTrunk.mesquiteTrunk.containerOfModule()
    //		queryOptionsDialog.addLabel("TNT - Options and Locations");
    String helpString =
        "This module will prepare a matrix for TNT, and ask TNT do to an analysis.  A command-line version of TNT must be installed. "
            + "You can ask it to do a bootstrap analysis or not. "
            + "Mesquite will read in the trees found by TNT. ";

    queryOptionsDialog.appendToHelpString(helpString);
    queryOptionsDialog.setHelpURL(zephyrRunnerEmployer.getProgramURL());

    MesquiteTabbedPanel tabbedPanel = queryOptionsDialog.addMesquiteTabbedPanel();

    tabbedPanel.addPanel("TNT Program Details", true);
    externalProcRunner.addItemsToDialogPanel(queryOptionsDialog);
    Checkbox parallelCheckBox =
        queryOptionsDialog.addCheckBox("use PVM for parallel processing", parallel);
    parallelCheckBox.addItemListener(this);
    IntegerField slavesField =
        queryOptionsDialog.addIntegerField(
            "Number of Slaves", numSlaves, 4, 0, MesquiteInteger.infinite);
    IntegerField maxRamField =
        queryOptionsDialog.addIntegerField("mxram value", mxram, 4, 0, MesquiteInteger.infinite);

    tabbedPanel.addPanel("Search Options", true);
    Choice searchStyleChoice = null;
    if (bootstrapAllowed)
      searchStyleChoice =
          queryOptionsDialog.addPopUpMenu(
              "Type of search/resampling:",
              new String[] {
                "Regular Search",
                "Bootstrap",
                "Jackknife",
                "Symmetric Resampled",
                "Poisson Bootstrap"
              },
              searchStyle);
    queryOptionsDialog.addLabel("Regular Search Commands");
    searchField = queryOptionsDialog.addTextAreaSmallFont(searchArguments, 7, 80);
    searchScriptPathField =
        queryOptionsDialog.addTextField(
            "Path to TNT run file containing search commands", searchScriptPath, 40);
    Button browseSearchScriptPathButton =
        queryOptionsDialog.addAListenedButton("Browse...", null, this);
    browseSearchScriptPathButton.setActionCommand("browseSearchScript");
    harvestOnlyStrictConsensusBox =
        queryOptionsDialog.addCheckBox("only acquire strict consensus", harvestOnlyStrictConsensus);
    queryOptionsDialog.addHorizontalLine(1);
    //		Checkbox doBootstrapBox = queryOptionsDialog.addCheckBox("do bootstrapping", doBootstrap);
    if (bootstrapAllowed) {
      bootStrapRepsField =
          queryOptionsDialog.addIntegerField(
              "Resampling Replicates", bootstrapreps, 8, 0, MesquiteInteger.infinite);
      queryOptionsDialog.addLabel("Resampling Search Commands");
      bootstrapSearchField =
          queryOptionsDialog.addTextAreaSmallFont(bootstrapSearchArguments, 7, 80);
      bootSearchScriptPathField =
          queryOptionsDialog.addTextField(
              "Path to TNT run file containing search commands for resampled",
              bootSearchScriptPath,
              30);
      Button browseBootSearchScriptPathButton =
          queryOptionsDialog.addAListenedButton("Browse...", null, this);
      browseSearchScriptPathButton.setActionCommand("browseBootSearchScript");
      resamplingAllConsensusTreesBox =
          queryOptionsDialog.addCheckBox(
              "allow TNT to calculate consensus tree", !resamplingAllConsensusTrees);
    }

    adjustDialogText();
    queryOptionsDialog.addHorizontalLine(1);
    queryOptionsDialog.addNewDialogPanel();
    useDefaultsButton = queryOptionsDialog.addAListenedButton("Set to Defaults", null, this);
    useDefaultsButton.setActionCommand("setToDefaults");

    tabbedPanel.addPanel("Other Options", true);
    convertGapsBox =
        queryOptionsDialog.addCheckBox(
            "convert gaps to missing (to avoid gap=extra state)", convertGapsToMissing);
    queryOptionsDialog.addHorizontalLine(1);
    queryOptionsDialog.addLabel("Post-Search TNT Commands");
    otherOptionsField = queryOptionsDialog.addTextAreaSmallFont(otherOptions, 7, 80);
    queryOptionsDialog.addHorizontalLine(1);
    queryOptionsDialog.addNewDialogPanel();
    useDefaultsOtherOptionsButton =
        queryOptionsDialog.addAListenedButton("Set to Defaults", null, this);
    useDefaultsOtherOptionsButton.setActionCommand("setToDefaultsOtherOptions");

    tabbedPanel.cleanup();
    queryOptionsDialog.nullifyAddPanel();

    queryOptionsDialog.completeAndShowDialog("Search", "Cancel", null, null);

    if (buttonPressed.getValue() == 0) {
      boolean infererOK = (treeInferer == null || treeInferer.optionsChosen());
      if (externalProcRunner.optionsChosen() && infererOK) {
        if (bootstrapAllowed) {
          bootstrapreps = bootStrapRepsField.getValue();
          bootstrapSearchArguments = bootstrapSearchField.getText();
          bootSearchScriptPath = bootSearchScriptPathField.getText();
          harvestOnlyStrictConsensus = harvestOnlyStrictConsensusBox.getState();
          resamplingAllConsensusTrees = !resamplingAllConsensusTreesBox.getState();
          searchStyle = searchStyleChoice.getSelectedIndex();
        }
        numSlaves = slavesField.getValue();
        otherOptions = otherOptionsField.getText();
        convertGapsToMissing = convertGapsBox.getState();
        parallel = parallelCheckBox.getState();
        //				doBootstrap = doBootstrapBox.getState();
        searchArguments = searchField.getText();
        searchScriptPath = searchScriptPathField.getText();
        mxram = maxRamField.getValue();

        storeRunnerPreferences();
      }
    }
    queryOptionsDialog.dispose();
    if (closeWizard) MesquiteDialog.closeWizard();

    return (buttonPressed.getValue() == 0);
  }
コード例 #26
0
    @SuppressWarnings("unchecked")
    @Override
    public void actionPerformed(ActionEvent ae) {
      String action = ae.getActionCommand();

      LinkTriple[] addNodes = null;
      if (action.equals("Fetch")) {
        addNodes = iSparql.ExploreURI(urlText.getText());
        addLinks(addNodes);
        // Cytoscape.getCurrentNetwork().addNode( Cytoscape.getCyNode( urlText.getText(), true ) );
      }
      if (action.equals("Fetch Selected")) {
        CyNetwork network = Cytoscape.getCurrentNetwork();
        Set nodeset = network.getSelectedNodes();
        java.util.List<LinkTriple> nodeList = new LinkedList<LinkTriple>();
        for (Object o : nodeset) {
          CyNode node = (CyNode) o;
          for (LinkTriple newNode : iSparql.ExploreURI(node.getIdentifier())) {
            nodeList.add(newNode);
          }
        }
        if (filterCheckbox.getState())
          addLinks(iSparql.NodeFilter(null, nodeList.toArray(new LinkTriple[0])));
        else addLinks(nodeList.toArray(new LinkTriple[0]));
      }
      if (action.equals("Find Nodes")) {
        CyAttributes nodeAttr = Cytoscape.getNodeAttributes();

        CyNetwork network = Cytoscape.getCurrentNetwork();
        Set nodeset = network.getSelectedNodes();
        java.util.List<Map<String, Object>> nodeList = new LinkedList<Map<String, Object>>();
        for (Object o : nodeset) {
          CyNode node = (CyNode) o;
          Map<String, Object> map = new HashMap<String, Object>();
          String id = node.getIdentifier();
          map.put("ID", id);
          for (String attr : nodeAttr.getAttributeNames()) {
            if (nodeAttr.hasAttribute(id, attr)) {
              System.out.println(id + " " + attr + " " + nodeAttr.getType(attr));
              if (nodeAttr.getType(attr) == CyAttributes.TYPE_STRING) {
                Object iAttr = nodeAttr.getAttribute(id, attr);
                map.put(attr, iAttr);
              }
            }
          }
          nodeList.add(map);
        }
        LinkTriple[] links = iSparql.NodeSearch(null, nodeList, "ID");
        addLinks(links);
      }
      if (action.equals("Edit Namespaces")) {
        Map<String, String> nameMap = prefs.getNameSpaces();
        Map<String, String> newMap = NameSpaceEditor.EditDialog(nameMap);
        for (String key : nameMap.keySet()) {
          prefs.removeNameSpace(key);
        }
        for (String key : newMap.keySet()) {
          prefs.addNameSpace(key, newMap.get(key));
        }
      }
    }
コード例 #27
0
ファイル: Cent.java プロジェクト: Auzzy/personal
  public void keyPressed(KeyEvent e) {
    if (e.getSource() == hard & e.getKeyCode() != e.VK_ENTER)
      if (hard.getText().length() > 0) hard.setText("");
    if (start) {
      if (e.getKeyCode() == e.VK_ENTER) {
        if (end.getState()) {
          norm = false;
          start2 = true;
          hard.show();
          hard.setText("");
          all.clearRect(0, 0, dimX, dimY);
        }
        if (reg.getState()) norm = true;
        start = false;
      }
      repaint();
    } else {
      if (dir == -1) {
        if (e.getKeyCode() == e.VK_LEFT) dir = 0;
        if (e.getKeyCode() == e.VK_UP) dir = 1;
        if (e.getKeyCode() == e.VK_RIGHT) dir = 2;
        if (e.getKeyCode() == e.VK_DOWN) dir = 3;
      }

      if (dir == 0) {
        if (e.getKeyCode() == e.VK_UP) dir2 = 1;
        if (e.getKeyCode() == e.VK_RIGHT) dir2 = 2;
        if (e.getKeyCode() == e.VK_DOWN) dir2 = 3;
      } else if (dir == 1) {
        if (e.getKeyCode() == e.VK_LEFT) dir2 = 0;
        if (e.getKeyCode() == e.VK_RIGHT) dir2 = 2;
        if (e.getKeyCode() == e.VK_DOWN) dir2 = 3;
      } else if (dir == 2) {
        if (e.getKeyCode() == e.VK_LEFT) dir2 = 0;
        if (e.getKeyCode() == e.VK_UP) dir2 = 1;
        if (e.getKeyCode() == e.VK_DOWN) dir2 = 3;
      } else if (dir == 3) {
        if (e.getKeyCode() == e.VK_LEFT) dir2 = 0;
        if (e.getKeyCode() == e.VK_UP) dir2 = 1;
        if (e.getKeyCode() == e.VK_RIGHT) dir2 = 2;
      }
      repaint();

      if (e.getKeyCode() == e.VK_SPACE & !fire) {
        fire = true;
        fireX = youX + 5;
        fireY = youY - 5;
      }
      if (e.getKeyCode() == e.VK_P) {
        if (move) move = false;
        else move = true;
      }
      if (e.getKeyCode() == e.VK_N) {
        lose = false;
        flea = false;
        score = 0;
        level = 1;
        lives = 3;
        setup();
      }
      if (e.getKeyCode() == e.VK_T) {
        buf.clearRect(0, 0, dimX, dimY);
        all.drawImage(img, 0, 0, this);
        start = true;
        lose = false;
        score = 0;
        level = 1;
        lives = 3;
        reg.show();
        end.show();
        setup();
        repaint();
      }
    }
  }