Search in sources :

Example 1 with ConflictType

use of net.parostroj.timetable.actions.TrainsCycleChecker.ConflictType in project grafikon by jub77.

the class DriverCycleDelegate method getTrainCycleErrors.

@Override
public String getTrainCycleErrors(TrainsCycle cycle) {
    TrainDiagram diagram = model.getDiagram();
    TimeConverter c = diagram.getTimeConverter();
    StringBuilder result = new StringBuilder();
    List<TrainsCycleChecker.Conflict> conflicts = checker.checkConflicts(cycle);
    for (TrainsCycleChecker.Conflict item : conflicts) {
        TrainsCycleItem fromItem = item.getFrom();
        TrainsCycleItem toItem = item.getTo();
        for (ConflictType conflictType : this.colapseTimeConflictTypes(item.getType())) {
            switch(conflictType) {
                case NODE:
                    addNewLineIfNotEmpty(result);
                    result.append(String.format("%s %s", ResourceLoader.getString("ec.move.nodes"), formatItems(fromItem, toItem, c)));
                    break;
                case TRANSITION_TIME:
                    addNewLineIfNotEmpty(result);
                    result.append(String.format("%s %s", ResourceLoader.getString("ec.move.nodes.time.problem"), formatItems(fromItem, toItem, c)));
                    break;
                case TIME:
                case SETUP_TIME:
                    addNewLineIfNotEmpty(result);
                    result.append(String.format("%s %s", ResourceLoader.getString("ec.problem.time"), formatItems(fromItem, toItem, c)));
                    break;
            }
        }
    }
    return result.toString();
}
Also used : TrainsCycleChecker(net.parostroj.timetable.actions.TrainsCycleChecker) TrainsCycleItem(net.parostroj.timetable.model.TrainsCycleItem) TimeConverter(net.parostroj.timetable.model.TimeConverter) ConflictType(net.parostroj.timetable.actions.TrainsCycleChecker.ConflictType) TrainDiagram(net.parostroj.timetable.model.TrainDiagram)

Example 2 with ConflictType

use of net.parostroj.timetable.actions.TrainsCycleChecker.ConflictType in project grafikon by jub77.

the class TCDelegate method checkConflicts.

private void checkConflicts(TrainsCycle cycle, StringBuilder result) {
    List<Conflict> conflicts = checker.checkConflicts(cycle);
    TimeConverter c = cycle.getDiagram().getTimeConverter();
    for (Conflict item : conflicts) {
        TrainsCycleItem fromItem = item.getFrom();
        TrainsCycleItem toItem = item.getTo();
        for (ConflictType conflictType : item.getType()) {
            switch(conflictType) {
                case NODE:
                    addNewLineIfNotEmpty(result);
                    result.append(String.format("%s %s", ResourceLoader.getString("ec.problem.nodes"), formatItems(fromItem, toItem, c)));
                    if (!cycle.isPartOfSequence() && fromItem == cycle.getLastItem() && toItem == cycle.getFirstItem()) {
                        addNewLineIfNotEmpty(result);
                        result.append(ResourceLoader.getString("ec.problem.startend"));
                    }
                    break;
                case TIME:
                    addNewLineIfNotEmpty(result);
                    result.append(String.format("%s %s", ResourceLoader.getString("ec.problem.time"), formatItems(fromItem, toItem, c)));
                    break;
                default:
                    break;
            }
        }
    }
}
Also used : Conflict(net.parostroj.timetable.actions.TrainsCycleChecker.Conflict) TrainsCycleItem(net.parostroj.timetable.model.TrainsCycleItem) TimeConverter(net.parostroj.timetable.model.TimeConverter) ConflictType(net.parostroj.timetable.actions.TrainsCycleChecker.ConflictType)

Aggregations

ConflictType (net.parostroj.timetable.actions.TrainsCycleChecker.ConflictType)2 TimeConverter (net.parostroj.timetable.model.TimeConverter)2 TrainsCycleItem (net.parostroj.timetable.model.TrainsCycleItem)2 TrainsCycleChecker (net.parostroj.timetable.actions.TrainsCycleChecker)1 Conflict (net.parostroj.timetable.actions.TrainsCycleChecker.Conflict)1 TrainDiagram (net.parostroj.timetable.model.TrainDiagram)1