2525C symbol highlight/ selection

2644
3
Jump to solution
07-06-2012 06:46 PM
CarlosColón-Maldonado
Occasional Contributor III
I've taken the long road towards getting to the bottom of this on my own, but I'm running into a brick wall, especially now that the release version of Runtime makes no difference on these two issues:

1. The original intent of implementing 2525C symbol highlighting appeared in the prereleased version, though it did not work, but now it seems to have vanished from the API altogether. Is it going to be available eventually? If it is available now, what am I doing wrong (code below)?

    Message msg = messageProcessor.createMessageFrom(index);
    if (msg != null) {
     msg.setProperty(MessageHelper..MESSAGE_ACTION_PROPERTY_NAME,
       "highlight");
     messageProcessor.processMessage(msg);
    }

2. In order to have a better interactivity with the above, I'd like to be able to highlight the symbol that I choose by mouse-clicking to it. I am familiar with your sample app the makes a simple selection to polylines that are stored on a GraphicsLayer being managed by a HitTestOverlay with the use of HitTestListeners. I figured that, since the GroupLayer, now called MessageGroupLayer, creates GraphicsLayer types for each message type it handles, I could use something like below to determine symbols within a mouse-click region. Problem? The method GraphicsLayer.getGraphicIDs(x,y,tol) throws a null exception every time. Help?

    Layer[] layers = messageGroupLayer.getLayers();
    List<Graphic> selected = new ArrayList<Graphic>();
    for (Layer layer : layers) {
     if (layer.getClass() == GraphicsLayer.class) {
      float x = (float) screenPoint.getX();
      float y = (float) screenPoint.getY();
      GraphicsLayer gLayer = (GraphicsLayer) layer;
      try {
       int size = gLayer.getGraphicIDs().length;
       int[] list = gLayer.getGraphicIDs(x, y, 100);
       for (int id : list) {
        if (gLayer.isGraphicSelected(id))
         selected.add(gLayer.getGraphic(id));
       }
      } catch (Exception e1) {
       System.err.println("Cannot collect graphics: "
         + e1.getLocalizedMessage() + "\n");
       e1.printStackTrace();
      }
     }
    }
    System.out.println("Hit test: " + selected.size());
1 Solution

Accepted Solutions
CarlosColón-Maldonado
Occasional Contributor III
I would like to confirm that this issue has been solved in version 10.1.1 as follows:

Code:

@Override public void onMouseClicked(MouseEvent mouseEvent) {     for(Layer l : msgGroupLayer.getLayers()){      if(l instanceof com.esri.map.GraphicsLayer){       GraphicsLayer gl = (GraphicsLayer)l;       gl.setSelectionColor(Color.WHITE);       int[] ids = gl.getGraphicIDs(mouseEvent.getX(), mouseEvent.getY(), 0);       for(int i : ids){        gl.select(i);       }      }              }     super.onMouseClicked(event); }


To obtain the associated Message objects from the selected 2525C symbols, the message processor will have to be used to obtain them with the graphic objects from the graphics layer.

Unfortunately, the Java tool kit code does not allow the flexibility of desired behavior once the selected graphics are set as selected and highlighted with the desired color out-of-box. Therefore, the HitTestOverlay and associated objects will have to be re-created and modified to achieve it.

Thanks for the support.

View solution in original post

0 Kudos
3 Replies
EricBader
Occasional Contributor III
Hi Carlos.
With Final, this worked for me, highlighting all of graphics used in the MessageProcessorApp sample:

      try{
       for(Layer l : msgGroupLayer.getLayers()){
        if(l instanceof com.esri.map.GraphicsLayer){
         GraphicsLayer gl = (GraphicsLayer)l;
         SimpleMarkerSymbol sms = new SimpleMarkerSymbol(Color.YELLOW,20,Style.CIRCLE);

         gl.setSelectionSymbol(sms);
         int[] ids = gl.getGraphicIDs();
         for(int i : ids){
          gl.select(i);
         }
        }
        
       }
      }catch(Exception e){
       e.printStackTrace();
      }


Is this helpful at all?
0 Kudos
CarlosColón-Maldonado
Occasional Contributor III
Hi Carlos.
With Final, this worked for me, highlighting all of graphics used in the MessageProcessorApp sample:

      try{
       for(Layer l : msgGroupLayer.getLayers()){
        if(l instanceof com.esri.map.GraphicsLayer){
         GraphicsLayer gl = (GraphicsLayer)l;
         SimpleMarkerSymbol sms = new SimpleMarkerSymbol(Color.YELLOW,20,Style.CIRCLE);

         gl.setSelectionSymbol(sms);
         int[] ids = gl.getGraphicIDs();
         for(int i : ids){
          gl.select(i);
         }
        }
        
       }
      }catch(Exception e){
       e.printStackTrace();
      }


Is this helpful at all?


Hi, Eric,

Thanks for your input. This is, in fact, helpful. I was able to implement your code and it works great. The only caveat I have now is that it is hard to determine which shape to use for every single marker because military markers are drawn in different shapes, i.e., circles, squares, rectangles, and diamonds for single points. I suppose I could query the sic (symbol id code) to determine that for the single-point graphic layer only. The other "lines" and "areas" layers could use their own simple marker for selection.

One question, though. Is there a way to make the selection marker non-filling, i.e., paint the border only and not the entire circle? This at least would show what was actually selected and not obscure it. It seems to me that it cannot be done because it essentially replaces the symbol used at selection rather than layering it over.

thanks in advanced,
0 Kudos
CarlosColón-Maldonado
Occasional Contributor III
I would like to confirm that this issue has been solved in version 10.1.1 as follows:

Code:

@Override public void onMouseClicked(MouseEvent mouseEvent) {     for(Layer l : msgGroupLayer.getLayers()){      if(l instanceof com.esri.map.GraphicsLayer){       GraphicsLayer gl = (GraphicsLayer)l;       gl.setSelectionColor(Color.WHITE);       int[] ids = gl.getGraphicIDs(mouseEvent.getX(), mouseEvent.getY(), 0);       for(int i : ids){        gl.select(i);       }      }              }     super.onMouseClicked(event); }


To obtain the associated Message objects from the selected 2525C symbols, the message processor will have to be used to obtain them with the graphic objects from the graphics layer.

Unfortunately, the Java tool kit code does not allow the flexibility of desired behavior once the selected graphics are set as selected and highlighted with the desired color out-of-box. Therefore, the HitTestOverlay and associated objects will have to be re-created and modified to achieve it.

Thanks for the support.
0 Kudos