Package org.geomajas.configuration.client

Examples of org.geomajas.configuration.client.ScaleInfo


      double pixPerUnit = map.getUnitLength() / map.getPixelLength();
      // if resolutions have been defined the old way, calculate the scale configuration
      if (map.getResolutions().size() > 0) {
        for (Double resolution : map.getResolutions()) {
          if (map.isResolutionsRelative()) {
            map.getScaleConfiguration().getZoomLevels().add(new ScaleInfo(1., resolution));
          } else {
            map.getScaleConfiguration().getZoomLevels().add(new ScaleInfo(1. / resolution));
          }
        }
        map.getResolutions().clear();
      }
      // convert the scales so we have both relative and pix/unit
View Full Code Here


  public void testSetAsText() {
    ScaleInfoEditor editor = new ScaleInfoEditor();
    editor.setAsText("1:2000");
    Object o = editor.getValue();
    Assert.assertTrue(o instanceof ScaleInfo);
    ScaleInfo info = (ScaleInfo)o;
    Assert.assertEquals(1, info.getNumerator(), 0.001);
    Assert.assertEquals(2000, info.getDenominator(), 0.001);
    Assert.assertEquals(0, info.getPixelPerUnit(), 0);
    cdpp.completeScale(info, 10);
    Assert.assertEquals(0.005, info.getPixelPerUnit(), 0.00001);
  }
View Full Code Here

    Assert.assertEquals(0.005, info.getPixelPerUnit(), 0.00001);
  }

  @Test
  public void testIncontext() {
    ScaleInfo info = holder.getScaleInfo();
    Assert.assertEquals(1, info.getNumerator(), 0.001);
    Assert.assertEquals(2500, info.getDenominator(), 0.001);
    Assert.assertEquals(0, info.getPixelPerUnit(), 0);
    cdpp.completeScale(info, 100);
    Assert.assertEquals(0.04, info.getPixelPerUnit(), 0.00001);
  }
View Full Code Here

   */
  @Deprecated
  public void setResolutions(List<Double> resolutions) {
    getZoomLevels().clear();
    for (Double resolution : resolutions) {
      getZoomLevels().add(new ScaleInfo(1. / resolution));
    }
  }
View Full Code Here

    int pos = text.indexOf(':');
    if (pos > 0) {
      try {
        double numerator = Double.parseDouble(text.substring(0, pos));
        double denominator = Double.parseDouble(text.substring(pos + 1));
        setValue(new ScaleInfo(numerator, denominator));
      } catch (Exception e) {
        throw new IllegalArgumentException("Scale " + text
            + " could not be parsed. The following format was expected:" + " (x : y).", e);
      }
    } else {
      try {
        // Not recommended....
        setValue(new ScaleInfo(Double.parseDouble(text)));
      } catch (Exception e) {
        throw new IllegalArgumentException("Scale " + text
            + " could not be parsed. The following format was expected:" + " (x : y).", e);
      }
    }
View Full Code Here

TOP

Related Classes of org.geomajas.configuration.client.ScaleInfo

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.