Programming with JViews Maps > Creating a Map Application Using the API > Using the GUI Beans > Area of Interest Panel

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 Figure 3.3.

areainterest.png

Figure 3.3 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 popup) 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:

IlvRect rectangle=new IlvRect((float)Math.toRadians(15),(float)Math.toRadians(35),(float)Math.toRadians(45),(float)Math.toRadians(25));
IlvAreaOfInterest europe=new IlvAreaOfInterest("Europe",rectangle,0,null);
IlvJAreaOfInterestPanel.refreshPreview(view,europe,64);
IlvAreaOfInterestVector areas=IlvAreasOfInterestProperty.GetAreasOfInterest(view.getManager());
areas.addElement(europe);