Пример #1
0
 /** Creates a new TouchDemo object */
 public TouchDemo() {
   if (Touchscreen.isSupported()) {
     final TouchDemoScreen screen = new TouchDemoScreen();
     pushScreen(screen);
   } else {
     UiApplication.getUiApplication()
         .invokeLater(
             new Runnable() {
               public void run() {
                 Dialog.alert("This application requires a touch screen device.");
                 System.exit(0);
               }
             });
   }
 }
  /** Creates a new MapActionDemoScreen object */
  public MapActionDemoScreen() {
    super(Screen.DEFAULT_CLOSE | Screen.DEFAULT_MENU | Manager.NO_VERTICAL_SCROLL);

    setTitle("Map Action Demo");

    // Activate pinch gesturing
    if (Touchscreen.isSupported()) {
      final InputSettings is = TouchscreenSettings.createEmptySet();
      is.set(TouchscreenSettings.DETECT_PINCH, 1);
      this.addInputSettings(is);
    }

    _map = MapFactory.getInstance().generateRichMapField();
    _map.getMapField()
        .setDimensions(new MapDimensions(Display.getWidth(), Display.getHeight() - 130));

    // Register for field updates (when the center and zoom changes)
    _map.getMapField().addChangeListener(this);

    // Change the MapAction class the MapField uses
    _restrictedMapAction = new RestrictedMapAction();
    _map.getMapField().setAction(_restrictedMapAction);

    // Disable shared mode
    _map.getAction().disableOperationMode(MapConstants.MODE_SHARED_FOCUS);

    // Label fields to show the user location info
    _latField = new LabelField("Latitude: ");
    _lonField = new LabelField("Longitude: ");
    _zoomField = new LabelField("Zoom: ");

    add(_map);
    add(_latField);
    add(_lonField);
    add(_zoomField);
  }