use of net.parostroj.timetable.visitors.AbstractEventVisitor in project grafikon by jub77.
the class TrainRegionCollector method processEvent.
@Override
public void processEvent(Event event) {
AbstractEventVisitor visitor = new AbstractEventVisitor() {
@Override
public void visitDiagramEvent(Event event) {
switch(event.getType()) {
case ADDED:
if (event.getObject() instanceof Train) {
newTrain((Train) event.getObject());
}
break;
case REMOVED:
if (event.getObject() instanceof Train) {
deleteTrain((Train) event.getObject());
}
break;
default:
break;
}
}
@Override
public void visitTrainEvent(Event event) {
switch(event.getType()) {
case SPECIAL:
modifiedTrain((Train) event.getSource());
break;
case ATTRIBUTE:
if (event.getAttributeChange().checkName(Train.ATTR_MANAGED_FREIGHT, Train.ATTR_TECHNOLOGICAL_BEFORE, Train.ATTR_TECHNOLOGICAL_AFTER)) {
modifiedTrain((Train) event.getSource());
}
break;
default:
break;
}
}
};
EventProcessing.visit(event, visitor);
}
Aggregations