Search in sources :

Example 16 with Event

use of net.parostroj.timetable.model.events.Event in project grafikon by jub77.

the class WeightTableRow method setWeightInfo.

public void setWeightInfo(LineClass lineClass, Integer weight) {
    weights.put(lineClass, weight);
    engineClass.fireEvent(new Event(engineClass, this, new AttributeChange("weight.info", null, null)));
}
Also used : AttributeChange(net.parostroj.timetable.model.events.AttributeChange) Event(net.parostroj.timetable.model.events.Event)

Example 17 with Event

use of net.parostroj.timetable.model.events.Event in project grafikon by jub77.

the class CirculationPane method setModel.

public void setModel(ApplicationModel model) {
    this.delegate = new TCDelegate(model) {

        private TCDetailsViewDialog editDialog;

        @Override
        public void showEditDialog(JComponent component) {
            if (editDialog == null) {
                editDialog = new TCDetailsViewDialog(GuiComponentUtils.getWindow(component), true);
            }
            editDialog.setLocationRelativeTo(component);
            editDialog.updateValues(this, diagram);
            editDialog.setVisible(true);
        }

        @Override
        public TrainsCycleType getType() {
            return type;
        }

        @Override
        public void handleEvent(Action action, TrainsCycle cycle, Train train) {
            if (action == Action.DIAGRAM_CHANGE) {
                diagram = delegate.getTrainDiagram();
                updateTypes();
                this.fireEvent(Action.REFRESH, null);
            }
        }
    };
    trainsCyclesPane.setModel(this.delegate, new TrainColorChooser() {

        @Override
        public Color getIntervalColor(TimeInterval interval) {
            if (!interval.getTrain().isCovered(type, interval)) {
                return Color.black;
            } else {
                return Color.gray;
            }
        }
    });
    model.getMediator().addColleague(new GTEventsReceiverColleague() {

        @Override
        public void processTrainDiagramEvent(Event event) {
            if (event.getType() == Event.Type.ADDED && event.getObject() instanceof TrainsCycleType) {
                Wrapper<TrainsCycleType> wrapper = new Wrapper<>((TrainsCycleType) event.getObject());
                typesComboBox.addItem(wrapper);
                typesComboBox.setSelectedItem(wrapper);
            } else if (event.getType() == Event.Type.REMOVED && event.getObject() instanceof TrainsCycleType) {
                typesComboBox.removeItem(new Wrapper<>((TrainsCycleType) event.getObject()));
            }
        }
    });
}
Also used : Wrapper(net.parostroj.timetable.gui.wrappers.Wrapper) GTEventsReceiverColleague(net.parostroj.timetable.mediator.GTEventsReceiverColleague) TCDelegate(net.parostroj.timetable.gui.views.TCDelegate) Color(java.awt.Color) JComponent(javax.swing.JComponent) TrainColorChooser(net.parostroj.timetable.output2.gt.TrainColorChooser) Event(net.parostroj.timetable.model.events.Event) ItemEvent(java.awt.event.ItemEvent) TCDetailsViewDialog(net.parostroj.timetable.gui.dialogs.TCDetailsViewDialog)

Example 18 with Event

use of net.parostroj.timetable.model.events.Event in project grafikon by jub77.

the class FreightNet method moveConnectionImpl.

private void moveConnectionImpl(FNConnection conn, int indexFrom, int indexTo) {
    List<FNConnection> connList = this.fromMap.get(conn.getFrom());
    if (indexTo < 0 || indexTo >= connList.size()) {
        throw new IllegalArgumentException(String.format("Connection moved to illegal place: %d (size %d)", indexTo, connList.size()));
    }
    FNConnection removedConn = connList.remove(indexFrom);
    if (removedConn != null) {
        connList.add(indexTo, conn);
        this.fireEvent(new Event(this, Event.Type.MOVED, conn, ListData.createData(indexFrom, indexTo)));
    }
}
Also used : Event(net.parostroj.timetable.model.events.Event)

Example 19 with Event

use of net.parostroj.timetable.model.events.Event in project grafikon by jub77.

the class FreightNet method addConnectionImpl.

private void addConnectionImpl(FNConnection conn) {
    this.fromMap.put(conn.getFrom(), conn);
    this.toMap.put(conn.getTo(), conn);
    this.fromTrainMap.put(conn.getFrom().getTrain(), conn);
    this.toTrainMap.put(conn.getTo().getTrain(), conn);
    this.fireEvent(new Event(this, Event.Type.ADDED, conn));
}
Also used : Event(net.parostroj.timetable.model.events.Event)

Example 20 with Event

use of net.parostroj.timetable.model.events.Event in project grafikon by jub77.

the class PenaltyTableRow method setAcceleration.

public void setAcceleration(int acceleration) {
    if (this.acceleration != acceleration) {
        this.acceleration = acceleration;
        category.fireEvent(new Event(category, this, new AttributeChange("penalty.info", null, null)));
    }
}
Also used : AttributeChange(net.parostroj.timetable.model.events.AttributeChange) Event(net.parostroj.timetable.model.events.Event)

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