⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shapes.java

📁 world wind java sdk 源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            TitledBorder b = BorderFactory.createTitledBorder(title);//            b.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));            return new CompoundBorder(b, BorderFactory.createEmptyBorder(10, 10, 10, 10));        }        private JPanel makeAttributesPanel()        {            JPanel panel = new JPanel(new GridLayout(1, 2, 8, 8));            panel.add(this.makePathAttributesPanel());            panel.add(this.makeInteriorAttributesPanel());            return panel;        }        private JPanel makePathAttributesPanel()        {            JPanel outerPanel = new JPanel(new BorderLayout(6, 6));            outerPanel.setBorder(this.createTitleBorder("Path Attributes"));            GridLayout nameLayout = new GridLayout(0, 1, 6, 6);            JPanel namePanel = new JPanel(nameLayout);            GridLayout valueLayout = new GridLayout(0, 1, 6, 6);            JPanel valuePanel = new JPanel(valueLayout);            namePanel.add(new JLabel("Follow Terrain"));            JCheckBox ckb = new JCheckBox();            ckb.setSelected(currentFollowTerrain);            ckb.addActionListener(new ActionListener()            {                public void actionPerformed(ActionEvent actionEvent)                {                    currentFollowTerrain = ((JCheckBox) actionEvent.getSource()).isSelected();                    update();                }            });            valuePanel.add(ckb);            JLabel label;            namePanel.add(label = new JLabel("Conformance"));            int[] values = new int[] {1, 2, 4, 8, 10, 15, 20, 30, 40, 50};            String[] strings = new String[values.length];            for (int i = 0; i < values.length; i++)                strings[i] = Integer.toString(values[i]) + " pixels";            JSpinner sp = new JSpinner(                new SpinnerListModel(strings));            onTerrainOnlyItems.add(label);            onTerrainOnlyItems.add(sp);            sp.addChangeListener(new ChangeListener()            {                public void stateChanged(ChangeEvent changeEvent)                {                    String v = (String) ((JSpinner) changeEvent.getSource()).getValue();                    currentTerrainConformance = Integer.parseInt(v.substring(0, v.indexOf(" ")));                    update();                }            });            sp.setValue(Integer.toString(currentTerrainConformance) + " pixels");            valuePanel.add(sp);            namePanel.add(label = new JLabel("Subsegments"));            sp = new JSpinner(new SpinnerListModel(new String[] {"1", "2", "5", "10", "20", "40", "50"}));            offTerrainOnlyItems.add(label);            offTerrainOnlyItems.add(sp);            sp.addChangeListener(new ChangeListener()            {                public void stateChanged(ChangeEvent changeEvent)                {                    String v = (String) ((JSpinner) changeEvent.getSource()).getValue();                    currentNumSubsegments = Integer.parseInt(v);                    update();                }            });            sp.setValue(Integer.toString(currentNumSubsegments));            valuePanel.add(sp);            namePanel.add(new JLabel("Type"));            final JComboBox cb = new JComboBox(new String[] {"Great Circle", "Linear", "Rhumb Line"});            cb.addActionListener(new ActionListener()            {                public void actionPerformed(ActionEvent actionEvent)                {                    currentPathType = (String) cb.getSelectedItem();                    update();                }            });            cb.setSelectedItem("Great Circle");            valuePanel.add(cb);            namePanel.add(new JLabel("Style"));            final JComboBox cb1 = new JComboBox(new String[] {"None", "Solid", "Dash"});            cb1.addActionListener(new ActionListener()            {                public void actionPerformed(ActionEvent actionEvent)                {                    currentPathStyle = (String) cb1.getSelectedItem();                    update();                }            });            cb1.setSelectedItem("Solid");            valuePanel.add(cb1);            namePanel.add(new JLabel("Width"));            sp = new JSpinner(                new SpinnerListModel(new String[] {"1.0", "1.25", "1.5", "2.0", "3.0", "4.0", "5.0", "10.0"}));            sp.addChangeListener(new ChangeListener()            {                public void stateChanged(ChangeEvent changeEvent)                {                    currentPathWidth = Float.parseFloat((String) ((JSpinner) changeEvent.getSource()).getValue());                    update();                }            });            sp.setValue(Float.toString(currentPathWidth));            valuePanel.add(sp);            namePanel.add(new JLabel("Color"));            JComboBox cb2 = new JComboBox(new String[] {"Red", "Green", "Blue", "Yellow"});            cb2.setSelectedItem(currentPathColor);            cb2.addActionListener(new ActionListener()            {                public void actionPerformed(ActionEvent actionEvent)                {                    currentPathColor = (String) ((JComboBox) actionEvent.getSource()).getSelectedItem();                    update();                }            });            valuePanel.add(cb2);            namePanel.add(new JLabel("Opacity"));            sp = new JSpinner(new SpinnerNumberModel(this.currentPathOpacity, 0, 10, 1));            sp.addChangeListener(new ChangeListener()            {                public void stateChanged(ChangeEvent changeEvent)                {                    currentPathOpacity = (Integer) ((JSpinner) changeEvent.getSource()).getValue();                    update();                }            });            valuePanel.add(sp);            namePanel.add(new JLabel("Offset"));            sp = new JSpinner(                new SpinnerListModel(new String[] {"0", "10", "100", "1000", "10000", "100000", "1000000"}));            sp.addChangeListener(new ChangeListener()            {                public void stateChanged(ChangeEvent changeEvent)                {                    currentOffset = Float.parseFloat((String) ((JSpinner) changeEvent.getSource()).getValue());                    update();                }            });            sp.setValue("0");            valuePanel.add(sp);            outerPanel.add(namePanel, BorderLayout.WEST);            outerPanel.add(valuePanel, BorderLayout.CENTER);            return outerPanel;        }        private JPanel makeInteriorAttributesPanel()        {            JPanel outerPanel = new JPanel(new BorderLayout(6, 6));            outerPanel.setBorder(this.createTitleBorder("Surface Attributes"));            GridLayout nameLayout = new GridLayout(0, 1, 6, 6);            JPanel namePanel = new JPanel(nameLayout);            GridLayout valueLayout = new GridLayout(0, 1, 6, 6);            JPanel valuePanel = new JPanel(valueLayout);            namePanel.add(new JLabel("Style"));            final JComboBox cb1 = new JComboBox(new String[] {"None", "Solid"});            cb1.addActionListener(new ActionListener()            {                public void actionPerformed(ActionEvent actionEvent)                {                    currentInteriorStyle = (String) cb1.getSelectedItem();                    update();                }            });            cb1.setSelectedItem("Solid");            valuePanel.add(cb1);            namePanel.add(new JLabel("Opacity"));            JSpinner sp = new JSpinner(new SpinnerNumberModel(this.currentBorderOpacity, 0, 10, 1));            sp.addChangeListener(new ChangeListener()            {                public void stateChanged(ChangeEvent changeEvent)                {                    currentInteriorOpacity = (Integer) ((JSpinner) changeEvent.getSource()).getValue();                    update();                }            });            valuePanel.add(sp);            namePanel.add(new JLabel("Color"));            final JComboBox cb2 = new JComboBox(new String[] {"Red", "Green", "Blue", "Yellow"});            cb2.setSelectedItem(currentInteriorColor);            cb2.addActionListener(new ActionListener()            {                public void actionPerformed(ActionEvent actionEvent)                {                    currentInteriorColor = (String) ((JComboBox) actionEvent.getSource()).getSelectedItem();                    update();                }            });            valuePanel.add(cb2);            namePanel.add(new JLabel("Border"));            final JComboBox cb5 = new JComboBox(new String[] {"None", "Solid"});            cb5.addActionListener(new ActionListener()            {                public void actionPerformed(ActionEvent actionEvent)                {                    currentBorderStyle = (String) cb5.getSelectedItem();                    update();                }            });            cb5.setSelectedItem("Solid");            valuePanel.add(cb5);            namePanel.add(new JLabel("Border Width"));            sp = new JSpinner(                new SpinnerListModel(new String[] {"1.0", "1.25", "1.5", "1.75", "2.0", "3.0", "4.0", "5.0"}));            sp.addChangeListener(new ChangeListener()            {                public void stateChanged(ChangeEvent changeEvent)                {                    currentBorderWidth = Float.parseFloat((String) ((JSpinner) changeEvent.getSource()).getValue());                    update();                }            });            sp.setValue(Float.toString(currentBorderWidth));            valuePanel.add(sp);            namePanel.add(new JLabel("Border Color"));            JComboBox cb4 = new JComboBox(new String[] {"Red", "Green", "Blue", "Yellow"});            cb4.setSelectedItem(currentBorderColor);            cb4.addActionListener(new ActionListener()            {                public void actionPerformed(ActionEvent actionEvent)                {                    currentBorderColor = (String) ((JComboBox) actionEvent.getSource()).getSelectedItem();                    update();                }            });            valuePanel.add(cb4);            namePanel.add(new JLabel("Border Opacity"));            sp = new JSpinner(new SpinnerNumberModel(this.currentBorderOpacity, 0, 10, 1));            sp.addChangeListener(new ChangeListener()            {                public void stateChanged(ChangeEvent changeEvent)                {                    currentBorderOpacity = (Integer) ((JSpinner) changeEvent.getSource()).getValue();                    update();                }            });            valuePanel.add(sp);            outerPanel.add(namePanel, BorderLayout.WEST);            outerPanel.add(valuePanel, BorderLayout.CENTER);            return outerPanel;        }        private void setupSelection()        {            this.wwjPanel.getWwd().addSelectListener(new SelectListener()            {                private WWIcon lastToolTipIcon = null;                private BasicDragger dragger = new BasicDragger(AppFrame.this.wwjPanel.getWwd());                public void selected(SelectEvent event)                {                    // Have hover selections show a picked icon's tool tip.                    if (event.getEventAction().equals(SelectEvent.HOVER))                    {                        // If a tool tip is already showing, undisplay it.                        if (lastToolTipIcon != null)                        {                            lastToolTipIcon.setShowToolTip(false);                            this.lastToolTipIcon = null;                            AppFrame.this.wwjPanel.getWwd().repaint();                        }                        // If there's a selection, we're not dragging, and the selection is an icon, show tool tip.                        if (event.hasObjects() && !this.dragger.isDragging())                        {                            if (event.getTopObject() instanceof WWIcon)                            {                                this.lastToolTipIcon = (WWIcon) event.getTopObject();                                lastToolTipIcon.setShowToolTip(true);                                AppFrame.this.wwjPanel.getWwd().repaint();                            }                        }                    }                    // Have rollover events highlight the rolled-over object.                    else if (event.getEventAction().equals(SelectEvent.ROLLOVER) && !this.dragger.isDragging())                    {//                        AppFrame.this.highlight(event.getTopObject());                    }                    // Have drag events drag the selected object.                    else if (event.getEventAction().equals(SelectEvent.DRAG_END)                        || event.getEventAction().equals(SelectEvent.DRAG))                    {                        // Delegate dragging computations to a dragger.                        this.dragger.selected(event);                        // We missed any roll-over events while dragging, so highlight any under the cursor now,                        // or de-highlight the dragged shape if it's no longer under the cursor.                        if (event.getEventAction().equals(SelectEvent.DRAG_END))                        {                            PickedObjectList pol = wwjPanel.getWwd().getObjectsAtCurrentPosition();                            if (pol != null)                            {//                                AppFrame.this.highlight(pol.getTopObject());                                AppFrame.this.wwjPanel.getWwd().redraw();                            }                        }                    }                }            });        }    }    private static final String APP_NAME = "World Wind Shapes";    static    {        if (Configuration.isMacOS())        {            System.setProperty("apple.laf.useScreenMenuBar", "true");            System.setProperty("com.apple.mrj.application.apple.menu.about.name", APP_NAME);            System.setProperty("com.apple.mrj.application.growbox.intrudes", "false");        }    }    public static void main(String[] args)    {        try        {            AppFrame frame = new AppFrame();            frame.setTitle(APP_NAME);            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);            frame.setVisible(true);        }        catch (Exception e)        {            e.printStackTrace();        }    }}

⌨️ 快捷键说明

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