Package org.geomajas.gwt.client.gfx.paintable.mapaddon

Examples of org.geomajas.gwt.client.gfx.paintable.mapaddon.ScaleBar


  /** If the map view changes, redraw the map model and the scale bar. */
  public void onMapViewChanged(MapViewChangedEvent event) {
    if (graphics.isReady()) {
      if (scaleBarEnabled) {
        ScaleBar scalebar = (ScaleBar) addons.get("scalebar");
        if (scalebar != null) {
          scalebar.adjustScale(mapModel.getMapView().getCurrentScale());
          render(scalebar, RenderGroup.SCREEN, RenderStatus.UPDATE);
        }
      }
      if (event != null && event.isPanDragging()) {
        render(mapModel, null, RenderStatus.UPDATE);
View Full Code Here


  public void setScalebarEnabled(boolean enabled) {
    scaleBarEnabled = enabled;
    final String scaleBarId = "scalebar";

    if (scaleBarEnabled) {
      ScaleBar scalebar = new ScaleBar("scalebar", this);
      scalebar.setVerticalAlignment(VerticalAlignment.BOTTOM);
      scalebar.setHorizontalMargin(2);
      scalebar.setVerticalMargin(2);
      scalebar.initialize(getMapModel().getMapInfo().getDisplayUnitType(), unitLength, new Coordinate(20,
          graphics.getHeight() - 25));
      scalebar.adjustScale(mapModel.getMapView().getCurrentScale());
      registerMapAddon(scalebar);
    } else {
      unregisterMapAddon(addons.get(scaleBarId));
    }
  }
View Full Code Here

public class ScaleBarTest {

  @Test
  public void testGetBestFitMetric() throws Exception {
    ScaleBar sb = new ScaleBar("scaleBar", null);
    sb.initialize(UnitType.METRIC, 1.0d, null);

    sb.calculateBestFit(3.779527559055119); // 1:1000 (96 dpi), best fit is 25 meters for 125 pixels
    Assert.assertTrue("should be same units", 25 == sb.getWidthInUnits());
    Assert.assertTrue("should be same units", 94 == sb.getWidthInPixels());

    sb.calculateBestFit(0.003779527559055119); // 1:1000000 (96 dpi)
    Assert.assertTrue("should be same units", 25000 == sb.getWidthInUnits());
    Assert.assertTrue("should be same units", 94 == sb.getWidthInPixels());
  }
View Full Code Here

    Assert.assertTrue("should be same units", 94 == sb.getWidthInPixels());
  }

  @Test
  public void testGetBestFitEnglish() throws Exception {
    ScaleBar sb = new ScaleBar("scaleBar", null);
    sb.initialize(UnitType.ENGLISH, 1.0d, null);

    sb.calculateBestFit(3.779527559055119); // 1:1000 (96 dpi), best fit is 25 meters for 125 pixels
    Assert.assertFalse("Should be yards", sb.getWidthInUnitsIsMiles());
    Assert.assertTrue("should be same units", 25 == sb.getWidthInUnits());
    Assert.assertTrue("should be same pixels", 86 == sb.getWidthInPixels());

    sb.calculateBestFit(0.003779527559055119); // 1:1000000 (96 dpi)
    Assert.assertTrue("Should be yards", sb.getWidthInUnitsIsMiles());
    Assert.assertTrue("should be same units", 10 == sb.getWidthInUnits());
    Assert.assertTrue("should be same pixels", 61 == sb.getWidthInPixels());
  }
View Full Code Here

  // gwt formatter doesn't work for unittesting (not initialized)
  @Ignore
  @Test
  public void testformatUnitsMetric() throws Exception {
    ScaleBar sb = new ScaleBar("scaleBar", null);
    sb.initialize(UnitType.METRIC, 1.0d, null);
    sb.calculateBestFit(3.779527559055119);

    Assert.assertEquals("should be same", "25 m", sb.formatUnits(25));
    Assert.assertEquals("should be same", "25.1 km", sb.formatUnits(25100));
  }
View Full Code Here

TOP

Related Classes of org.geomajas.gwt.client.gfx.paintable.mapaddon.ScaleBar

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.