Solved! Go to Solution.
          //get layers in message group layer           Layer[] layers = mgl.getLayers();           System.out.println("there are layers : " + layers.length);                      //go through the layers in the message group layer to do a hit test on each one:           for(Layer gLayer : layers)           {            System.out.println("Layer name = " + gLayer.getName());            System.out.println("--------------------------------");                        //cast to graphics layer            GraphicsLayer gl = (GraphicsLayer) gLayer;                        int[] all_graphics = gl.getGraphicIDs();               System.out.println("total graphics = " + all_graphics.length);                              int[] ids = gl.getGraphicIDs((float)arg0.getX(),(float) arg0.getY(), 5, 4000);                              if (ids.length > 0)               {                               System.out.println("hit result with " + ids.length);                                gl.setSelectionIDs(ids, true);               }           }map clicked at -156543.03392799944,626172.1357119977 there are layers : 3 Layer name = position_reports_Lines -------------------------------- total graphics = 4001 hit result with 4000 Layer name = position_reports -------------------------------- total graphics = 4001 hit result with 4000 Layer name = chemlights -------------------------------- total graphics = 4000 hit result with 4000
getGraphicIDs
public int[] getGraphicIDs(float x,
float y,
int tolerance)
Finds the graphics near the supplied x,y in pixels. Both visible and invisible graphics are returned. The graphics must have been through a Map draw cycle before they can be found.
Parameters:
x - the x coordinates of the point for searching.
y - the y coordinates of the point for searching.
tolerance - the search tolerance in pixels
Returns:
the first 10 graphics within the search tolerance.
 
for (GraphicsLayer layer : this.graphicsLayers) {
layer.clearSelection();
// Get the maximum number of graphics per layer within 5 pixels of the X and Y of
// the selected mouse click.
int[] hitGraphicsIDs = layer.getGraphicIDs(mouseEvent.getX(),
mouseEvent.getY(),
5,
layer.getNumberOfGraphics());
layer.setSelectionIDs(hitGraphicsIDs, true);
try {
for (int id : hitGraphicsIDs) {
this.graphicsQueue.put(layer.getGraphic(id));
}
} catch (InterruptedException e) {
// TODO Log
e.printStackTrace();
break;
}
}
List<Pair<Message> selectedMgs = new ArrayList<Message>();
for (Graphic graph : graphics) {
MessageProcessor mp = messageGroupLayer.getMessageProcessor();
Message msg =  mp.createMessageFrom(graph);
if (msg != null)
selectedMgs.add(msg);
}
Graphic graph = messageProcessor().getGraphic(value.getID());
for (Layer layer : symbolLayer.getLayers()) {
GraphicsLayer gLayer = (GraphicsLayer)layer;
if ((gLayer.getGraphic(graph.getUid()) != null)) {
// TODO: Also bring layer to front!!
gLayer.bringToFront(graph.getUid());
}
}
          //get layers in message group layer           Layer[] layers = mgl.getLayers();           System.out.println("there are layers : " + layers.length);                      //go through the layers in the message group layer to do a hit test on each one:           for(Layer gLayer : layers)           {            System.out.println("Layer name = " + gLayer.getName());            System.out.println("--------------------------------");                        //cast to graphics layer            GraphicsLayer gl = (GraphicsLayer) gLayer;                        int[] all_graphics = gl.getGraphicIDs();               System.out.println("total graphics = " + all_graphics.length);                              int[] ids = gl.getGraphicIDs((float)arg0.getX(),(float) arg0.getY(), 5, 4000);                              if (ids.length > 0)               {                               System.out.println("hit result with " + ids.length);                                gl.setSelectionIDs(ids, true);               }           }map clicked at -156543.03392799944,626172.1357119977 there are layers : 3 Layer name = position_reports_Lines -------------------------------- total graphics = 4001 hit result with 4000 Layer name = position_reports -------------------------------- total graphics = 4001 hit result with 4000 Layer name = chemlights -------------------------------- total graphics = 4000 hit result with 4000