<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1476415452600_3122">Hi Johann Sorel,</div><div id="yui_3_16_0_ym19_1_1476415452600_3121">Thanks for responding.</div><div id="yui_3_16_0_ym19_1_1476415452600_3097"><br></div><div id="yui_3_16_0_ym19_1_1476415452600_3098" dir="ltr">I adapted SquareGraphics demo to take care of screen flickering issue. Now every eqpt id refreshing its location in background and map.getCanvas().repaint() is invoked from a separate  thread every 15 secs to update locations of all eqpt on screen .<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1476415452600_4948"><br></div><div id="yui_3_16_0_ym19_1_1476415452600_3312" dir="ltr">But now i am having another problem. The squares are not changing size when the map is zoomed in/out. How do I fix it? <br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1476415452600_3393"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1476415452600_4392">Code attached below:<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1476415452600_3403">===</div><div dir="ltr" id="yui_3_16_0_ym19_1_1476415452600_3530">import java.awt.Color;<br id="yui_3_16_0_ym19_1_1476415452600_4682">import java.awt.Graphics2D;<br id="yui_3_16_0_ym19_1_1476415452600_4683">import java.awt.Shape;<br id="yui_3_16_0_ym19_1_1476415452600_4684">import java.awt.geom.Rectangle2D;<br id="yui_3_16_0_ym19_1_1476415452600_4685">import java.awt.geom.RoundRectangle2D;<br id="yui_3_16_0_ym19_1_1476415452600_4686">import java.sql.Connection;<br id="yui_3_16_0_ym19_1_1476415452600_4687">import java.sql.PreparedStatement;<br id="yui_3_16_0_ym19_1_1476415452600_4688">import java.sql.ResultSet;<br id="yui_3_16_0_ym19_1_1476415452600_4689">import java.sql.SQLException;<br id="yui_3_16_0_ym19_1_1476415452600_4690">import java.util.Collection;<br id="yui_3_16_0_ym19_1_1476415452600_4691">import java.util.List;<br id="yui_3_16_0_ym19_1_1476415452600_4692">import java.util.concurrent.Executors;<br id="yui_3_16_0_ym19_1_1476415452600_4693">import java.util.concurrent.ScheduledExecutorService;<br id="yui_3_16_0_ym19_1_1476415452600_4694">import java.util.concurrent.TimeUnit;<br id="yui_3_16_0_ym19_1_1476415452600_4695">import org.apache.sis.geometry.GeneralDirectPosition;<br id="yui_3_16_0_ym19_1_1476415452600_4696">import org.apache.sis.storage.DataStoreException;<br id="yui_3_16_0_ym19_1_1476415452600_4697">import org.geotoolkit.display.canvas.AbstractReferencedCanvas2D;<br id="yui_3_16_0_ym19_1_1476415452600_4698"><br id="yui_3_16_0_ym19_1_1476415452600_4699">import org.geotoolkit.display.canvas.RenderingContext;<br id="yui_3_16_0_ym19_1_1476415452600_4700">import org.geotoolkit.display.canvas.VisitFilter;<br id="yui_3_16_0_ym19_1_1476415452600_4701">import org.geotoolkit.display.primitive.SearchArea;<br id="yui_3_16_0_ym19_1_1476415452600_4702">//import org.geotoolkit.display.VisitFilter;<br id="yui_3_16_0_ym19_1_1476415452600_4703">//import org.geotoolkit.display.SearchArea;<br id="yui_3_16_0_ym19_1_1476415452600_4704">import org.geotoolkit.display2d.canvas.J2DCanvas;<br id="yui_3_16_0_ym19_1_1476415452600_4705">import org.geotoolkit.display2d.canvas.RenderingContext2D;<br id="yui_3_16_0_ym19_1_1476415452600_4706">import org.geotoolkit.display2d.primitive.GraphicJ2D;<br id="yui_3_16_0_ym19_1_1476415452600_4707">import org.geotoolkit.referencing.CRS;<br id="yui_3_16_0_ym19_1_1476415452600_4708"><br id="yui_3_16_0_ym19_1_1476415452600_4709">import org.opengis.display.primitive.Graphic;<br id="yui_3_16_0_ym19_1_1476415452600_4710">import org.opengis.geometry.DirectPosition;<br id="yui_3_16_0_ym19_1_1476415452600_4711">import org.opengis.geometry.Envelope;<br id="yui_3_16_0_ym19_1_1476415452600_4712">import org.opengis.geometry.MismatchedDimensionException;<br id="yui_3_16_0_ym19_1_1476415452600_4713">import org.opengis.referencing.crs.CoordinateReferenceSystem;<br id="yui_3_16_0_ym19_1_1476415452600_4714">import org.opengis.referencing.operation.MathTransform;<br id="yui_3_16_0_ym19_1_1476415452600_4715">import org.opengis.referencing.operation.TransformException;<br id="yui_3_16_0_ym19_1_1476415452600_4716">import org.opengis.util.FactoryException;<br id="yui_3_16_0_ym19_1_1476415452600_4717">import org.openide.util.Exceptions;<br id="yui_3_16_0_ym19_1_1476415452600_4718">import org.openide.util.Lookup;<br id="yui_3_16_0_ym19_1_1476415452600_4719"><br id="yui_3_16_0_ym19_1_1476415452600_4720">public class SquaresGraphicTorpedo implements GraphicJ2D, Runnable {<br id="yui_3_16_0_ym19_1_1476415452600_4721"><br id="yui_3_16_0_ym19_1_1476415452600_4722">    double lat = 22.796212;<br id="yui_3_16_0_ym19_1_1476415452600_4723">    double lon = 86.198888;<br id="yui_3_16_0_ym19_1_1476415452600_4724">    String eqptId = null;<br id="yui_3_16_0_ym19_1_1476415452600_4725">    ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);<br id="yui_3_16_0_ym19_1_1476415452600_4726"><br id="yui_3_16_0_ym19_1_1476415452600_4727">    public SquaresGraphicTorpedo(String eqptId) {<br id="yui_3_16_0_ym19_1_1476415452600_4728">        this.eqptId = eqptId;<br id="yui_3_16_0_ym19_1_1476415452600_4729">        int initialDelay = 0;<br id="yui_3_16_0_ym19_1_1476415452600_4730">        int period = 1;<br id="yui_3_16_0_ym19_1_1476415452600_4731">        executor.scheduleWithFixedDelay(this, initialDelay, period, TimeUnit.MINUTES);<br id="yui_3_16_0_ym19_1_1476415452600_4732">    }<br id="yui_3_16_0_ym19_1_1476415452600_4733"><br id="yui_3_16_0_ym19_1_1476415452600_4734">    @Override<br id="yui_3_16_0_ym19_1_1476415452600_4735">    public void paint(RenderingContext2D context) {<br id="yui_3_16_0_ym19_1_1476415452600_4736"><br id="yui_3_16_0_ym19_1_1476415452600_4737">        final Graphics2D g2d = context.getGraphics();<br id="yui_3_16_0_ym19_1_1476415452600_4738"><br id="yui_3_16_0_ym19_1_1476415452600_4739"><br id="yui_3_16_0_ym19_1_1476415452600_4748">//        context.switchToObjectiveCRS();<br id="yui_3_16_0_ym19_1_1476415452600_4749">        try {<br id="yui_3_16_0_ym19_1_1476415452600_4750">            CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326");<br id="yui_3_16_0_ym19_1_1476415452600_4751">            CoordinateReferenceSystem targetCRS = context.getDisplayCRS();<br id="yui_3_16_0_ym19_1_1476415452600_4752">            MathTransform tr = CRS.findMathTransform(sourceCRS, targetCRS);<br id="yui_3_16_0_ym19_1_1476415452600_4753">            /*<br id="yui_3_16_0_ym19_1_1476415452600_4754">         * From this point we can convert an arbitrary amount of coordinates using the<br id="yui_3_16_0_ym19_1_1476415452600_4755">         * same MathTransform object. It could be in concurrent threads if we wish.<br id="yui_3_16_0_ym19_1_1476415452600_4756">             */<br id="yui_3_16_0_ym19_1_1476415452600_4757">            DirectPosition sourcePt = new GeneralDirectPosition(<br id="yui_3_16_0_ym19_1_1476415452600_4758">                    lat, // 27°59'17"N<br id="yui_3_16_0_ym19_1_1476415452600_4759">                    lon);  // 86°55'31"E<br id="yui_3_16_0_ym19_1_1476415452600_4760">            DirectPosition targetPt = tr.transform(sourcePt, null);<br id="yui_3_16_0_ym19_1_1476415452600_4761"><br id="yui_3_16_0_ym19_1_1476415452600_4762">//            System.out.println("ptDst.x: " + targetPt.getCoordinate()[0] + " ptDst.y: " + targetPt.getCoordinate()[1]);<br id="yui_3_16_0_ym19_1_1476415452600_4763">            RoundRectangle2D.Double rect = new RoundRectangle2D.Double(targetPt.getCoordinate()[0], targetPt.getCoordinate()[1], 20, 10, 10, 10);<br id="yui_3_16_0_ym19_1_1476415452600_4764"><br id="yui_3_16_0_ym19_1_1476415452600_4765">            g2d.setPaint(Color.RED);<br id="yui_3_16_0_ym19_1_1476415452600_4766">            g2d.fill(rect);<br id="yui_3_16_0_ym19_1_1476415452600_4767"><br id="yui_3_16_0_ym19_1_1476415452600_4770">        } catch (FactoryException | MismatchedDimensionException | TransformException ex) {<br id="yui_3_16_0_ym19_1_1476415452600_4771">            Exceptions.printStackTrace(ex);<br id="yui_3_16_0_ym19_1_1476415452600_4772">        }<br id="yui_3_16_0_ym19_1_1476415452600_4773"><br id="yui_3_16_0_ym19_1_1476415452600_4774">    }</div><div dir="ltr" id="yui_3_16_0_ym19_1_1476415452600_5303"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1476415452600_5302">@Override<br id="yui_3_16_0_ym19_1_1476415452600_5265">    public void run() {<br id="yui_3_16_0_ym19_1_1476415452600_5266"><br id="yui_3_16_0_ym19_1_1476415452600_5267">        getLastLocationOfTheDay();<br id="yui_3_16_0_ym19_1_1476415452600_5268"><br id="yui_3_16_0_ym19_1_1476415452600_5269">    }<br id="yui_3_16_0_ym19_1_1476415452600_5270"><br id="yui_3_16_0_ym19_1_1476415452600_5271">    private void getLastLocationOfTheDay() {<br id="yui_3_16_0_ym19_1_1476415452600_5272">        <br id="yui_3_16_0_ym19_1_1476415452600_5273">    }<br id="yui_3_16_0_ym19_1_1476415452600_5274"><br id="yui_3_16_0_ym19_1_1476415452600_5275">  <br id="yui_3_16_0_ym19_1_1476415452600_5276"><br id="yui_3_16_0_ym19_1_1476415452600_5277">    @Override<br id="yui_3_16_0_ym19_1_1476415452600_5278">    public List<Graphic> getGraphicAt(RenderingContext context, SearchArea mask, VisitFilter filter, List<Graphic> graphics) {<br id="yui_3_16_0_ym19_1_1476415452600_5279">        return graphics;<br id="yui_3_16_0_ym19_1_1476415452600_5280">    }<br id="yui_3_16_0_ym19_1_1476415452600_5281"><br id="yui_3_16_0_ym19_1_1476415452600_5282">    @Override<br id="yui_3_16_0_ym19_1_1476415452600_5283">    public Object getUserObject() {<br id="yui_3_16_0_ym19_1_1476415452600_5284">        return null;<br id="yui_3_16_0_ym19_1_1476415452600_5285">    }<br id="yui_3_16_0_ym19_1_1476415452600_5286"><br id="yui_3_16_0_ym19_1_1476415452600_5287">    @Override<br id="yui_3_16_0_ym19_1_1476415452600_5288">    public Envelope getEnvelope() {<br id="yui_3_16_0_ym19_1_1476415452600_5289">        return null;<br id="yui_3_16_0_ym19_1_1476415452600_5290">    }<br id="yui_3_16_0_ym19_1_1476415452600_5291"><br id="yui_3_16_0_ym19_1_1476415452600_5292">    @Override<br id="yui_3_16_0_ym19_1_1476415452600_5293">    public double getZOrderHint() {<br id="yui_3_16_0_ym19_1_1476415452600_5294">        return 0.0;<br id="yui_3_16_0_ym19_1_1476415452600_5295">    }<br id="yui_3_16_0_ym19_1_1476415452600_5296"><br id="yui_3_16_0_ym19_1_1476415452600_5297">    @Override<br id="yui_3_16_0_ym19_1_1476415452600_5298">    public void setZOrderHint(double d) {<br id="yui_3_16_0_ym19_1_1476415452600_5299"><br id="yui_3_16_0_ym19_1_1476415452600_5300">    }<br id="yui_3_16_0_ym19_1_1476415452600_5301"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1476415452600_3531">==<br></div><div id="yui_3_16_0_ym19_1_1476415452600_3049"><span id="yui_3_16_0_ym19_1_1476415452600_5363">Thanks and regards</span></div><div id="yui_3_16_0_ym19_1_1476415452600_5406"><span id="yui_3_16_0_ym19_1_1476415452600_5363"><br></span></div><div id="yui_3_16_0_ym19_1_1476415452600_5404"><span id="yui_3_16_0_ym19_1_1476415452600_5363">Asutosh Gopinath</span></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"><font face="Arial" size="2"> On Thursday, October 13, 2016 1:54 PM, johann sorel <johann.sorel@geomatys.com> wrote:<br></font></div>  <br><br> <div class="y_msg_container"><div id="yiv4595509073"><div>
    Hello,<br clear="none">
    <br clear="none">
    The rendering engine is stateless by default, but we have some
    possible alternatives.<br clear="none">
    <br clear="none">
    Solution 1 :<br clear="none">
    final JMap2D jmap = new JMap2D();<br clear="none">
    jmap.getCanvas().setRenderingHint(GO2Hints.KEY_BEHAVIOR_MODE,
    GO2Hints.BEHAVIOR_KEEP_TILE);<br clear="none">
    This will ask the swing widget to replace the image at the last
    moment when possible, it should reduce the flickering.<br clear="none">
    You can also try the 'GO2Hints.BEHAVIOR_ON_FINISH'<br clear="none">
    <br clear="none">
    Solution 2 :<br clear="none">
    final JMap2D jmap = new JMap2D(true);<br clear="none">
    The boolean argument is for 'statefull', the engine will cache more
    informations and use separate buffers<br clear="none">
    for each layer. But it use more memory.<br clear="none">
    <br clear="none">
    Solution 3 :<br clear="none">
    There is also the solution to create a custom decoration over the
    map,<br clear="none">
    A demo is available in the demo-samples module, package :
    org.geotoolkit.pending.demo.rendering.customdecoration<br clear="none">
    But it require a lot more work.<br clear="none">
    <br clear="none">
    <br clear="none">
    <br clear="none">
    Johann Sorel<br clear="none">
    <br clear="none">
    <br clear="none">
    <br clear="none">
    <div class="yiv4595509073yqt8857071416" id="yiv4595509073yqt87890"><div class="yiv4595509073moz-cite-prefix">On 12/10/2016 06:51, Gopinath Asutosh
      wrote:<br clear="none">
    </div>
    <blockquote type="cite">
      <div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;">
        <div id="yiv4595509073yui_3_16_0_ym19_1_1476247003393_2725">Hi ,</div>
        <div dir="ltr" id="yiv4595509073yui_3_16_0_ym19_1_1476247003393_2831">I want
          to show over 100 objects representing vehicles moving on GIS
          map. The locations of vehicle change every 10 secs.</div>
        <div dir="ltr" id="yiv4595509073yui_3_16_0_ym19_1_1476247003393_2939">I tried
          to create a circle with its center located on GPS coordinates
          obtained from devices mounted on vehicles. Whenever new
          coordinates are received I create a new circle and call
          store.updateFeatures. This plots the circles on new location
          but it also simultaneously causes the screen to flicker a lot
          due to which the animation effect is lost.<br clear="none">
        </div>
        <div dir="ltr" id="yiv4595509073yui_3_16_0_ym19_1_1476247003393_3021"><br clear="none">
        </div>
        <div dir="ltr" id="yiv4595509073yui_3_16_0_ym19_1_1476247003393_2937">It is
          possible to animate any object using geotoolkit without
          causing the screen to flicker.</div>
        <div dir="ltr" id="yiv4595509073yui_3_16_0_ym19_1_1476247003393_3171"><br clear="none">
        </div>
        <div dir="ltr" id="yiv4595509073yui_3_16_0_ym19_1_1476247003393_3174">Thanks
          and regards</div>
        <div dir="ltr" id="yiv4595509073yui_3_16_0_ym19_1_1476247003393_3175">Asutosh
          Gopinath<br clear="none">
        </div>
      </div>
      <br clear="none">
      <fieldset class="yiv4595509073mimeAttachmentHeader"></fieldset>
      <br clear="none">
      <pre>_______________________________________________
Geotoolkit mailing list
<a rel="nofollow" shape="rect" class="yiv4595509073moz-txt-link-abbreviated" ymailto="mailto:Geotoolkit@lists.osgeo.org" target="_blank" href="mailto:Geotoolkit@lists.osgeo.org">Geotoolkit@lists.osgeo.org</a>
<a rel="nofollow" shape="rect" class="yiv4595509073moz-txt-link-freetext" target="_blank" href="http://lists.osgeo.org/mailman/listinfo/geotoolkit">http://lists.osgeo.org/mailman/listinfo/geotoolkit</a></pre>
    </blockquote></div>
    <br clear="none">
  </div></div><br><div class="yqt8857071416" id="yqt15577">_______________________________________________<br clear="none">Geotoolkit mailing list<br clear="none"><a shape="rect" ymailto="mailto:Geotoolkit@lists.osgeo.org" href="mailto:Geotoolkit@lists.osgeo.org">Geotoolkit@lists.osgeo.org</a><br clear="none"><a shape="rect" href="http://lists.osgeo.org/mailman/listinfo/geotoolkit" target="_blank">http://lists.osgeo.org/mailman/listinfo/geotoolkit</a></div><br><br></div>  </div> </div>  </div></div></body></html>