<div class="gmail_quote"><div>After adding some logs I noticed the following:</div><div><br></div><div>The TargetGraphicBuilder'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<GraphicJ2D> {</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<GraphicJ2D> createGraphics(MapLayer layer, Canvas canvas) {</div><div> logger.debug("Creating Graphics");</div>
<div> if (canvas instanceof J2DCanvas) {</div><div> final J2DCanvas j2dcanvas = (J2DCanvas) canvas;</div><div> return makeTargets(j2dcanvas);</div><div> }</div><div> logger.debug("Canvas not a J2DCanvas");</div>
<div> return Collections.emptyList();</div><div> }</div><div><br></div><div> private Collection makeTargets(J2DCanvas canvas) {</div><div> ArrayList<TargetGraphic> targetGraphics = new ArrayList<TargetGraphic>();</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<GraphicJ2D> 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>