WorldWind Java on a Netbeans Platform TopComponent

2019-05-25 01:37发布

I'm trying to add a layer to WorldWind Java (version 1.2) situated on a Netbeans Platform TopComponent (using netbeans 7.0). The TopComponent is in Editor mode, and for WWJ I use WorldWindowGLCanvas which is the single swing component on the TopComponent and it is placed with BorderLayout.CENTER. If I add the layers using the constructor all works well, I can see the layers fine. If I add the layer using swing controls (eg a button) the layer gets added to the layer list but it is not rendered. This happens for both WMS and Renderable layer. Same process on a pure swing application works fine which leads me to believe that the rendering process in WWJ is somehow conflicting with the TopComponent painting. Any help with be greatly appreciated.

1条回答
啃猪蹄的小仙女
2楼-- · 2019-05-25 02:03

I've set up a demo using NetBeans Platform (7.0.1) with gov.nasa.worldwind.awt.WorldWindowGLCanvas and gov.nasa.worldwindx.examples.LayerPanel

Initialization Code:

private void initComponents() {
    canvas = new WorldWindowGLCanvas();

    Model model = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);
    canvas.setModel(model);

    layerPanel = new LayerPanel(canvas);

    setLayout(new BorderLayout());
    add(canvas, BorderLayout.CENTER);
    add(layerPanel, BorderLayout.WEST);
}
private WorldWindowGLCanvas canvas;
private LayerPanel layerPanel;

This works the same as it does running the sample as a stand alone so I would say that the problem does not lie in the NetBeans Platform. Without any code it's hard to say what's going wrong.

Note that the gov.nasa.worldwind.awt.WorldWindowGLCanvas is not a Swing component but a heavy weight component. This is irrelevant to your question but I couldn't help but point it out. The Swing component is gov.nasa.worldwind.awt.WorldWindowGLJPanel

Edit: I realize my answer is not very helpful, so to remedy that I would add a suggestion. You could try to invalidate the TopComponent and call repaint whenever you need it to render the new layer.

查看更多
登录 后发表回答