Search in sources :

Example 31 with Train

use of net.parostroj.timetable.model.Train 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

Train (net.parostroj.timetable.model.Train)31 TimeInterval (net.parostroj.timetable.model.TimeInterval)8 LinkedList (java.util.LinkedList)5 Node (net.parostroj.timetable.model.Node)5 TrainsCycle (net.parostroj.timetable.model.TrainsCycle)5 TrainsCycleItem (net.parostroj.timetable.model.TrainsCycleItem)5 List (java.util.List)4 TrainDiagram (net.parostroj.timetable.model.TrainDiagram)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 FNConnection (net.parostroj.timetable.model.FNConnection)3 TranslatedString (net.parostroj.timetable.model.TranslatedString)3 Component (java.awt.Component)2 Rectangle (java.awt.Rectangle)2 Shape (java.awt.Shape)2 JOptionPane (javax.swing.JOptionPane)2 TrainIntervalsBuilder (net.parostroj.timetable.actions.TrainIntervalsBuilder)2 GuiComponentUtils (net.parostroj.timetable.gui.utils.GuiComponentUtils)2 Group (net.parostroj.timetable.model.Group)2 Route (net.parostroj.timetable.model.Route)2