示例#1
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);
  }
示例#2
0
  public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting() == false) {
      if (e.getSource() == list) {
        if (list.getSelectedIndex() != -1) {
          Person person = list.getSelectedValue();
          setPerson(person);
        }
      }

      if (e.getSource() == eventList) {
        if (eventList.getSelectedIndex() != -1) {
          int index = eventList.getSelectedIndex();
          Event event = events[index];

          eventText.setText(Utils.formatDate(event.getDate()) + ": " + event.getNote());
        }
      }
    }
  }