## modules/graphics/src/main/java/javafx/scene/input/KeyCombination.java

Print this page

    rev 4839 : RT-2529: Locale specific runtime errors (Turkish)

      11  * This code is distributed in the hope that it will be useful, but WITHOUT
      12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14  * version 2 for more details (a copy is included in the LICENSE file that
      15  * accompanied this code).
      16  *
      17  * You should have received a copy of the GNU General Public License version
      18  * 2 along with this work; if not, write to the Free Software Foundation,
      19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
      20  *
      21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
      22  * or visit www.oracle.com if you need additional information or have any
      23  * questions.
      24  */
      25
      26 package javafx.scene.input;
      27
      28 import com.sun.javafx.tk.Toolkit;
      29 import java.util.ArrayList;
      30 import java.util.List;

      31
      32 // PENDING_DOC_REVIEW
      33 /**
      34  * Represents a combination of keys which are used in keyboard shortcuts.
      35  * A key combination consists of a main key and a set of modifier keys. The main
      36  * key can be specified by its key code - {@code KeyCodeCombination} or key
      37  * character - {@code KeyCharacterCombination}. A modifier key is {@code shift},
      38  * {@code control}, {@code alt}, {@code meta} or {@code shortcut} and can be
      39  * defined as {@code DOWN}, {@code UP} or {@code ANY}.
      40  * <p>
      41  * The {@code shortcut} modifier is used to represent the modifier key which is
      42  * used commonly in keyboard shortcuts on the host platform. This is for
      43  * example {@code control} on Windows and {@code meta} (command key) on Mac.
      44  * By using {@code shortcut} key modifier developers can create platform
      45  * independent shortcuts. So the "Shortcut+C" key combination is handled
      46  * internally as "Ctrl+C" on Windows and "Meta+C" on Mac.
      47  * @since JavaFX 2.0
      48  */
      49 public abstract class KeyCombination {
      50
     563                                     ? "Conflicting modifiers specified!"
     564                                     : "Duplicate modifiers specified!");
     565                 }
     566
     567                 modifierValue = modifier.getValue();
     568             }
     569         }
     570
     571         return modifierValue;
     572     }
     573
     574     private static String normalizeToken(final String token) {
     575         final String[] words = token.split("\\s+");
     576         final StringBuilder sb = new StringBuilder();
     577
     578         for (final String word: words) {
     579             if (sb.length() > 0) {
     580                 sb.append(' ');
     581             }
     582
     583             sb.append(word.substring(0, 1).toUpperCase());
     584             sb.append(word.substring(1).toLowerCase());
     585         }
     586
     587         return sb.toString();
     588     }
     589
     590     private static String[] splitName(String name) {
     591         List<String> tokens = new ArrayList<String>();
     592         char[] chars = name.trim().toCharArray();
     593
     594         final int STATE_BASIC = 0;      // general text
     595         final int STATE_WHITESPACE = 1; // spaces found
     596         final int STATE_SEPARATOR = 2;  // plus found
     597         final int STATE_QUOTED = 3;     // quoted text
     598
     599         int state = STATE_BASIC;
     600         int tokenStart = 0;
     601         int tokenEnd = -1;
     602
     603         for (int i = 0; i < chars.length; i++) {
     604             char c = chars[i];
      11  * This code is distributed in the hope that it will be useful, but WITHOUT
      12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14  * version 2 for more details (a copy is included in the LICENSE file that
      15  * accompanied this code).
      16  *
      17  * You should have received a copy of the GNU General Public License version
      18  * 2 along with this work; if not, write to the Free Software Foundation,
      19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
      20  *
      21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
      22  * or visit www.oracle.com if you need additional information or have any
      23  * questions.
      24  */
      25
      26 package javafx.scene.input;
      27
      28 import com.sun.javafx.tk.Toolkit;
      29 import java.util.ArrayList;
      30 import java.util.List;
      31 import java.util.Locale;
      32
      33 // PENDING_DOC_REVIEW
      34 /**
      35  * Represents a combination of keys which are used in keyboard shortcuts.
      36  * A key combination consists of a main key and a set of modifier keys. The main
      37  * key can be specified by its key code - {@code KeyCodeCombination} or key
      38  * character - {@code KeyCharacterCombination}. A modifier key is {@code shift},
      39  * {@code control}, {@code alt}, {@code meta} or {@code shortcut} and can be
      40  * defined as {@code DOWN}, {@code UP} or {@code ANY}.
      41  * <p>
      42  * The {@code shortcut} modifier is used to represent the modifier key which is
      43  * used commonly in keyboard shortcuts on the host platform. This is for
      44  * example {@code control} on Windows and {@code meta} (command key) on Mac.
      45  * By using {@code shortcut} key modifier developers can create platform
      46  * independent shortcuts. So the "Shortcut+C" key combination is handled
      47  * internally as "Ctrl+C" on Windows and "Meta+C" on Mac.
      48  * @since JavaFX 2.0
      49  */
      50 public abstract class KeyCombination {
      51
     564                                     ? "Conflicting modifiers specified!"
     565                                     : "Duplicate modifiers specified!");
     566                 }
     567
     568                 modifierValue = modifier.getValue();
     569             }
     570         }
     571
     572         return modifierValue;
     573     }
     574
     575     private static String normalizeToken(final String token) {
     576         final String[] words = token.split("\\s+");
     577         final StringBuilder sb = new StringBuilder();
     578
     579         for (final String word: words) {
     580             if (sb.length() > 0) {
     581                 sb.append(' ');
     582             }
     583
     584             sb.append(word.substring(0, 1).toUpperCase(Locale.ROOT));
     585             sb.append(word.substring(1).toLowerCase(Locale.ROOT));
     586         }
     587
     588         return sb.toString();
     589     }
     590
     591     private static String[] splitName(String name) {
     592         List<String> tokens = new ArrayList<String>();
     593         char[] chars = name.trim().toCharArray();
     594
     595         final int STATE_BASIC = 0;      // general text
     596         final int STATE_WHITESPACE = 1; // spaces found
     597         final int STATE_SEPARATOR = 2;  // plus found
     598         final int STATE_QUOTED = 3;     // quoted text
     599
     600         int state = STATE_BASIC;
     601         int tokenStart = 0;
     602         int tokenEnd = -1;
     603
     604         for (int i = 0; i < chars.length; i++) {
     605             char c = chars[i];