Example #1
0
  public void updateSearch() {
    if (search.getText().length() > 0) {
      Vector<Person> subset = new Vector<Person>();
      for (Person person : people) {
        if (person.fullName().contains(search.getText())) {
          subset.add(person);
        }
      }

      list.setListData(subset);
    } else {
      list.setListData(people);
    }
  }
Example #2
0
  public void setPerson(Person person) {
    personName.setText(person.fullName());
    lAge.setText("Age: " + person.ageYears());
    lBirth.setText("Born: " + Utils.formatDate(person.birthDate));
    if (person.isAlive()) lDeath.setText("Died: N/A");
    else lDeath.setText("Died: " + Utils.formatDate(person.deathDate));
    lEyeColor.setText("Eye Color: " + person.eyeColor);
    lHairColor.setText("Hair Color: " + person.hairColor);
    lHeight.setText("Height: " + person.height);
    lInt.setText("Intelligence: " + person.intelligence.geneString());
    lFriends.setText("Friends: " + person.friendships.size());

    // father.setText("");
    // mother.setText("");
    father.setListData(new Person[] {});
    mother.setListData(new Person[] {});
    Vector<Person> listValues = new Vector<Person>();
    for (Relationship rel : Relationship.values()) {
      List<Person> rels = person.relations.get(rel);
      for (Person p : rels) {
        // listValues.add(rel.name(p.gender) + ": " + p.fullName());
        if (rel == Relationship.Parent && p.gender == 'M') father.setListData(new Person[] {p});
        else if (rel == Relationship.Parent && p.gender == 'F')
          mother.setListData(new Person[] {p});

        listValues.add(p);
      }
    }

    relations.setListData(listValues);
    ((PersonRelationListRenderer) (relations.getCellRenderer())).setRelative(person);

    events = town.getEventManager().getEventsByPerson(person);
    String[] data = new String[events.length];

    for (int i = 0; i < events.length; i++) {
      data[i] = Utils.formatDate(events[i].getDate()) + ": " + events[i].getNote();
    }

    eventList.setListData(data);
  }