com.esri.adf.web.data
Class WebScaleBar

java.lang.Object
  extended by com.esri.adf.web.data.WebScaleBar
All Implemented Interfaces:
WebContextInitialize, WebContextObserver, Serializable

public class WebScaleBar
extends Object
implements WebContextInitialize, WebContextObserver, Serializable

The WebScaleBar renders a scale bar within the map control.

To include a scale bar in the map, when declaring the map control in the map tag, a value binding to the scale bar object must be passed.

 <a:map value="#{mapContext.webMap}" scaleBar="#{mapContext.attributes['scaleBar']}" ... />
 

The scale bar may be rendered in one of two ways :
1. Default, calculated in the WebADF.
2. Using ScaleBarFunctionality of the resource.

Default : (Computed in this web control)

 <managed-bean>
   <managed-bean-name>mapContext</managed-bean-name>
   <managed-bean-class>com.esri.adf.web.data.WebContext</managed-bean-class>
   ...
   <map-entry>
     <key>scaleBar</key>
     <value>#{scaleBar}</value>
   </map-entry>
   ...
 </managed-bean>
 

Declared bean (WEB-INF/context-attributes.xml)

  <managed-bean>
   <managed-bean-name>scaleBar</managed-bean-name>
   <managed-bean-class>com.esri.adf.web.data.WebScaleBar</managed-bean-class>
   <managed-bean-scope>none</managed-bean-scope>
 </managed-bean>
 

Using functionality (example : Using AGSScaleBarFunctionality)
Declare bean (WEB-INF/functionalities/ags-functionalities.xml)

 <managed-bean>
   <managed-bean-name>agsScaleBar</managed-bean-name>
   <managed-bean-class>com.esri.adf.web.ags.data.AGSScaleBarFunctionality</managed-bean-class>
   <managed-bean-scope>none</managed-bean-scope>
 </managed-bean>
 

Add agsScaleBar functionality to list of functionalities in the resource. (WEB-INF/faces-config.xml)

 <managed-bean>
   <managed-bean-name>agsResource</managed-bean-name>
   <managed-bean-class>com.esri.adf.web.ags.data.AGSLocalMapResource</managed-bean-class>
   ...
   <managed-property>
     <property-name>functionalities</property-name>
     <map-entries>
       ...
       <map-entry>
         <key>scaleBar</key>
         <value>#{agsScaleBar}</value>
       </map-entry>
     ...
 </managed-bean>
 

Specify resource id to use scale bar functionality (WEB-INF/context-attribute.xml).

 <managed-bean>
   <managed-bean-name>scaleBar</managed-bean-name>
   <managed-bean-class>com.esri.adf.web.data.WebScaleBar</managed-bean-class>
   ...
   <managed-property>
     <property-name>resourceId</property-name>
     <value>agsResource</value>
   </managed-property>
 </managed-bean>
 

Note : When using default scale bar implementation, if no spatial reference information is found in the web context, no scale bar is rendered

See Also:
Serialized Form

Field Summary
static String POSITION_BOTTOM_LEFT
          Position of scabe bar within map control : bottom-left
static String POSITION_BOTTOM_RIGHT
          Position of scabe bar within map control : bottom-right
static String POSITION_NONE
          Position of scabe bar within map control : none
static String POSITION_TOP_LEFT
          Position of scabe bar within map control : top-left
static String POSITION_TOP_RIGHT
          Position of scabe bar within map control : top-right
static String TYPE_ALTERNATING
          Alternating
static String TYPE_DOUBLE_ALTERNATING
          Double Alternating
static String TYPE_SINGLE_DIVISION
          Single Division
static String TYPE_STEPPED_SCALE_LINE
          Stepped Scale Line
static int UNITS_FEET
          Scale bar display units : Feet
static int UNITS_KILOMETERS
          Scale bar display units : Kilometers
static int UNITS_METERS
          Scale bar display units : Meters
static int UNITS_MILES
          Scale bar display units : Miles
 
