Actually I took this example few days ago to show my code in this mail list...
Because there is too much code to dig in in our project.
We develop a web application based on google maps api which renders maps in images.

I have attached 2 methods which render images in our project (i've cut them a bit to simplify).

Anyway, how can I contact to a module maintainer ? And which module maintainer?


Jody Garnett wrote:
Dennis Yavorsky wrote:
I've tryed this too:
mapContext = new DefaultMapContext(crs);
nothing changes...

also I've tryed to pass to context.setAreaOfInterest envelope like this: new Envelope(0.0, 0.0, 0.0, 0.0) and this changed nothing too(Same image on the pane), but possible explanation for this is that
JMapPane calls setAreaOfInterest on context again with his envelope
(but i don't know where JMapPane gets his envelope)
It asks the data for the data bounds.

You are spending a lot of time and effort on this JMapPane is not supported; it is only an example to show you how to get something on the screen at all (and so we can show some visible results as people learn geotools for the first time). Have a look at what the paint method is doing; see how it calls the renderer etc...

You can also talk to the module maintainer and ask for help.

If you go to GeoTools trunk you will see some real widgets taking shape as part of unsupported/widgets-swing.
Jody


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

    public synchronized void renderToGraphics(Graphics graphics, 
ImageProperties imageProperties) {
        validate(imageProperties);

        long renderingTime = System.currentTimeMillis();
        int width = imageProperties.getImageWidth(), height = 
imageProperties.getImageHeight();
        Rectangle paintArea = new Rectangle(width, height);
        Envelope areaOfInterest = imageProperties.createEnvelope();

        graphics.setColor(new Color(0x969696));
        graphics.fillRect(0, 0, width, height);

        mapContext.setAreaOfInterest(areaOfInterest, getCRS());

        MapLayer[] mapLayers = 
mapLayersManager.getLayersToEnvelopAllNeededArea(new Envelope(areaOfInterest));
        for (MapLayer mapLayer : mapLayers) {

            Envelope envelope = mapLayer.getEnvelope();
            Point2D leftTop = worldToPixel(imageProperties, envelope.getMinX(), 
envelope.getMaxY(), width, height);
            Point2D righBottom = worldToPixel(imageProperties, 
envelope.getMaxX(), envelope.getMinY(), width, height);
            long x = (long) leftTop.getX(), y = (long) leftTop.getY();
            long w = ((long) righBottom.getX()) - ((long) leftTop.getX()), h = 
((long) righBottom.getY()) - ((long) leftTop.getY());
            if (x < 0) {
                w = w + x;
                x = 0;
            }
            if (x + w > width) {
                w = width - x;
            }
            if (y < 0) {
                h = h + y;
                y = 0;
            }
            if (y + h > height) {
                h = height - y;
            }

            graphics.setColor(new Color(0xffffff));
            graphics.fillRect((int) x, (int) y, (int) w, (int) h);

            mapContext.clearLayerList();

            mapLayer.applyLayer(mapContext);
            renderer.paint((Graphics2D) graphics, paintArea, new 
ReferencedEnvelope(areaOfInterest, getCRS()));
//            renderer.paint((Graphics2D) graphics, paintArea, new 
ReferencedEnvelope(areaOfInterest, getCRS()),
//                    RendererUtilities.worldToScreenTransform(areaOfInterest, 
paintArea, getCRS()));
//            AffineTransform at = RendererUtilities.worldToScreenTransform(
//                            new ReferencedEnvelope(areaOfInterest, getCRS()), 
paintArea);
//            renderer.paint((Graphics2D) graphics, paintArea, at);

            mapContext.clearLayerList();
        }
        boolean gc = false;
        if (++renderedImagesCount >= MAX_RENDERED_IMAGES_COUNT_BEFORE_GC) {
            renderedImagesCount = 0;
            gc = true;
            System.gc();
        }
        renderingTime = (System.currentTimeMillis() - renderingTime);

        log.info("Render complete. Applied layers count: " + mapLayers.length + 
", imageProperties: " + imageProperties.getImageFileName() + (gc ? " [GC]" : 
"") + ". Overall time(ms): " + renderingTime);
        System.out.println("Render complete. Applied layers count: " + 
mapLayers.length + ", imageProperties: " + imageProperties.getImageFileName() + 
(gc ? " [GC]" : "") + ". Overall time(ms): " + renderingTime);
    }


        private CoordinateReferenceSystem getCRS() {
        if (crs != null) {
            return crs;
        }
        try {
            String wkt1 = "PROJCS[\"Google Mercator\", \n" +
                    "  GEOGCS[\"WGS 84\", \n" +
                    "    DATUM[\"World Geodetic System 1984\", \n" +
                    "      SPHEROID[\"WGS 84\", 6378137.0, 298.257223563, 
AUTHORITY[\"EPSG\",\"7030\"]], \n" +
                    "      AUTHORITY[\"EPSG\",\"6326\"]], \n" +
                    "    PRIMEM[\"Greenwich\", 0.0, 
AUTHORITY[\"EPSG\",\"8901\"]], \n" +
                    "    UNIT[\"degree\", 0.017453292519943295], \n" +
                    "    AXIS[\"Geodetic latitude\", NORTH], \n" +
                    "    AXIS[\"Geodetic longitude\", EAST], \n" +
                    "    AUTHORITY[\"EPSG\",\"4326\"]], \n" +
                    "  PROJECTION[\"Mercator (1SP)\", 
AUTHORITY[\"EPSG\",\"9804\"]], \n" +
                    "  PARAMETER[\"semi_major\", 6378137.0], \n" +
                    "  PARAMETER[\"semi_minor\", 6378137.0], \n" +
                    "  PARAMETER[\"latitude_of_origin\", 0.0], \n" +
                    "  PARAMETER[\"central_meridian\", 0.0], \n" +
                    "  PARAMETER[\"scale_factor\", 1.0], \n" +
                    "  PARAMETER[\"false_easting\", 0.0], \n" +
                    "  PARAMETER[\"false_northing\", 0.0], \n" +
                    "  UNIT[\"m\", 1.0], \n" +
                    "  AXIS[\"Easting\", EAST], \n" +
                    "  AXIS[\"Northing\", NORTH], \n" +
                    "  AUTHORITY[\"EPSG\",\"900913\"]]";


            crs = CRS.parseWKT(wkt1);

            System.out.println("crs = '" + crs + "'");
            return crs;
        } catch (Throwable fe) {
            System.out.println("On prjCRS creation a FactoryException :" + fe);
            fe.printStackTrace();
        }
        return null;
    }
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to