<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Martin,<div><br></div><div>Thanks for your quick response.<div>The reason why I am looking to use the Graphics2D API is because I need to fill multiple circles around a certain point with each circle having different grid values. This would be very easy with Graphics2D. </div></div><div><br></div><div apple-content-edited="true">Kind regards,</div><div apple-content-edited="true">Jacob   </div>
<br><div><div>On 02 Aug 2013, at 19:00, Martin Desruisseaux <<a href="mailto:martin.desruisseaux@geomatys.fr">martin.desruisseaux@geomatys.fr</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
  
    <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
  
  <div bgcolor="#FFFFFF" text="#000000">
    Hello Jacob<br>
    <br>
    Le 02/08/13 17:58, Jacob Beeusaert a écrit :<br>
    <blockquote cite="mid:4E843E3B-1409-446C-A5E3-E6A8C828D705@beeusaert.com" type="cite">I am having some issues using Graphics2D to draw a
      GridCoverage using the GridCoverageBuilder. I've written a Test
      for the behaviour. Hopefully someone can help me understand what
      is going on.</blockquote>
    <br>
    I had a look to the test. I didn't checked deeply, but I would
    suggest to follow different steps:<br>
    <br>
    <blockquote cite="mid:4E843E3B-1409-446C-A5E3-E6A8C828D705@beeusaert.com" type="cite">
      <div>
        <div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span style="color: rgb(147, 26, 104); "></span><span style=""><span class="Apple-tab-span" style="white-space: pre; "></span></span>// Will use
          sample value in the range -10000 inclusive to 10000 exclusive.
          <div style="margin: 0px; ">builder.setSampleRange(-10000,
            10000);</div>
        </div>
      </div>
    </blockquote>
    <br>
    I would suggest to avoid negative sample values, as they are not
    supported by IndexColorModel. While the library tries to workaround
    this limitation, there is more risk of unexpected results and it
    often consume more memory. I rather suggest:<br>
    <br>
    <pre>builder.setSampleRange(1, 20000);</pre>
    <br>
    and replace:<br>
    <br>
    <blockquote cite="mid:4E843E3B-1409-446C-A5E3-E6A8C828D705@beeusaert.com" type="cite">
      <div>
        <div style="margin: 0px; font-size: 11px; font-family: Monaco; ">
          <div style="margin: 0px; ">elevation.setLinearTransform(0.01,
            0);</div>
          <div style="margin: 0px; ">elevation.addNodataValue(<span style="color: rgb(57, 51, 255); ">"No data"</span>,
            10000);</div>
        </div>
      </div>
    </blockquote>
    <br>
    by:<br>
    <br>
    <pre>elevation.setLinearTransform(0.01, -500);
elevation.addNodataValue("No data", 0);
</pre>
    <br>
    While not essential, using "0" for "no-data" also reduce the risk of
    unexpected results and allows a few optimization in the library.<br>
    <br>
    On the following question:<br>
    <br>
    <blockquote cite="mid:4E843E3B-1409-446C-A5E3-E6A8C828D705@beeusaert.com" type="cite">
      <div>
        <div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span style=""><span class="Apple-tab-span" style="white-space: pre; "></span></span>//How to define
          the grid value of the stuff we will draw? setColor??</div>
      </div>
    </blockquote>
    <br>
    I would not recommend to use ColorSpace or Graphics2D, since they
    are for drawing visual objects rather than computing geophysical
    values. Instead, I suggest:<br>
    <br>
    <pre>WritableRaster raster = image.getRaster();
raster.setSample(x, y, 0, value);
</pre>
    <br>
        Regards,<br>
    <br>
            Martin<br>
    <br>
  </div>

_______________________________________________<br>Geotoolkit mailing list<br><a href="mailto:Geotoolkit@lists.osgeo.org">Geotoolkit@lists.osgeo.org</a><br>http://lists.osgeo.org/mailman/listinfo/geotoolkit<br></blockquote></div><br></body></html>