Exemplo n.º 1
0
 @Override
 public void keyReleased(KeyEvent e) {
   String s = search.getText().toLowerCase().trim();
   if (s.equals("") == false) {
     // First pass: Starts with (So that Ney is prioritized before McCartney)
     for (Integer id : planetNames.keySet()) {
       String name = planetNames.get(id).toLowerCase();
       if (name.startsWith(s)) {
         universe.centerOnPoint(planetCoordinates.get(id));
         return;
       }
     }
     // Second pass: Contains
     for (Integer id : planetNames.keySet()) {
       String name = planetNames.get(id).toLowerCase();
       if (name.contains(s)) {
         universe.centerOnPoint(planetCoordinates.get(id));
         return;
       }
     }
   }
 }
Exemplo n.º 2
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == hw) {
     PartialPlanetBlock planet = getPlanet(-1, settings.playerNr);
     if (planet != null) {
       Point p = planetCoordinates.get(planet.planetNumber);
       if (p != null) universe.centerOnPoint(p);
     }
   } else if (e.getSource() == names) {
     repaint();
   } else if (e.getSource() == colorize) {
     repaint();
   }
 }