Re: [OpenMap Users] Newbie questions

From: Don Dietrick <dietrick@bbn.com>
Date: Mon Aug 11 2003 - 16:35:41 EDT

Hi Ben,

It's not really a swing thing that's causing this. The rendering
algorithms in Java rely on the windowing environment to paint stuff -
you can see from the stack trace that the java.awt.Font class is
kicking off the problem trying to get a GraphicsEnvironment to get the
font metrics. You just have to give the Java process a toolkit, even
though nothing is getting rendered to a screen. You can use xvfb or
some other X virtual frame buffer thing (I forget the name but others
on the list have mentioned it before).

- Don

On Monday, August 11, 2003, at 03:47 PM, Benjamin.May@bookspan.com
wrote:

>  
> Hrm, well so far so good. I am able to do some basic stuff. For now, I
> am just using a default setting Projection. I can worry about getting
> the position attributes once I am able to just write a file out at all
> ;) When I try to instantiate the ImageServer as in Keith's example, I
> get the following exception:
>  
> Exception in thread "main" java.lang.InternalError: Can't connect to
> X11 window server using ':0.0' as the value of the DISPLAY variable.
>         at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
>         at
> sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:54)
>         at java.lang.Class.forName0(Native Method)
>         at java.lang.Class.forName(Class.java:115)
>         at
> java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnviro
> nment.java:53)
>         at java.awt.Font.initializeFont(Font.java:259)
>         at java.awt.Font.<init>(Font.java:293)
>         at java.awt.Font.decode(Font.java:773)
>         at com.bbn.openmap.layer.LabelLayer.<init>(Unknown Source)
>         at com.bbn.openmap.layer.DateLayer.<init>(Unknown Source)
>         at java.lang.Class.newInstance0(Native Method)
>         at java.lang.Class.newInstance(Class.java:232)
>         at com.bbn.openmap.util.ComponentFactory.create(Unknown Source)
>         at com.bbn.openmap.image.ImageServer.getLayers(Unknown Source)
>         at com.bbn.openmap.image.ImageServer.setProperties(Unknown
> Source)
>         at com.bbn.openmap.image.ImageServer.<init>(Unknown Source)
>         at com.bbn.openmap.image.ImageServer.<init>(Unknown Source)
>         at Test.getMapAsJPEG(Test.java:47)
>         at Test.main(Test.java:27)
> Now, I am trying to save an image without using swing at all, so I am
> confused why the image manager is trying to act as an XWin client. Is
> the imagemanager inherently swing-related? If so I should probably
> chose another way to do this. Thanks again guys!
>
>
> -----Original Message-----
> From: Benjamin.May@bookspan.com [mailto:Benjamin.May@bookspan.com]
> Sent: Monday, August 11, 2003 2:52 PM
> To: kalphonso@diamonddata.com
> Cc: openmap-users@bbn.com
> Subject: RE: [OpenMap Users] Newbie questions
>
>  
> This is a good start... What class is that in? You have some methods
> (getMapProperties() for instance) which you dont provide here. Are the
> openmap methods? Where are you passing it the co-ordinates so it knows
> what map to draw? Thanks!
>
> Here is the block of code I use to generate a map jpeg from a set of
> properties and a map projection.
>  
>  
>  public byte [] getMapAsJPEG(HttpSession session)
>   {
>      Properties props = getMapProperties();
>  
>       ImageServer imageServer = new ImageServer("mapDemo", props);
>       com.bbn.openmap.image.SunJPEGFormatter formatter = new
> com.bbn.openmap.image.SunJPEGFormatter();
>       formatter.setImageQuality(1.0f);
>       imageServer.setFormatter(formatter);
>       byte [] imageBytes = imageServer.createImage(getMapProjection());
>       return imageBytes;
>   }
>
>

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, BBN Technologies, dietrick@bbn.com
10 Moulton Street, Cambridge, MA 02138
617-873-3031 [fax]-2794
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

--
[To unsubscribe to this list send an email to "majdart@bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Mon Aug 11 16:35:49 2003

This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:36 EDT