コード例 #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);
      }
    }
  }
コード例 #3
0
  /** Constructor. */
  public TilePatternAnimationView() {
    super();

    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    // list for the animation sequence
    sequenceField = new EnumerationChooser<Animation>(Animation.class);
    sequenceField.addActionListener(this);

    // list for the separation
    separationField = new EnumerationIconChooser<AnimationSeparation>(AnimationSeparation.class);
    separationField.addActionListener(this);

    // add the two lists
    add(sequenceField);
    add(Box.createRigidArea(new Dimension(5, 0)));
    add(separationField);
  }