Search in sources :

Example 1 with DriverCycleDelegate

use of net.parostroj.timetable.gui.views.DriverCycleDelegate in project grafikon by jub77.

the class MainFrame method initializeFrame.

/**
 * initializes frame.
 */
private void initializeFrame() {
    provider.setPresentationModel(model);
    lastOpened = new HashMap<>();
    // set local before anything else
    String loadedLocale = null;
    try {
        IniConfigSection section = AppPreferences.getPreferences().getSection("main");
        loadedLocale = section.get("locale.program");
        String templateLocale = section.get("locale.output");
        if (loadedLocale != null) {
            Locale locale = ModelUtils.parseLocale(loadedLocale);
            model.setLocale(locale);
            Locale.setDefault(locale);
        } else {
            model.setLocale(null);
        }
        if (templateLocale != null) {
            model.getOutputSettings().setLocale(ModelUtils.parseLocale(templateLocale));
        }
    } catch (IOException e) {
        log.warn("Cannot load preferences.", e);
    }
    log.debug("Locale: {}", Locale.getDefault());
    executeScriptAction = new ExecuteScriptAction(model);
    initComponents();
    this.addWindowListener(new MainFrameWindowListener(model, this));
    trainsPane.setModel(model);
    engineCyclesPane.setModel(new EngineCycleDelegate(model), interval -> {
        TrainsCycleType type = interval.getTrain().getDiagram().getEngineCycleType();
        if (!interval.getTrain().isCovered(type, interval)) {
            return Color.black;
        } else {
            return Color.gray;
        }
    });
    trainUnitCyclesPane.setModel(new TrainUnitCycleDelegate(model), interval -> {
        TrainsCycleType type = interval.getTrain().getDiagram().getTrainUnitCycleType();
        if (!interval.getTrain().isCovered(type, interval)) {
            return Color.black;
        } else {
            return Color.gray;
        }
    });
    driverCyclesPane.setModel(new DriverCycleDelegate(model), interval -> {
        TrainsCycleType type = interval.getTrain().getDiagram().getDriverCycleType();
        if (!interval.getTrain().isCovered(type, interval)) {
            return Color.black;
        } else {
            return Color.gray;
        }
    });
    circulationPane.setModel(model);
    freightNetPane2.setModel(model);
    model.addListener(this);
    model.addListener(statusBar);
    netPane.setModel(model);
    this.updateView();
    model.setDiagram(null);
    // apply preferences
    try {
        this.loadFromPreferences(AppPreferences.getPreferences());
    } catch (IOException e) {
        log.error("Error loading preferences.", e);
    }
    // add predefined scripts
    for (ScriptAction sd : model.getScriptsLoader().getScriptActions()) {
        addScriptAction(sd, ExecuteScriptAction.MODEL_PREFIX, scriptsMenuModel);
    }
    // add gui scripts
    for (ScriptAction sd : model.getGuiScriptsLoader().getScriptActions()) {
        addScriptAction(sd, ExecuteScriptAction.GUI_PREFIX, scriptsMenuGui);
    }
    statusBar.setModel(model);
}
Also used : EngineCycleDelegate(net.parostroj.timetable.gui.views.EngineCycleDelegate) DriverCycleDelegate(net.parostroj.timetable.gui.views.DriverCycleDelegate) IOException(java.io.IOException) ScriptAction(net.parostroj.timetable.actions.scripts.ScriptAction) IniConfigSection(net.parostroj.timetable.gui.ini.IniConfigSection) TrainUnitCycleDelegate(net.parostroj.timetable.gui.views.TrainUnitCycleDelegate)

Aggregations

IOException (java.io.IOException)1 ScriptAction (net.parostroj.timetable.actions.scripts.ScriptAction)1 IniConfigSection (net.parostroj.timetable.gui.ini.IniConfigSection)1 DriverCycleDelegate (net.parostroj.timetable.gui.views.DriverCycleDelegate)1 EngineCycleDelegate (net.parostroj.timetable.gui.views.EngineCycleDelegate)1 TrainUnitCycleDelegate (net.parostroj.timetable.gui.views.TrainUnitCycleDelegate)1