Example #1
0
 private void refreshIfNeeded() {
   Log.e(tag, "refreshing");
   if (MainModel.isChanged()) {
     clearFamilyStoryLines();
     clearLifeStory();
     clearSpouseLine();
     mMap.clear();
     mMap.setMapType(Settings.getMapType());
     showEvents();
   }
   MainModel.setChanged(false);
 }
Example #2
0
 private void showEvents() {
   for (String eventId : MainModel.events.keySet()) {
     if (MainModel.isEventVisible(eventId)) {
       showEvent(eventId);
     }
   }
 }
Example #3
0
  private void setUpMap() {
    mMap.setOnMarkerClickListener(
        new GoogleMap.OnMarkerClickListener() {
          @Override
          public boolean onMarkerClick(Marker marker) {
            //              Log.e(tag, "clicked on marker");
            String eventId = marker.getSnippet();
            setEvent(eventId);
            refreshIfNeeded();
            return false;
          }
        });

    mMap.setMapType(Settings.getMapType());

    computeMarkerColors();

    showEvents();

    selEventId = ((MapActivityInterface) getActivity()).getEventId();
    if (selEventId != null) {
      Log.e(tag, "Setting up initial event");
      setEvent(selEventId);
      Event e = MainModel.getEvent(selEventId);
      mMap.animateCamera(
          CameraUpdateFactory.newLatLngZoom(new LatLng(e.getLat(), e.getLng()), 12.0f));
    }
    //        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude,
    //              longitude), 12.0f));
  }
Example #4
0
  private void setEvent(String eventId) {
    Event e = MainModel.getEvent(eventId);
    Person p = MainModel.getPerson(e.getPersonId());
    String eventText =
        p.getFirstName()
            + " "
            + p.getLastName()
            + System.getProperty("line.separator")
            + e.fullDescription();
    //        Log.e(tag, "setting event text to " + eventText);
    event_text.setText(eventText);
    selPersonId = e.getPersonId();
    selEventId = eventId;
    updateLines();

    showGenderImage(p.getGender());
  }
Example #5
0
  private void recDrawFamilyStoryLines(Event event, int width) {
    //    Log.e(tag, "Called recDraw with event "+event.toString()+" width: "+width);
    Person p = event.getPerson();
    Person mother = MainModel.getPerson(p.getMotherId());
    Person father = MainModel.getPerson(p.getFatherId());
    if (mother != null) {
      Event firstMotherEvent = mother.getEarliestEvent();
      drawFamilyStoryLine(event, firstMotherEvent, width);
      ;
      recDrawFamilyStoryLines(firstMotherEvent, width - Settings.FAMILY_LINE_DEC);
    }

    if (father != null) {
      Event firstFatherEvent = father.getEarliestEvent();
      drawFamilyStoryLine(event, firstFatherEvent, width);
      recDrawFamilyStoryLines(firstFatherEvent, width - Settings.FAMILY_LINE_DEC);
    }
  }
Example #6
0
  private void updateSpouseLines() {
    clearSpouseLine();

    if (!Settings.isSpouseLinesEnabled()) return;

    Event selEvent = MainModel.getEvent(selEventId);
    Person p = selEvent.getPerson();
    Person spouse = MainModel.getPerson(p.getSpouseId());

    if (spouse == null || selEvent == null) return;

    Event firstSpouseEvent = spouse.getEarliestEvent();

    if (firstSpouseEvent == null) return;

    if (!MainModel.isEventVisible(selEvent.getId())
        || !MainModel.isEventVisible(firstSpouseEvent.getId())) return;
    spouseLine =
        drawLine(selEvent, firstSpouseEvent, SPOUSE_LINE_WIDTH, Settings.getSpouseLineColor());
  }
Example #7
0
  private void updateLifeStory() {
    //      Log.e(tag, "updating life story");
    ArrayList<Event> events = MainModel.getPerson(selPersonId).getSortedEvents();
    ArrayList<Event> visibleEvents = new ArrayList<Event>();
    for (int i = 0; i < events.size(); i++) {
      Event curr_event = events.get(i);
      if (MainModel.isEventVisible(curr_event.getId())) {
        visibleEvents.add(curr_event);
        //                Log.e(tag, "visible event: "+curr_event.toString());
      }
    }

    clearLifeStory();
    if (!Settings.isLifeLinesEnabled()) return;

    for (int j = 1; j < visibleEvents.size(); j++) {
      Event event1 = visibleEvents.get(j - 1);
      Event event2 = visibleEvents.get(j);
      lifeStory.add(drawLine(event1, event2, LIFE_STORY_WIDTH, Settings.getLifeStoryColor()));
    }
  }
Example #8
0
 private void showEvent(String eventId) {
   Event e = MainModel.getEvent(eventId);
   LatLng pos =
       new LatLng(
           e.getLat() + Math.random() / MARKER_FUDGE_DENOM,
           e.getLng() + Math.random() / MARKER_FUDGE_DENOM);
   String description = e.getDescription();
   float event_color =
       (description_hues.containsKey(description))
           ? description_hues.get(description)
           : DEFAULT_MARKER_COLOR;
   mMap.addMarker(
       new MarkerOptions()
           .position(pos)
           .snippet(eventId)
           .icon(BitmapDescriptorFactory.defaultMarker(event_color)));
 }
Example #9
0
 /**
  * If the source and target events are visible, draw a line between the source and target, and
  * save it in the map of lines. This is so that the lines can be removed when changing the
  * selected event.
  */
 private void drawFamilyStoryLine(Event source, Event target, int width) {
   if (source == null || target == null) return;
   if (MainModel.isEventVisible(source.getId()) && MainModel.isEventVisible(target.getId())) {
     familyLines.add(drawLine(source, target, width, Settings.getFamilyStoryColor()));
   }
 }
Example #10
0
 private void updateFamilyStoryLines() {
   clearFamilyStoryLines();
   if (!Settings.isFamilyLinesEnabled()) return;
   recDrawFamilyStoryLines(MainModel.getEvent(selEventId), Settings.START_FAMILY_LINE_WIDTH);
 }