com.esri.core.symbol.advanced
Class MessageProcessor

java.lang.Object
  extended by com.esri.core.symbol.advanced.MessageProcessor

public class MessageProcessor
extends Object

A MessageProcessor allows you to process a Message from external resources. For example, display a military symbol by passing a 2525C message to a MessageProcesor. Each MessageProcessor comes with a SymbolDictionary.DictionaryType, which dictates message format understood by MessageProcessor, e.g. a message needs to have one or more properties from 'wkid', ''sic', '_Type', '_Action' and '_Control_Points' in order to be successfully processed by a 2525C MessageProcessor. Each dictionary type is backed by a resource bundle which includes dictionary data file and message type files. The path to the resource files needs to be specified when a MessageProcessor object is initialized. A MessageProcessor is bound to a GroupLayer, which is used to display, update and remove MultiLayerSymbol associated with the message. The GroupLayer has to be added into JMap, otherwise MessageProcessor will fail to process the message.

Creates a MessageProcessor object:

     MapView map = new MapView(this);
     GroupLayer groupLayers = new GroupLayer();
     map.addLayer(groupLayers);
     
     try {
       MessageProcessor processor = new MessageProcessor(DictionaryType.Mil2525C, groupLayers);
     }catch(FileNotFoundException ex) {
        ex.printStackTrace();
     }
   
Creates a Message object, then process it:
     
      Message message = new Message();
      UUID uuid = UUID.randomUUID();
      message.setID(uuid.toString());
      message.setProperty("_Type", "position_report");
      message.setProperty("_Action", "update");
      message.setProperty("_Control_Points", "7846271.25206,4091857.83028");
      message.setProperty("sic", "SFGPUCRRL--E---");
      message.setProperty("_WKID", "3857");
      message.setProperty("UniqueDesignation", "Mad dog");
      processor.processMessage(message);
   


Constructor Summary
MessageProcessor(SymbolDictionary.DictionaryType type, MessageGroupLayer groupLayer)
           
MessageProcessor(SymbolDictionary.DictionaryType type, MessageGroupLayer groupLayer, String symbolDictionaryPath)
           
 
Method Summary
 Message createMessageFrom(Graphic graphic)
          Creates a Message from a Graphic object.
 Message createMessageFrom(String messageID)
          Creates a Message from an existing message ID.
 SpatialReference getDefaultMessageSpatialReference()
          Gets the default message spatial reference.
 SymbolDictionary.DictionaryType getDictionaryType()
          Gets the dictionary type.
 Graphic getGraphic(String messageID)
          Retrieves the graphic which originates from the message with specified id.
 String[] getMessageTypesSupported()
          Gets the message types supported.
 SymbolDictionary getSymbolDictionary()
           
 boolean processMessage(Message message)
          Processes the message which conforms to the format dictated by the dictionary type.
 void setDefaultMessageSpatialReference(SpatialReference sr)
          Sets the default message spatial reference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageProcessor

public MessageProcessor(SymbolDictionary.DictionaryType type,
                        MessageGroupLayer groupLayer)

MessageProcessor

public MessageProcessor(SymbolDictionary.DictionaryType type,
                        MessageGroupLayer groupLayer,
                        String symbolDictionaryPath)
Method Detail

getSymbolDictionary

public SymbolDictionary getSymbolDictionary()

processMessage

public boolean processMessage(Message message)
Processes the message which conforms to the format dictated by the dictionary type. MessageProcessor uses message properties to create, update, delete or otherwise change the state of the graphic(geometry and attributes). MessageProcessor determines which message properties should be persisted on graphic as attributes.

Parameters:
message - A Message object
Returns:
true if the message is processed successfully.

createMessageFrom

public Message createMessageFrom(Graphic graphic)
Creates a Message from a Graphic object. The message gets populated with properties understood by the message processor. If the specified graphic is created from previous message, the returned message is the same as the previous one except that '_Action' property is empty.

Parameters:
graphic - a Graphic object.
Returns:
a Message object populated with attributes/geometry from the specified graphic.

createMessageFrom

public Message createMessageFrom(String messageID)
Creates a Message from an existing message ID. The message ID is used previously to create or update a graphic. The returned message has the same attributes as the previous message with specified message ID except that '_Action' property is empty.

Parameters:
messageID - message ID
Returns:
a Message object with attributes from previous message with same message id.

getDefaultMessageSpatialReference

public SpatialReference getDefaultMessageSpatialReference()
Gets the default message spatial reference. Message spatial reference is used by control points inside the message. Usually a WKID or WKT property indicates the message spatial reference. If WKID or WKT property is omitted, this default message spatial reference is treated as the message spatial reference. If default message spatial reference is not set, it will be the same as the map's spatial reference.

Returns:
the default spatial reference.

setDefaultMessageSpatialReference

public void setDefaultMessageSpatialReference(SpatialReference sr)
Sets the default message spatial reference. Message spatial reference is used by control points inside the message. Usually a WKID or WKT property indicates the message spatial reference. If WKID or WKT property is omitted, this default message spatial reference is treated as the message spatial reference. If default message spatial reference is not set, it will be the same as the map's spatial reference.

Parameters:
sr - the default message spatial reference to set.

getDictionaryType

public SymbolDictionary.DictionaryType getDictionaryType()
Gets the dictionary type. The dictionary type is associated with a resource bundle, which includes dictionary data file and message type configuration files. Only Mil2525C dictionary type is available for now.

Returns:
the mType the processor type.

getMessageTypesSupported

public String[] getMessageTypesSupported()
Gets the message types supported. A message requires a type property which describes how message is processed. The message type is defined in the resource bundle as a configuration file in JSON format. A message type contains properties like type name, layer name and renderer.

a sample message type file:

    {
       "type": "position_report",
       "layerName": "position_reports",
       "renderer":
           {
              "type"           : "dictionary",
              "description"    : "postion report",
              "dictionaryType" : "2525C",
              "field"          : "sic"
           }
   }
    
    

Returns:
the message types supported

getGraphic

public Graphic getGraphic(String messageID)
Retrieves the graphic which originates from the message with specified id.

Parameters:
messageID - message id.
Returns:
a Graphic object populated with the properties of message of specified id.


Copyright © 2012. All Rights Reserved.