Пример #1
0
  /** This method is called when the selection of one of the two combo boxes is changed. */
  public void actionPerformed(ActionEvent ev) {

    sequenceField.hidePopup();
    separationField.hidePopup();

    try {
      if (ev.getSource() == sequenceField) {
        Animation listValue = sequenceField.getValue();
        Animation tileValue = tilePattern.getAnimation();
        if (listValue != tileValue) {
          // the tile pattern's animation sequence has changed
          tilePattern.setAnimation(listValue);
        }
      } else {
        AnimationSeparation listValue = separationField.getValue();
        AnimationSeparation tileValue = tilePattern.getAnimationSeparation();
        if (listValue != tileValue) {
          // the direction of the animation separation has changed
          tilePattern.setAnimationSeparation(listValue);
        }
      }
    } catch (TilesetException ex) {
      JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
      update(tilePattern);
    }
  }
Пример #2
0
  /**
   * This method is called when the tile pattern is changed.
   *
   * @param tilePattern the tile pattern to represent in this view (can be null)
   */
  public void update(TilePattern tilePattern) {

    this.tilePattern = tilePattern;
    if (tilePattern == null) {
      sequenceField.setEnabled(false);
      separationField.setEnabled(false);
    } else {
      Animation sequence = tilePattern.getAnimation();
      sequenceField.setEnabled(true);
      sequenceField.setValue(sequence);

      if (tilePattern.isAnimated()) {
        separationField.setValue(tilePattern.getAnimationSeparation());
        separationField.setEnabled(true);
      } else {
        separationField.setEnabled(false);
      }
    }
  }