Class TLcdScaleFormat

java.lang.Object
java.text.Format
com.luciad.text.TLcdScaleFormat
All Implemented Interfaces:
ILcdFormatter, ILcdParser, Serializable, Cloneable

public class TLcdScaleFormat extends Format implements ILcdFormatter, ILcdParser

Formats and parses unitless map scale ratios of the format nominator separator denominator from and to the double representation of the scale.
The parse method also accepts single values, which are interpreted as 1 separator value.

Some examples:


   TLcdScaleFormat scaleFormat = new TLcdScaleFormat(NumberFormat.getInstance(Locale.US));
   String scaleAsString = "1:25,000";
   Double scale = scaleFormat.parse(scaleAsString);//0.00004
   TLcdMapScale scale = scaleFormat.parseMapScale(scaleAsString);//a TLcdMapScale of 1:25,000
 
and

  TLcdScaleFormat scaleFormat = new TLcdScaleFormat(NumberFormat.getInstance(Locale.US));
  Double scale = 0.00004;
  String scaleAsString = scaleFormat.format(scale);//"1 : 25,000"
  String scaleAsString = scaleFormat.format(new TLcdMapScale(scale));//"1 : 25,000"
 
The format also parses numbers with common decadic multiple suffixes (k for kilo, m for mega/million, b for billion, g for giga, t for trillion/tera). For example:

  TLcdScaleFormat scaleFormat = new TLcdScaleFormat(NumberFormat.getInstance(Locale.US));
  String scaleAsString = "1:25K";
  Double scale = scaleFormat.parse(scaleAsString);//0.00004
 
Since:
2012.1
See Also:
  • Constructor Details

    • TLcdScaleFormat

      public TLcdScaleFormat()
      Creates a new scale format with a default NumberFormat used to parse and format the nominator and denominator, and a default separator character (':').
    • TLcdScaleFormat

      public TLcdScaleFormat(NumberFormat aNumberFormat)
      Creates a new scale format where aNumberFormat is used to parse and format the nominator and denominator. A default separator character is used (':').
      Parameters:
      aNumberFormat - The number format used for parsing and formatting of the nominator and denominator
    • TLcdScaleFormat

      public TLcdScaleFormat(NumberFormat aNumberFormat, char aSeparator)
      Creates a new scale format where aNumberFormat is used to parse and format the nominator and denominator. aSeparator is used to separate the nominator from the denominator
      Parameters:
      aNumberFormat - The number format used for parsing and formatting of the nominator and denominator
      aSeparator - The separator char between the nominator and the denominator. aNumberFormat must not parse aSeparator, so e.g. using a '.' as separator might not work with certain Locale settings.
  • Method Details