Beispiel #1
1
  /**
   * Sets a mnemomic for the specified button.
   *
   * @param b button
   * @param mnem mnemonics that have already been assigned
   */
  public static void setMnemonic(final AbstractButton b, final StringBuilder mnem) {
    // do not set mnemonics for Mac! Alt+key used for special characters.
    if (Prop.MAC) return;

    // find and assign unused mnemomic
    final String label = b.getText();
    final int ll = label.length();
    for (int l = 0; l < ll; l++) {
      final char ch = Character.toLowerCase(label.charAt(l));
      if (!letter(ch) || mnem.indexOf(Character.toString(ch)) != -1) continue;
      b.setMnemonic(ch);
      mnem.append(ch);
      break;
    }
  }
 private static char solutionAlgorithm(char maxKey, int maxValue, int valuesCounter) {
   // Probably can play with this to make more efficient algorithm
   if (valuesCounter >= LETTERS_NEEDED_TO_DETECT_SPACE) return ' ';
   else if (maxValue >= 3) return Character.toLowerCase(maxKey);
   else if (valuesCounter == maxValue && Character.isUpperCase(maxKey))
     return Character.toLowerCase(maxKey);
   else return UNKNOWN_CHAR;
 }
Beispiel #3
0
  private static Point getDeckPosition(CGraphics g_src, char type) {
    Point result = new Point();

    int offset;
    if (Character.toLowerCase(type) == 'd') offset = -3 * g_src.cardWidth() / 2;
    else offset = g_src.cardWidth() / 2;

    result.x = g_src.displayWidth() / 2 + offset;
    result.y = g_src.displayHeight() / 2 - g_src.cardHeight() / 2;

    return result;
  }
Beispiel #4
0
 // Convenience method for the LookupAction constructor
 private static boolean isVowel(char c) {
   switch (Character.toLowerCase(c)) {
     case 'a':
     case 'e':
     case 'i':
     case 'o':
     case 'u':
       return true;
     default:
       return false;
   }
 }
    /**
     * Handles the mnemonics for the menu items. Will also handle duplicate mnemonics. Perhaps this
     * should be moved into BasicPopupMenuUI. See 4670831
     */
    public void menuKeyPressed(MenuKeyEvent e) {
      // Handle the case for Escape or Enter...
      char keyChar = e.getKeyChar();
      if (!Character.isLetterOrDigit(keyChar)) return;

      MenuSelectionManager manager = e.getMenuSelectionManager();
      MenuElement selectedPath[] = manager.getSelectedPath();

      for (int i = selectedPath.length - 1; i >= 0; i--) {
        if (selectedPath[i] == menuItem) {
          JPopupMenu popupMenu = ((JMenu) menuItem).getPopupMenu();
          MenuElement items[] = popupMenu.getSubElements();

          int index = -1;

          for (int j = 0; j < items.length; j++) {
            int key = ((JMenuItem) items[j]).getMnemonic();
            if (Character.toLowerCase((char) key) == Character.toLowerCase(keyChar)) {
              index = j;
              break;
            }
          }

          if (index != -1) {
            // Invoke the menu action
            JMenuItem item = (JMenuItem) items[index];
            if (!(item instanceof JMenu)) {
              // Let Submenus be handled by menuKeyTyped
              manager.clearSelectedPath();
              item.doClick();
            }
          }

          e.consume();
          return;
        }
      }
    }
Beispiel #6
0
  /**
   * Returns true if the keyword is found.
   *
   * @return result of check
   */
  private boolean found() {
    if (keyword.isEmpty()) return false;

    final int sl = keyword.length();
    final int wl = text.length();
    if (wl < sl) return false;
    final int p = text.pos();
    int s = -1;
    while (++s != sl) {
      if (Character.toLowerCase(text.next()) != keyword.charAt(s)) break;
    }
    text.pos(p);
    return s == sl;
  }
    /**
     * Set the fields from the ProjectionClass
     *
     * @param projClass projection class to use
     */
    private void setFieldsWithClassParams(ProjectionClass projClass) {

      // set the projection in the JComboBox
      String want = projClass.toString();
      for (int i = 0; i < projClassCB.getItemCount(); i++) {
        ProjectionClass pc = (ProjectionClass) projClassCB.getItemAt(i);
        if (pc.toString().equals(want)) {
          projClassCB.setSelectedItem((Object) pc);
          break;
        }
      }

      // set the parameter fields
      paramPanel.removeAll();
      paramPanel.setVisible(0 < projClass.paramList.size());

      List widgets = new ArrayList();
      for (int i = 0; i < projClass.paramList.size(); i++) {
        ProjectionParam pp = (ProjectionParam) projClass.paramList.get(i);
        // construct the label
        String name = pp.name;
        String text = "";
        // Create a decent looking label
        for (int cIdx = 0; cIdx < name.length(); cIdx++) {
          char c = name.charAt(cIdx);
          if (cIdx == 0) {
            c = Character.toUpperCase(c);
          } else {
            if (Character.isUpperCase(c)) {
              text += " ";
              c = Character.toLowerCase(c);
            }
          }
          text += c;
        }
        widgets.add(GuiUtils.rLabel(text + ": "));
        // text input field
        JTextField tf = new JTextField();
        pp.setTextField(tf);
        tf.setColumns(12);
        widgets.add(tf);
      }
      GuiUtils.tmpInsets = new Insets(4, 4, 4, 4);
      JPanel widgetPanel = GuiUtils.doLayout(widgets, 2, GuiUtils.WT_N, GuiUtils.WT_N);

      paramPanel.add("North", widgetPanel);
      paramPanel.add("Center", GuiUtils.filler());
    }
