コード例 #1
0
    private void analyzeParents(FamilyMember m) {
      HistoricalFigure father = m.hf.getHfLink("father");
      FamilyMember m1 = null, m2 = null;
      if (father.getId() != -1) {
        try {
          m1 = get(father.getId(), new FamilyMember(father, m.generation - 1, m.distance + 1));
          if (!m1.getRelation().equals("")) {
            m.father = m1;
            analyzeParents(m1);
            addMember(m1);

            if (m.generation == 0) analyzeChildren(m1);
          } else {
            m1 = null;
          }
        } catch (MemeberExistsException e) {
        }
      }
      HistoricalFigure mother = m.hf.getHfLink("mother");
      if (mother.getId() != -1) {
        try {
          m2 = get(mother.getId(), new FamilyMember(mother, m.generation - 1, m.distance + 1));
          if (!m2.getRelation().equals("")) {
            m.mother = m2;
            analyzeParents(m2);
            addMember(m2);
          } else {
            m2 = null;
          }
        } catch (MemeberExistsException e) {
        }
      }
      if (m1 != null && m2 != null) {
        m1.spouse = m2;
        m2.spouse = m1;
        links.add(new FamilyLink("spouse", m1, m2));
      }
      if (m1 != null) {
        links.add(new FamilyLink("child", m1, m));
        m1.children.add(m);
      }
      if (m2 != null) {
        links.add(new FamilyLink("child", m2, m));
        m2.children.add(m);
      }
    }
コード例 #2
0
 private void analyzeSpouse(FamilyMember m) {
   HistoricalFigure spouse = m.hf.getHfLink("spouse");
   if (spouse.getId() != -1) {
     FamilyMember m2;
     try {
       m2 = get(spouse.getId(), new FamilyMember(spouse, m.generation, m.distance + 1));
       if (!m2.getRelation().equals("")) {
         m.spouse = m2;
         m2.spouse = m;
         links.add(new FamilyLink("spouse", m, m2));
         addMember(m2, m);
       }
     } catch (MemeberExistsException e) {
     }
   }
 }
コード例 #3
0
 private void analyzeChildren(FamilyMember m) {
   List<HistoricalFigure> children = m.hf.getHfLinks("child");
   for (HistoricalFigure c : children) {
     FamilyMember m3;
     try {
       m3 = get(c.getId(), new FamilyMember(c, m.generation + 1, m.distance + 1));
       if (!m3.getRelation().equals("")) {
         m.children.add(m3);
         links.add(new FamilyLink("child", m, m3));
         m3.strongLink = true;
         addMember(m3);
         analyzeSpouse(m3);
         analyzeChildren(m3);
       }
     } catch (MemeberExistsException e) {
     }
   }
 }