<div class="gmail_quote"><div>After adding some logs I noticed the following:</div><div><br></div><div>The TargetGraphicBuilder&#39;s  createGraphics() is only called when loaded or when the state changed. It seems that the underlying</div>
<div>assumption for the builder is that it will only be called once or twice to create a set of static graphics.... This does not fit with my</div><div>use case where the targetmanager manages a list of dynamically changing targets. I assumed createGraphics will be called every time </div>
<div>a repaint is needed - but this is not the case it seems.</div><div><br></div><div>Is there anything I can do about this ? Is there a way of adding a graphic directly to a map layer ? </div><div><br></div><div><div>public class TargetGraphicBuilder implements GraphicBuilder&lt;GraphicJ2D&gt; {</div>
<div><br></div><div>    private final static Logger logger = LoggerFactory.getLogger(TargetGraphicBuilder.class);</div><div>    private TargetManager targetManager;</div><div><br></div><div>    public TargetGraphicBuilder(TargetManager manager) {</div>
<div>        targetManager = manager;</div><div>        </div><div>    }</div><div><br></div><div>    @Override</div><div>    public Collection&lt;GraphicJ2D&gt; createGraphics(MapLayer layer, Canvas canvas) {</div><div>        logger.debug(&quot;Creating Graphics&quot;);</div>
<div>        if (canvas instanceof J2DCanvas) {</div><div>            final J2DCanvas j2dcanvas = (J2DCanvas) canvas;</div><div>            return makeTargets(j2dcanvas);</div><div>        }</div><div>        logger.debug(&quot;Canvas not a J2DCanvas&quot;);</div>
<div>        return Collections.emptyList();</div><div>    }</div><div><br></div><div>    private Collection makeTargets(J2DCanvas canvas) {</div><div>        ArrayList&lt;TargetGraphic&gt; targetGraphics = new ArrayList&lt;TargetGraphic&gt;();</div>
<div>        for (Target t : targetManager.getAllTargets()) {</div><div>            targetGraphics.add(new TargetGraphic(canvas, t));</div><div>        }</div><div>        return Collections.unmodifiableList(targetGraphics);</div>
<div>    }</div><div><br></div><div>    @Override</div><div>    public Class&lt;GraphicJ2D&gt; getGraphicType() {</div><div>        return GraphicJ2D.class;</div><div>    }</div><div><br></div><div>    @Override</div><div>
    public Image getLegend(MapLayer layer) throws PortrayalException {</div><div>        return null;</div><div>    }</div><div><br></div><div>    public String getName() {</div><div>        return targetManager.getName();</div>
<div>    }</div><div>}</div></div></div><br>-- <br>Thys Meintjes<br><br><br>