Scale Control Bar

The Scale Control Bar bean is represented by the IlvJMapScaleControl class. This bean enables users to see the scale of the map. The setscale.png button also enables users to control the scale interactively by entering a new setting.
An example of the Scale Control Bar is shown in Scale Control Bar.
scalebar1.png
Scale Control Bar

Including the bean in an application

To include the Scale Control Bar bean in your application, write the following lines of code:
IlvJMapScaleControl scaleControl = new IlvJMapScaleControl();
scaleControl.setView(view);

Adding the bean to a Swing container

You can then add this bean in your Swing hierarchy.
panel.add(scaleControl, BorderLayout.SOUTH);
The Scale Control Bar bean then attaches itself and listens for scale changes for the view in order to update the displayed scale.

Customizing the appearance and behavior

You can prevent users from entering changes to the map scale by means of this bean (this makes the Control Scale button disappear) using:
scaleControl.setAllowScaleEdition(false); 
If the way the scale is presented is not appropriate for your needs, many tools are provided to change the prefix (“1/”), suffix, or even the number formatter:
scaleControl.setPrefix(null);
scaleControl.setSuffix("th");
scaleControl.setScaleFormat(new DecimalFormat());