terrainprofilepanel.java

来自「world wind java sdk 源码」· Java 代码 · 共 660 行 · 第 1/2 页

JAVA
660
字号
        		});        		this.panel3.add(this.showEyeCheckBox);        		//---- zeroBaseCheckBox ----        		this.zeroBaseCheckBox.setText("MSL Base");        		this.zeroBaseCheckBox.setToolTipText("Show mean sea level in profile graph");        		this.zeroBaseCheckBox.setAlignmentX(0.5F);        		this.zeroBaseCheckBox.setHorizontalAlignment(SwingConstants.TRAILING);        		this.zeroBaseCheckBox.setSelected(true);        		this.zeroBaseCheckBox.addItemListener(new ItemListener() {        			public void itemStateChanged(ItemEvent e) {        				zeroBaseCheckBoxItemStateChanged(e);        			}        		});        		this.panel3.add(this.zeroBaseCheckBox);        	}        	this.panel1.add(this.panel3, BorderLayout.CENTER);            //======== panel8 ========            {                this.panel8.setLayout(new GridLayout(2, 2, 20, 10));                String[] profileSizeValues = new String[] {"x1", "x2", "x3", "x4", "x5", "x7", "x10"};                //======== panel4 ========                {                    this.panel4.setBorder(BorderFactory.createEmptyBorder());                    this.panel4.setLayout(new BorderLayout(5, 0));                    //---- profileWidthSpinner ----                    this.profileWidthSpinner.setToolTipText("Profile width");                    this.profileWidthSpinner.setBorder(new EmptyBorder(5, 5, 5, 5));                    this.profileWidthSpinner.setAlignmentX(1.5F);                    this.profileWidthSpinner.setModel(new SpinnerListModel(profileSizeValues));                    this.profileWidthSpinner.setValue("x1");                    this.profileWidthSpinner.addChangeListener(new ChangeListener() {                        public void stateChanged(ChangeEvent e) {                            profileWidthSpinnerStateChanged(e);                        }                    });                    this.panel4.add(this.profileWidthSpinner, BorderLayout.CENTER);                    //---- profileWidthLabel ----                    this.profileWidthLabel.setText("Profile Width:");                    this.panel4.add(this.profileWidthLabel, BorderLayout.WEST);                }                this.panel8.add(this.panel4);                //======== panel4b ========                {                    this.panel4b.setBorder(BorderFactory.createEmptyBorder());                    this.panel4b.setLayout(new BorderLayout(5, 0));                    //---- profileLengthSpinner ----                    this.profileLengthSpinner.setToolTipText("Profile Length along track");                    this.profileLengthSpinner.setBorder(new EmptyBorder(5, 5, 5, 5));                    this.profileLengthSpinner.setAlignmentX(1.5F);                    this.profileLengthSpinner.setModel(new SpinnerListModel(profileSizeValues));                    this.profileLengthSpinner.setValue("x1");                    this.profileLengthSpinner.addChangeListener(new ChangeListener() {                        public void stateChanged(ChangeEvent e) {                            profileLengthSpinnerStateChanged(e);                        }                    });                    this.panel4b.add(this.profileLengthSpinner, BorderLayout.CENTER);                    //---- profileLengthLabel ----                    this.profileLengthLabel.setText("Profile Length:");                    this.panel4b.add(this.profileLengthLabel, BorderLayout.WEST);                }                this.panel8.add(this.panel4b);                //======== panel4c ========                {                    this.panel4c.setBorder(BorderFactory.createEmptyBorder());                    this.panel4c.setLayout(new BorderLayout(5, 0));                    //---- profileSameSize ----                    this.profilesSameSize.setText("Same size");                    this.profilesSameSize.addChangeListener(new ChangeListener() {                        public void stateChanged(ChangeEvent e) {                            profilesSameSizeStateChanged(e);                        }                    });                    this.panel4c.add(this.profilesSameSize, BorderLayout.CENTER);                }                this.panel8.add(this.panel4c);                //======== panel4d ========                {                    this.panel4d.setBorder(BorderFactory.createEmptyBorder());                    this.panel4d.setLayout(new BorderLayout(5, 0));                    //---- profileFollowPath ----                    this.profileFollowPath.setText("Whole track length");                    this.profileFollowPath.addChangeListener(new ChangeListener() {                        public void stateChanged(ChangeEvent e) {                            profileFollowPathStateChanged(e);                        }                    });                    this.panel4d.add(this.profileFollowPath, BorderLayout.CENTER);                }                this.panel8.add(this.panel4d);            }            this.panel1.add(this.panel8, BorderLayout.SOUTH);        }        add(this.panel1, BorderLayout.CENTER);    }    private JPanel panel1;    private JPanel panel2;    private JPanel panel6;    private JPanel panel5;    private JComboBox sizeComboBox;    private JPanel panel7;    private JComboBox followComboBox;    private JPanel panel3;    private JCheckBox proportionalCheckBox;    private JCheckBox showEyeCheckBox;    private JCheckBox zeroBaseCheckBox;    private JPanel panel4;    private JSpinner profileWidthSpinner;    private JLabel profileWidthLabel;    private JPanel panel8;    private JPanel panel4b;    private JSpinner profileLengthSpinner;    private JLabel profileLengthLabel;    private JPanel panel4c;    private JCheckBox profilesSameSize;    private JPanel panel4d;    private JCheckBox profileFollowPath;    private static class TerrainProfileController    {        private static final HashMap<String, Dimension> sizes = new HashMap<String, Dimension>();        public static String[] getSizeKeys()        {            return sizes.keySet().toArray(new String[1]);        }        static        {            sizes.put(GRAPH_SIZE_SMALL_TEXT, new Dimension(250, 100));            sizes.put(GRAPH_SIZE_MEDIUM_TEXT, new Dimension(450, 140));            sizes.put(GRAPH_SIZE_LARGE_TEXT, new Dimension(655, 240));        }        private static final HashMap<String, String> follows = new HashMap<String, String>();        public static String[] getFollowKeys()        {            return follows.keySet().toArray(new String[1]);        }        static        {            follows.put(FOLLOW_VIEW_TEXT, TerrainProfileLayer.FOLLOW_VIEW);            follows.put(FOLLOW_CURSOR_TEXT, TerrainProfileLayer.FOLLOW_CURSOR);            //follows.put(FOLLOW_EYE_TEXT, TerrainProfileLayer.FOLLOW_EYE);            follows.put(FOLLOW_OBJECT_TEXT, TerrainProfileLayer.FOLLOW_OBJECT);            follows.put(FOLLOW_NONE_TEXT, TerrainProfileLayer.FOLLOW_NONE);        }        private WorldWindow wwd;        private TerrainProfileLayer tpl;  // Perpendicular to track        private TerrainProfileLayer tpl2; // Parallel to the track        private boolean wholeTrackLength = false;        public TerrainProfileController()        {            this.tpl = new TerrainProfileLayer();            this.tpl.setZeroBased(true);            this.tpl2 = new TerrainProfileLayer();            this.tpl2.setZeroBased(true);            this.tpl2.setPosition(AVKey.SOUTHEAST);        }        public WorldWindow getWwd()        {            return wwd;        }        public void setWwd(WorldWindow wwd)        {            this.wwd = wwd;            if (this.wwd != null)            {                ApplicationTemplate.insertBeforeCompass(wwd, tpl);                this.tpl.setEventSource(wwd);                ApplicationTemplate.insertBeforeCompass(wwd, tpl2);                this.tpl2.setEventSource(wwd);                this.tpl2.setPathType(Polyline.RHUMB_LINE);                // Move scalebar to north west                for (Layer layer : wwd.getModel().getLayers())                    if (layer instanceof ScalebarLayer)                        ((ScalebarLayer)layer).setPosition(AVKey.NORTHWEST);                update();            }        }        private void update()        {            if (this.wwd != null)                this.wwd.redraw();        }        public void setShowEyePosition(boolean showEye)        {            this.tpl.setShowEyePosition(showEye);            this.tpl2.setShowEyePosition(showEye);            this.update();        }        public boolean getShowEyePosition()        {            return this.tpl.getShowEyePosition();        }        public void setZeroBased(boolean keepProportions)        {            this.tpl.setZeroBased(keepProportions);            this.tpl2.setZeroBased(keepProportions);            this.update();        }        public boolean getShowZeroBased()        {            return this.tpl.getZeroBased();        }        public void setKeepProportions(boolean keepProportions)        {            this.tpl.setKeepProportions(keepProportions);            this.tpl2.setKeepProportions(keepProportions);            this.update();        }        public boolean getKeepProportions()        {            return this.tpl.getKeepProportions();        }        public void setProfileSize(String size)        {            Dimension dim = sizes.get(size);            if (dim != null)            {                this.tpl.setSize(dim);                this.tpl2.setSize(dim);                this.update();            }        }        public Dimension getProfileSize()        {            return this.tpl.getSize();        }        public void setFollow(String followName)        {            String follow = follows.get(followName);            if (follow != null)            {                this.tpl.setFollow(follow);                if (follow.equals(TerrainProfileLayer.FOLLOW_OBJECT) || follow.equals(TerrainProfileLayer.FOLLOW_EYE))                    this.tpl2.setFollow(                        this.wholeTrackLength ? TerrainProfileLayer.FOLLOW_PATH : TerrainProfileLayer.FOLLOW_OBJECT);                else                    this.tpl2.setFollow(TerrainProfileLayer.FOLLOW_NONE);                this.update();            }        }        public String getFollow()        {            return this.tpl.getFollow();        }        public void setWholeTrackLength(boolean state)        {            if (this.wholeTrackLength != state)            {                this.wholeTrackLength = state;                if (!this.tpl2.getFollow().equals(TerrainProfileLayer.FOLLOW_NONE))                    this.tpl2.setFollow(                        this.wholeTrackLength ? TerrainProfileLayer.FOLLOW_PATH : TerrainProfileLayer.FOLLOW_OBJECT);                this.update();            }        }        public void setProfileWidthFactor(double factor)        {            this.tpl.setProfileLengthFactor(factor);  // perpendicular profile            this.update();        }        public void setProfileLengthFactor(double factor)        {            this.tpl2.setProfileLengthFactor(factor);   // along track rofile            this.update();        }        public double getProfileWidthFactor()        {            return this.tpl.getProfileLenghtFactor();        }        public double getProfileLengthFactor()        {            return this.tpl2.getProfileLenghtFactor();        }        public void updatePosition(Position position, Angle heading)        {            this.tpl.setObjectPosition(position);            this.tpl.setObjectHeading(heading);            this.tpl2.setObjectPosition(position);            this.tpl2.setObjectHeading(heading.addDegrees(-90));            this.update();        }        public void updatePath(ArrayList<? extends LatLon> positions)        {            this.tpl2.setPathPositions(positions);            this.update();        }    }}

⌨️ 快捷键说明

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