<!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 text="#000000" bgcolor="#ffffff">
    It's the way you calculate your radar circle which is wrong.<br>
    <br>
    I'm sure it's your Elipse2D which is completly flat. you must not
    have &lt;0 values for width and height.<br>
    try :<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Math.abs(bottomRight.x - topLeft.x),<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Math.abs(bottomRight.y - topLeft.y));<br>
    <br>
    at least you will see your circle.<br>
    <br>
    the reason is when you rotate the map your topleft point is not
    anymore the topleft, same for the bottomRight.<br>
    <br>
    <br>
    johann<br>
    <br>
    On 03/08/2011 08:46, Thys Meintjes wrote:
    <blockquote
cite="mid:CAHRf99=FZpgDmd1A2tjfzQ3RAgCtbp+Qf9Nn8pP2hyORXZ7Q0Q@mail.gmail.com"
      type="cite">
      <div>Hi All,&nbsp;</div>
      <div><br>
      </div>
      <div>In my Graphic below I'm drawing range rings from a center. To
        scale the range rings geographically I calculate the circles'
        bounding boxes and then transform to screen coordinates.</div>
      <div>See below. When I now use the map rotate widget the rings get
        drawn with the bounding box untransformed. Passing the circle to
        &nbsp;AffineTransform2D.createTransformedShape()</div>
      <div>and drawing that shape doesn't draw anything at all... Could
        anyone spot the bug in my code ?&nbsp;</div>
      <div><br>
      </div>
      <div>public class RadarGraphic extends AbstractGraphicJ2D {</div>
      <div><br>
      </div>
      <div>&nbsp; &nbsp; private final static Logger logger =
        LoggerFactory.getLogger(RadarGraphic.class);</div>
      <div>&nbsp; &nbsp; private GeodeticCalculator calc;</div>
      <div>&nbsp; &nbsp; private Radar radar;</div>
      <div><br>
      </div>
      <div>&nbsp; &nbsp; public RadarGraphic(J2DCanvas canvas, Radar radar) {</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; super(canvas, canvas.getObjectiveCRS2D());</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; this.radar = radar;</div>
      <div>
        &nbsp; &nbsp; &nbsp; &nbsp; calc = new
        GeodeticCalculator(DefaultGeographicCRS.WGS84);</div>
      <div>&nbsp; &nbsp; }</div>
      <div><br>
      </div>
      <div>&nbsp; &nbsp; @Override</div>
      <div>&nbsp; &nbsp; public void paint(RenderingContext2D context) {</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; final Graphics2D g2d = context.getGraphics();</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; // transform from geographic to screen space</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; final AffineTransform2D transformer =
        context.getObjectiveToDisplay();</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp;
//transformer.setToRotation(context.getCanvas().getController().getRotation());</div>
      <div><br>
      </div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; final DirectPosition radarPosition =
        radar.getAntennaPosition();</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; if (radarPosition == null) {</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; logger.debug("Radar " + radar.getName() + "
        antenna position not set");</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
      <div><br>
      </div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; Point2D.Double center = new
        Point2D.Double(radarPosition.getOrdinate(0),
        radarPosition.getOrdinate(1));</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; for (Double range : radar.getRangeList()) {</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawRangeRing(g2d, center, range, transformer);</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
      <div><br>
      </div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; drawRadar(g2d, center, transformer);</div>
      <div>&nbsp; &nbsp; }</div>
      <div><br>
      </div>
      <div>&nbsp; &nbsp; private void drawRangeRing(Graphics2D g2d, Point2D.Double
        center, Double range, AffineTransform2D transformer) {</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; // topLeft&nbsp;</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; calc.setStartingGeographicPoint(center);</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; calc.setDirection(-45.0, Math.sqrt(2.0) * range);</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; Point2D.Double topLeft = (Point2D.Double)
        calc.getDestinationGeographicPoint();</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; // bottomRight</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; calc.setStartingGeographicPoint(center);</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; calc.setDirection(135.0, Math.sqrt(2.0) * range);</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; Point2D.Double bottomRight = (Point2D.Double)
        calc.getDestinationGeographicPoint();</div>
      <div><br>
      </div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; transformer.transform(topLeft, topLeft);</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; transformer.transform(bottomRight, bottomRight);</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; g2d.setStroke(new BasicStroke(4));</div>
      <div><br>
      </div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; Shape circle = new Ellipse2D.Double(</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; topLeft.x,</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; topLeft.y,</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bottomRight.x - topLeft.x,</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bottomRight.y - topLeft.y);</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; g2d.setPaint(Color.GREEN);</div>
      <div>&nbsp; &nbsp; &nbsp; &nbsp; g2d.draw(circle);</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div>&nbsp; &nbsp; }</div>
      <div><br>
      </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>