Unregistered
07-23-2007, 01:55 PM
Hi all first time user... In any case I used some of the exmaple code to get the WorldWindowGLCanvas to display in a tabbed pane in our application. When the application comes up everything is nicely sized and looks great. When I maximize the the application everything resizes correctly, however when I restore the window, the WorldWindowGLCanvas does not resize, it stays at the maximized size, that in turn makes the other components on the GUI resize incorrectly, and the WorldWindowGLCanvas is bigger than the tabbed pane that houses it. I have tried all sorts of things, but nothing seems to work.
Code below:
WorldWindPanel
extends JPanel
{
public static LayerAction[] layers = new LayerAction[]{
new LayerAction(new BMNGSurfaceLayer(), true),
new LayerAction(new LandsatI3(), true),
new LayerAction(new USGSDigitalOrtho(), false),
new LayerAction(new USGSUrbanAreaOrtho(), true),
new LayerAction(new EarthNASAPlaceNameLayer(), true),
new LayerAction(new CompassLayer(), true),
};
private static final WorldWindowGLCanvas wwd = new WorldWindowGLCanvas();
public WorldWindPanel(LayerAction[] layers)
{
LayerList layerList = new LayerList();
try
{
setLayout(new BorderLayout());
wwd.setPreferredSize(new Dimension(800, 600));
add(wwd, BorderLayout.CENTER);
StatusBar statusBar = new StatusBar();
statusBar.setEventSource(wwd);
add(statusBar, BorderLayout.PAGE_END);
//add(mainPanel, BorderLayout.CENTER);
JPanel westContainer = new JPanel(new BorderLayout());
{
JPanel westPanel = new JPanel(new GridLayout(0, 1, 0, 10));
westPanel.setBorder(BorderFactory.create EmptyBorder(9, 9, 9, 9));
{
JPanel layersPanel = new JPanel(new GridLayout(0, 1, 0, 15));
layersPanel.setBorder(new TitledBorder("Layers"));
for (LayerAction action : layers)
{
JCheckBox jcb = new JCheckBox(action);
jcb.setSelected(action.selected);
layersPanel.add(jcb);
layerList.add(action.layer);
if (action.layer instanceof TiledImageLayer)
{
((TiledImageLayer) action.layer).setShowImageTileOutlines(
false);
}
if (action.layer instanceof LandsatI3)
{
((TiledImageLayer) action.layer).setDrawBoundingVolumes(fal se);
}
if (action.layer instanceof USGSDigitalOrtho)
{
((TiledImageLayer) action.layer).setDrawTileIDs(false);
}
}
westPanel.add(layersPanel);
westContainer.add(westPanel, BorderLayout.NORTH);
}
}
this.add(westContainer, BorderLayout.WEST);
//this.pack();
// Dimension prefSize = this.getPreferredSize();
// prefSize.setSize(prefSize.getWidth(), 1.1 * prefSize.getHeight());
// this.setSize(prefSize);
// Center the app on the user's screen.
// Dimension parentSize;
// Point parentLocation = new Point(0, 0);
// parentSize = Toolkit.getDefaultToolkit().getScreenSiz e();
// int x = parentLocation.x + (parentSize.width - prefSize.width) / 2;
// int y = parentLocation.y + (parentSize.height - prefSize.height) / 2;
// this.setLocation(x, y);
Model m = (Model) WorldWind.createConfigurationComponent(
AVKey.MODEL_CLASS_NAME);
m.setLayers(layerList);
m.setShowWireframeExterior(false);
m.setShowWireframeInterior(false);
m.setShowTessellationBoundingVolumes(fal se);
wwd.setModel(m);
}
catch (Exception e)
{
e.printStackTrace();
}
}
Code below:
WorldWindPanel
extends JPanel
{
public static LayerAction[] layers = new LayerAction[]{
new LayerAction(new BMNGSurfaceLayer(), true),
new LayerAction(new LandsatI3(), true),
new LayerAction(new USGSDigitalOrtho(), false),
new LayerAction(new USGSUrbanAreaOrtho(), true),
new LayerAction(new EarthNASAPlaceNameLayer(), true),
new LayerAction(new CompassLayer(), true),
};
private static final WorldWindowGLCanvas wwd = new WorldWindowGLCanvas();
public WorldWindPanel(LayerAction[] layers)
{
LayerList layerList = new LayerList();
try
{
setLayout(new BorderLayout());
wwd.setPreferredSize(new Dimension(800, 600));
add(wwd, BorderLayout.CENTER);
StatusBar statusBar = new StatusBar();
statusBar.setEventSource(wwd);
add(statusBar, BorderLayout.PAGE_END);
//add(mainPanel, BorderLayout.CENTER);
JPanel westContainer = new JPanel(new BorderLayout());
{
JPanel westPanel = new JPanel(new GridLayout(0, 1, 0, 10));
westPanel.setBorder(BorderFactory.create EmptyBorder(9, 9, 9, 9));
{
JPanel layersPanel = new JPanel(new GridLayout(0, 1, 0, 15));
layersPanel.setBorder(new TitledBorder("Layers"));
for (LayerAction action : layers)
{
JCheckBox jcb = new JCheckBox(action);
jcb.setSelected(action.selected);
layersPanel.add(jcb);
layerList.add(action.layer);
if (action.layer instanceof TiledImageLayer)
{
((TiledImageLayer) action.layer).setShowImageTileOutlines(
false);
}
if (action.layer instanceof LandsatI3)
{
((TiledImageLayer) action.layer).setDrawBoundingVolumes(fal se);
}
if (action.layer instanceof USGSDigitalOrtho)
{
((TiledImageLayer) action.layer).setDrawTileIDs(false);
}
}
westPanel.add(layersPanel);
westContainer.add(westPanel, BorderLayout.NORTH);
}
}
this.add(westContainer, BorderLayout.WEST);
//this.pack();
// Dimension prefSize = this.getPreferredSize();
// prefSize.setSize(prefSize.getWidth(), 1.1 * prefSize.getHeight());
// this.setSize(prefSize);
// Center the app on the user's screen.
// Dimension parentSize;
// Point parentLocation = new Point(0, 0);
// parentSize = Toolkit.getDefaultToolkit().getScreenSiz e();
// int x = parentLocation.x + (parentSize.width - prefSize.width) / 2;
// int y = parentLocation.y + (parentSize.height - prefSize.height) / 2;
// this.setLocation(x, y);
Model m = (Model) WorldWind.createConfigurationComponent(
AVKey.MODEL_CLASS_NAME);
m.setLayers(layerList);
m.setShowWireframeExterior(false);
m.setShowWireframeInterior(false);
m.setShowTessellationBoundingVolumes(fal se);
wwd.setModel(m);
}
catch (Exception e)
{
e.printStackTrace();
}
}