Author: kono
Date: 2011-06-08 17:00:03 -0700 (Wed, 08 Jun 2011)
New Revision: 25681
Modified:
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/AcceleratorParser.java
Log:
Code had been re-formated because it was broken. NO FUNCTIONAL CHANGES.
Modified:
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/AcceleratorParser.java
===================================================================
---
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/AcceleratorParser.java
2011-06-08 21:57:08 UTC (rev 25680)
+++
core3/swing-application-api/trunk/src/main/java/org/cytoscape/application/swing/AcceleratorParser.java
2011-06-09 00:00:03 UTC (rev 25681)
@@ -39,124 +39,124 @@
*/
final class AcceleratorParser {
- private static final Logger logger =
LoggerFactory.getLogger(AcceleratorParser.class);
+ private static final Logger logger =
LoggerFactory.getLogger(AcceleratorParser.class);
- private static final String PREFIX = "VK_";
- private static final String FUNCTION_KEY = "fn";
+ private static final String PREFIX = "VK_";
+ private static final String FUNCTION_KEY = "fn";
- private static final Map<String, Integer> MOD_MAP = new HashMap<String,
Integer>();
+ private static final Map<String, Integer> MOD_MAP = new HashMap<String,
Integer>();
- static {
- MOD_MAP.put("command",
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
- MOD_MAP.put("cmd",
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
- MOD_MAP.put("meta",
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
- MOD_MAP.put("control",
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
- MOD_MAP.put("ctrl",
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
- MOD_MAP.put("shift", InputEvent.SHIFT_MASK);
- MOD_MAP.put("alt", InputEvent.ALT_MASK);
- MOD_MAP.put("option", InputEvent.ALT_MASK);
- MOD_MAP.put("opt", InputEvent.ALT_MASK);
- MOD_MAP.put("fn1", KeyEvent.VK_F1);
- MOD_MAP.put("fn2", KeyEvent.VK_F2);
- MOD_MAP.put("fn3", KeyEvent.VK_F3);
- MOD_MAP.put("fn4", KeyEvent.VK_F4);
- MOD_MAP.put("fn5", KeyEvent.VK_F5);
- MOD_MAP.put("fn6", KeyEvent.VK_F6);
- MOD_MAP.put("fn7", KeyEvent.VK_F7);
- MOD_MAP.put("fn8", KeyEvent.VK_F8);
- MOD_MAP.put("fn9", KeyEvent.VK_F9);
- MOD_MAP.put("fn10", KeyEvent.VK_F10);
- }
+ static {
+ MOD_MAP.put("command",
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
+ MOD_MAP.put("cmd",
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
+ MOD_MAP.put("meta",
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
+ MOD_MAP.put("control",
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
+ MOD_MAP.put("ctrl",
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
+ MOD_MAP.put("shift", InputEvent.SHIFT_MASK);
+ MOD_MAP.put("alt", InputEvent.ALT_MASK);
+ MOD_MAP.put("option", InputEvent.ALT_MASK);
+ MOD_MAP.put("opt", InputEvent.ALT_MASK);
+ MOD_MAP.put("fn1", KeyEvent.VK_F1);
+ MOD_MAP.put("fn2", KeyEvent.VK_F2);
+ MOD_MAP.put("fn3", KeyEvent.VK_F3);
+ MOD_MAP.put("fn4", KeyEvent.VK_F4);
+ MOD_MAP.put("fn5", KeyEvent.VK_F5);
+ MOD_MAP.put("fn6", KeyEvent.VK_F6);
+ MOD_MAP.put("fn7", KeyEvent.VK_F7);
+ MOD_MAP.put("fn8", KeyEvent.VK_F8);
+ MOD_MAP.put("fn9", KeyEvent.VK_F9);
+ MOD_MAP.put("fn10", KeyEvent.VK_F10);
+ }
- /**
- * Parses an accelerator combination.
- *
- * A well formed accelerator combination has the following syntax:
- *
- * <pre>
- * <modifiers>* <virtualKey>
- * modifiers := command | cmd | meta | control |
- * ctrl | shift | alt | option | opt
- * virtualKey := a constant in java.awt.event.KeyEvent beginning with
VK_
- * </pre>
- * <p>
- * Modifiers do not necessarily have the same meaning as those listed in
- * <code>KeyEvent</code> or <code>InputEvent</code>. Modifiers have the
- * following meanings:
- * <ul>
- * <li><code>command</code>, <code>cmd</code>, <code>meta</code>,
- * <code>control</code>, <code>ctrl</code>: the Control key for Windows and
- * Linux users or the Apple key for Mac users</li>
- * <li><code>shift</code>: the Shift key</li>
- * <li><code>alt</code>, <code>option</code>, <code>opt</code>: the Alt
key,
- * also called the Option key on Mac keyboards</li>
- * </ul>
- * </p>
- *
- * <p>
- * Examples of valid accelerator combinations:
- * <ul>
- * <li><code>cmd shift a</code></li>
- * <li><code>insert</code></li>
- * <li><code>shift circumflex</code></li>
- * </ul>
- * </p>
- *
- * @param string
- * A well formatted accelerator combination described above.
- */
- static KeyStroke parse(final String string) {
+ /**
+ * Parses an accelerator combination.
+ *
+ * A well formed accelerator combination has the following syntax:
+ *
+ * <pre>
+ * <modifiers>* <virtualKey>
+ * modifiers := command | cmd | meta | control |
+ * ctrl | shift | alt | option | opt
+ * virtualKey := a constant in java.awt.event.KeyEvent beginning
with VK_
+ * </pre>
+ * <p>
+ * Modifiers do not necessarily have the same meaning as those listed in
+ * <code>KeyEvent</code> or <code>InputEvent</code>. Modifiers have the
+ * following meanings:
+ * <ul>
+ * <li><code>command</code>, <code>cmd</code>, <code>meta</code>,
+ * <code>control</code>, <code>ctrl</code>: the Control key for Windows
and
+ * Linux users or the Apple key for Mac users</li>
+ * <li><code>shift</code>: the Shift key</li>
+ * <li><code>alt</code>, <code>option</code>, <code>opt</code>: the Alt
key,
+ * also called the Option key on Mac keyboards</li>
+ * </ul>
+ * </p>
+ *
+ * <p>
+ * Examples of valid accelerator combinations:
+ * <ul>
+ * <li><code>cmd shift a</code></li>
+ * <li><code>insert</code></li>
+ * <li><code>shift circumflex</code></li>
+ * </ul>
+ * </p>
+ *
+ * @param string
+ * A well formatted accelerator combination described above.
+ */
+ static KeyStroke parse(final String string) {
- // Special case: function keys
- if (string.startsWith(FUNCTION_KEY))
- return KeyStroke.getKeyStroke(MOD_MAP.get(string), 0);
+ // Special case: function keys
+ if (string.startsWith(FUNCTION_KEY))
+ return KeyStroke.getKeyStroke(MOD_MAP.get(string), 0);
- int keyCode = 0;
- int modifierCode = 0;
- final StringTokenizer tokenizer = new StringTokenizer(string);
+ int keyCode = 0;
+ int modifierCode = 0;
+ final StringTokenizer tokenizer = new StringTokenizer(string);
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- if (tokenizer.hasMoreTokens())
- modifierCode |= lookupModifier(token);
- else
- keyCode = lookupVKCode(token);
- }
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ if (tokenizer.hasMoreTokens())
+ modifierCode |= lookupModifier(token);
+ else
+ keyCode = lookupVKCode(token);
+ }
- if (keyCode == 0)
- return null;
+ if (keyCode == 0)
+ return null;
- return KeyStroke.getKeyStroke(keyCode, modifierCode);
- }
+ return KeyStroke.getKeyStroke(keyCode, modifierCode);
+ }
- private static int lookupModifier(String mod) {
- final Integer modifier = MOD_MAP.get(mod.toLowerCase());
- if (modifier == null) {
- logger.warn("The modifier '" + mod + "' is invalid; valid modifiers
are: " + MOD_MAP.keySet().toString());
- return 0;
+ private static int lookupModifier(String mod) {
+ final Integer modifier = MOD_MAP.get(mod.toLowerCase());
+ if (modifier == null) {
+ logger.warn("The modifier '" + mod + "' is invalid;
valid modifiers are: " + MOD_MAP.keySet().toString());
+ return 0;
+ }
+ return modifier;
}
- return modifier;
- }
- private static int lookupVKCode(final String name) {
+ private static int lookupVKCode(final String name) {
- String newName = name.toUpperCase();
- if (newName.startsWith(PREFIX) == false)
- newName = PREFIX + newName;
+ String newName = name.toUpperCase();
+ if (newName.startsWith(PREFIX) == false)
+ newName = PREFIX + newName;
- final String error = "The virtual key '" + newName + "' does not
exist.";
+ final String error = "The virtual key '" + newName + "' does
not exist.";
- int code = 0;
- try {
- code = KeyEvent.class.getField(newName).getInt(KeyEvent.class);
- } catch (NoSuchFieldException ex) {
- code = 0;
- logger.warn(error);
- } catch (IllegalAccessException ex) {
- code = 0;
- logger.warn(error);
+ int code = 0;
+ try {
+ code =
KeyEvent.class.getField(newName).getInt(KeyEvent.class);
+ } catch (NoSuchFieldException ex) {
+ code = 0;
+ logger.warn(error);
+ } catch (IllegalAccessException ex) {
+ code = 0;
+ logger.warn(error);
+ }
+
+ return code;
}
-
- return code;
- }
}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.