World Wind Forums

Go Back   World Wind Forums > WorldWind JAVA forums > Development Help

Development Help Help for building applications or diagnosing problems with WWJ

Reply
 
Thread Tools Display Modes
Old 05-26-2007, 02:05 PM   #1
fabrizio.giudici
Senior Member
 
Join Date: May 2007
Location: Milan, Genoa (Italy)
Posts: 112
Default Using WWIcon for photos - extension needed?

Thanks to the hints by patmurris, I've been able to understand the usage of icons. I used them to put waypoints (path) and photos on WW.



In order to render photos, I had to do some changes to WW (by copying and changing two classes). In facts, WWIcon is based on a string path which points to an external picture resource, while my thumbnails are generated in-memory.

The changes are small - I think that they could be incorporated in WW for more flexibility. Anyone interested? Should I post them here?
__________________
--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941
fabrizio.giudici is offline   Reply With Quote
Old 05-26-2007, 04:55 PM   #2
ghchinoy
Junior Member
 
Join Date: Jan 2006
Location: Colorado, USA
Posts: 18
Default

fabrizio,

great job. please do post them here. we can get the community to try to incorporate them into a running set of documentation.

h
ghchinoy is offline   Reply With Quote
Old 05-26-2007, 06:23 PM   #3
patmurris
WWJ Consultant
 
patmurris's Avatar
 
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
Default

Keep in mind the WWJ SDK is a kind of pre-alpha version and a lot may evolve before a stable release comes out. So some of the code produced now may just break or become obsolete with future release.

Also, there is no clear protocol to submit code to the WWJ team at NLT...
__________________
My World Wind Java Blog & WW.net Plugins page
patmurris is offline   Reply With Quote
Old 05-27-2007, 06:45 PM   #4
TomServo
God. Root. What is difference?
 
TomServo's Avatar
 
Join Date: Sep 2004
Location: Eastern Pennsylvania
Posts: 2,856
Default

I am working on it... hopefully we can just setup something on the SF SVN.
__________________


Earth is Square blog

PUBLIC NOTICE AS REQUIRED BY LAW: Any use of this forum post, in any manner whatsoever, will increase the amount of disorder in the universe. Although no liability is implied herein, the consumer is warned that this process will ultimately lead to the heat death of the universe.
TomServo is offline   Reply With Quote
Old 05-28-2007, 06:53 AM   #5
fabrizio.giudici
Senior Member
 
Join Date: May 2007
Location: Milan, Genoa (Italy)
Posts: 112
Default

Ok, I'll post the code this evening... see you later.
__________________
--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941
fabrizio.giudici is offline   Reply With Quote
Old 05-29-2007, 09:38 PM   #6
fireblade
Junior Member
 
Join Date: May 2007
Posts: 5
Default

what do you use to place your waypoints? UserFacingIcon ? I am am trying to plot waypoints in a seperate thread (to "simulate" real time) but if I play with the camera too much while my waypoints are being plotted they disappear. are you plotting your points in real time or just all at once?
fireblade is offline   Reply With Quote
Old 06-01-2007, 08:40 AM   #7
fabrizio.giudici
Senior Member
 
Join Date: May 2007
Location: Milan, Genoa (Italy)
Posts: 112
Default

Sorry for the delay, I've been busy. I'll try to post the code in the afternoon. See you later.

PS For waypoints, I have both things: plot everything at once and in sequence. Nevertheless I've got some troubles with the latter. See you later in the afternoon.
__________________
--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941
fabrizio.giudici is offline   Reply With Quote
Old 06-01-2007, 01:17 PM   #8
fabrizio.giudici
Senior Member
 
Join Date: May 2007
Location: Milan, Genoa (Italy)
Posts: 112
Default

Here are the changes I suggest. As I anticipated, my problem is that WWIcon describes the image in terms of the "path" property, a string pointing to the image resource name. This is not good if you have a dynamic image which is created in memory or loaded from a different storage than the codebase.

So, first I suggest to add a method to WWIcon:

Code:
public BufferedImage getImage()
The IconRenderer class should be changed as follows:

1. The iconTextures cache should be indexed by Object and not by String

private java.util.HashMap<Object, Texture> iconTextures = new java.util.HashMap<Object, Texture>();

2. Changes in the drawIcon() method:

Code:
        Object key = icon.getImage();
        
        if (key == null)
        {
            key = icon.getPath();
        }
            
        Texture iconTexture = this.iconTextures.get(key);
        if (iconTexture == null)
            iconTexture = this.initializeTexture(dc, icon);
3. Changes in the initializeTexture() method:

Code:
            Texture iconTexture = null;
            BufferedImage image = icon.getImage();
            
            if (image != null)
            {
                iconTexture = TextureIO.newTexture(image, true);  
                this.iconTextures.put(image, iconTexture);
            }
            else
            {
              // ... the current code that loads the icon
            }

            iconTexture.bind();
3. Changes to the isIconValid() method:

Code:
        
if (icon == null || (icon.getPath() == null && icon.getImage() == null))
            return false;
The idea is that if getImage() returns null, the behaviour stays the same as now, that is the icon is loaded from the getPath() resource name; otherwise, the provided image is used.

My implementation can be found here:

https://bluemarine.dev.java.net/sour...=1968&view=log
__________________
--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941
fabrizio.giudici is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:32 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.