wwpanel.java

来自「world wind java sdk 源码」· Java 代码 · 共 104 行

JAVA
104
字号
/*Copyright (C) 2001, 2007 United States Governmentas represented by the Administrator of theNational Aeronautics and Space Administration.All Rights Reserved.*/package gov.nasa.worldwind.applications.sar;import gov.nasa.worldwind.awt.WorldWindowGLCanvas;import gov.nasa.worldwind.*;import gov.nasa.worldwind.layers.Layer;import gov.nasa.worldwind.layers.ScalebarLayer;import gov.nasa.worldwind.layers.TerrainProfileLayer;import gov.nasa.worldwind.util.StatusBar;import gov.nasa.worldwind.avlist.AVKey;import javax.swing.*;import java.awt.*;import java.beans.PropertyChangeListener;import java.beans.PropertyChangeEvent;/** * @author tag * @version $Id: WWPanel.java 8158 2008-12-10 22:28:32Z patrickmurris $ */public class WWPanel extends JPanel{    private WorldWindowGLCanvas wwd;    private StatusBar statusBar;    private final PropertyChangeListener propertyChangeListener = new PropertyChangeListener()    {        @SuppressWarnings({"StringEquality"})        public void propertyChange(PropertyChangeEvent propertyChangeEvent)        {            if (propertyChangeEvent.getPropertyName() == SAR2.ELEVATION_UNIT)                updateElevationUnit(propertyChangeEvent.getNewValue());            if (propertyChangeEvent.getPropertyName() == SAR2.ANGLE_FORMAT)                updateAngleFormat(propertyChangeEvent.getNewValue());        }    };    public WWPanel()    {        super(new BorderLayout());        this.wwd = new WorldWindowGLCanvas();        this.wwd.setPreferredSize(new Dimension(800, 800));        // Create the default model as described in the current worldwind properties.        Model m = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);        this.wwd.setModel(m);        this.wwd.addPropertyChangeListener(this.propertyChangeListener);        this.add(this.wwd, BorderLayout.CENTER);        this.statusBar = new StatusBar();        this.add(statusBar, BorderLayout.PAGE_END);        this.statusBar.setEventSource(wwd);    }    public WorldWindowGLCanvas getWwd()    {        return wwd;    }    public StatusBar getStatusBar()    {        return statusBar;    }    private void updateElevationUnit(Object newValue)    {        for (Layer layer : this.wwd.getModel().getLayers())        {            if (layer instanceof ScalebarLayer)            {                if (SAR2.UNIT_IMPERIAL.equals(newValue))                    ((ScalebarLayer) layer).setUnit(ScalebarLayer.UNIT_IMPERIAL);                else // Default to metric units.                    ((ScalebarLayer) layer).setUnit(ScalebarLayer.UNIT_METRIC);            }            else if (layer instanceof TerrainProfileLayer)            {                if (SAR2.UNIT_IMPERIAL.equals(newValue))                    ((TerrainProfileLayer) layer).setUnit(TerrainProfileLayer.UNIT_IMPERIAL);                else // Default to metric units.                    ((TerrainProfileLayer) layer).setUnit(TerrainProfileLayer.UNIT_METRIC);            }        }        if (SAR2.UNIT_IMPERIAL.equals(newValue))            this.statusBar.setElevationUnit(StatusBar.UNIT_IMPERIAL);        else // Default to metric units.            this.statusBar.setElevationUnit(StatusBar.UNIT_METRIC);    }    private void updateAngleFormat(Object newValue)    {        this.statusBar.setAngleFormat((String)newValue);    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?