Ejemplo n.º 1
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;
      }
    }
  }
Ejemplo n.º 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;
      }
    }
  }
 // prints countries with number of earthquakes
 private void printQuakes() {
   int totalWaterQuakes = quakeMarkers.size();
   for (Marker country : countryMarkers) {
     String countryName = country.getStringProperty("name");
     int numQuakes = 0;
     for (Marker marker : quakeMarkers) {
       EarthquakeMarker eqMarker = (EarthquakeMarker) marker;
       if (eqMarker.isOnLand()) {
         if (countryName.equals(eqMarker.getStringProperty("country"))) {
           numQuakes++;
         }
       }
     }
     if (numQuakes > 0) {
       totalWaterQuakes -= numQuakes;
       System.out.println(countryName + ": " + numQuakes);
     }
   }
   System.out.println("OCEAN QUAKES: " + totalWaterQuakes);
 }
Ejemplo n.º 4
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);
        }
      }
    }
  }