public PropertyAction(RADProperty<?> aProperty) { super(); property = (RADProperty<Object>) aProperty; String name = (String) aProperty.getValue("actionName"); // NOI18N if (name == null) { StringBuilder sb = new StringBuilder(aProperty.getName()); sb.setCharAt(0, Character.toUpperCase(sb.charAt(0))); name = sb.toString(); } putValue(Action.NAME, name); }
// keyboard discovery code private void _mapKey(char charCode, int keyindex, boolean shift, boolean altgraph) { log("_mapKey: " + charCode); // if character is not in map, add it if (!charMap.containsKey(new Integer(charCode))) { log("Notified: " + (char) charCode); KeyEvent event = new KeyEvent( applet(), 0, 0, (shift ? KeyEvent.SHIFT_MASK : 0) + (altgraph ? KeyEvent.ALT_GRAPH_MASK : 0), ((Integer) vkKeys.get(keyindex)).intValue(), (char) charCode); charMap.put(new Integer(charCode), event); log("Mapped char " + (char) charCode + " to KeyEvent " + event); if (((char) charCode) >= 'a' && ((char) charCode) <= 'z') { // put shifted version of a-z in automatically int uppercharCode = (int) Character.toUpperCase((char) charCode); event = new KeyEvent( applet(), 0, 0, KeyEvent.SHIFT_MASK + (altgraph ? KeyEvent.ALT_GRAPH_MASK : 0), ((Integer) vkKeys.get(keyindex)).intValue(), (char) uppercharCode); charMap.put(new Integer(uppercharCode), event); log("Mapped char " + (char) uppercharCode + " to KeyEvent " + event); } } }
private static void uppercaseFirstLetter(final StringBuffer buf) { if (buf.length() > 1) { char[] firstLetter = new char[1]; buf.getChars(0, 1, firstLetter, 0); buf.setCharAt(0, Character.toUpperCase(firstLetter[0])); } }
public void actionPerformed(ActionEvent e) { if (e.getSource() == from) { String tmpFrom = from.getText().trim(); String tmpTo = to.getText().trim(); if (tmpFrom.equals("MST") || tmpFrom.equals("mst")) findMinSpan(); else { try { // check if from exists // String str = from.getText(); // fixa så man kan skippa att skriva första med stor bokstav tmpFrom = Character.toUpperCase(tmpFrom.charAt(0)) + tmpFrom.substring(1); int pos = noderna.findLeading(tmpFrom).getNodeNo(); route.setText(introText + "\n"); from.setText(noderna.find(pos).toString()); } catch (NullPointerException npe) { route.setText(felTextStart + "\n"); return; } if (!tmpTo.equals("")) { findShort(); } } } else if (e.getSource() == to) { String tmpFrom = from.getText().trim(); String tmpTo = to.getText().trim(); if (tmpTo.equals("MST") || tmpTo.equals("mst")) findMinSpan(); else { try { // check if to exists // String str = to.getText(); tmpTo = Character.toUpperCase(tmpTo.charAt(0)) + tmpTo.substring(1); int pos = noderna.findLeading(tmpTo).getNodeNo(); route.setText(introText + "\n"); to.setText(noderna.find(pos).toString()); } catch (NullPointerException npe) { route.setText(felTextStart + "\n"); return; } if (!tmpFrom.equals("")) { findShort(); } } /* else if ( ! from.getText().equals("") ) findShort(); */ } }
// ==================================================================== private void findShort() { // svårt att behålla linjefärgerna? int start, s**t; try { // read from station String str = from.getText(); str = Character.toUpperCase(str.charAt(0)) + str.substring(1); start = noderna.find(str).getNodeNo(); } catch (NullPointerException npe) { route.setText(felTextStart + "\n"); return; } try { // read to station String str = to.getText(); str = Character.toUpperCase(str.charAt(0)) + str.substring(1); s**t = noderna.find(str).getNodeNo(); } catch (NullPointerException npe) { route.setText(felTextSlut + "\n"); return; } double totWeight = 0; int totNodes = 0; route.setText(""); karta.clearLayer(DrawGraph.Layer.OVERLAY); Iterator<BusEdge> it = grafen.shortestPath(start, s**t); while (it.hasNext()) { BusEdge e = it.next(); route.append(makeText1(e) + "\n"); totNodes++; totWeight += e.getWeight(); // draw the shortest path BusStop from = noderna.find(e.from), to = noderna.find(e.to); karta.drawLine( from.xpos, from.ypos, to.xpos, to.ypos, Color.black, 4.0, DrawGraph.Layer.OVERLAY); } karta.repaint(); route.append("Antal: " + totNodes + " totalvikt: " + totWeight + "\n"); from.setText(""); to.setText(""); } // findShort
/** * 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()); }
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 String ucWords(String wordsToConvert) { wordsToConvert = wordsToConvert.toLowerCase(); Boolean ucChar = false; String convertedString = ""; for (int i = 0; i < wordsToConvert.length(); i++) { if (i == 0 | ucChar) { convertedString += Character.toUpperCase(wordsToConvert.charAt(i)); } else { convertedString += Character.toString(wordsToConvert.charAt(i)); } if (Character.isWhitespace(wordsToConvert.charAt(i))) { ucChar = true; } else { ucChar = false; } } return convertedString; }
private LogLevelWrapper(LogLevel logLevel) { this.logLevel = logLevel; String temp = logLevel .toString() .toLowerCase() .replace('_', ' '); // replace underscores in the name with spaces this.toString = Character.toUpperCase(temp.charAt(0)) + temp.substring(1); // add the command line character to the end (so if an error message says use a log level, you // can easily translate) String commandLineCharacter = new LoggingCommandLineConverter().getLogLevelCommandLine(logLevel); if (commandLineCharacter != null && !commandLineCharacter.equals("")) { this.toString += " (-" + commandLineCharacter + ")"; } }
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; } }
private OptionInfo getMenuInfo(Action each) { final String text = (String) each.getValue(Action.NAME); int mnemonic = -1; int mnemonicIndex = -1; StringBuilder plainText = new StringBuilder(); for (int i = 0; i < text.length(); i++) { char ch = text.charAt(i); if (ch == '&' || ch == '_') { if (i + 1 < text.length()) { final char mnemonicsChar = text.charAt(i + 1); mnemonic = Character.toUpperCase(mnemonicsChar); mnemonicIndex = i; } continue; } plainText.append(ch); } return new OptionInfo(plainText.toString(), mnemonic, mnemonicIndex, this, each); }
@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; }