예제 #1
0
 protected void setActive(Component component, boolean active) {
   if (component instanceof Tile) {
     Tile tile = (Tile) component;
     if (active) {
       tile.addTiledView(_points);
       tile.addMouseListener(_ml);
       tile.addMouseWheelListener(_mwl);
       InputMap im = tile.getInputMap();
       ActionMap am = tile.getActionMap();
       im.put(KS_BACK_SPACE, "backspace");
       im.put(KS_UP, "up");
       im.put(KS_DOWN, "down");
       am.put("backspace", _bsa);
       am.put("up", _uaa);
       am.put("down", _daa);
     } else {
       tile.removeTiledView(_points);
       tile.removeMouseListener(_ml);
       tile.removeMouseWheelListener(_mwl);
       InputMap im = tile.getInputMap();
       ActionMap am = tile.getActionMap();
       im.remove(KS_BACK_SPACE);
       im.remove(KS_UP);
       im.remove(KS_DOWN);
       am.remove("backspace");
       am.remove("up");
       am.remove("down");
     }
   }
 }
예제 #2
0
 // -------->
 // original code:
 // ftp://ftp.oreilly.de/pub/examples/english_examples/jswing2/code/goodies/Mapper.java
 // modified by terai
 //     private Hashtable<Object, ArrayList<KeyStroke>> buildReverseMap(InputMap im) {
 //         Hashtable<Object, ArrayList<KeyStroke>> h = new Hashtable<>();
 //         if (Objects.isNull(im.allKeys())) {
 //             return h;
 //         }
 //         for (KeyStroke ks: im.allKeys()) {
 //             Object name = im.get(ks);
 //             if (h.containsKey(name)) {
 //                 h.get(name).add(ks);
 //             } else {
 //                 ArrayList<KeyStroke> keylist = new ArrayList<>();
 //                 keylist.add(ks);
 //                 h.put(name, keylist);
 //             }
 //         }
 //         return h;
 //     }
 private void loadBindingMap(Integer focusType, InputMap im, ActionMap am) {
   if (Objects.isNull(im.allKeys())) {
     return;
   }
   ActionMap tmpAm = new ActionMap();
   for (Object actionMapKey : am.allKeys()) {
     tmpAm.put(actionMapKey, am.get(actionMapKey));
   }
   for (KeyStroke ks : im.allKeys()) {
     Object actionMapKey = im.get(ks);
     Action action = am.get(actionMapKey);
     if (Objects.isNull(action)) {
       model.addBinding(new Binding(focusType, "____" + actionMapKey.toString(), ks.toString()));
     } else {
       model.addBinding(new Binding(focusType, actionMapKey.toString(), ks.toString()));
     }
     tmpAm.remove(actionMapKey);
   }
   if (Objects.isNull(tmpAm.allKeys())) {
     return;
   }
   for (Object actionMapKey : tmpAm.allKeys()) {
     model.addBinding(new Binding(focusType, actionMapKey.toString(), ""));
   }
 }