|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.graphics.map.ESRIMap
public class ESRIMap
The ESRIMap class is, at it's core, an image server, whose images are retrieved from a running ArcGIS Server. It encapsulates all of the communication with the ArcGIS Server,and the interfaces and classes for managing and manipulating maps via that server. Map layer management, zooming, panning, selections, etc. are handled by the methods on this class. There are no OLAP specific implementations on this class, so it should be able to be used in relational data applications, as well.
After getting a map image, always disconnect from the ArcGIS Server. Thus, you should connect to the server, get an image, and disconnect. If you neglect the disconnect() after connecting and using a map, the map service will be held the ArcGIS Server, which has a limited number of instances available.
Using the ESRIMap class, you can perform basic operations such as zoom, pan, selection, etc.
Working with layers from the MapService: Each map service is comprised of layers. There must be a corresponding layer to the data that you send to ESRIMap. The linking between the data and the map layer is done with the descriptorList that is passed into the classify() method and with layername and fieldname.
Retrieving the MapImage: The map and legend image are returned as PNG encoded MIME data, in the form of a byte stream. The following code may be used to convert the byte stream into a Java Image.
ImageIcon myImageIcon = new ImageIcon( esriMap.getImageMimeData() ); Image myImage = myImageIcon.getImage();
Constructor Summary | |
---|---|
ESRIMap()
Initializes a newly created object |
|
ESRIMap(ESRIConnection connection)
Creates a new ESRIMap, and initializes a server based on the information in the provided ESRIConnection object. |
Method Summary | |
---|---|
void |
applyGraphStyle(GraphStyle style)
This method sets color and font information on ESRIMap. |
double |
calculateDistance(int startx,
int starty,
int endx,
int endy)
Returns the distance (in map coordinates) between two points (in screen coordinates) |
java.lang.String |
chooseField(java.lang.Object[] data,
java.lang.String layerName,
java.lang.String[] fieldNames,
int numToCheck)
Selects a field, from those provided, that best matches the provided data. |
void |
classify(com.sas.graphics.components.CategorizationModel cm,
java.lang.String layerName,
java.lang.String fieldName,
java.lang.String[] descriptorList,
java.lang.Double[] valueList,
java.lang.Boolean[] exceptionList)
Classifies the map based on the desired classification type and the number of desired breaks. |
void |
clearAllSubsets()
Clears any subsets that have been applied to the map. |
void |
clearAnnotations()
Clears any MapAnnotations that have been set on this object. |
void |
clearSelections()
Clears any selections that have been set on the map. |
void |
clearSubset(java.lang.String layerName)
Clears any subset that's been set on a specific layer. |
void |
connect()
Establish the connection to ArcGIS Server. |
double[] |
convertToMapCoord(int x,
int y)
Converts a screen coordinate to a map coordinate |
void |
disconnect()
Release Context and remove all the connection between Client and ArcGIS Server. |
java.util.HashMap |
getDefaultLayerVisibilities()
Gets a list of the layers available on the map service, and a value indicating their default visibility. |
java.lang.String[] |
getFieldNames(java.lang.String layerName)
Returns an array of field names available on the specified layer of the map service. |
java.lang.Object[] |
getFieldValues(java.lang.String layerName,
java.lang.String fieldName,
int numValues)
Returns an array of values from the map service, based on the layerName and fieldName provided. |
java.lang.String |
getImageDescription()
Return the Image Description as String. |
byte[] |
getImageMimeData()
Returns the generated map image as MIME Data. |
java.lang.String |
getImageURL()
When using this method the map image is stored on the ArcGIS server, and a URL is passed back to use as a link to the image. |
com.esri.arcgis.carto.IMap |
getIMap()
Returns the IMap reference used by this object. |
com.esri.arcgis.carto.IMapServer |
getIMapServer()
Returns the IMapServer reference used by this object. |
java.lang.String[] |
getLayerNames()
Returns a list of all layer names on the map service. |
java.util.HashMap |
getLayerVisibilities()
Gets a list of the layers available on the map service, and a value indicating their visibility. |
java.lang.String |
getLayerVisibility(java.lang.String layerName)
Returns whether the specified layer is visible Possible values are: ESRIConnection.ESRI_LAYER_ALWAYSOFF - The indicated layer is never drawn. |
byte[] |
getLegendMimeData(boolean noDataToDisplay)
Returns the legend image as MIME data. |
java.lang.String |
getLegendTitle()
Returns the currently set legend title. |
java.lang.String |
getLegendValueFormat()
Returns the format that is currently being used by the legend values. |
java.util.Locale |
getLocale()
Returns the Locale object used by this class. |
void |
getMap()
Loads the map with the default map and image descriptions. |
void |
getMap(java.lang.String strMapDesc,
java.lang.String strImageDesc)
Loads the map based on the passed in mapDescription and imageDescription. |
java.lang.String |
getMapDescription()
Return the Description as String. |
double[] |
getMapExtents()
Returns the currently used map extents. |
java.lang.String[] |
getMapServiceNames()
Returns a list of ESRI Map Service names that are available on the map server. |
java.lang.String[] |
getSelectList(java.util.Map layerToFieldMap)
Returns a list of selected regions. |
java.lang.String[] |
identify(int x,
int y)
Identifies a map feature based on Mouse click selection. |
java.lang.String[] |
identify(int x,
int y,
java.lang.String[] fieldIds)
Identifies a map feature based on Mouse click selection. |
boolean |
isShowLegendTitle()
Returns whether the legend title is currently displayed. |
boolean |
isShowMissing()
Returns whether missing values should show up in the legend, if they are present in the map. |
boolean |
isUseBoundsColors()
Sets whether the overflow and underflow colors should be used. |
boolean |
isUseTwoColorRamp()
Returns whether the ESRIMap is currently using a two color ramp. |
boolean |
isValidLayer(java.lang.String layerName)
Checks to see if layerName is a valid layer on the map service. |
boolean |
isValidLayerAndField(java.lang.String layerName,
java.lang.String fieldName)
This is a convenience method that will check to see if the passed in layer name is valid, and if so, whether fieldName is a valid field on that layer. |
void |
pan(int startx,
int starty,
int endx,
int endy)
Pans the current map extent. |
int |
rectangularSelect(int startx,
int starty,
int endx,
int endy,
boolean controlPressed,
java.lang.String classifiedLayer)
Uses a rectangle to select regions and add their feature IDs to the selection list. |
void |
resetMapDescription()
Resets the saved map description to the current map description. |
int |
select(int x,
int y,
boolean controlPressed,
java.lang.String classifiedLayer)
Selects a map region and adds its feature ID to the selection list |
int |
selectByField(java.lang.String[] values,
boolean controlPressed,
java.lang.String classifiedLayer,
java.lang.String fieldName)
This method will search through the features on the passed in classifiedLayer, and select those features in which the fieldName is equal to one of the passed in values. |
java.lang.String[] |
selectLayerAndField(int x,
int y,
java.util.Map layerToFieldMap)
Utility routine to retrieve the map layer and field value based on mouse click location. |
void |
setAnnotations(java.util.ArrayList annotations)
Sets an ArrayList of MapAnnotations that are drawn on the map. |
void |
setLayerVisibilities(java.util.HashMap map)
Sets the visibilities of the layers using the passed-in HashMap. |
void |
setLayerVisibility(java.lang.String layerName,
java.lang.String visible)
Changes the visibility of the passed-in layer. |
void |
setLegendImageSize(java.awt.Dimension d)
Sets the size of the exported legend image. |
void |
setLegendTitle(java.lang.String legendTitle)
Sets the title to be displayed on the legend image. |
void |
setLegendValueFormat(java.lang.String legendFormat)
Sets the format to be used on the legend values. |
void |
setLocale(java.util.Locale locale)
Sets the Locale object used by this class. |
void |
setMapExtents(double xmin,
double xmax,
double ymin,
double ymax)
Sets the map extents that should be used for this map. |
void |
setMapImageSize(java.awt.Dimension d)
Sets the size of the exported map image. |
void |
setShowLegendTitle(boolean showLegendTitle)
Sets whether or not the legend title should be displayed in the legend image. |
void |
setShowMissing(boolean showMissing)
Sets whether missing values should show up in the legend, if they are present in the map. |
void |
setUseBoundsColors(boolean useBoundsColors)
Returns whether the overflow and underflow colors should be used for values that don't fall into a range. |
void |
setUseTwoColorRamp(boolean useTwoColorRamp)
ESRIMap can either use a two color ramp or a three color ramp when creating colors for classifying the data. |
void |
subset(java.lang.String layerName,
java.lang.String fieldName,
java.lang.String[] values)
Subsets the map based on the features described by the fieldName and values parameters. |
double[] |
testData(java.lang.Object[] data,
java.lang.String layerName,
java.lang.String fieldName)
This method checks to see how much of the passed-in data matches the data that is found on the ESRI map service. |
void |
undoClassification(java.lang.String layerName)
Undoes any classification that has been done on the specified layer. |
double[] |
zoomFeatures(java.lang.String layerName,
java.lang.String fieldName,
java.lang.String[] values)
Zooms to the minimum extents that surround the features described by the fieldName and values parameters. |
void |
zoomFullExtent()
Zooms the extent of the current map to the full extent of that map, which is the default extent on that map service. |
void |
zoomIn(int x,
int y,
double factor)
Zooms and centers the extent of the current map to the specified pixelX, pixelY, and factor arguments. |
void |
zoomOut(int x,
int y,
double factor)
Zooms out and centers the extent of the current to the specified pixelX, pixelY, and factor arguments. |
void |
zoomTo(int startx,
int starty,
int endx,
int endy)
Zooms the map to the provided rectangle, defined in pixel coordinates pixelX, pixelY, and factor arguments. |
void |
zoomTo(long startx,
long starty,
long endx,
long endy)
Zooms the map to the provided rectangle, defined in map coordinates. |
Constructor Detail |
---|
public ESRIMap()
public ESRIMap(ESRIConnection connection)
connection
- - Contains the information needed to connect and use the ESRI serverESRIConnection
Method Detail |
---|
public void connect() throws ESRIException
NOTE!!! It is very important that the call to disconnect() is made after the map has been used. Failure to do so will cause the map service to be held by the ArcGIS Server, which has a limited number of instances available. The intended use is to connect to the service, get an image, and disconnect.
ESRIException
- when Server does not exist or wrong authetication detailsdisconnect()
public void disconnect() throws ESRIException
ESRIException
- when server fails to release objectconnect()
public java.lang.String getMapDescription()
public java.lang.String getImageDescription()
public void getMap(java.lang.String strMapDesc, java.lang.String strImageDesc) throws ESRIException
strMapDesc
- value of Map DescriptionstrImageDesc
- value of Image Description
ESRIException
- when either Map or Image Description are not able to loadresetMapDescription()
,
getMapDescription()
,
getImageDescription()
public void getMap() throws ESRIException
ESRIException
- when there is a problem connecting or getting information
from the ESRI server.public java.lang.String getImageURL() throws ESRIException
ESRIException
- failed to get the url from ArcGIS ServergetImageMimeData()
public byte[] getImageMimeData() throws ESRIException
ESRIException
- failed to get the MimeData from ArcGIS ServergetImageURL()
public byte[] getLegendMimeData(boolean noDataToDisplay)
noDataToDisplay
- true if there is no data to draw a legend with, or if
the user wantes the default, "No values" legend.
getImageMimeData()
public void zoomIn(int x, int y, double factor) throws ESRIException
x
- the X pixel value to center.y
- the Y pixel value to center.factor
- the value to zoom the map by.
ESRIException
- when there is a problem connecting or getting information
from the ESRI server.public void resetMapDescription()
public void zoomTo(int startx, int starty, int endx, int endy) throws ESRIException
startx
- the X pixel value of the top left corner.starty
- the Y pixel value of the top left corner.endx
- the X pixel value of the bottom right corner.endy
- the Y pixel value of the bottom right corner.
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public void zoomTo(long startx, long starty, long endx, long endy) throws ESRIException
startx
- the X value of the top left corner.starty
- the Y value of the top left corner.endx
- the X value of the bottom right corner.endy
- the Y value of the bottom right corner.
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public double[] zoomFeatures(java.lang.String layerName, java.lang.String fieldName, java.lang.String[] values) throws ESRIException
layerName = "States"
fieldName = "StateName"
vales = ["North Carolina","South Carolina"]
layerName
- - The name of the layer to searchfieldName
- - The field in the map service to usevalues
- - The values for the field to "subset", find the extents, and
return them.
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public void subset(java.lang.String layerName, java.lang.String fieldName, java.lang.String[] values) throws ESRIException
layerName = "States"
fieldName = "StateName"
vales = ["North Carolina","South Carolina"]
Note: In order to see the effects of this method, the layer must be visible.
layerName
- - The name of the layer to searchfieldName
- - The field in the map service to usevalues
- - The values for the field to subset
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.setLayerVisibilities(HashMap)
,
setLayerVisibility(String, String)
public void clearAllSubsets() throws ESRIException
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public void clearSubset(java.lang.String layerName) throws ESRIException
layerName
- - The layer name
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public java.lang.String[] identify(int x, int y) throws ESRIException
["StateName","North Carolina","FIPS","37"]
x
- the X pixel value of selection.y
- the Y pixel value of selection.
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public java.lang.String[] identify(int x, int y, java.lang.String[] fieldIds) throws ESRIException
["StateName","North Carolina","FIPS","37"]
x
- the X pixel value of selection.y
- the Y pixel value of selection.fieldIds
- the field name of the desired field/value pairs to return. If
this is null, all field/value pairs are returned.
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public void zoomOut(int x, int y, double factor) throws ESRIException
x
- the X pixel value to center.y
- the Y pixel value to center.factor
- -
How much to zoom out.
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public void zoomFullExtent() throws ESRIException
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public void pan(int startx, int starty, int endx, int endy) throws ESRIException
startx
- starty
- endx
- endy
-
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public java.lang.String[] getLayerNames() throws ESRIException
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public void setLayerVisibilities(java.util.HashMap map) throws ESRIException
map
- a HashMap containing entries with a layername as a key and one of the above visibility
values as its value
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.setLayerVisibility(String, String)
public void setLayerVisibility(java.lang.String layerName, java.lang.String visible) throws ESRIException
layerName
- - The name of the layervisible
- - The new visibility value
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public void clearSelections() throws ESRIException
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public void classify(com.sas.graphics.components.CategorizationModel cm, java.lang.String layerName, java.lang.String fieldName, java.lang.String[] descriptorList, java.lang.Double[] valueList, java.lang.Boolean[] exceptionList) throws ESRIException
The supported classification types are:
cm
- - The CategorizationModel used to determine the break values.layerName
- - The layer name to classify.fieldName
- - The field on that layer to usedescriptorList
- - A list of the id field values of the map features to
classify. For instance, the array might be { "NC","SC" } if North Carolina
and South Carolina were to be classified.valueList
- - A list of values that correspond to the descriptorList. This array
represents the measure value for each colored feature. For instance, using
the above example, the array
might be { 100000, 112000 } if North Carolina had a measure value of 100000 and
South Carolina had a measure value of 112000.exceptionList
- - A list of booleans that determine if each observation should
be represented by the excepetion color, instead of drawn in the normal color.
This list can be null.
Note: In order for the effects of this method to be seen, the layer must be visible.
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.setLayerVisibilities(HashMap)
,
setLayerVisibility(String, String)
public void undoClassification(java.lang.String layerName) throws ESRIException
layerName
- The name of the layer
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.classify(CategorizationModel, String, String, String[], Double[], Boolean[])
public void setMapExtents(double xmin, double xmax, double ymin, double ymax) throws ESRIException
xmin
- - Minimum x value of the envelope to usexmax
- - Maximum x value of the envelope to useymin
- - Minimum y value of the envelope to useymax
- - Maximum y value of the envelope to use
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public double[] getMapExtents() throws ESRIException
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server. Most likely this is due to not finding a map area or its extents.public java.lang.String[] getSelectList(java.util.Map layerToFieldMap) throws ESRIException
layerToFieldMap
- The Map of layer names and corresponding field names
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public java.lang.String[] selectLayerAndField(int x, int y, java.util.Map layerToFieldMap) throws ESRIException
x
- the X pixel value of mouse click event.y
- the Y pixel value of mouse click event.layerToFieldMap
- the map of which fields to use with which layers.
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public int rectangularSelect(int startx, int starty, int endx, int endy, boolean controlPressed, java.lang.String classifiedLayer) throws ESRIException
startx
- The x value of the top-left corner of the selection
rectangle, in pixel coordinatesstarty
- The y value of the top-left corner of the selection
rectangle, in pixel coordinatesendx
- The x value of the bottom-right corner of the selection
rectangle, in pixel coordinatesendy
- The y value of the bottom-right corner of the selection
rectangle, in pixel coordinatescontrolPressed
- If control is pressed, any resulting selections will be
added to the current selection list. Otherwise, they will
replace the current list.classifiedLayer
- The layer that is currently being classified.
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public int select(int x, int y, boolean controlPressed, java.lang.String classifiedLayer) throws ESRIException
x
- The X pixel value of selection point.y
- The Y pixel value of selection point.controlPressed
- - If control is pressed, any resulting selections will
be added to the current selection list. Otherwise, they will replace the
current list.classifiedLayer
- - The layer that is currently being classified.
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public double calculateDistance(int startx, int starty, int endx, int endy) throws ESRIException
startx
- The start x positionstarty
- The start y positionendx
- The end x positionendy
- The end y position
ESRIException
public int selectByField(java.lang.String[] values, boolean controlPressed, java.lang.String classifiedLayer, java.lang.String fieldName) throws ESRIException
values
- the values to selectcontrolPressed
- whether to keep any previous selectionsclassifiedLayer
- the name of the layer to select onfieldName
- the name of the field on that layer
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public void setMapImageSize(java.awt.Dimension d)
d
- The size of the imagepublic void setLegendImageSize(java.awt.Dimension d)
d
- The size of the imagepublic java.util.Locale getLocale()
public void setLocale(java.util.Locale locale)
locale
- The locale to set.public boolean isShowMissing()
public void setShowMissing(boolean showMissing)
showMissing
- Boolean used to display missings in the legend.public boolean isUseTwoColorRamp()
setUseTwoColorRamp(boolean)
public void setUseTwoColorRamp(boolean useTwoColorRamp)
useTwoColorRamp
- The useTwoColorRamp to set.setStartColor(Color)
,
setMidColor(Color)
,
setEndColor(Color)
public java.lang.String getLegendValueFormat()
setLegendValueFormat(String)
public void setLegendValueFormat(java.lang.String legendFormat)
legendFormat
- The legendFormat to set.getLegendValueFormat()
public java.util.HashMap getLayerVisibilities() throws ESRIException
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.setLayerVisibilities(HashMap)
,
setLayerVisibility(String, String)
public java.util.HashMap getDefaultLayerVisibilities() throws ESRIException
ESRIException
setLayerVisibilities(HashMap)
,
setLayerVisibility(String, String)
public java.lang.String getLayerVisibility(java.lang.String layerName) throws ESRIException
layerName
- The name of the layer
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.setLayerVisibilities(HashMap)
,
setLayerVisibility(String, String)
public boolean isValidLayer(java.lang.String layerName) throws ESRIException
layerName
- The name to check
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public boolean isValidLayerAndField(java.lang.String layerName, java.lang.String fieldName) throws ESRIException
layerName
- The layer to check forfieldName
- The field on that layer
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public java.lang.String getLegendTitle()
public void setLegendTitle(java.lang.String legendTitle)
legendTitle
- The new titlegetLegendTitle()
,
setShowLegendTitle(boolean)
public boolean isShowLegendTitle()
setShowLegendTitle(boolean)
,
setLegendTitle(String)
public void setShowLegendTitle(boolean showLegendTitle)
showLegendTitle
- whether to show the legend titlesetLegendTitle(String)
,
isShowLegendTitle()
public com.esri.arcgis.carto.IMap getIMap()
public com.esri.arcgis.carto.IMapServer getIMapServer()
public java.lang.Object[] getFieldValues(java.lang.String layerName, java.lang.String fieldName, int numValues) throws ESRIException
layerName
- Name of the ESRI map layerfieldName
- FieldName of the variable to look atnumValues
- Number of values to return, or -1 to return all values
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public double[] testData(java.lang.Object[] data, java.lang.String layerName, java.lang.String fieldName) throws ESRIException
data
- The data to check againstlayerName
- The layer on the ESRI map servicefieldName
- The field name on that layer
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public java.lang.String[] getFieldNames(java.lang.String layerName) throws ESRIException
layerName
- The layer to check
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public java.lang.String chooseField(java.lang.Object[] data, java.lang.String layerName, java.lang.String[] fieldNames, int numToCheck) throws ESRIException
data
- The array of data to check againstlayerName
- The layer of the map service to checknumToCheck
- Number of map service values that should be used to check, or -1 to check
all values
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public java.lang.String[] getMapServiceNames() throws ESRIException
ESRIException
- when there is a problem connecting to or getting information
from the ESRI server.public void applyGraphStyle(GraphStyle style)
The font information for the legend values is also retrieved from the GraphStyle.
style
- GraphStyle to usepublic boolean isUseBoundsColors()
setUseBoundsColors(boolean)
public void setUseBoundsColors(boolean useBoundsColors)
useBoundsColors
- Whether to use the boundary colors.isUseBoundsColors()
public void setAnnotations(java.util.ArrayList annotations)
annotations
- public void clearAnnotations()
public double[] convertToMapCoord(int x, int y)
x
- The x positiony
- The y position
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |