[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[udig-devel] Re: export png
|
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
>