|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.esri.adf.web.data.WebGraphics
public class WebGraphics
The WebGraphics class represents a simple way to add feature graphics and images to a map. It is primarily intended
for showing geographic items on the map whose geographic position does not necessarily matter. Some example uses for
the WebGraphics include adding a logo for your organization to the map, adding text to the map such as a copyright,
or adding a scalebar. There is no restriction on the types of features added to a WebGraphics; points, lines, and
polygons can all be added. Images can also be added by implementing GraphicImage2
interface and adding it to
WebGraphics. There can only be one WebGraphics associated with a map at a given time.
WebGraphics items are added at the top of the map, above all layers from all resources. Their visibility can not be
controlled through the TOC (table of contents) control. Queries can not be executed against WebGraphics since it is
not a type of GISResource. You can add items to WebGraphics by calling any of these methods
addGraphics(GraphicElement)
or addRenderer(GraphicRenderer)
or addImage(GraphicImage)
An alternative for adding geographic features programmatically is to use the GraphicsResource
which allows
you to display and query geographic features and allows for those items to appear in the TOC. GraphicsResources also
allow for multiple GraphicsLayers, therefore it’s possible to group features as layers which allows for the
visibility of those groups of features to be changed by the end-user. This is not easily done with the WebGraphics.
To use the WebGraphics, it needs to be registered as a context attribute of the WebContext. This is most commonly done through settings in the context-attributes.xml file and the faces-config.xml file for the web application. If you generate an application through Manager or IDE wizards, it will have done this for you.
Here is an example of how WebGraphics is declared in context-attributes.xml :
<managed-bean>
<managed-bean-name>graphics</managed-bean-name>
<managed-bean-class>com.esri.adf.web.data.WebGraphics</managed-bean-class>
<managed-bean-scope>none</managed-bean-scope>
</managed-bean>
Here is an example of how WebGraphics is registered as an attribute of the WebContext in faces-config.xml:
<managed-bean>
<managed-bean-name>mapContext</managed-bean-name>
<managed-property>
<property-name>attributes</property-name>
<map-entries>
<map-entry>
<key>graphics</key>
<value>#{graphics}</value>
</map-entry>
.
.
.
</map-entries>
</managed-property>
</managed-bean>
Field Summary | |
---|---|
protected WebContext |
context
Holds the reference to WebContext object. |
protected WebExtent |
extent
Holds the map's current extent. |
protected byte[] |
imageBytes
Holds the WebGraphics image bytes. |
protected List<GraphicImage> |
images
Holds the list of image that are available in the WebGraphics. |
protected List<GraphicElement> |
lineGraphics
Holds the list of polyline graphics that are available in the WebGraphics. |
protected List<GraphicImage> |
lineImages
Holds the list of polyline images that are available in the WebGraphics. |
protected List<GraphicRenderer> |
lineRenderers
Holds the list of polyline renderers that are available in the WebGraphics. |
protected List<GraphicElement> |
pointGraphics
Holds the list of point graphics that are available in the WebGraphics. |
protected List<GraphicImage> |
pointImages
Holds the list of point images that are available in the WebGraphics. |
protected List<GraphicRenderer> |
pointRenderers
Holds the list of point renderers that are available in the WebGraphics. |
protected List<GraphicElement> |
polygonGraphics
Holds the list of polygon graphics that are available in the WebGraphics. |
protected List<GraphicImage> |
polygonImages
Holds the list of polygon images that are available in the WebGraphics. |
protected List<GraphicRenderer> |
polygonRenderers
Holds the list of polygon renderers that are available in the WebGraphics. |
static String |
WEBGRAPHICS_IMAGE_FORMAT
Default image format that is used for generating WebGraphics. |
Constructor Summary | |
---|---|
WebGraphics()
|
Method Summary | |
---|---|
void |
addGraphics(GraphicElement element)
Adds a point, multipoint, polyline or polygon graphic to the map. |
void |
addImage(GraphicImage image)
Adds an image to the map. |
void |
addRenderer(GraphicRenderer renderer)
Adds a renderer to the map. |
void |
clearGraphics()
Clears all graphic elements, images, and renderers from the WebGraphics object. |
void |
destroy()
The cleaup chores (such as releasing held resources) of attributes of a WebContext should be performed in
this method. |
byte[] |
exportGraphics()
Exports all the graphics as a byte array based on the WebMap current state. |
byte[] |
exportGraphics(ExportProperties properties)
Draw all the graphics and return as a byte array. |
List<GraphicElement> |
getLineGraphics()
Returns the list of line graphics that are displayed in the map as WebGraphics. |
List<GraphicElement> |
getPointGraphics()
Returns the list of point graphics that are displayed in the map as WebGraphics. |
List<GraphicElement> |
getPolygonGraphics()
Returns the list of polygon graphics that are displayed in the map as WebGraphics. |
void |
init(WebContext webContext)
The initialization chores of attributes of a WebContext should be performed in this method. |
boolean |
isEmpty()
Returns true if no graphics elements, images, or renderers are currently referenced by the WebGraphics object. |
boolean |
isGraphicsExists(GraphicElement element)
Determines if the element has already been added to the map. |
boolean |
isImageExists(GraphicImage image)
Determines if the image has already been added to the map. |
boolean |
isRendererExists(GraphicRenderer renderer)
Determines if the renderer has already been added to the map. |
boolean |
isWebGraphicsChanged()
Determines whether WebGraphics changed or not. |
void |
removeGraphics(GraphicElement element)
Removes the specified element from WebGraphics. |
void |
removeImage(GraphicImage image)
Removes the specified image from the WebGraphics. |
void |
removeRenderer(GraphicRenderer renderer)
Removes the specified renderer from the WebGraphics. |
void |
resetWebGraphics()
This method resets the WebGraphics and forces the next exportGraphics() call to redraw the graphics even though the current extent of WebMap may not have changed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String WEBGRAPHICS_IMAGE_FORMAT
protected WebContext context
WebContext
object.
protected byte[] imageBytes
protected WebExtent extent
WebMap.getCurrentExtent()
protected List<GraphicElement> pointGraphics
protected List<GraphicElement> lineGraphics
protected List<GraphicElement> polygonGraphics
protected List<GraphicImage> pointImages
protected List<GraphicImage> lineImages
protected List<GraphicImage> polygonImages
protected List<GraphicImage> images
protected List<GraphicRenderer> pointRenderers
protected List<GraphicRenderer> lineRenderers
protected List<GraphicRenderer> polygonRenderers
Constructor Detail |
---|
public WebGraphics()
Method Detail |
---|
public void init(WebContext webContext)
WebContextInitialize
The initialization chores of attributes of a WebContext
should be performed in this method.
Typically this method is called by the WebContext
when the context itself is initialized. It is important
to note that this method is again called by the context when a GISResource
is dynamically added to or
removed from the context. Classes that implement this method should keep this in mind and adapt the method to react
to the callbacks in these circumstances as well.
A WebContext
attribute is usable only after this method has been called.
init
in interface WebContextInitialize
webContext
- WebContext
- the WebContextWebContext.init(WebContext)
,
WebContext.addResource(String, GISResource, int)
,
WebContext.removeResource(GISResource)
public void destroy()
WebContextInitialize
The cleaup chores (such as releasing held resources) of attributes of a WebContext
should be performed in
this method.
Typically this method is called by the WebContext
when the context itself is destroyed.
The WebContext
attribute is unusable after this method has been called.
destroy
in interface WebContextInitialize
WebContext.destroy()
public List<GraphicElement> getPointGraphics()
public List<GraphicElement> getLineGraphics()
public List<GraphicElement> getPolygonGraphics()
public void addGraphics(GraphicElement element)
element
- the graphic element to add in the mappublic void addImage(GraphicImage image)
image
- the image to add in the mappublic void addRenderer(GraphicRenderer renderer)
renderer
- public void clearGraphics()
public void resetWebGraphics()
public void removeGraphics(GraphicElement element)
element
- the graphic element to removeaddGraphics(GraphicElement)
public void removeImage(GraphicImage image)
image
- the image to removeaddImage(GraphicImage)
public void removeRenderer(GraphicRenderer renderer)
renderer
- the renderer to removeaddRenderer(GraphicRenderer)
public boolean isGraphicsExists(GraphicElement element)
element
- the element to be checked for existence
public boolean isImageExists(GraphicImage image)
image
- the image to be checked for existence
public boolean isRendererExists(GraphicRenderer renderer)
renderer
- the renderer to be checked for existence
public boolean isEmpty()
public boolean isWebGraphicsChanged()
public byte[] exportGraphics()
WebMap
current state. For Example width, height, DPI,
extent etc. The graphics are drawn only if there is a change in the map's current extent from the previous
exportGraphics() call, otherwise it returns the copy of the byte array that this object holds. The byte array is in
the PNG Image format. WEBGRAPHICS_IMAGE_FORMAT
.
resetWebGraphics()
public byte[] exportGraphics(ExportProperties properties)
properties
- the export properties that are used for drawing graphics.addGraphics(GraphicElement)
,
addImage(GraphicImage)
,
addRenderer(GraphicRenderer)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |