Hi All,<div><br></div><div>I have a custom graphic that paints range rings on a layer - this works as expected, the rings are painted. However when I use the map rotate widget to rotate the map the range rings disappear.</div>
<div><br></div><div>Here is my custom graphic (using squares for testing purposes):</div><div><br></div><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> RenderingContext2D context;</div><div> private AffineTransform2D transformer;</div><div> private Graphics2D g2d;</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> this.context = context;</div><div> g2d = context.getGraphics();</div><div> </div>
<div> context.switchToDisplayCRS();</div><div> transformer = context.getObjectiveToDisplay();</div><div><br></div><div> final DirectPosition radarPosition = radar.getAntennaPosition();</div><div> Point2D.Double center = new Point2D.Double(radarPosition.getOrdinate(1), radarPosition.getOrdinate(0));</div>
<div><br></div><div> for (double range : radar.getRangeList()) {</div><div> drawRangeRing(center, range);</div><div> }</div><div> }</div><div><br></div><div> private void drawRangeRing(final Point2D.Double center, double range) {</div>
<div><br></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>// 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(transformer.createTransformedShape(circle));</div><div><br></div><div> //Shape line = new Line2D.Double(topLeft, bottomRight);</div><div> //g2d.draw(transformer.createTransformedShape(line));</div>
<div><br></div><div> g2d.setPaint(Color.GREEN);</div><div> Shape blokkie = new Rectangle2D.Double(topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y);</div><div> g2d.draw(transformer.createTransformedShape(blokkie));</div>
<div> }</div><div><br></div><div> @Override</div><div> public List<Graphic> getGraphicAt(RenderingContext context, SearchArea mask, VisitFilter filter, List<Graphic> graphics) {</div><div> return graphics;</div>
<div> }</div><div>}</div><br>-- <br>Thys Meintjes<br><br><br>
</div>