Пример #1
0
  /**
   * Sets the panel in which the GUI should be implemented Any standard swing components can be used
   *
   * @param panel The GUI panel
   */
  public void setPanel(JPanel panel) {
    this.panel = panel;

    panel.setLayout(new BorderLayout());

    JLabel label =
        new JLabel("Produces an effect similar to thermal erosion", (int) JLabel.CENTER_ALIGNMENT);
    panel.add(label, BorderLayout.PAGE_START);

    JPanel iterations = new JPanel();
    iterations.setLayout(new FlowLayout());

    label = new JLabel("Iterations ");
    iterations.add(label);
    sldIterations = new JSlider(1, 100, 1);
    sldIterations.addChangeListener(this);
    iterations.add(sldIterations);
    txtIterations = new JTextField(Integer.toString((int) sldIterations.getValue()));
    txtIterations.setEditable(false);
    txtIterations.setPreferredSize(new Dimension(35, 25));
    iterations.add(txtIterations);

    panel.add(iterations, BorderLayout.CENTER);

    btnApply = new JButton("Apply Thermal Erosion");
    btnApply.addActionListener(this);
    panel.add(btnApply, BorderLayout.PAGE_END);

    if (preview) parent.refreshMiniView(apply(preview));
  }
Пример #2
0
 public void stateChanged(ChangeEvent e) {
   if (e.getSource().equals(sldIterations)) {
     txtIterations.setText(Integer.toString((int) sldIterations.getValue()));
     if (preview) {
       parent.setPreviewMap(parent.getHeightMap(), 128);
       parent.refreshMiniView(apply(preview));
     }
   }
 }