![]() |
|
|||||||
| Development Help Help for building applications or diagnosing problems with WWJ |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Mar 2008
Posts: 91
![]() |
I have an small application that I want to use to swap between flat and round globes. I start off with the default round earth, and I can move the globe with the mouse as usual. When I click a key, it swaps to the flat globe, but my mouse actions are gone. I am using bits and pieces from the FlatWorld example, so I have been through that example exhaustively to figure this out.
Are there any ideas on why the orbit behavior being stopped/removed when swapping flat/round globes ? BTW: I am utilizing the same enableFlatGlobe(boolean) in the FlatWorldPanel.java file, so the concept of swapping is already solved. Thank you for any help. Zak Last edited by patmurris; 04-23-2009 at 09:55 PM. Reason: Solved |
|
|
|
|
|
#2 |
|
Member
Join Date: Mar 2008
Posts: 91
![]() |
I comment out the setView(..) lines in enableFlatGlobe(bool) method, and the globes still move, albeit not correctly since I am not swapping the orbit behavior based on the globe type. So, from what I can tell, it is an issue with setView(..) and I don't know how I can figure it out...
Any ideas on what I can try next ? Thanks. Here is the code I am trying: (If you comment out the setView methods, you will see the MouseMovements will still work) Code:
public class Test {
private static boolean isRound = true;
private static WorldWindowGLCanvas canvas;
private static Globe roundGlobe;
private static FlatGlobe flatGlobe;
public static void main(String[] args) throws GLException, IOException{
try{
Model displayModel = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);
canvas = new WorldWindowGLCanvas();
canvas.setModel(displayModel);
Globe g = displayModel.getGlobe();
if (g instanceof FlatGlobe)
{
flatGlobe = (FlatGlobe)g;
roundGlobe = new Earth();
}
else if(g instanceof Earth)
{
flatGlobe = new EarthFlat();
roundGlobe = canvas.getModel().getGlobe();
}
JFrame frame = new JFrame();
frame.getContentPane().add(canvas);
frame.setVisible(true);
canvas.addKeyListener(new KeyListener(){
public void keyPressed(KeyEvent arg0) {
}
public void keyReleased(KeyEvent arg0) {
}
public void keyTyped(KeyEvent arg0) {
isRound = !isRound;
enableFlatGlobe(isRound);
}
});
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}catch(Exception e){
e.printStackTrace();
}
}
private static String getProjection()
{
return FlatGlobe.PROJECTION_LAT_LON;
}
public static boolean isFlatGlobe()
{
return canvas.getModel().getGlobe() instanceof FlatGlobe;
}
public static void enableFlatGlobe(boolean flat)
{
if(isFlatGlobe() == flat)
return;
if(!flat)
{
// Switch to round globe
canvas.getModel().setGlobe(roundGlobe) ;
// Switch to orbit view and update with current position
FlatOrbitView flatOrbitView = (FlatOrbitView)canvas.getView();
BasicOrbitView orbitView = new BasicOrbitView();
orbitView.setCenterPosition(flatOrbitView.getCenterPosition());
orbitView.setZoom(flatOrbitView.getZoom( ));
orbitView.setHeading(flatOrbitView.getHeading());
orbitView.setPitch(flatOrbitView.getPitch());
canvas.setView(orbitView);
// Change sky layer
LayerList layers = canvas.getModel().getLayers();
for(int i = 0; i < layers.size(); i++)
{
if(layers.get(i) instanceof SkyColorLayer)
layers.set(i, new SkyGradientLayer());
}
}
else
{
// Switch to flat globe
canvas.getModel().setGlobe(flatGlobe);
flatGlobe.setProjection(getProjection());
// Switch to flat view and update with current position
BasicOrbitView orbitView = (BasicOrbitView)canvas.getView();
FlatOrbitView flatOrbitView = new FlatOrbitView();
flatOrbitView.setCenterPosition(orbitView.getCenterPosition());
flatOrbitView.setZoom(orbitView.getZoom( ));
flatOrbitView.setHeading(orbitView.getHeading());
flatOrbitView.setPitch(orbitView.getPitch());
canvas.setView(flatOrbitView);
// Change sky layer
LayerList layers = canvas.getModel().getLayers();
for(int i = 0; i < layers.size(); i++)
{
if(layers.get(i) instanceof SkyGradientLayer)
layers.set(i, new SkyColorLayer());
}
}
canvas.redraw();
}
public static JFrame createContainer(final GlobeCanvas canvas){
JFrame frame = new JFrame();
frame.getContentPane().add(canvas);
frame.setVisible(true);
canvas.addKeyListener(new KeyListener(){
public void keyPressed(KeyEvent arg0) {
}
public void keyReleased(KeyEvent arg0) {
}
public void keyTyped(KeyEvent arg0) {
isRound = !isRound;
canvas.enableFlatGlobe(isRound);
}
});
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
return frame;
}
}
|
|
|
|
|
|
#3 |
|
WWJ Consultant
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
![]() |
You example code works as expected for me, i see no issues right away...
|
|
|
|
|
|
#4 |
|
Member
Join Date: Mar 2008
Posts: 91
![]() |
I am running it on a Macbook Pro, so I wonder if that is the problem....I will try it out on a PC and post the results.
|
|
|
|
|
|
#5 |
|
Member
Join Date: Mar 2008
Posts: 91
![]() |
Strange thing is that I can run the FlatWorld example on my Macbook Pro and it works beautifully, but executing that code doesn't work. Personally, I don't see any major differences between the two.
|
|
|
|
|
|
#6 |
|
Member
Join Date: Mar 2008
Posts: 91
![]() |
This was fixed by using the latest version of WW 0.6.
|
|
|
|
|
|
#7 |
|
WWJ Consultant
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
![]() |
I thought you where already using 0.6... Yes switching from flat to round was a problem before.
|
|
|
|
|
|
#8 |
|
Member
Join Date: Mar 2008
Posts: 91
![]() |
Well, I thought I was too, but I dropped a fresh version of 0.6 in my build path and it worked instantly.
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Virtual Globes Special Issue - Computers & Geosciences | TomServo | Announcements & News | 3 | 02-07-2009 06:31 AM |