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; }
public static String scaleToString(ScaleInfo scale) { NumberFormat numberFormat = NumberFormat.getFormat("###,###"); return numberFormat.format(scale.getNumerator()) + " : " + numberFormat.format(scale.getDenominator()); }
/** * 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()); }