I'm evaluating the UniqueValueRenderer with a GraphicsLayer on ArcGIS Runtime SDK for Java 10.2.3 - Jdk 8u40 - Windows XP.
I have no problem creating a GraphicsLayer with sample data and attributes, in order to test the UniqueValueRenderer to get different symbols according to attributes values.
With Simple symbol (SimpleMarkerSymbol, ...) and PictureMarkerSymbol it is working fine.
But it's not wokring with CompositeSymbol ! is it a known issue ??? In this case I compose my UniqueValueRenderer with simple symbols and 1 CompositeSymbol for one attribute value, and I get the following exception :
Java version : 1.8.0_40 (Oracle Corporation) x86
Rendering engine : DirectX
...
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.lang.RuntimeException
at com.esri.map.GraphicsLayer.setRenderer(Unknown Source)
at com.mycode.sandbox.eval.arcgis.EvaluationApp.colorUniqueValueRendering(EvaluationApp.java:762)
at com.mycode.sandbox.eval.arcgis.EvaluationApp.actionPerformed(EvaluationApp.java:406)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:751)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:702)
at java.awt.EventQueue$3.run(EventQueue.java:696)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:724)
at java.awt.EventQueue$4.run(EventQueue.java:722)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:721)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.RuntimeException
at com.esri.map.GraphicsLayer.nativeSetRenderer(Native Method)
at com.esri.map.GraphicsLayer.setRenderer(Unknown Source)
... 38 more
my Code :
private void colorUniqueValueRenderingComplex() { final String ATTRIBUTE_NAME = "CAPITAL"; if (graphicLayerCplx != null) { graphicLayerCplx.removeAll(); } else { graphicLayerCplx = new GraphicsLayer(); map.getLayers().add(graphicLayerCplx); final SimpleMarkerSymbol SYM_DEFAULT = new SimpleMarkerSymbol(Color.GRAY, 12, Style.TRIANGLE); final SimpleMarkerSymbol SYM_NON_CAPITAL = new SimpleMarkerSymbol(Color.GREEN, 9, Style.CIRCLE); final CompositeSymbol compositeMarkerSquare = new CompositeSymbol(); compositeMarkerSquare.getSymbols().add(new SimpleMarkerSymbol(Color.GREEN, 16, SimpleMarkerSymbol.Style.SQUARE)); compositeMarkerSquare.getSymbols().add(new SimpleMarkerSymbol(Color.YELLOW, 10, SimpleMarkerSymbol.Style.SQUARE)); final UniqueValueRenderer uvRenderer = new UniqueValueRenderer(); uvRenderer.setAttributeName1(ATTRIBUTE_NAME); uvRenderer.addValue(new UniqueValueInfo(new Object[] { "Y" }, compositeMarkerSquare)); uvRenderer.addValue(new UniqueValueInfo(new Object[] { "N" }, SYM_NON_CAPITAL)); uvRenderer.setDefaultSymbol(SYM_DEFAULT); graphicLayerCplx.setRenderer(uvRenderer); } final Map<String, Object> attCapY = ImmutableMap.<String, Object> builder().put(ATTRIBUTE_NAME, "Y").build(); final Map<String, Object> attCapN = ImmutableMap.<String, Object> builder().put(ATTRIBUTE_NAME, "N").build(); final Map<String, Object> attCapZ = ImmutableMap.<String, Object> builder().put(ATTRIBUTE_NAME, "Z").build(); graphicLayerCplx.addGraphic(new Graphic(new Point(4.00, 44.00), null, attCapN)); graphicLayerCplx.addGraphic(new Graphic(new Point(4.20, 44.30), null, attCapN)); graphicLayerCplx.addGraphic(new Graphic(new Point(4.40, 44.60), null, attCapY)); graphicLayerCplx.addGraphic(new Graphic(new Point(4.60, 44.90), null, attCapY)); graphicLayerCplx.addGraphic(new Graphic(new Point(4.80, 45.20), null, attCapY)); graphicLayerCplx.addGraphic(new Graphic(new Point(5.00, 45.50), null, attCapZ)); }
Any ideas for a solution ? Is it working with ArcGIS Runtime for Java 10.2.4 on Windows 7 for exemple ?...
I have also tested it on ArcGIS Runtime SDK for Java 10.2.4 - Jdk 8u40 - Windows 7, and same exception occured...