[geotk] repaint issue with rotate map decoration

Thys Meintjes sthysel at gmail.com
Thu Jul 28 02:17:01 EDT 2011


Hi All,

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.

Here is my custom graphic (using squares for testing purposes):

public class RadarGraphic extends AbstractGraphicJ2D {

    private final static Logger logger =
LoggerFactory.getLogger(RadarGraphic.class);
    private GeodeticCalculator calc;
    private Radar radar;
    RenderingContext2D context;
    private AffineTransform2D transformer;
    private Graphics2D g2d;

    public RadarGraphic(J2DCanvas canvas, Radar radar) {
        super(canvas, canvas.getObjectiveCRS2D());
        this.radar = radar;
        calc = new GeodeticCalculator(DefaultGeographicCRS.WGS84);
    }

    @Override
    public void paint(RenderingContext2D context) {
        this.context = context;
        g2d = context.getGraphics();

        context.switchToDisplayCRS();
        transformer = context.getObjectiveToDisplay();

        final DirectPosition radarPosition = radar.getAntennaPosition();
        Point2D.Double center = new
Point2D.Double(radarPosition.getOrdinate(1), radarPosition.getOrdinate(0));

        for (double range : radar.getRangeList()) {
            drawRangeRing(center, range);
        }
    }

    private void drawRangeRing(final Point2D.Double center, double range) {

        // topLeft
        calc.setStartingGeographicPoint(center);
        calc.setDirection(-45.0, Math.sqrt(2.0) * range);
        Point2D.Double topLeft = (Point2D.Double)
calc.getDestinationGeographicPoint();
        // bottomRight
        calc.setStartingGeographicPoint(center);
        calc.setDirection(135.0, Math.sqrt(2.0) * range);
        Point2D.Double bottomRight = (Point2D.Double)
calc.getDestinationGeographicPoint();

//        Shape circle = new Ellipse2D.Double(
//                topLeft.x,
//                topLeft.y,
//                bottomRight.x - topLeft.x,
//                bottomRight.y - topLeft.y);
//        g2d.setPaint(Color.GREEN);
//        g2d.draw(transformer.createTransformedShape(circle));

        //Shape line = new Line2D.Double(topLeft, bottomRight);
        //g2d.draw(transformer.createTransformedShape(line));

        g2d.setPaint(Color.GREEN);
        Shape blokkie = new Rectangle2D.Double(topLeft.x, topLeft.y,
bottomRight.x - topLeft.x, bottomRight.y - topLeft.y);
        g2d.draw(transformer.createTransformedShape(blokkie));
    }

    @Override
    public List<Graphic> getGraphicAt(RenderingContext context, SearchArea
mask, VisitFilter filter, List<Graphic> graphics) {
        return graphics;
    }
}

-- 
Thys Meintjes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geotoolkit/attachments/20110728/20a3194f/attachment.html


More information about the Geotoolkit mailing list