コード例 #1
0
  private void showSelectMarkers() {
    // if lastClicked is a city marker, show only that city marker and
    // earthquake markers that affect that city
    if (cityMarkers.contains(lastClicked)) {
      hideUnclickedMarkers(cityMarkers);

      for (Marker marker : quakeMarkers) {
        EarthquakeMarker quakeMarker = (EarthquakeMarker) marker;
        double quakeDistanceToCity = quakeMarker.getDistanceTo(lastClicked.getLocation());
        double quakeDangerRadius = quakeMarker.threatCircle();
        if (quakeDistanceToCity > quakeDangerRadius) {
          marker.setHidden(true);
        }
      }

      // if lastClicked is an earthquake marker, show only that earthquake marker
      // and city markers that can be affected by that earthquake
    } else if (quakeMarkers.contains(lastClicked)) {
      hideUnclickedMarkers(quakeMarkers);

      EarthquakeMarker quakeMarker = (EarthquakeMarker) lastClicked;
      double quakeDangerRadius = quakeMarker.threatCircle();

      for (Marker marker : cityMarkers) {
        double quakeDistanceToCity = quakeMarker.getDistanceTo(marker.getLocation());
        if (quakeDistanceToCity > quakeDangerRadius) {
          marker.setHidden(true);
        }
      }
    }
  }
コード例 #2
0
  // Helper method that will check if an earthquake marker was clicked on
  // and respond appropriately
  private void checkEarthquakesForClick() {
    if (lastClicked != null) return;
    // Loop over the earthquake markers to see if one of them is selected
    for (Marker m : quakeMarkers) {
      EarthquakeMarker marker = (EarthquakeMarker) m;
      if (!marker.isHidden() && marker.isInside(map, mouseX, mouseY)) {
        lastClicked = marker;

        for (Marker mhide : quakeMarkers) if (mhide != lastClicked) mhide.setHidden(true);

        for (Marker mhide : cityMarkers)
          if (mhide.getDistanceTo(marker.getLocation()) > marker.threatCircle())
            mhide.setHidden(true);

        return;
      }
    }
  }
コード例 #3
0
  // Helper method that will check if a city marker was clicked on
  // and respond appropriately
  private void checkCitiesForClick() {
    if (lastClicked != null) return;
    // Loop over the earthquake markers to see if one of them is selected
    for (Marker marker : cityMarkers) {
      if (!marker.isHidden() && marker.isInside(map, mouseX, mouseY)) {
        lastClicked = (CommonMarker) marker;
        // Hide all the other earthquakes and hide
        for (Marker mhide : cityMarkers) if (mhide != lastClicked) mhide.setHidden(true);

        for (Marker mhide : quakeMarkers) {
          EarthquakeMarker quakeMarker = (EarthquakeMarker) mhide;
          if (quakeMarker.getDistanceTo(marker.getLocation()) > quakeMarker.threatCircle())
            quakeMarker.setHidden(true);
        }
        return;
      }
    }
  }