The Area of Interest panel bean is represented by the IlvJAreaOfInterestPanel class. The Area of
Interest panel bean enables users to select and display frequently
used areas of a map.
An example of the Area of Interest panel is shown in Area of Interest panel.
![areainterest.png](../usrprgmaps/_media/areainterest_default.png)
Area of Interest panel
Including the bean in an application
To include the Area of Interest panel bean
in your application, write the following line of code:
IlvJAreaOfInterestPanel areaPanel = new IlvJAreaOfInterestPanel(view, true, true, true);
The first boolean value indicates whether
users can add areas of interest, the second boolean allows them
to remove areas of interest, and the third boolean allows them to
rename areas of interest.
Adding the bean to a Swing container
You then have to insert the bean into your
swing user interface:
panel.add(areaPanel, BorderLayout.CENTER);
The Area of Interest panel bean then attaches itself and listens
to the IlvAreasOfInterestProperty property of the
manager of the view. Whenever an area is added to the underlying
IlvAreaOfInterestVector, its name and
preview icon are displayed on the Area of Interest panel bean.
Managing the Area of Interest and preview images
This panel also provides interesting
static utility methods to manage the preview images and the
creation of the area of interest.
To create an area for everything visible on the view (this is the
method usually called when clicking the New
Area of Interest button), you can insert the following lines of
code in your application:
IlvAreaOfInterest currentArea=IlvJAreaOfInterestPanel.createLocationFromView(view,64,false); currentArea.setName("Current Area");
If you want the users to provide the area
name themselves (by means of a dialog box) use:
IlvAreaOfInterest currentArea=IlvJAreaOfInterestPanel.createLocationFromView(view,64,true);
This bean also provides a method that
updates the area of interest preview icon with what would be
visible with the current map settings and contents:
IlvJAreaOfInterestPanel.refreshPreview(view,area,maxDimension);
For example:
- To create an area for Europe bounds:
IlvRect rectangle=new IlvRect((float)Math.toRadians(15),(float)Math.toRadians(35),(float)Math.toRa dians(45),(float)Math.toRadians(25)); IlvAreaOfInterest europe=new IlvAreaOfInterest("Europe",rectangle,0,null);
- To update its preview image:
IlvJAreaOfInterestPanel.refreshPreview(view,europe,64);
- You would then have to add the area to the property of the manager for proper management by the Area of Interest bean:
IlvAreaOfInterestVector areas=IlvAreasOfInterestProperty.GetAreasOfInterest(view.getManager()); areas.addElement(europe);