Constructor Summary
WebScaleBar()
           
 
Method Summary
 void destroy()
          Implements WebContext.destroy()
 int getHeight()
          Get height of scale bar.
 String getImageUrl()
          If the scale bar uses a ScaleBarFunctionality, this method returns the URL to the image generated by calling ScaleBarFunctionality.exportImage().
 double getMapDistance()
          Get map distance represented by scale bar.
 int getMaxPrecision()
          Get maximum precision set.
 String getPosition()
          Get position of scale bar on the map control.
 ScaleBarFunctionality getScaleBarFunctionality()
          Return the scaleBarFunctionality used to draw the scale bar
 double getScreenDistance()
          Get screen distance, in pixels to be drawn by scale bar.
 String getType()
          Get the type of scale bar.
 int getUnits()
          Get the units to be shown in the scale bar.
 int getWidth()
          Get width of scale bar.
 void init(WebContext webContext)
          Implements WebContextInitialize.init(WebContext)
 boolean isScaleBarAvailable()
           Returns true if this scale bar is available for use by the user.
 void setHeight(int height)
          Set height of scale bar.
 void setMaxPrecision(int maxPrecision)
          Set maximum precision.
 void setPosition(String position)
          Set the position of the scale bar on the map control.
 void setResourceId(String resourceId)
          Set resource id to be used to retrieve scaleBarFunctionality.
 void setScaleBarFunctionality(ScaleBarFunctionality scaleBarFunctionality)
          Set the ScaleBarFunctionality that must be used to render the scalebar.
 void setType(String type)
          Set the type of scale bar to be rendered.
 void setUnits(int units)
          Set the units of scale bar to be rendered.
 void setWidth(int width)
          Set width of scale bar.
 void update(WebContext webContext, Object arg)
          Implements WebContextObserver.update(WebContext, Object)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNITS_METERS

public static final int UNITS_METERS
Scale bar display units : Meters

See Also:
Constant Field Values

UNITS_KILOMETERS

public static final int UNITS_KILOMETERS
Scale bar display units : Kilometers

See Also:
Constant Field Values

UNITS_FEET

public static final int UNITS_FEET
Scale bar display units : Feet

See Also:
Constant Field Values

UNITS_MILES

public static final int UNITS_MILES
Scale bar display units : Miles

See Also:
Constant Field Values

TYPE_ALTERNATING

public static final String TYPE_ALTERNATING
Alternating

See Also:
Constant Field Values

TYPE_DOUBLE_ALTERNATING

public static final String TYPE_DOUBLE_ALTERNATING
Double Alternating

See Also:
Constant Field Values

TYPE_SINGLE_DIVISION

public static final String TYPE_SINGLE_DIVISION
Single Division

See Also:
Constant Field Values

TYPE_STEPPED_SCALE_LINE

public static final String TYPE_STEPPED_SCALE_LINE
Stepped Scale Line

See Also:
Constant Field Values

POSITION_BOTTOM_LEFT

public static final String POSITION_BOTTOM_LEFT
Position of scabe bar within map control : bottom-left

See Also:
Constant Field Values

POSITION_BOTTOM_RIGHT

public static final String POSITION_BOTTOM_RIGHT
Position of scabe bar within map control : bottom-right

See Also:
Constant Field Values

POSITION_TOP_RIGHT

public static final String POSITION_TOP_RIGHT
Position of scabe bar within map control : top-right

See Also:
Constant Field Values

POSITION_TOP_LEFT

public static final String POSITION_TOP_LEFT
Position of scabe bar within map control : top-left

See Also:
Constant Field Values

POSITION_NONE

public static final String POSITION_NONE
Position of scabe bar within map control : none

See Also:
Constant Field Values
Constructor Detail

WebScaleBar

public WebScaleBar()
Method Detail

init

public void init(WebContext webContext)
Implements WebContextInitialize.init(WebContext)

Specified by:
init in interface WebContextInitialize
Parameters:
webContext - WebContext- the WebContext
See Also:
WebContext.init(WebContext), WebContext.addResource(String, GISResource, int), WebContext.removeResource(GISResource)

