Search in sources :

Example 21 with Event

use of net.parostroj.timetable.model.events.Event 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);
}
Also used : AbstractEventVisitor(net.parostroj.timetable.visitors.AbstractEventVisitor) Event(net.parostroj.timetable.model.events.Event) Train(net.parostroj.timetable.model.Train)

Aggregations

Event (net.parostroj.timetable.model.events.Event)21 AttributeChange (net.parostroj.timetable.model.events.AttributeChange)12 Color (java.awt.Color)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ItemEvent (java.awt.event.ItemEvent)1 MouseEvent (java.awt.event.MouseEvent)1 JComponent (javax.swing.JComponent)1 PopupMenuEvent (javax.swing.event.PopupMenuEvent)1 PopupMenuListener (javax.swing.event.PopupMenuListener)1 TCDetailsViewDialog (net.parostroj.timetable.gui.dialogs.TCDetailsViewDialog)1 TCDelegate (net.parostroj.timetable.gui.views.TCDelegate)1 Wrapper (net.parostroj.timetable.gui.wrappers.Wrapper)1 GTEventsReceiverColleague (net.parostroj.timetable.mediator.GTEventsReceiverColleague)1 Route (net.parostroj.timetable.model.Route)1 Train (net.parostroj.timetable.model.Train)1 TrainColorChooser (net.parostroj.timetable.output2.gt.TrainColorChooser)1 AbstractEventVisitor (net.parostroj.timetable.visitors.AbstractEventVisitor)1