<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>