Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Re: export png

You can just use Display.syncExec instead of asyncExec, then you won't
need the wait loop.

Cole

On 8/17/07, Andrea Antonello <andrea.antonello@xxxxxxxxx> wrote:
> Sounds to be a good moment to learn to use the wizards. I'm stuck of
> my paltry save dialogs :)
> Where to start from?
>
> Ciao
> Andrea
>
>
> On Fri, 17 Aug 2007 09:47:05 -0700 Jody Garnett
> <jgarnett@xxxxxxxxxxxxxxx> probably wrote:
>
> > Woot - now all we need to do is wrap this up as an "Export Wizard"
> > for an official release :-)
> > Jody
> >
> > Andrea Antonello wrote:
> > > Alright, forget what I posted before, at least a part,
> > > there is an easier way to get the image, instead of make all the
> > > renderers draw on a new created image :), there is a method which I
> > > didn't notice (do things fast, do them fast...) , which is:
> > > RenderedImage image = activeMap.getRenderManager().getImage();
> > >
> > > And that is it. Rendered with everything on it, I guess that takes
> > > directly the panels graphic.
> > >
> > > Very nice... all reduced to really few lines of code...
> > > Ciao
> > > Andrea
> > >
> > >
> > >
> > >
> > > On Fri, 17 Aug 2007 09:16:31 +0200 "andrea antonello"
> > > <andrea.antonello@xxxxxxxxx> probably wrote:
> > >
> > >
> > >> I just noticed that doing it that way the labels are not
> > >> exported... any idea about that?
> > >>
> > >> Andrea
> > >>
> > >> On 8/17/07, Andrea Antonello <andrea.antonello@xxxxxxxxx> wrote:
> > >>
> > >>> For own usage I needed to implement a simple png export. Since
> > >>> JGrass would contain it but some more time is needed to its first
> > >>> release :) and since the code is really few, I paste it below. I
> > >>> remember someone was interested in that, so enjoy :)
> > >>>
> > >>> PS: is there another way to deal with the filedialog or do I have
> > >>> to use the asyncexec?
> > >>>
> > >>> _____________________________________________________________________
> > >>>
> > >>>         public void op(Display display, Object target,
> > >>> IProgressMonitor monitor) throws Exception {
> > >>>
> > >>>                 IMap activeMap = ApplicationGIS.getActiveMap();
> > >>>
> > >>>                 List<IRenderer> renderers =
> > >>> activeMap.getRenderManager().getRenderers();
> > >>>
> > >>>                 int w =
> > >>> activeMap.getRenderManager().getMapDisplay().getWidth(); int h =
> > >>> activeMap.getRenderManager().getMapDisplay().getHeight();
> > >>> BufferedImage bImage = new BufferedImage(w, h,
> > >>> BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = (Graphics2D)
> > >>> bImage.createGraphics();
> > >>>
> > >>>                 for (IRenderer renderer : renderers) {
> > >>>                         renderer.render(g2d, monitor);
> > >>>                 }
> > >>>
> > >>>                 goGo = false;
> > >>>
> > >>>                 Display.getDefault().asyncExec(new Runnable() {
> > >>>
> > >>>                         public void run() {
> > >>>                                 FileDialog fileDialog = new
> > >>> FileDialog(new Shell(Display .getDefault()), SWT.SAVE);
> > >>>                                 fileDialog.setText("Choose the
> > >>> output png file"); path = fileDialog.open();
> > >>>                                 goGo = true;
> > >>>                         }
> > >>>                 });
> > >>>                 while (!goGo) {
> > >>>                         try {
> > >>>                                 Thread.sleep(300);
> > >>>                         } catch (InterruptedException e) {
> > >>>                                 e.printStackTrace();
> > >>>                         }
> > >>>                 }
> > >>>                 goGo = false;
> > >>>
> > >>>                 if (path == null || path.length() < 1) {
> > >>>                         return;
> > >>>                 }
> > >>>
> > >>>                 ImageIO.write(bImage, "png", new File(path));
> > >>>
> > >>>         }
> > >>>
> > >>> _____________________________________________________________________
> > >>>
> > >>>
> > >>> Ciao
> > >>> Andrea
> > >>>
> > >>>
> > > _______________________________________________
> > > User-friendly Desktop Internet GIS (uDig)
> > > http://udig.refractions.net
> > > http://lists.refractions.net/mailman/listinfo/udig-devel
> > >
> >
> > _______________________________________________
> > User-friendly Desktop Internet GIS (uDig)
> > http://udig.refractions.net
> > http://lists.refractions.net/mailman/listinfo/udig-devel
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
>


Back to the top