/** * 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; } }
/** * Sets the denominator for a relative scale. * * @param denominator * the denominator for a relative scale */ public void setDenominator(double denominator) { this.denominator = denominator; setPixelPerUnitBased(false); postConstruct(); }
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; }
/** * Get the minimum scale for which this layer should be visible (maximum zoom out). * * @return minimum scale (pix/map unit) * @deprecated use {@link #getMinimumScale()} */ @Deprecated public double getViewScaleMin() { return minimumScale.getPixelPerUnit(); }
/** Finish configuration. */ @PostConstruct protected void postConstruct() { if (null == zoomToPointScale) { zoomToPointScale = new ScaleInfo(maximumScale); } }
public static String scaleToString(ScaleInfo scale) { NumberFormat numberFormat = NumberFormat.getFormat("###,###"); return numberFormat.format(scale.getNumerator()) + " : " + numberFormat.format(scale.getDenominator()); }
/** * 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); }
/** * Get the maximum scale for which this layer should be visible (maximum zoom in). * * @return maximum scale (pix/map unit) * @deprecated use {@link #getMaximumScale()} */ @Deprecated public double getViewScaleMax() { return maximumScale.getPixelPerUnit(); }
/** * Set the minimum scale for which this layer should be visible (maximum zoom out). * * @param viewScaleMin * scale (pix/map unit) * @deprecated use {@link #setMinimumScale(ScaleInfo)}} */ @Deprecated public void setViewScaleMin(double viewScaleMin) { setMinimumScale(new ScaleInfo(viewScaleMin)); }
/** * Get the list of supported resolutions for the layer. Each resolution is specified in map units per pixel. * * @return list of supported resolutions * @deprecated use {@link #getZoomLevels()} */ @Deprecated public List<Double> getResolutions() { List<Double> resolutions = new ArrayList<Double>(); for (ScaleInfo scale : getZoomLevels()) { resolutions.add(1. / scale.getPixelPerUnit()); } return resolutions; }
/** * Set the maximum scale for which this layer should be visible (maximum zoom in). * * @param viewScaleMax * scale (pix/map unit) * @deprecated use {@link #setMaximumScale(ScaleInfo)} */ @Deprecated public void setViewScaleMax(double viewScaleMax) { setMaximumScale(new ScaleInfo(viewScaleMax)); }
/** * Sets the numerator for a relative scale. * * @param numerator * the numerator for a relative scale */ public void setNumerator(double numerator) { this.numerator = numerator; setPixelPerUnitBased(false); if (denominator != 0) { postConstruct(); } }
protected RangeConfig getRangeConfigForCurrentScale(ViewConfig viewConfig, double scale) { for (RangeConfig config : viewConfig.getRangeConfigs()) { double scaleMax = config.getMaximumScale().getPixelPerUnit(); double scaleMin = config.getMinimumScale().getPixelPerUnit(); if (scale <= scaleMax && scale >= scaleMin) { return config; } } return null; }
/** * Set the list of supported resolutions. Each resolution is specified in map units per pixel. * * @param resolutions * resolutions * @deprecated use {@link #setZoomLevels()} */ @Deprecated public void setResolutions(List<Double> resolutions) { getZoomLevels().clear(); for (Double resolution : resolutions) { getZoomLevels().add(new ScaleInfo(1. / resolution)); } }
/** * Sets the scale value in pixel per map unit. * * @param pixelPerUnit * the scale value (pix/map unit) */ public void setPixelPerUnit(double pixelPerUnit) { if (pixelPerUnit < MINIMUM_PIXEL_PER_UNIT) { pixelPerUnit = MINIMUM_PIXEL_PER_UNIT; } if (pixelPerUnit > MAXIMUM_PIXEL_PER_UNIT) { pixelPerUnit = MAXIMUM_PIXEL_PER_UNIT; } this.pixelPerUnit = pixelPerUnit; setPixelPerUnitBased(true); postConstruct(); }
/** * Returns the maximum scale (maximum zoom in) of this map. The minimum scale is indirectly determined from the * maximum bounds. As a better alternative for this value, use {@link #getScaleConfiguration}. * * @return the maximum scale (pixels/unit) * @deprecated use {@link #getScaleConfiguration} */ @Deprecated public float getMaximumScale() { return (float) getScaleConfiguration().getMaximumScale().getPixelPerUnit(); }
/** * Set maximum scale (maximum zoom in) of this map. As a better alternative for this value, use * {@link #getScaleConfiguration}. * * @param maximumScale * the maximum scale (pixels/unit) * @deprecated use {@link #setScaleConfiguration} */ @Deprecated public void setMaximumScale(float maximumScale) { getScaleConfiguration().setMaximumScale(new ScaleInfo((double) maximumScale)); }
protected FreeForAllZoomStrategy(ClientMapInfo mapInfo, Bbox maxBounds) { ScaleConfigurationInfo scaleConfigurationInfo = mapInfo.getScaleConfiguration(); maximumScale = scaleConfigurationInfo.getMaximumScale().getPixelPerUnit(); this.maxBounds = maxBounds; }
@Override public boolean isShowing() { if (markedAsVisible) { if (viewPort.getScale() >= layerInfo.getMinimumScale().getPixelPerUnit() && viewPort.getScale() <= layerInfo.getMaximumScale().getPixelPerUnit()) { return true; } } return false; } }