예제 #1
0
 public void keyPressed() {
   if (key == ' ') {
     log.debug("programmed: fire panTo + zoomTo");
     PanMapEvent panMapEvent = new PanMapEvent(this, maps.get(0).getId());
     Location location = new Location(52.4115f, 13.0516f);
     panMapEvent.setLocation(location);
     eventDispatcher.fireMapEvent(panMapEvent);
     ZoomMapEvent zoomMapEvent = new ZoomMapEvent(this, maps.get(0).getId());
     zoomMapEvent.setSubType("zoomTo");
     zoomMapEvent.setZoomLevel(14);
     eventDispatcher.fireMapEvent(zoomMapEvent);
   }
 }
예제 #2
0
  public void keyPressed(char key, int keyCode) {
    for (UnfoldingMap map : maps) {
      if (map.isActive()) {
        if (key == '+' || key == '-') {
          ZoomMapEvent zoomMapEvent = new ZoomMapEvent(this, map.getId());
          zoomMapEvent.setTransformationCenterLocation(map.getCenter());
          zoomMapEvent.setSubType(ZoomMapEvent.ZOOM_BY_LEVEL);
          if (key == '+') {
            zoomMapEvent.setZoomLevelDelta(1);
          } else {
            zoomMapEvent.setZoomLevelDelta(-1);
          }
          eventDispatcher.fireMapEvent(zoomMapEvent);

        } else if (key == PConstants.CODED) {

          // FIXME Use toLocation instead of panLeft, etc to allow listening maps to pan
          // correctly.
          if (keyCode == PConstants.LEFT
              || keyCode == PConstants.RIGHT
              || keyCode == PConstants.UP
              || keyCode == PConstants.DOWN) {
            PanMapEvent panMapEvent = new PanMapEvent(this, map.getId());
            switch (keyCode) {
              case PConstants.LEFT:
                panMapEvent.setSubType(PanMapEvent.PAN_LEFT);
                break;
              case PConstants.RIGHT:
                panMapEvent.setSubType(PanMapEvent.PAN_RIGHT);
                break;
              case PConstants.UP:
                panMapEvent.setSubType(PanMapEvent.PAN_UP);
                break;
              case PConstants.DOWN:
                panMapEvent.setSubType(PanMapEvent.PAN_DOWN);
                break;
            }
            eventDispatcher.fireMapEvent(panMapEvent);
          }
        }
      }
    }
  }