Scale Bar

The Scale Bar bean is represented by the IlvJAutomaticScaleBar class. This bean enables users to estimate distances using the displayed scale bar.
An example of the Scale Bar is shown in Scale Bar .
scalebar.png
Scale Bar

Including the bean in an application

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

Adding the bean to a Swing container

You can then add this bean into your Swing hierarchy.
panel.add(graphicScale, BorderLayout.SOUTH);
The Scale Bar bean then attaches itself and listens to the IlvDisplayPreferencesProperty property of the manager of the view. Whenever the underlying IlvDisplayPreferences are changed (see Display Preferences Editor), the units used to display distances change.
You can also force the scale bar bean to use specific units, regardless of the IlvDisplayPreferencesProperty settings, by calling the setFarUnit and setNearUnit methods in your application code.

Changing the appearance of the scale bar

The following controls change the appearance of the scale bar:
  • To set the margins between the scale bar and the border of the component:
  • To set the text spacing between the scale text and the scale bar:
    graphicScale.setMarginHeight(2);
    graphicScale.setMarginWidth(2);
    graphicScale.setTextSpacing(2);
    
  • To set the style used to draw the scale bar (double or single scale – alternate colors or not):
    graphicScale.setScaleStyle(IlvScaleBar.DOUBLE_DASH_SCALE_EVEN);
    
  • To change the way labels are displayed:
    graphicScale.setScaleTextMode(IlvScaleBar.THREE_LABELS);
    
  • To set the height of the scale bar:
    graphicScale.setScaleHeight(10);