Package org.geomajas.gwt.client.spatial

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


   */
  public Bbox getBounds() {
    if (isEmpty()) {
      return null;
    }
    return new Bbox(coordinate.getX(), coordinate.getY(), 0, 0);
  }
View Full Code Here


      if (point.getY() > maxY) {
        maxY = point.getY();
      }
    }

    return new Bbox(minX, minY, maxX - minX, maxY - minY);
  }
View Full Code Here

  /**
   * Return the closest bounding box around the geometry.
   */
  public Bbox getBounds() {
    Bbox bounds = null;
    if (!isEmpty()) {
      for (Polygon polygon : polygons) {
        if (bounds == null) {
          bounds = polygon.getBounds();
        } else {
          bounds = bounds.union(polygon.getBounds());
        }
      }
    }
    return bounds;
  }
View Full Code Here

  @Before
  public void setUp() {
    mapView = new MapView();
    mapView.setSize(200, 100);
    mapView.setMaxBounds(new Bbox(0, 0, 1000, 400));
    mapView.setMaximumScale(2);
    mapView.setCurrentScale(1.0, MapView.ZoomOption.LEVEL_CLOSEST);
    mapView.setCenterPosition(new Coordinate(500, 200));
  }
View Full Code Here

  public void testPanning() {
    CaptureHandler handler = new CaptureHandler();
    mapView.addMapViewChangedHandler(handler);
    // pan to other allowed position
    mapView.setCenterPosition(new Coordinate(900, 300));
    handler.expect(new Bbox(800, 250, 200, 100), 1.0, true);
    // pan outside max bounds
    mapView.setCenterPosition(new Coordinate(1000, 400));
    // should pan as far as possible
    handler.expect(new Bbox(800, 300, 200, 100), 1.0, true);
    // translate outside max bounds
    mapView.translate(100, 100);
    // no movement
    handler.expect(new Bbox(800, 300, 200, 100), 1.0, true);
    handler.validate();
  }
View Full Code Here

  @Test
  public void testZoomingNoResolutions() {
    CaptureHandler handler = new CaptureHandler();
    mapView.addMapViewChangedHandler(handler);
    // pan to initial position
    mapView.applyBounds(new Bbox(400, 150, 200, 100), MapView.ZoomOption.LEVEL_CLOSEST);
    handler.expect(new Bbox(400, 150, 200, 100), 1.0, true);
    // zoom out
    mapView.setCurrentScale(0.5, MapView.ZoomOption.LEVEL_CLOSEST);
    handler.expect(new Bbox(300, 100, 400, 200), 0.5, false);
    // zoom out beyond maximum bounds
    mapView.setCurrentScale(0.2, MapView.ZoomOption.LEVEL_CLOSEST);
    // should zoom out as far as possible
    handler.expect(new Bbox(100, 0, 800, 400), 0.25, false);
    // zoom in beyond maximum scale
    mapView.setCurrentScale(3, MapView.ZoomOption.LEVEL_CLOSEST);
    // should zoom in as far as possible
    handler.expect(new Bbox(450, 175, 100, 50), 2, false);
    handler.validate();
  }
View Full Code Here

    resolutions.add(1 / 2.0);
    mapView.setResolutions(resolutions);
    CaptureHandler handler = new CaptureHandler();
    mapView.addMapViewChangedHandler(handler);
    // apply initial bounds
    mapView.applyBounds(new Bbox(300, 100, 400, 200), MapView.ZoomOption.LEVEL_CLOSEST);
    // should snap to closest (scale 0.5 -> 0.4)
    handler.expect(new Bbox(250, 75, 500, 250), 0.4, false);
    // force next level
    mapView.scale(1.001, MapView.ZoomOption.LEVEL_CHANGE);
    // zooms in to 1.0
    handler.expect(new Bbox(400, 150, 200, 100), 1.0, false);
    handler.validate();
  }
View Full Code Here

    resolutions.add(1 / 2.0);
    mapView.setResolutions(resolutions);
   
    // no scale limitations
    mapView.setMaximumScale(Double.MAX_VALUE);
    mapView.setMaxBounds(new Bbox(-1E20, -1E20, 2E20, 2E20));
   
    CaptureHandler handler = new CaptureHandler();
    HandlerRegistration registration = mapView.addMapViewChangedHandler(handler);
    // force 1.0
    mapView.setCurrentScale(1.0, MapView.ZoomOption.LEVEL_CLOSEST);
    // zooms in to 1.0
    handler.expect(new Bbox(400, 150, 200, 100), 1.0, true);
    // force 2.0
    mapView.setCurrentScale(2.0, MapView.ZoomOption.LEVEL_CLOSEST);
    // zooms in to 2.0
    handler.expect(new Bbox(450, 175, 100, 50), 2.0, false);
    // force 0.01
    mapView.setCurrentScale(0.01, MapView.ZoomOption.LEVEL_CLOSEST);
    // zooms in to 0.01
    handler.expect(new Bbox(-9500, -4800, 20000, 10000), 0.01, false);
    // fitting
    // force 1.0
    mapView.setCurrentScale(1.0, MapView.ZoomOption.LEVEL_FIT);
    // zooms in to 1.0
    handler.expect(new Bbox(400, 150, 200, 100), 1.0, false);
    // force 2.0
    mapView.setCurrentScale(2.0, MapView.ZoomOption.LEVEL_FIT);
    // zooms in to 2.0
    handler.expect(new Bbox(450, 175, 100, 50), 2.0, false);
    // force 0.01
    mapView.setCurrentScale(0.01, MapView.ZoomOption.LEVEL_FIT);
    // zooms in to 0.01
    handler.expect(new Bbox(-9500, -4800, 20000, 10000), 0.01, false);
    handler.validate();
    registration.removeHandler();
   
    // test for 1 resolution
    resolutions = new ArrayList<Double>();
    resolutions.add(1 / 1.0);
    mapView.setResolutions(resolutions);
    handler = new CaptureHandler();
    mapView.addMapViewChangedHandler(handler);
    // force 2.0
    mapView.setCurrentScale(2.0, MapView.ZoomOption.LEVEL_FIT);
    // zooms in to 1.0
    handler.expect(new Bbox(400, 150, 200, 100), 1.0, false);
    // force 1.0
    mapView.setCurrentScale(2.0, MapView.ZoomOption.LEVEL_FIT);
    // zooms in to 1.0
    handler.expect(new Bbox(400, 150, 200, 100), 1.0, true);
    // force 0.5
    mapView.setCurrentScale(0.5, MapView.ZoomOption.LEVEL_FIT);
    // zooms in to 1.0 (which is not fitting, but there is no other option)
    handler.expect(new Bbox(400, 150, 200, 100), 1.0, true);
    // force 2.0
    mapView.setCurrentScale(2.0, MapView.ZoomOption.LEVEL_CLOSEST);
    // zooms in to 1.0
    handler.expect(new Bbox(400, 150, 200, 100), 1.0, true);
    // force 1.0
    mapView.setCurrentScale(2.0, MapView.ZoomOption.LEVEL_CLOSEST);
    // zooms in to 1.0
    handler.expect(new Bbox(400, 150, 200, 100), 1.0, true);
    // force 0.5
    mapView.setCurrentScale(0.5, MapView.ZoomOption.LEVEL_CLOSEST);
    // zooms in to 1.0
    handler.expect(new Bbox(400, 150, 200, 100), 1.0, true);
    handler.validate();
   
  }
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

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.