[Turn] WorldWind development WorldWindowGLCanvas .setPreferredSize () function can not be found

High temperature value holiday, the column is not intended to turn csdn three-dimensional GIS development, talking about worldwind Java 3D GIS development stuff, very interested. Happens demanding environments already exist, directly playing up. The latest Worldwind and JOGL download back, unzip load, then test and JOGL Java, everything is going well. However, the first demo package when typing, but found no WorldWindowGLCanvas setPreferredSize (achieve) function. The first idea, demo too old, may be the latest version of this function worldwind abandoned, for a new function. However, the latest search, worldwind sample was found still use the function. Google it, on the question of the function can not find more than me, WorldWind community and stackoverflow forum also has a lot of questions, there is no uniform solution in the forum post can be seen that most people are not met. Before then I began to suspect that Linux is not something I uninstalled be ruined, and put the windows system environment tried, same problem. After dinner, grilled opened worldwind api Description, Discovery inherited javax.media.opengl.awt.GLCanvas in question.

Error reason:

JOGL reference, I downloaded the official jogamp.org jogamp-all-platforms.7z come. worldwind bag gluegen-rt.jar and jogl-all.jar with the official jar different. Therefore, the problem lies here, the two worldwind bag JOGL file copy, and references to the latest version without the official Eclipse project external_lib in.
Note:
the Linux 32 bits requires the following four: gluegen-rt.jar, gluegen-RT-Linux-i586.jar-natives, JOGL-all.jar are, JOGL-All-natives-Linux-i586.jar
the Linux 64 bit requires the following four: gluegen-rt.jar, gluegen-RT-Linux-amd64.jar-natives, JOGL-all.jar are, JOGL-All-natives-Linux-amd64.jar
Windows 32 bits requires the following four: gluegen -rt.jar, gluegen-rt-natives- windows-i586.jar, jogl-all.jar, jogl-all-natives-windows-i586.jar
under windows 64-bit environment, you need the following four: gluegen-rt.jar , gluegen-rt-natives-windows -amd64.jar, jogl-all.jar, jogl-all-natives-windows-amd64.jar

Demo operating results:

Code:

package gov.nasa.worldwind.study;

import gov.nasa.worldwind.Model;
import gov.nasa.worldwind.WorldWind;
import gov.nasa.worldwind.avlist.AVKey;
import gov.nasa.worldwind.awt.WorldWindowGLCanvas;
import gov.nasa.worldwind.util.StatusBar;
import gov.nasa.worldwindx.examples.LayerPanel;

import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;



public class  extends JFrame
{
    protected WorldWindowGLCanvas worldWindowGLCanvas; 
    protected StatusBar statusBar;                    
    protected Model modelEarth;
    protected LayerPanel layerPanel; 
    
    public  ()
    {
        
        Dimension canvasSize = new Dimension(850, 650);
        this.worldWindowGLCanvas = new WorldWindowGLCanvas();
        this.worldWindowGLCanvas.setPreferredSize(canvasSize);

        //创建Earth模型,并与画面绑定
        modelEarth = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);
        this.worldWindowGLCanvas.setModel(modelEarth);
        this.add(this.worldWindowGLCanvas, BorderLayout.CENTER);

        //增加状态栏
        this.statusBar = new StatusBar();
        this.add(statusBar, BorderLayout.PAGE_END);
        this.statusBar.setEventSource(worldWindowGLCanvas);

        //显示图层面板
        layerPanel = new LayerPanel(worldWindowGLCanvas);
        this.add(layerPanel, BorderLayout.WEST);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
        this.setSize(canvasSize);
    }
    public static void main(String[] args)
    {
        String title = "系统";
        AppDemo1 app = new AppDemo1();  
        app.setTitle( "WorldWindDemo"+":" + title); 
        app.setVisible(true);
    }
}

Original link: https://www.dazhuanlan.com/2019/10/17/5da7cbfb15f5a/

Guess you like

Origin www.cnblogs.com/rainbow70626/p/12310181.html