/** * Constructs a scale info object with the specified scale value. The scale value should be interpreted as * pixels/map unit. This is especially useful for raster images for which the image resolution indirectly determines * the optimal view scale of the image. * * @param pixelPerUnit * the scale value in pixel per map unit) */ public ScaleInfo(double pixelPerUnit) { if (pixelPerUnit < MINIMUM_PIXEL_PER_UNIT) { pixelPerUnit = MINIMUM_PIXEL_PER_UNIT; } if (pixelPerUnit > MAXIMUM_PIXEL_PER_UNIT) { pixelPerUnit = MAXIMUM_PIXEL_PER_UNIT; } setPixelPerUnit(pixelPerUnit); }
/** * Copy constructor. Creates a deep copy of the specified {@link ScaleInfo} object. * * @param other the scale info to copy * @since 1.11.0 */ public ScaleInfo(ScaleInfo other) { setDenominator(other.getDenominator()); setNumerator(other.getNumerator()); setPixelPerUnit(other.getPixelPerUnit()); // must copy all state setPixelPerUnitBased(other.isPixelPerUnitBased()); }
/** * Transforms a TMS tile-set description object into a Geomajas {@link ScaleInfo} object. * * @param tileSet * The tile set description. * @return The default Geomajas scale object. */ public ScaleInfo asScaleInfo(TileSet tileSet) { ScaleInfo scaleInfo = new ScaleInfo(); scaleInfo.setPixelPerUnit(1 / tileSet.getUnitsPerPixel()); return scaleInfo; } }
public static ScaleInfo stringToScale(String value) { NumberFormat numberFormat = NumberFormat.getFormat("###,###"); String[] scale2 = value.split(":"); ScaleInfo si; if (scale2.length == 1) { si = new ScaleInfo(1D, numberFormat.parse(scale2[0].trim())); } else { si = new ScaleInfo(numberFormat.parse(scale2[0].trim()), numberFormat.parse(scale2[1].trim())); } si.setPixelPerUnit(si.getNumerator() / si.getDenominator() * PPM); return si; }