Select to view content in your preferred language

Tracking MessageProcessor-Created Graphics Layers on MessageGroupLayer

2205
4
Jump to solution
02-14-2014 12:05 PM
CarlosColón-Maldonado
Frequent Contributor
Greetings,

I seem to remember that the layers contained by the MessageGroupLayer are not created at construction, but as the types of symbols are created upon processing their particular Message using the MessageProcessor, i.e., single-point, lines or area each per position report or spot report type, and that these layers are named based on these combinations. I would like to be able maintain a reference to each GraphicsLayer as they are created on the group layer, but it seems that the getLayers method of the MessageGroupLayer is inherited from a GroupLayerBase class that is not accessible, and it also appears that adding a layer initialization complete listener does not capture them (the way I tried).

1. Is there a way to capture these layers on creation for reference, or

2. Could I manually create them on MessageGroupLayer construction so that I could capture their reference then and, will the MessageProcessor have a problem with it?

Thanks in advanced.
0 Kudos
1 Solution

Accepted Solutions
CarlosColón-Maldonado
Frequent Contributor
Maybe you can tell me what you are trying to do?


Hi Mark,

Long time no hear from you; busy as usual? Recall my desire to:

1- bring upfront the graphics layer containing the selected symbol(s) when single-points appear on separate sub layers (spots vs position reports), and

2- implement currency state on single-point symbols by modifying its look-and-fell's background colors (original color = current, grayed out = stale, transparent = old).

Well, I figure that if I have a reference to each of these layers, I could:

1- Reorder their index within the group layer, and

2- add a picture marker symbol created using a buffered image from the symbol dictionary so that I could modify its look-and-fell before adding it. Doing this will force me to use the message processor only on multiple points symbols while directly adding picture markers to the graphics layers directly. To try this, I had to obtain a reference to the graphics layers.

To update this post, I was able to obtain a reference to them, but I have yet to try the above,  as follows:

I implemented a sub-class like below (interfaces are used for obvious reasons)
public class RpwsEsriSymbolLayer extends MessageGroupLayer implements ISymbolLayer, IDisposable


