Package org.geomajas.gwt.client.spatial

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


    // Immediately draw or remove the max extent rectangle:
    if (drawTargetMaxExtent) {
      targetMaxExtentRectangle = new GfxGeometry("targetMaxExtentRectangle");
      targetMaxExtentRectangle.setStyle(targetMaxExtentRectangleStyle);

      Bbox targetMaxExtent = getOverviewMaxBounds();

      Bbox box = getMapModel().getMapView().getWorldViewTransformer().worldToView(targetMaxExtent);
      LinearRing shell = getMapModel().getGeometryFactory().createLinearRing(
          new Coordinate[] { new Coordinate(-2, -2), new Coordinate(getWidth() + 2, -2),
              new Coordinate(getWidth() + 2, getHeight() + 2), new Coordinate(-2, getHeight() + 2) });
      LinearRing hole = getMapModel().getGeometryFactory().createLinearRing(
          new Coordinate[] { new Coordinate(box.getX(), box.getY()),
              new Coordinate(box.getMaxX(), box.getY()), new Coordinate(box.getMaxX(), box.getMaxY()),
              new Coordinate(box.getX(), box.getMaxY()) });
      Polygon polygon = getMapModel().getGeometryFactory().createPolygon(shell, new LinearRing[] { hole });
      targetMaxExtentRectangle.setGeometry(polygon);
      render(targetMaxExtentRectangle, RenderGroup.SCREEN, RenderStatus.ALL);
    } else {
      render(targetMaxExtentRectangle, RenderGroup.SCREEN, RenderStatus.DELETE);
View Full Code Here


  /**
   * Apply a maximum extent. This will extend the map extend to be used by the percentage to increase.
   */
  private void updateMaxExtent() {
    if (targetMap.getMapModel().isInitialized()) {
      Bbox targetMaxBounds = getOverviewMaxBounds();

      MapView mapView = getMapModel().getMapView();

      // Set the maxBounds on this map as well:
      mapView.setMaxBounds(targetMaxBounds.buffer(targetMaxBounds.getWidth()));

      // apply buffer
      if (maxExtentIncreasePercentage > 0) {
        targetMaxBounds = targetMaxBounds
            .buffer(targetMaxBounds.getWidth() * maxExtentIncreasePercentage / 100);
      }

      // Then apply the map extent:
      mapView.applyBounds(targetMaxBounds, MapView.ZoomOption.LEVEL_FIT);
      super.onMapViewChanged(null);
View Full Code Here

   * Update the rectangle, and perhaps the entire map if needed.
   */
  private void updatePov() {
    MapView mapView = getMapModel().getMapView();
    WorldViewTransformer transformer = new WorldViewTransformer(mapView);
    Bbox targetBox = targetMap.getMapModel().getMapView().getBounds();
    Bbox overviewBox = mapView.getBounds();

    // check if bounds are valid
    if (Double.isNaN(overviewBox.getX())) {
      return;
    }

    // zoom if current view is too small
    if (dynamicOverview && !overviewBox.contains(targetBox)) {
      // mapView.applyBounds(overviewBox.union(targetBox), MapView.ZoomOption.LEVEL_FIT);
      // super.onMapViewChanged(null);
    }

    // calculate boxSize
    Coordinate viewBegin = transformer.worldToView(targetBox.getOrigin());
    Coordinate viewEnd = transformer.worldToView(targetBox.getEndPoint());

    double width = Math.abs(viewEnd.getX() - viewBegin.getX());
    double height = Math.abs(viewEnd.getY() - viewBegin.getY());
    viewBegin.setY(viewBegin.getY() - height);

    // show recticle or box
    if (width < 20) {
      if (null != targetRectangle) {
        render(targetRectangle, RenderGroup.SCREEN, RenderStatus.DELETE);
        targetRectangle = null;
      }
      if (null == targetReticle) {
        targetReticle = new Image("targetReticle");
        targetReticle.setHref(Geomajas.getIsomorphicDir() + TARGET_RETICLE_IMAGE);
        targetReticle.setBounds(new Bbox(0, 0, 21, 21));
      }
      double x = viewBegin.getX() + (width / 2) - 10;
      double y = viewBegin.getY() + (width / 2) - 10;
      targetReticle.getBounds().setX(x);
      targetReticle.getBounds().setY(y);
      render(targetReticle, RenderGroup.SCREEN, RenderStatus.UPDATE);

    } else {
      if (null != targetReticle) {
        render(targetReticle, RenderGroup.SCREEN, RenderStatus.DELETE);
        targetReticle = null;
      }
      if (null == targetRectangle) {
        targetRectangle = new Rectangle("targetRect");
        targetRectangle.setStyle(rectangleStyle);
      }
      targetRectangle.setBounds(new Bbox(viewBegin.getX(), viewBegin.getY(), width, height));
      render(targetRectangle, RenderGroup.SCREEN, RenderStatus.UPDATE);
    }
  }
View Full Code Here

   * overviewMap are used. It it was set the maximum bounds of the target view is used.
   *
   * @return maxBounds for overview map
   */
  private Bbox getOverviewMaxBounds() {
    Bbox targetMaxBounds;
    if (!useTargetMaxExtent) {
      targetMaxBounds = new Bbox(getMapModel().getMapInfo().getInitialBounds());
    } else {
      // maxBounds was not configured, or need to use maxBounds from target
      if (targetMap.getMapModel().isInitialized()) {
        // rely on target map bounds
        targetMaxBounds = targetMap.getMapModel().getMapView().getMaxBounds();
      } else {
        // fall back to configured bounds (should be temporary)
        targetMaxBounds = new Bbox(targetMap.getMapModel().getMapInfo().getMaxBounds());
      }
    }
    return targetMaxBounds;
  }
View Full Code Here

  }

  @Test
  public void getBounds() {
    Envelope env = jts.getEnvelopeInternal();
    Bbox bbox = gwt.getBounds();
    Assert.assertEquals(env.getMinX(), bbox.getX(), DELTA);
    Assert.assertEquals(env.getMinY(), bbox.getY(), DELTA);
    Assert.assertEquals(env.getMaxX(), bbox.getMaxX(), DELTA);
    Assert.assertEquals(env.getMaxY(), bbox.getMaxY(), DELTA);
  }
View Full Code Here

  }

  @Test
  public void getBounds() {
    Envelope env = jts.getEnvelopeInternal();
    Bbox bbox = gwt.getBounds();
    Assert.assertEquals(env.getMinX(), bbox.getX(), DELTA);
    Assert.assertEquals(env.getMinY(), bbox.getY(), DELTA);
    Assert.assertEquals(env.getMaxX(), bbox.getMaxX(), DELTA);
    Assert.assertEquals(env.getMaxY(), bbox.getMaxY(), DELTA);
  }
View Full Code Here

  // -------------------------------------------------------------------------
  // Private methods:
  // -------------------------------------------------------------------------

  private void applyPosition() {
    background.setBounds(new Bbox(getHorizontalMargin(), getVerticalMargin(), getWidth(), getHeight()));

    north.setHorizontalMargin(getHorizontalMargin() + 16);
    north.setVerticalMargin(getVerticalMargin());

    east.setHorizontalMargin(getHorizontalMargin() + 32);
View Full Code Here

  }

  public void onMapViewChanged(MapViewChangedEvent event) {
    // assume google coordinates here
    if (googleMap != null) {
      Bbox latLon = convertToLatLon(event.getBounds());
      fitGoogleMapBounds(googleMap, latLon.getX(), latLon.getY(), latLon.getMaxX(), latLon.getMaxY());
    }
  }
View Full Code Here

  private Bbox convertToLatLon(Bbox bounds) {
    // convert corners
    Coordinate orig = convertToLatLon(bounds.getOrigin());
    Coordinate end = convertToLatLon(bounds.getEndPoint());
    return new Bbox(orig.getX(), orig.getY(), end.getX() - orig.getX(), end.getY() - orig.getY());
  }
View Full Code Here

  public Watermark(String id, MapWidget map) {
    super(id, 125, 12);
    this.map = map;
    image = new Image(id + "-img");
    image.setBounds(new Bbox(0, 0, 125, 12));
    image.setHref(Geomajas.getIsomorphicDir() + "geomajas/mapaddon/powered_by_geomajas.gif");
    image.setStyle(new PictureStyle(1));

    dummy = new Rectangle(getId() + "-dummy");
    dummy.setStyle(new ShapeStyle("#FFFFFF", 0, "#FFFFFF", 0, 0));
    dummy.setBounds(new Bbox(0, 0, 1, 1));
  }
View Full Code Here

TOP

Related Classes of org.geomajas.gwt.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.