Exemplo n.º 1
0
    protected JPanel makeDetailHintControlPanel() {
      JPanel controlPanel = new JPanel(new BorderLayout(0, 10));
      controlPanel.setBorder(
          new CompoundBorder(
              BorderFactory.createEmptyBorder(9, 9, 9, 9), new TitledBorder("Detail Hint")));

      JPanel elevationSliderPanel = new JPanel(new BorderLayout(0, 5));
      {
        int MIN = -10;
        int MAX = 10;
        int cur = 0;
        JSlider slider = new JSlider(MIN, MAX, cur);
        slider.setMajorTickSpacing(10);
        slider.setMinorTickSpacing(1);
        slider.setPaintTicks(true);
        Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
        labelTable.put(-10, new JLabel("-1.0"));
        labelTable.put(0, new JLabel("0.0"));
        labelTable.put(10, new JLabel("1.0"));
        slider.setLabelTable(labelTable);
        slider.setPaintLabels(true);
        slider.addChangeListener(
            new ChangeListener() {
              public void stateChanged(ChangeEvent e) {
                double hint = ((JSlider) e.getSource()).getValue() / 10d;
                setWedgeDetailHint(hint);
                getWwd().redraw();
              }
            });
        elevationSliderPanel.add(slider, BorderLayout.SOUTH);
      }

      JPanel sliderPanel = new JPanel(new GridLayout(2, 0));
      sliderPanel.add(elevationSliderPanel);

      controlPanel.add(sliderPanel, BorderLayout.SOUTH);
      return controlPanel;
    }
    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);
    }