/** Finish configuration. */ @PostConstruct protected void postConstruct() { if (pixelPerUnitBased) { // Calculate numerator and denominator if (pixelPerUnit > PIXEL_PER_METER) { this.numerator = pixelPerUnit / conversionFactor; this.denominator = 1; } else { this.numerator = 1; this.denominator = PIXEL_PER_METER / pixelPerUnit; } setPixelPerUnitBased(false); } else { // Calculate PPU this.pixelPerUnit = numerator / denominator * conversionFactor; setPixelPerUnitBased(true); } } }
/** * 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(); }
/** * 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(); } }
/** * 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(); }
/** * 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()); }