Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] ApplicationGIS drawMap example

Okay in discussion on IRC the actual request turned out a bit different.

The idea is to delay a layer refresh; until the entire image is ready. The idea is to update a style; and not watch the screen draw the new features in. Since the rendering system is listening to the renderer turn over and issue events; perhaps we could configure the renderer to only issue an event when it is "done" ?

Jesse you are a bit more familiar with the rendering system at this level; could we, place something on the style blackboard and then modify the BasicFeatureRenderer to issue less events in this case?

Jody

On 19/01/2011, at 2:21 PM, Jody Garnett wrote:

Here is a cut&paste of calling AppplicationGIS.drawMap (it comes from the box preview code used in printing):

    BufferedImage preview;
    State current;
    public void createPreview( Graphics2D graphics, final IProgressMonitor monitor ) {
Dimension size = getBox().getSize();

        try {
            if (map != null) {
                preview = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
                Graphics2D g = preview.createGraphics();
                try {
                    ApplicationGIS.drawMap(new DrawMapParameter(g, new java.awt.Dimension(
                            size.width, size.height), this.map, monitor));
                } finally {
                    g.dispose();
                }
                current = new State(map.getViewportModel(), getBox().getSize());
                graphics.drawImage(preview, 0, 0, size.width, size.height, 0, 0,
                        preview.getWidth(), preview.getHeight(), null);
            }
        } catch (Exception e) {
            PrintingModelPlugin.log("", e); //$NON-NLS-1$
            String message = "Error rendering Map:  " + e.getMessage(); //$NON-NLS-1$
            drawErrorMessage(graphics, message);
        }
        setDirty(false);
    }

You could do something similar to get an image; for use in a View.

To make a single threaded renderer we could use this code as an example; MapEditor uses the "widget" MapViewer to get the job done; perhaps we can teach it to be single threaded using something similar to ApplicationGIS.drawMap.

Out of curiosity why are you interested in a single threaded renderer?

Jody


Back to the top