Package org.geomajas.puregwt.client.spatial

Examples of org.geomajas.puregwt.client.spatial.Bbox


          viewPort.setMapSize(display.asWidget().getOffsetWidth(), display.asWidget().getOffsetHeight());
          layersModel.initialize(r.getMapInfo(), viewPort, eventBus);
          viewPort.initialize(r.getMapInfo(), eventBus);

          // Immediately zoom to the initial bounds as configured:
          Bbox initialBounds = factory.createBbox(r.getMapInfo().getInitialBounds());
          viewPort.applyBounds(initialBounds);

          // If there are already some MapGadgets registered, draw them now:
          for (Entry<MapGadget, ScreenContainer> entry : gadgets.entrySet()) {
            entry.getKey().onDraw(viewPort, entry.getValue());
View Full Code Here


    this.eventBus = eventBus;
    crs = mapInfo.getCrs();

    // Calculate maximum bounds:
    maxBounds = factory.createBbox(mapInfo.getMaxBounds());
    Bbox initialBounds = factory.createBbox(mapInfo.getInitialBounds());
    // if the max bounds was not configured, take the union of initial and layer bounds
    Bbox all = factory.createBbox(org.geomajas.geometry.Bbox.ALL);
    if (maxBounds.equals(all)) {
      for (ClientLayerInfo layerInfo : mapInfo.getLayers()) {
        maxBounds = factory.createBbox(initialBounds);
        maxBounds = maxBounds.union(factory.createBbox(layerInfo.getMaxExtent()));
      }
View Full Code Here

  public void applyScale(double newScale, Coordinate rescalePoint) {
    double limitedScale = zoomStrategy.checkScale(newScale, ZoomOption.LEVEL_CLOSEST);
    if (limitedScale != scale) {
      // Calculate theoretical new bounds. First create a BBOX of correct size:
      Bbox newBbox = factory.createBbox(0, 0, getMapWidth() / limitedScale, getMapHeight() / limitedScale);

      // Calculate translate vector to assure rescalePoint is on the same position as before.
      double factor = limitedScale / scale;
      double dX = (rescalePoint.getX() - position.getX()) * (1 - 1 / factor);
      double dY = (rescalePoint.getY() - position.getY()) * (1 - 1 / factor);

      // Apply translation to set the BBOX on the correct location:
      newBbox.setCenterPoint(new Coordinate(position.getX(), position.getY()));
      newBbox.translate(dX, dY);

      // Now apply on this view port:
      scale = limitedScale;
      position = newBbox.getCenterPoint();
      if (eventBus != null) {
        if (dX == 0 && dY == 0) {
          eventBus.fireEvent(new ViewPortScaledEvent(this));
        } else {
          eventBus.fireEvent(new ViewPortChangedEvent(this));
View Full Code Here

    StopPropagationHandler handler = new StopPropagationHandler();
    left.addMouseUpHandler(new MouseUpHandler() {

      public void onMouseUp(MouseUpEvent event) {
        Bbox bounds = viewPort.getBounds();
        double deltaX = -bounds.getWidth() / 3;
        PanAnimation animation = new PanAnimation(viewPort);
        animation.panTo(deltaX, 0, 300);
        event.stopPropagation();
      }
    });
    left.addMouseDownHandler(handler);
    left.addClickHandler(handler);
    left.addDoubleClickHandler(handler);

    right.addMouseUpHandler(new MouseUpHandler() {

      public void onMouseUp(MouseUpEvent event) {
        Bbox bounds = viewPort.getBounds();
        double deltaX = bounds.getWidth() / 3;
        PanAnimation animation = new PanAnimation(viewPort);
        animation.panTo(deltaX, 0, 300);
        event.stopPropagation();
      }
    });
    right.addMouseDownHandler(handler);
    right.addClickHandler(handler);
    right.addDoubleClickHandler(handler);

    up.addMouseUpHandler(new MouseUpHandler() {

      public void onMouseUp(MouseUpEvent event) {
        Bbox bounds = viewPort.getBounds();
        double deltaY = bounds.getHeight() / 3;
        PanAnimation animation = new PanAnimation(viewPort);
        animation.panTo(0, deltaY, 300);
        event.stopPropagation();
      }
    });
    up.addMouseDownHandler(handler);
    up.addClickHandler(handler);
    up.addDoubleClickHandler(handler);

    down.addMouseUpHandler(new MouseUpHandler() {

      public void onMouseUp(MouseUpEvent event) {
        Bbox bounds = viewPort.getBounds();
        double deltaY = -bounds.getHeight() / 3;
        PanAnimation animation = new PanAnimation(viewPort);
        animation.panTo(0, deltaY, 300);
        event.stopPropagation();
      }
    });
View Full Code Here

    }
  }

  public void onDoubleClick(DoubleClickEvent event) {
    // Zoom in on the event location:
    Bbox bounds = mapPresenter.getViewPort().getBounds();
    double x = lastClickPosition.getX() - (bounds.getWidth() / 4);
    double y = lastClickPosition.getY() - (bounds.getHeight() / 4);
    Bbox newBounds = factory.createBbox(x, y, bounds.getWidth() / 2, bounds.getHeight() / 2);
    mapPresenter.getViewPort().applyBounds(newBounds);
  }
View Full Code Here

        public void onMouseUp(MouseUpEvent event) {
          if (event.getNativeButton() != NativeEvent.BUTTON_RIGHT && dragging) {
            dragging = false;
            if (screenBounds != null) {
              Bbox worldBounds = viewPort.transform(screenBounds, RenderSpace.SCREEN, RenderSpace.WORLD);
              viewPort.applyBounds(worldBounds);
            }
          }
          event.stopPropagation();
        }
View Full Code Here

    if (tileWidth == 0 || tileHeight == 0) {
      return codes;
    }

    // Calculate bounds relative to extents:
    Bbox clippedBounds = bounds.intersection(layerBounds);
    if (clippedBounds == null) {
      // TODO throw error? If this is null, then the server configuration is incorrect.
      return codes;
    }
    double relativeBoundX = Math.abs(clippedBounds.getX() - layerBounds.getX());
    double relativeBoundY = Math.abs(clippedBounds.getY() - layerBounds.getY());
    int currentMinX = (int) Math.floor(relativeBoundX / tileWidth);
    int currentMinY = (int) Math.floor(relativeBoundY / tileHeight);
    int currentMaxX = (int) Math.ceil((relativeBoundX + clippedBounds.getWidth()) / tileWidth) - 1;
    int currentMaxY = (int) Math.ceil((relativeBoundY + clippedBounds.getHeight()) / tileHeight) - 1;

    // Now fill the list with the correct codes:
    for (int x = currentMinX; x <= currentMaxX; x++) {
      for (int y = currentMinY; y <= currentMaxY; y++) {
        codes.add(new TileCode(currentTileLevel, x, y));
View Full Code Here

    // Assure dragging or clicking started inside this widget
    if (dragging) {
      shift |= event.isShiftKeyDown(); // shift is used when depressed either at beginning or end
      updateRectangle(event);

      Bbox bounds = factory.createBbox(rectangle.getX(), rectangle.getY(), rectangle.getWidth(),
          rectangle.getHeight());
      execute(mapPresenter.getViewPort().transform(bounds, RenderSpace.SCREEN, RenderSpace.WORLD));

      stopDragging();
    }
View Full Code Here

  }

  @Test
  public void testInitialBounds() {
    viewPort.initialize(mapInfo, eventBus);
    Bbox maxBounds = viewPort.getMaximumBounds();
    Assert.assertEquals(maxBounds.getX(), -100.0);
    Assert.assertEquals(maxBounds.getY(), -100.0);
    Assert.assertEquals(maxBounds.getMaxX(), 100.0);
    Assert.assertEquals(maxBounds.getMaxY(), 100.0);
  }
View Full Code Here

  @Test
  public void testSetMaxBounds() {
    mapInfo.setMaxBounds(new org.geomajas.geometry.Bbox(0, 0, 10, 10));
    viewPort.initialize(mapInfo, eventBus);
    Bbox maxBounds = viewPort.getMaximumBounds();
    Assert.assertEquals(maxBounds.getX(), 0.0);
    Assert.assertEquals(maxBounds.getY(), 0.0);
    Assert.assertEquals(maxBounds.getMaxX(), 10.0);
    Assert.assertEquals(maxBounds.getMaxY(), 10.0);
  }
View Full Code Here

TOP

Related Classes of org.geomajas.puregwt.client.spatial.Bbox

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.