<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body 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'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<br>
<br>
<br>
On 07/26/2011 11:42 AM, Thys Meintjes wrote:
<blockquote
cite="mid:CAHRf99nE5dmSLrprvw7gn=VHbXRitwAP7eXwc0z0S=momUBJZg@mail.gmail.com"
type="cite">
<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>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Geotoolkit mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Geotoolkit@lists.osgeo.org">Geotoolkit@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/geotoolkit">http://lists.osgeo.org/mailman/listinfo/geotoolkit</a>
</pre>
</blockquote>
<br>
</body>
</html>