<!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 <0 values for width and height.<br>
try :<br>
Math.abs(bottomRight.x - topLeft.x),<br>
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, </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
AffineTransform2D.createTransformedShape()</div>
<div>and drawing that shape doesn't draw anything at all... Could
anyone spot the bug in my code ? </div>
<div><br>
</div>
<div>public class RadarGraphic extends AbstractGraphicJ2D {</div>
<div><br>
</div>
<div> private final static Logger logger =
LoggerFactory.getLogger(RadarGraphic.class);</div>
<div> private GeodeticCalculator calc;</div>
<div> private Radar radar;</div>
<div><br>
</div>
<div> public RadarGraphic(J2DCanvas canvas, Radar radar) {</div>
<div> super(canvas, canvas.getObjectiveCRS2D());</div>
<div> this.radar = radar;</div>
<div>
calc = new
GeodeticCalculator(DefaultGeographicCRS.WGS84);</div>
<div> }</div>
<div><br>
</div>
<div> @Override</div>
<div> public void paint(RenderingContext2D context) {</div>
<div> final Graphics2D g2d = context.getGraphics();</div>
<div> // transform from geographic to screen space</div>
<div> final AffineTransform2D transformer =
context.getObjectiveToDisplay();</div>
<div>
//transformer.setToRotation(context.getCanvas().getController().getRotation());</div>
<div><br>
</div>
<div> final DirectPosition radarPosition =
radar.getAntennaPosition();</div>
<div> if (radarPosition == null) {</div>
<div> logger.debug("Radar " + radar.getName() + "
antenna position not set");</div>
<div> return;</div>
<div> }</div>
<div><br>
</div>
<div> Point2D.Double center = new
Point2D.Double(radarPosition.getOrdinate(0),
radarPosition.getOrdinate(1));</div>
<div> for (Double range : radar.getRangeList()) {</div>
<div> drawRangeRing(g2d, center, range, transformer);</div>
<div> }</div>
<div><br>
</div>
<div> drawRadar(g2d, center, transformer);</div>
<div> }</div>
<div><br>
</div>
<div> private void drawRangeRing(Graphics2D g2d, Point2D.Double
center, Double range, AffineTransform2D transformer) {</div>
<div> // topLeft </div>
<div> calc.setStartingGeographicPoint(center);</div>
<div> calc.setDirection(-45.0, Math.sqrt(2.0) * range);</div>
<div> Point2D.Double topLeft = (Point2D.Double)
calc.getDestinationGeographicPoint();</div>
<div> // bottomRight</div>
<div> calc.setStartingGeographicPoint(center);</div>
<div> calc.setDirection(135.0, Math.sqrt(2.0) * range);</div>
<div> Point2D.Double bottomRight = (Point2D.Double)
calc.getDestinationGeographicPoint();</div>
<div><br>
</div>
<div> transformer.transform(topLeft, topLeft);</div>
<div> transformer.transform(bottomRight, bottomRight);</div>
<div> </div>
<div> g2d.setStroke(new BasicStroke(4));</div>
<div><br>
</div>
<div> Shape circle = new Ellipse2D.Double(</div>
<div> topLeft.x,</div>
<div> topLeft.y,</div>
<div> bottomRight.x - topLeft.x,</div>
<div> bottomRight.y - topLeft.y);</div>
<div> g2d.setPaint(Color.GREEN);</div>
<div> g2d.draw(circle);</div>
<div><br>
</div>
<div><br>
</div>
<div> }</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>