Exemplo n.º 1
0
  public void actionPerformed(ActionEvent e) {
    Command cmd = e.getCommand();
    if (cmd != null) {
      // Free some memory
      freeThumbnails();
    }

    /* Handle different commands */
    if (cmd == aboutCommand) {
      midlet.showAboutView();
    } else if (cmd == helpCommand) {
      midlet.showHelpView();
    } else if (cmd == guidesCommand) {
      midlet.showGuideView();
    } else if (cmd == mapCommand) {
      GeoCoordinate loc = Self.getCurrentPosition();
      if (loc != null) {
        midlet.showMapView(guide, null, loc.getLatitude(), loc.getLongitude(), "My location");
      } else {
        Util.showAlert("Location error", "Could not get your location.");
      }
    } else if (cmd == selectCommand) {
      attractionList.actionPerformed(new ActionEvent(attractionList));
    } else if (cmd == backCommand) {
      Display.getInstance().exitApplication();
    }
  }
    /**
     * Sets tweet position randomly within radius
     *
     * @param tweet the tweet data
     */
    private void randomPlaceWithinRadius(Tweet tweet) {
      double radius = config.getRadius();
      double maxDegreeDiff = radius / SURFACE_DISTANCE;
      double latR = random.nextDouble();
      double lonR = random.nextDouble();

      latR = (latR - 0.5) * 2; // -1 to 1
      lonR = (lonR - 0.5) * 2; // -1 to 1
      GeoCoordinate sc = config.getPosition();
      GeoCoordinate gc =
          new GeoCoordinate(
              sc.getLatitude() + latR * maxDegreeDiff, sc.getLongitude() + lonR * maxDegreeDiff, 0);

      tweet.setUserCoordinate(gc);
    }