/*
* JFLAP - Formal Languages and Automata Package
*
*
* Susan H. Rodger
* Computer Science Department
* Duke University
* August 27, 2009
* Copyright (c) 2002-2009
* All rights reserved.
* JFLAP is open source software. Please see the LICENSE for terms.
*
*/
package automata.event;
import java.util.EventObject;
import automata.Automaton;
import automata.Note;
/**
* This event is given to listeners of an automaton interested in events when a
* transition on an automaton is added, removed, or changed.
*
* @see automata.Automaton
* @see automata.Transition
* @see automata.Automaton#addTransition
* @see automata.Automaton#removeTransition
* @see automata.event.AutomataTransitionListener
*
* @author Thomas Finley
*/
public class AutomataNoteEvent extends EventObject {
/**
* Instantiates a new AutomataStateEvent
.
*
* @param auto
* the Automaton
that generated the event
* @param note
* the Note
that was added or removed, or changed
* @param add
* true
if the note is added, false
* if removed
* @param change
* true
if some property of the note was
* changed, false
if this is not simply added or removed
*/
public AutomataNoteEvent(Automaton auto, Note note,
boolean add, boolean change) {
super(auto);
myNote = note;
myAdd = add;
myChange = change;
}
/**
* Returns the Automaton
that generated this event.
*
* @return the Automaton
that generated this event
*/
public Automaton getAutomaton() {
return (Automaton) getSource();
}
/**
* Returns the Transition
that was added/removed.
*
* @return the Transition
that was added/removed
*/
public Note getNote() {
return myNote;
}
/**
* Returns if this was an add.
*
* @return true
if this event indicates the addition of a
* transition, false
otherwise
*/
public boolean isAdd() {
return myAdd;
}
/**
* Returns if this was a delete.
*
* @return true
if this event indicates the removal of a
* transition, false
otherwise
*/
public boolean isDelete() {
return !(myAdd || myChange);
}
/**
* Returns if this was a simple change in a property of the transition.
*
* @return true
if the properties of this transition were
* changed, false
otherwise
*/
public boolean isChange() {
return myChange;
}
/** Was this an add? */
private boolean myAdd;
/** Which transition did we add/remove? */
private Note myNote;
/** Is this a change in property? */
private boolean myChange;
}