A yes, thanks - I realized this only after posting last time.<div><br></div><div>Thanks Johann<br><br><div class="gmail_quote">On Tue, Jul 26, 2011 at 12:28 PM, Sorel <span dir="ltr">&lt;<a href="mailto:johann.sorel@geomatys.fr">johann.sorel@geomatys.fr</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><u></u>

  
    
    
  
  <div bgcolor="#ffffff" text="#000000">
    Hello,<br>
    <br>
    Like you noticed, the graphic objects are cached, (the
    createGraphics is only called once).<br>
    You must see the rendering engine very much like a 3D scene graph.<br>
    There is a root node which contains other graphics and so on, so the
    createGraphics can return a single Graphic which contain several
    children graphics for each radar.<br>
    The graphic builder takes the MapLayer and the J2DCanvas in
    parameter, this allow the graphic to attach a listener on the
    MapLayer and update his graphic children when needed or recreate
    it&#39;s children each time.<br>
    <br>
    The canvas can be repaint at any time using :<br>
    getCanvas().getController().repaint();<br>
    <br>
    You can choose to repaint only on events or use an external thread
    to repaint at regular interval.<br>
    <br>
    johann<div><div></div><div class="h5"><br>
    <br>
    <br>
    On 07/26/2011 11:42 AM, Thys Meintjes wrote:
    </div></div><blockquote type="cite"><div><div></div><div class="h5">
      <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>
      </div></div><pre><fieldset></fieldset>
_______________________________________________
Geotoolkit mailing list
<div class="im"><a href="mailto:Geotoolkit@lists.osgeo.org" target="_blank">Geotoolkit@lists.osgeo.org</a>
<a href="http://lists.osgeo.org/mailman/listinfo/geotoolkit" target="_blank">http://lists.osgeo.org/mailman/listinfo/geotoolkit</a>
</div></pre>
    </blockquote>
    <br>
  </div>

<br>_______________________________________________<br>
Geotoolkit mailing list<br>
<a href="mailto:Geotoolkit@lists.osgeo.org">Geotoolkit@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/geotoolkit" target="_blank">http://lists.osgeo.org/mailman/listinfo/geotoolkit</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Thys Meintjes<br><br><br>
</div>