I imported a JSON Jackson jar in order to create a JSON node to pass to a dictionary renderer
    public RpwsEsriSymbolLayer(DictionaryType type) {         super(type);         this.messageProcessor = super.getMessageProcessor();         // create a single-point, a lines and a areas layer for position         // reports and spot reports each         this.layers = new GraphicsLayer[Constants.LAYER_NAMES.length];         try {             ObjectMapper mapper = new ObjectMapper();             JsonFactory factory = mapper.getJsonFactory();             JsonParser jp = factory.createJsonParser(Constants.SYMBOL_RENDERER_JSON);             JsonNode actualObj = jp.readValueAsTree();             int index = 0;             for (String name : Constants.LAYER_NAMES) {                 GraphicsLayer glayer = new GraphicsLayer();                 glayer.setName(name);                 glayer.setRenderer(new SymbolRenderer(actualObj));                 glayer.setSelectionColor(Color.WHITE);                 glayer.setVisible(true);                 internalAdd(glayer);                 this.layers[index++] = glayer;             }         } catch (Exception e) {             // Log Error         }     }


The constants on the code are
    /** Static names of containing layers of this group layer */     public static final String[]           LAYER_NAMES                        = {"spot_reports",             "position_reports",             "spot_reports_Lines",             "position_reports_Lines",             "spot_reports_Areas",             "position_reports_Areas"                                          };     ...      /**      * String representation of the JSON used to render military symbols.      */     public static final String             SYMBOL_RENDERER_JSON               = "{\"type\":\"dictionary\",\"dictionaryType\":\"2525C\",\"field\":\"sic\",\"symbolScaleFactor\":1.5,\"labelsVisible\":true,\"minLabelScale\":10000000,\"maxLabelScale\":0}";


I noticed once I did this that the JSON's symbolScaleFactor overrode the value on the JSON file, and that also overrode any value passed unto the super class, which was insteresting and not a problem, actually. Other than that, it all worked as expected.

Having done this, will the super class have a problem with handling a graphics layer that contains picture marker symbols on two of its six layers it controls? I realize that I probably shouldn't pass a dictionary renderer to those layers I want to pass markers to? Also, will the reordering of layers method on the GroupLayerBase class work on these layers?

View solution in original post

0 Kudos
4 Replies
MarkBaird
Esri Regular Contributor
Carlos,

The MessageGroupLayer does contain graphics layers which are created on demand when they are first needed. 

The MessageGroupLayer is not designed for you to add your own graphics layers and it maintains its own resources.  I don't believe we have exposed API for you to do this. 

You can of course see the layers in the MessageGroupLayer by using the getLayers function.

Maybe you can tell me what you are trying to do?

Mark
0 Kudos
CarlosColón-Maldonado
Frequent Contributor
Maybe you can tell me what you are trying to do?


Hi Mark,

Long time no hear from you; busy as usual? Recall my desire to:

1- bring upfront the graphics layer containing the selected symbol(s) when single-points appear on separate sub layers (spots vs position reports), and

2- implement currency state on single-point symbols by modifying its look-and-fell's background colors (original color = current, grayed out = stale, transparent = old).

Well, I figure that if I have a reference to each of these layers, I could:

1- Reorder their index within the group layer, and

2- add a picture marker symbol created using a buffered image from the symbol dictionary so that I could modify its look-and-fell before adding it. Doing this will force me to use the message processor only on multiple points symbols while directly adding picture markers to the graphics layers directly. To try this, I had to obtain a reference to the graphics layers.

To update this post, I was able to obtain a reference to them, but I have yet to try the above,  as follows:

I implemented a sub-class like below (interfaces are used for obvious reasons)
public class RpwsEsriSymbolLayer extends MessageGroupLayer implements ISymbolLayer, IDisposable


I imported a JSON Jackson jar in order to create a JSON node to pass to a dictionary renderer
    public RpwsEsriSymbolLayer(DictionaryType type) {         super(type);         this.messageProcessor = super.getMessageProcessor();         // create a single-point, a lines and a areas layer for position         // reports and spot reports each         this.layers = new GraphicsLayer[Constants.LAYER_NAMES.length];         try {             ObjectMapper mapper = new ObjectMapper();             JsonFactory factory = mapper.getJsonFactory();             JsonParser jp = factory.createJsonParser(Constants.SYMBOL_RENDERER_JSON);             JsonNode actualObj = jp.readValueAsTree();             int index = 0;             for (String name : Constants.LAYER_NAMES) {                 GraphicsLayer glayer = new GraphicsLayer();                 glayer.setName(name);                 glayer.setRenderer(new SymbolRenderer(actualObj));                 glayer.setSelectionColor(Color.WHITE);                 glayer.setVisible(true);                 internalAdd(glayer);                 this.layers[index++] = glayer;             }         } catch (Exception e) {             // Log Error         }     }


The constants on the code are
    /** Static names of containing layers of this group layer */     public static final String[]           LAYER_NAMES                        = {"spot_reports",             "position_reports",             "spot_reports_Lines",             "position_reports_Lines",             "spot_reports_Areas",             "position_reports_Areas"                                          };     ...      /**      * String representation of the JSON used to render military symbols.      */     public static final String             SYMBOL_RENDERER_JSON               = "{\"type\":\"dictionary\",\"dictionaryType\":\"2525C\",\"field\":\"sic\",\"symbolScaleFactor\":1.5,\"labelsVisible\":true,\"minLabelScale\":10000000,\"maxLabelScale\":0}";


I noticed once I did this that the JSON's symbolScaleFactor overrode the value on the JSON file, and that also overrode any value passed unto the super class, which was insteresting and not a problem, actually. Other than that, it all worked as expected.

Having done this, will the super class have a problem with handling a graphics layer that contains picture marker symbols on two of its six layers it controls? I realize that I probably shouldn't pass a dictionary renderer to those layers I want to pass markers to? Also, will the reordering of layers method on the GroupLayerBase class work on these layers?
0 Kudos
MarkBaird
Esri Regular Contributor
Carlos,

Would it help if there was something like a LayerListEventListener which works on the MessageGroupLayer?  This would fire as the graphics layers get added to the group layer.

It's certainly something I'd consider but it might not make it for the 10.2.2 release which will be out in a few weeks.

Mark
CarlosColón-Maldonado
Frequent Contributor
Would it help if there was something like a LayerListEventListener which works on the MessageGroupLayer?  This would fire as the graphics layers get added to the group layer.

It's certainly something I'd consider but it might not make it for the 10.2.2 release which will be out in a few weeks.


Perhaps, if I can use it to change its ordering of display within the message group layer. I have not tried this, but would the public reorderLayer work as well in my case?

I already have a reference to them since I am able to pre-create them for the message group layer at construction (and it doesn't seem to a problem using those (as far as I can tell).

An event listener for the graphics layer would come handy for capturing when a graphic has been added, modified or removed from it in order for me not have to keep track of its displaying symbols while not knowing if they were CRUD'd successfully. I'm noticing that my symbol references do not always coincide with what being displayed and/or visible.
0 Kudos