Пример #1
0
    public AppFrame() {
      JButton button = new JButton("Open VPF Database");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              showOpenDialog();
            }
          });

      Box box = Box.createHorizontalBox();
      box.setBorder(BorderFactory.createEmptyBorder(30, 30, 30, 30)); // top, left, bottom, right
      box.add(button);

      this.getLayerPanel().add(box, BorderLayout.SOUTH);
    }
    private void makeComponents() {
      this.getWwd().setPreferredSize(new Dimension(1024, 768));

      JPanel panel = new JPanel(new BorderLayout());
      {
        panel.setBorder(new EmptyBorder(10, 0, 10, 0));

        JPanel controlPanel = new JPanel(new BorderLayout(0, 10));
        controlPanel.setBorder(new EmptyBorder(20, 10, 20, 10));

        JPanel btnPanel = new JPanel(new GridLayout(5, 1, 0, 5));
        {
          JButton btn = new JButton("Zoom to Matterhorn");
          btn.setActionCommand(ACTION_COMMAND_BUTTON1);
          btn.addActionListener(this.controller);
          btnPanel.add(btn);

          btn = new JButton("DEMO getElevations()");
          btn.setActionCommand(ACTION_COMMAND_BUTTON2);
          btn.addActionListener(this.controller);
          btnPanel.add(btn);

          btn = new JButton("DEMO getElevation()");
          btn.setActionCommand(ACTION_COMMAND_BUTTON3);
          btn.addActionListener(this.controller);
          btnPanel.add(btn);

          btn = new JButton("DEMO new getElevations");
          btn.setActionCommand(ACTION_COMMAND_BUTTON4);
          btn.addActionListener(this.controller);
          btnPanel.add(btn);

          //                    btn = new JButton("Button 5");
          //                    btn.setActionCommand(ACTION_COMMAND_BUTTON5);
          //                    btn.addActionListener(this.controller);
          //                    btnPanel.add(btn);
        }
        controlPanel.add(btnPanel, BorderLayout.NORTH);

        JPanel vePanel = new JPanel(new BorderLayout(0, 5));
        {
          JLabel label = new JLabel("Vertical Exaggeration");
          vePanel.add(label, BorderLayout.NORTH);

          int MIN_VE = 1;
          int MAX_VE = 8;
          int curVe = (int) this.getWwd().getSceneController().getVerticalExaggeration();
          curVe = curVe < MIN_VE ? MIN_VE : (curVe > MAX_VE ? MAX_VE : curVe);
          JSlider slider = new JSlider(MIN_VE, MAX_VE, curVe);
          slider.setMajorTickSpacing(1);
          slider.setPaintTicks(true);
          slider.setSnapToTicks(true);
          Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
          labelTable.put(1, new JLabel("1x"));
          labelTable.put(2, new JLabel("2x"));
          labelTable.put(4, new JLabel("4x"));
          labelTable.put(8, new JLabel("8x"));
          slider.setLabelTable(labelTable);
          slider.setPaintLabels(true);
          slider.addChangeListener(
              new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                  double ve = ((JSlider) e.getSource()).getValue();
                  ActionEvent ae = new ActionEvent(ve, 0, ACTION_COMMAND_VERTICAL_EXAGGERATION);
                  controller.actionPerformed(ae);
                }
              });
          vePanel.add(slider, BorderLayout.SOUTH);
        }
        controlPanel.add(vePanel, BorderLayout.SOUTH);

        panel.add(controlPanel, BorderLayout.SOUTH);

        this.layerPanel = new LayerPanel(this.getWwd(), null);
        panel.add(this.layerPanel, BorderLayout.CENTER);
      }
      getContentPane().add(panel, BorderLayout.WEST);
    }