update

public void update(WebContext webContext,
                   Object arg)
Implements WebContextObserver.update(WebContext, Object)

Specified by:
update in interface WebContextObserver
Parameters:
webContext - the WebContext that has been refreshed
arg - the argument passed to the WebContext's refresh(arg) method
See Also:
WebContext.refresh(Object), WebContext.addObserver(WebContextObserver), WebContext.removeObserver(WebContextObserver)

destroy

public void destroy()
Implements WebContext.destroy()

Specified by:
destroy in interface WebContextInitialize
See Also:
WebContext.destroy()

getImageUrl

public String getImageUrl()
If the scale bar uses a ScaleBarFunctionality, this method returns the URL to the image generated by calling ScaleBarFunctionality.exportImage().


setScaleBarFunctionality

public void setScaleBarFunctionality(ScaleBarFunctionality scaleBarFunctionality)
Set the ScaleBarFunctionality that must be used to render the scalebar.

Parameters:
scaleBarFunctionality -

getScaleBarFunctionality

public ScaleBarFunctionality getScaleBarFunctionality()
Return the scaleBarFunctionality used to draw the scale bar


setResourceId

public void setResourceId(String resourceId)
Set resource id to be used to retrieve scaleBarFunctionality.

Parameters:
resourceId -

getWidth

public int getWidth()
Get width of scale bar.


setWidth

public void setWidth(int width)
Set width of scale bar. If using functionality, this property is ignored. Default 200.

Parameters:
width - Width of scale bar in pixels.

getHeight

public int getHeight()
Get height of scale bar.


setHeight

public void setHeight(int height)
Set height of scale bar. If using functionality, this property is ignored. Default 40.

Parameters:
height - Height of scale bar in pixels.

getPosition

public String getPosition()
Get position of scale bar on the map control.


setPosition

public void setPosition(String position)
Set the position of the scale bar on the map control. Default POSITION_BOTTOM_LEFT.

Parameters:
position - Position of scale bar on map control. Possible values POSITION_BOTTOM_LEFT, POSITION_BOTTOM_RIGHT, POSITION_TOP_RIGHT, POSITION_TOP_LEFT, POSITION_NONE. If position is POSITION_NONE, style declared in esri_styles.css is applied.

getMapDistance

public double getMapDistance()
Get map distance represented by scale bar. If using functionality, this property is null.


getScreenDistance

public double getScreenDistance()
Get screen distance, in pixels to be drawn by scale bar. If using functionality, this property is null.


getMaxPrecision

public int getMaxPrecision()
Get maximum precision set.


setMaxPrecision

public void setMaxPrecision(int maxPrecision)
Set maximum precision. Max precision specifies the maximum that the decimal can be moved to the right to calculate map distance. If using functionality, this property is ignored. Default 10.

Parameters:
maxPrecision -

getType

public String getType()
Get the type of scale bar.


setType

public void setType(String type)
Set the type of scale bar to be rendered. If using functionality, this property is ignored.

Parameters:
type - Type of scale bar. Possible values, TYPE_ALTERNATING, TYPE_DOUBLE_ALTERNATING, TYPE_SINGLE_DIVISION, TYPE_STEPPED_SCALE_LINE. Default TYPE_ALTERNATING.

getUnits

public int getUnits()
Get the units to be shown in the scale bar.


setUnits

public void setUnits(int units)
Set the units of scale bar to be rendered. If using functionality, this property is ignored.

Parameters:
units - Type of scale bar. Possible values, UNITS_METERS, UNITS_KILOMETERS, UNITS_FEET, UNITS_MILES. Default UNITS_METERS.

isScaleBarAvailable

public boolean isScaleBarAvailable()

Returns true if this scale bar is available for use by the user.

The scale bar is available if it is associated with a ScaleBarFunctionality or if the WebContext has a spatial reference associated with it.

Returns:
true if this scale bar is available for use by the user