Solved

Use Java3D AND Openmap

Posted on 2004-09-02
16
348 Views
Last Modified: 2008-01-09
Hi all,

I hope I am in the right topic!
I would like to view a Java3D scene from an openmap map,
so I read on the openmap web site that an OM3DViewerLauncher is needed: it is a
com.bbn.openmap.gui.Tool and said to be a button, however, when I add it to the ToolPanel which extends the swing class JToolBar, I had a ClassCastE0.xception due to the ToolPanel method  areComponentsVisible, in fact OM3DViewerLauncher is not a Component.

Does any one know about this problem?
Can you please explain me many thanks!

emmok
0
Comment
Question by:emmok
16 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 11961142
What type is it? For some reason you are tyring to cast it to a parent object that it is not.
0
 

Author Comment

by:emmok
ID: 11961194
Hi Girionis!

OM3DViewerLauncher class extends com.bbn.openmap.MapHandlerChild
and implements the Tool interface and ToolPanel extends javax.swing.JToolBar
implements java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, MapPanelChild, PropertyConsumer, java.awt.event.ComponentListener and we can add items using
add(Tool item, int index). So we can add a OM3DViewerLauncher  to a ToolPanel.
The problem is that in ToolPanel source code there is a method which casts items into Components, and I think the Exception comes from here.

public boolean areComponentsVisible() {
     Enumeration enum = items.elements();
     while (enum.hasMoreElements()) {
         Component comp = (Component)enum.nextElement();
         if (comp != filler && comp.isVisible()) {
             return true;
         }
     }
     return false;
 }

So what is the right solution for using an OM3DViewerLauncher...
Thanks very much!
0
 
LVL 35

Expert Comment

by:girionis
ID: 11961245
>  and I think the Exception comes from here.

Can you make *sure* that the exception is there? What line does it indicate?

ALso what is the output of this:

System.out.println(enum.nextElement().getClass());
0
 

Author Comment

by:emmok
ID: 11961349
Yes I'm sure the pb comes from what I explained,
I have this error :
java.lang.ClassCastException
      at com.bbn.openmap.gui.ToolPanel.areComponentsVisible(ToolPanel.java:581)
      at com.bbn.openmap.gui.ToolPanel.setVisibility(ToolPanel.java:575)
      at com.bbn.openmap.gui.ToolPanel.add(ToolPanel.java:216)
      at com.bbn.openmap.gui.ToolPanel.add(ToolPanel.java:239)
      at com.bbn.openmap.gui.ToolPanel.add(ToolPanel.java:226)

Just remind you that the ToolPanel is not "accessible" it is a class of the
openmap API and I can't change it, I can only use it. The source code is available on the openmap web site : http://openmap.bbn.com.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11961434
You won't change it, you just need to cast it to appropriate type. What type is the object you receive from the: enum.nextElement(); ?
0
 

Author Comment

by:emmok
ID: 11961469
What I wanted to say is that I work on a customized application which uses
libraries and ToolPanel is normaly included in the openmap.jar!
How can I manipulate it???!!!!! I could just see the source code!?
 
0
 
LVL 35

Expert Comment

by:girionis
ID: 11961478
Is it an open source? If yes then you should have the code already? Otherwise you can just decompile the jar files and get the source code.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:emmok
ID: 11961497
openmap is an open source, and since I have the code I could see the
internal method of the API class ToolPanel. But I am on Eclipse
and the project uses the jar file as a library!?  
0
 
LVL 35

Expert Comment

by:girionis
ID: 11961532
You might as well add all openmap source files in your project.
0
 
LVL 12

Expert Comment

by:Giant2
ID: 11962453
If you have the class files you can decompile them (you can use JAD for example to do this).
Normally an Opensource project is "open source", so you can download the source code from the site.
If you want to interact with source code in Eclipse, when you add the jar, specify where could be found the source code.

Hope this help you.
Bye, Giant.
0
 

Author Comment

by:emmok
ID: 11987758
Hi Giant2, Hi girionis,

Thanks for your suggestions, I have the source code (since it is an open source) and the solution is use the getFace() method of the OM3DViewerLauncher class which returs a Container...

Thanks very much,
emmok
0
 
LVL 35

Expert Comment

by:girionis
ID: 11989360
Hello emmok, if you feel you have been helped please accept an answer of split the points. Otherwise ask a question to community support (http://www.experts-exchange.com/Community_Support/) for zero points to PAQ this question and refund the points back to you.
0
 

Author Comment

by:emmok
ID: 11989591
Hi girionis,

I've just asked a question to community support,

Thanks
Bye!


 
0
 
LVL 35

Expert Comment

by:girionis
ID: 11990365
Fine by me.
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 12029973
PAQd, 150 points refunded.

GhostMod
Community Support Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
eclipse shortcuts 9 45
replace a word with other 1 40
Arrays.asList  VS  ArrayList 4 43
egit plugin on eclipse 8 27
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now