Beispiel #8
0
 public void keyTyped(char ch) {
   if (this.emuSys != null) {
     if (this.emuSys.getSwapKeyCharCase()) {
       if (Character.isUpperCase(ch)) {
         ch = Character.toLowerCase(ch);
       } else if (Character.isLowerCase(ch)) {
         ch = Character.toUpperCase(ch);
       }
     }
     if (this.emuSys.getConvertKeyCharToISO646DE()) {
       this.emuSys.keyTyped(TextUtil.toISO646DE(ch));
     } else {
       this.emuSys.keyTyped(ch);
     }
   }
 }
  public static int findDisplayedMnemonicIndex(String text, int mnemonic) {
    if (text == null || mnemonic == '\0') {
      return -1;
    }

    char uc = Character.toUpperCase((char) mnemonic);
    char lc = Character.toLowerCase((char) mnemonic);

    int uci = text.indexOf(uc);
    int lci = text.indexOf(lc);

    if (uci == -1) {
      return lci;
    } else if (lci == -1) {
      return uci;
    } else {
      return (lci < uci) ? lci : uci;
    }
  }
  public void go(String[] userInput) {
    if (userInput.length == 0) {
      txtTranscript.insert("You did not specify a direction.\n", txtTranscript.getText().length());
    } else {
      char direction = Character.toLowerCase(userInput[0].charAt(0));

      if (direction == 'n') {
        if (row > MINROW) {
          txtTranscript.insert("Moving north . . .\n", txtTranscript.getText().length());
          row--;
        } else {
          txtTranscript.insert("North is out of bounds..\n", txtTranscript.getText().length());
        }
      } else if (direction == 'e') {
        if (col < MAXCOL) {
          txtTranscript.insert("Moving east . . .\n", txtTranscript.getText().length());
          col++;
        } else {
          txtTranscript.insert("East is out of bounds..\n", txtTranscript.getText().length());
        }
      } else if (direction == 's') {
        if (row < MAXROW) {
          txtTranscript.insert("Moving south . . .\n", txtTranscript.getText().length());
          row++;
        } else {
          txtTranscript.insert("South is out of bounds..\n", txtTranscript.getText().length());
        }
      } else if (direction == 'w') {
        if (col > MINCOL) {
          txtTranscript.insert("Moving west . . .\n", txtTranscript.getText().length());
          col--;
        } else {
          txtTranscript.insert("West is out of bounds.\n", txtTranscript.getText().length());
        }
      } else {
        txtTranscript.insert(
            "Which direction did you want to go?\n", txtTranscript.getText().length());
      }
      printLocation();
    }
  }
 public static String lowercaseFirstLetter(String name, boolean lowercaseFirstLetter) {
   if (lowercaseFirstLetter && !isAllUppercaseName(name)) {
     name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
   }
   return name;
 }
  @NotNull
  private Pattern getPattern(String pattern) {
    if (!Comparing.strEqual(pattern, myPattern)) {
      myCompiledPattern = null;
      myPattern = pattern;
    }
    if (myCompiledPattern == null) {
      boolean allowToLower = true;
      final int eol = pattern.indexOf('\n');
      if (eol != -1) {
        pattern = pattern.substring(0, eol);
      }
      if (pattern.length() >= 80) {
        pattern = pattern.substring(0, 80);
      }

      final @NonNls StringBuffer buffer = new StringBuffer();

      if (containsOnlyUppercaseLetters(pattern)) {
        allowToLower = false;
      }

      if (allowToLower) {
        buffer.append(".*");
      }

      boolean firstIdentifierLetter = true;
      for (int i = 0; i < pattern.length(); i++) {
        final char c = pattern.charAt(i);
        if (Character.isLetterOrDigit(c)) {
          // This logic allows to use uppercase letters only to catch the name like PDM for
          // PsiDocumentManager
          if (Character.isUpperCase(c) || Character.isDigit(c)) {

            if (!firstIdentifierLetter) {
              buffer.append("[^A-Z]*");
            }

            buffer.append("[");
            buffer.append(c);
            if (allowToLower || i == 0) {
              buffer.append('|');
              buffer.append(Character.toLowerCase(c));
            }
            buffer.append("]");
          } else if (Character.isLowerCase(c)) {
            buffer.append('[');
            buffer.append(c);
            buffer.append('|');
            buffer.append(Character.toUpperCase(c));
            buffer.append(']');
          } else {
            buffer.append(c);
          }

          firstIdentifierLetter = false;
        } else if (c == '*') {
          buffer.append(".*");
          firstIdentifierLetter = true;
        } else if (c == '.') {
          buffer.append("\\.");
          firstIdentifierLetter = true;
        } else if (c == ' ') {
          buffer.append("[^A-Z]*\\ ");
          firstIdentifierLetter = true;
        } else {
          firstIdentifierLetter = true;
          // for standard RegExp engine
          // buffer.append("\\u");
          // buffer.append(Integer.toHexString(c + 0x20000).substring(1));

          // for OROMATCHER RegExp engine
          buffer.append("\\x");
          buffer.append(Integer.toHexString(c + 0x20000).substring(3));
        }
      }

      buffer.append(".*");

      try {
        myCompiledPattern = new Perl5Compiler().compile(buffer.toString());
      } catch (MalformedPatternException e) {
        // do nothing
      }
    }

    return myCompiledPattern;
  }
Beispiel #13
0
 private static boolean eq(char c1, char c2) {
   return Character.toLowerCase(c1) == c2;
 }
Beispiel #14
0
 public boolean isCircumflex(char c, char ch) {
   if (fCirc.indexOf(c) < 0) return false;
   return eq(c, Character.toLowerCase(ch));
 }
 private char lower(char keyChar) {
   return Character.toLowerCase(keyChar);
 }