001package jmri.jmrit.operations.setup;
002
003import java.awt.Color;
004import java.awt.JobAttributes.SidesType;
005import java.io.IOException;
006import java.util.*;
007
008import javax.swing.JComboBox;
009
010import org.jdom2.Element;
011import org.slf4j.Logger;
012import org.slf4j.LoggerFactory;
013
014import jmri.*;
015import jmri.beans.PropertyChangeSupport;
016import jmri.jmris.AbstractOperationsServer;
017import jmri.jmrit.operations.OperationsPanel;
018import jmri.jmrit.operations.rollingstock.RollingStockLogger;
019import jmri.jmrit.operations.setup.backup.AutoBackup;
020import jmri.jmrit.operations.setup.backup.AutoSave;
021import jmri.jmrit.operations.trains.TrainLogger;
022import jmri.jmrit.operations.trains.TrainManagerXml;
023import jmri.util.ColorUtil;
024import jmri.util.swing.JmriColorChooser;
025import jmri.web.server.WebServerPreferences;
026
027/**
028 * Operations settings.
029 *
030 * @author Daniel Boudreau Copyright (C) 2008, 2010, 2012, 2014, 2025
031 */
032public class Setup extends PropertyChangeSupport implements InstanceManagerAutoDefault, Disposable {
033
034    public static final String NONE = "";
035
036    // scale ratios from NMRA
037    public static final int Z_RATIO = 220;
038    public static final int N_RATIO = 160;
039    public static final int TT_RATIO = 120;
040    public static final int OO_RATIO = 76; // actual ratio 76.2
041    public static final int HO_RATIO = 87;
042    public static final int S_RATIO = 64;
043    public static final int O_RATIO = 48;
044    public static final int Gauge1_RATIO = 32; // NMRA #1
045    public static final int G_24_RATIO = 24;
046
047    // initial weight in milli ounces from NMRA
048    private static final int Z_INITIAL_WEIGHT = 364; // not specified by NMRA
049    private static final int N_INITIAL_WEIGHT = 500;
050    private static final int TT_INITIAL_WEIGHT = 750;
051    private static final int HOn3_INITIAL_WEIGHT = 750;
052    private static final int OO_INITIAL_WEIGHT = 750; // not specified by NMRA
053    private static final int HO_INITIAL_WEIGHT = 1000;
054    private static final int Sn3_INITIAL_WEIGHT = 1000;
055    private static final int S_INITIAL_WEIGHT = 2000;
056    private static final int On3_INITIAL_WEIGHT = 1500;
057    private static final int O_INITIAL_WEIGHT = 5000;
058    private static final int G_INITIAL_WEIGHT = 10000; // not specified by NMRA
059
060    // additional weight in milli ounces from NMRA
061    private static final int Z_ADD_WEIGHT = 100; // not specified by NMRA
062    private static final int N_ADD_WEIGHT = 150;
063    private static final int TT_ADD_WEIGHT = 375;
064    private static final int HOn3_ADD_WEIGHT = 375;
065    private static final int OO_ADD_WEIGHT = 500; // not specified by NMRA
066    private static final int HO_ADD_WEIGHT = 500;
067    private static final int Sn3_ADD_WEIGHT = 500;
068    private static final int S_ADD_WEIGHT = 500;
069    private static final int On3_ADD_WEIGHT = 750;
070    private static final int O_ADD_WEIGHT = 1000;
071    private static final int G_ADD_WEIGHT = 2000; // not specified by NMRA
072
073    // actual weight to tons conversion ratios (based on 40' boxcar at ~80 tons)
074    private static final int Z_RATIO_TONS = 130;
075    private static final int N_RATIO_TONS = 80;
076    private static final int TT_RATIO_TONS = 36;
077    private static final int HOn3_RATIO_TONS = 20;
078    private static final int OO_RATIO_TONS = 20;
079    private static final int HO_RATIO_TONS = 20; // 20 tons per ounce
080    private static final int Sn3_RATIO_TONS = 16;
081    private static final int S_RATIO_TONS = 14;
082    private static final int On3_RATIO_TONS = 8;
083    private static final int O_RATIO_TONS = 5;
084    private static final int G_RATIO_TONS = 2;
085
086    public static final int Z_SCALE = 1;
087    public static final int N_SCALE = 2;
088    public static final int TT_SCALE = 3;
089    public static final int HOn3_SCALE = 4;
090    public static final int OO_SCALE = 5;
091    public static final int HO_SCALE = 6;
092    public static final int Sn3_SCALE = 7;
093    public static final int S_SCALE = 8;
094    public static final int On3_SCALE = 9;
095    public static final int O_SCALE = 10;
096    public static final int Gauge1_SCALE = 11; // NMRA #1
097    public static final int G_24_SCALE = 12;
098
099    public static final int EAST = 1; // train direction serviced by this location
100    public static final int WEST = 2;
101    public static final int NORTH = 4;
102    public static final int SOUTH = 8;
103
104    public static final String EAST_DIR = Bundle.getMessage("East");
105    public static final String WEST_DIR = Bundle.getMessage("West");
106    public static final String NORTH_DIR = Bundle.getMessage("North");
107    public static final String SOUTH_DIR = Bundle.getMessage("South");
108
109    public static final String DESCRIPTIVE = Bundle.getMessage("Descriptive"); // Car types
110    public static final String AAR = Bundle.getMessage("ArrCodes"); // Car types
111
112    public static final String MONOSPACED = Bundle.getMessage("Monospaced"); // default printer font
113
114    public static final String STANDARD_FORMAT = Bundle.getMessage("StandardFormat");
115    public static final String TWO_COLUMN_FORMAT = Bundle.getMessage("TwoColumnFormat");
116    public static final String TWO_COLUMN_TRACK_FORMAT = Bundle.getMessage("TwoColumnTrackFormat");
117
118    public static final String PORTRAIT = Bundle.getMessage("Portrait");
119    public static final String LANDSCAPE = Bundle.getMessage("Landscape");
120    public static final String HALFPAGE = Bundle.getMessage("HalfPage");
121    public static final String HANDHELD = Bundle.getMessage("HandHeld");
122
123    public static final String PAGE_NORMAL = Bundle.getMessage("PageNormal");
124    public static final String PAGE_PER_TRAIN = Bundle.getMessage("PagePerTrain");
125    public static final String PAGE_PER_VISIT = Bundle.getMessage("PagePerVisit");
126
127    public static final String BUILD_REPORT_MINIMAL = "1";
128    public static final String BUILD_REPORT_NORMAL = "3";
129    public static final String BUILD_REPORT_DETAILED = "5";
130    public static final String BUILD_REPORT_VERY_DETAILED = "7";
131
132    // the following are converted to English spelling when storing to file, see KEYS below
133    public static final String ROAD = Bundle.getMessage("Road"); // the supported message format options
134    public static final String NUMBER = Bundle.getMessage("Number");
135    public static final String TYPE = Bundle.getMessage("Type");
136    public static final String MODEL = Bundle.getMessage("Model");
137    public static final String LENGTH = Bundle.getMessage("Length");
138    public static final String WEIGHT = Bundle.getMessage("Weight");
139    public static final String HP = Bundle.getMessage("HP");
140    public static final String LOAD = Bundle.getMessage("Load");
141    public static final String LOAD_TYPE = Bundle.getMessage("Load_Type");
142    public static final String COLOR = Bundle.getMessage("Color");
143    public static final String TRACK = Bundle.getMessage("Track");
144    public static final String DESTINATION = Bundle.getMessage("Destination");
145    public static final String DEST_TRACK = Bundle.getMessage("Dest&Track");
146    public static final String FINAL_DEST = Bundle.getMessage("Final_Dest");
147    public static final String FINAL_DEST_TRACK = Bundle.getMessage("FD&Track");
148    public static final String LOCATION = Bundle.getMessage("Location");
149    public static final String CONSIST = Bundle.getMessage("Consist");
150    public static final String DCC_ADDRESS = Bundle.getMessage("DCC_Address");
151    public static final String KERNEL = Bundle.getMessage("Kernel");
152    public static final String KERNEL_SIZE = Bundle.getMessage("Kernel_Size");
153    public static final String OWNER = Bundle.getMessage("Owner");
154    public static final String DIVISION = Bundle.getMessage("Division");
155    public static final String BLOCKING_ORDER = Bundle.getMessage("Blocking_Order");
156    public static final String RWE = Bundle.getMessage("RWE");
157    public static final String COMMENT = Bundle.getMessage("Comment");
158    public static final String DROP_COMMENT = Bundle.getMessage("SetOut_Msg");
159    public static final String PICKUP_COMMENT = Bundle.getMessage("PickUp_Msg");
160    public static final String HAZARDOUS = Bundle.getMessage("Hazardous");
161    public static final String LAST_TRAIN = Bundle.getMessage("LastTrain");
162    public static final String BLANK = " "; // blank has be a character or a space
163    public static final String TAB = Bundle.getMessage("Tab"); // used to tab out in tabular mode
164    public static final String TAB2 = Bundle.getMessage("Tab2");
165    public static final String TAB3 = Bundle.getMessage("Tab3");
166    
167    public static final String BOX = " [ ] "; // NOI18N
168
169    // these are for the utility printing when using tabs
170    public static final String NO_ROAD = "NO_ROAD"; // NOI18N
171    public static final String NO_NUMBER = "NO_NUMBER"; // NOI18N
172    public static final String NO_COLOR = "NO_COLOR"; // NOI18N
173
174    // truncated manifests
175    public static final String NO_DESTINATION = "NO_DESTINATION"; // NOI18N
176    public static final String NO_DEST_TRACK = "NO_DEST_TRACK"; // NOI18N
177    public static final String NO_LOCATION = "NO_LOCATION"; // NOI18N
178    public static final String NO_TRACK = "NO_TRACK"; // NOI18N
179
180    // Unit of Length
181    public static final String FEET = Bundle.getMessage("Feet");
182    public static final String METER = Bundle.getMessage("Meter");
183    public static final String FEET_ABV = Bundle.getMessage("FeetAbbreviation");
184    public static final String METER_ABV = Bundle.getMessage("MeterAbbreviation");
185
186    private static final String[] CAR_ATTRIBUTES = { ROAD, NUMBER, TYPE, LENGTH, WEIGHT, LOAD, LOAD_TYPE, HAZARDOUS,
187            COLOR, KERNEL, KERNEL_SIZE, OWNER, DIVISION, TRACK, LOCATION, DESTINATION, DEST_TRACK, FINAL_DEST, FINAL_DEST_TRACK,
188            BLOCKING_ORDER, COMMENT, DROP_COMMENT, PICKUP_COMMENT, RWE, LAST_TRAIN};
189    
190    private static final String[] ENGINE_ATTRIBUTES = {ROAD, NUMBER, TYPE, MODEL, LENGTH, WEIGHT, HP, CONSIST, OWNER,
191            TRACK, LOCATION, DESTINATION, COMMENT, DCC_ADDRESS, LAST_TRAIN};
192    /*
193     * The print Manifest and switch list user selectable options are stored in the
194     * xml file using the English translations.
195     */
196    private static final String[] KEYS = {"Road", "Number", "Type", "Model", "Length", "Weight", "Load", "Load_Type",
197            "HP", "Color", "Track", "Destination", "Dest&Track", "Final_Dest", "FD&Track", "Location", "Consist",
198            "DCC_Address", "Kernel", "Kernel_Size", "Owner", "Division", "Blocking_Order", "RWE", "Comment",
199            "SetOut_Msg", "PickUp_Msg", "Hazardous", "LastTrain", "Tab", "Tab2", "Tab3"};
200
201    private int scale = HO_SCALE; // Default scale
202    private int ratio = HO_RATIO;
203    private int ratioTons = HO_RATIO_TONS;
204    private int initWeight = HO_INITIAL_WEIGHT;
205    private int addWeight = HO_ADD_WEIGHT;
206    private String railroadName = NONE;
207    private int traindir = EAST + WEST + NORTH + SOUTH;
208    private int maxTrainLength = 1000; // maximum train length
209    private int maxEngineSize = 6; // maximum number of engines that can be assigned to a train
210    private double horsePowerPerTon = 1; // Horsepower per ton
211    private int carMoves = 5; // default number of moves when creating a route
212    private String carTypes = DESCRIPTIVE;
213    private String ownerName = NONE;
214    private String fontName = MONOSPACED;
215    private int manifestFontSize = 10;
216    private int buildReportFontSize = 10;
217    private String manifestOrientation = PORTRAIT;
218    private String switchListOrientation = PORTRAIT;
219    private SidesType sidesType = SidesType.ONE_SIDED;
220    private boolean printHeader = true;
221    private Color pickupEngineColor = Color.black;
222    private Color dropEngineColor = Color.black;
223    private Color pickupColor = Color.black;
224    private Color dropColor = Color.black;
225    private Color localColor = Color.black;
226    private String[] pickupEngineMessageFormat = { ROAD, NUMBER, BLANK, MODEL, BLANK, BLANK, LOCATION, COMMENT };
227    private String[] dropEngineMessageFormat = { ROAD, NUMBER, BLANK, MODEL, BLANK, BLANK, DESTINATION, COMMENT };
228    private String[] pickupManifestMessageFormat = { ROAD, NUMBER, TYPE, LENGTH, COLOR, LOAD, HAZARDOUS, LOCATION,
229            COMMENT, PICKUP_COMMENT };
230    private String[] dropManifestMessageFormat = { ROAD, NUMBER, TYPE, LENGTH, COLOR, LOAD, HAZARDOUS, DESTINATION,
231            COMMENT, DROP_COMMENT };
232    private String[] localManifestMessageFormat = { ROAD, NUMBER, TYPE, LENGTH, COLOR, LOAD, HAZARDOUS, LOCATION,
233            DESTINATION, COMMENT };
234    private String[] pickupSwitchListMessageFormat = { ROAD, NUMBER, TYPE, LENGTH, COLOR, LOAD, HAZARDOUS, LOCATION,
235            COMMENT, PICKUP_COMMENT };
236    private String[] dropSwitchListMessageFormat = { ROAD, NUMBER, TYPE, LENGTH, COLOR, LOAD, HAZARDOUS, DESTINATION,
237            COMMENT, DROP_COMMENT };
238    private String[] localSwitchListMessageFormat = { ROAD, NUMBER, TYPE, LENGTH, COLOR, LOAD, HAZARDOUS, LOCATION,
239            DESTINATION, COMMENT };
240    private String[] missingCarMessageFormat = { ROAD, NUMBER, TYPE, LENGTH, COLOR, COMMENT };
241    private String pickupEnginePrefix = BOX + Bundle.getMessage("PickUpPrefix");
242    private String dropEnginePrefix = BOX + Bundle.getMessage("SetOutPrefix");
243    private String pickupCarPrefix = BOX + Bundle.getMessage("PickUpPrefix");
244    private String dropCarPrefix = BOX + Bundle.getMessage("SetOutPrefix");
245    private String localPrefix = BOX + Bundle.getMessage("LocalCarPrefix");
246    private String switchListPickupCarPrefix = BOX + Bundle.getMessage("PickUpPrefix");
247    private String switchListDropCarPrefix = BOX + Bundle.getMessage("SetOutPrefix");
248    private String switchListLocalPrefix = BOX + Bundle.getMessage("LocalCarPrefix");
249    private String miaComment = Bundle.getMessage("misplacedCars");
250    private String hazardousMsg = "(" + Bundle.getMessage("Hazardous") + ")";
251    private String logoURL = NONE;
252    private String panelName = "Panel"; // NOI18N
253    private String buildReportLevel = BUILD_REPORT_VERY_DETAILED;
254    private String routerBuildReportLevel = BUILD_REPORT_NORMAL;
255    private int carSwitchTime = 3; // how long it takes to move a car in minutes
256    private int travelTime = 4; // how long it takes a train to move from one location to another in minutes
257    private String yearModeled = NONE; // year being modeled
258    private String lengthUnit = FEET;
259    private String lengthUnitAbv = FEET_ABV;
260    private String iconNorthColor = NONE;
261    private String iconSouthColor = NONE;
262    private String iconEastColor = NONE;
263    private String iconWestColor = NONE;
264    private String iconLocalColor = NONE;
265    private String iconTerminateColor = NONE;
266
267    private boolean tab = false; // when true, tab out manifest and switch lists
268    private int tab1CharLength = Control.max_len_string_attibute;
269    private int tab2CharLength = 6; // arbitrary lengths
270    private int tab3CharLength = 8;
271
272    private String manifestFormat = STANDARD_FORMAT;
273    private boolean manifestEditorEnabled = false; // when true use text editor to view build report
274    private boolean switchListSameManifest = true; // when true switch list format is the same as the manifest
275    private boolean manifestTruncated = false; // when true, manifest is truncated if switch list is available
276    private boolean manifestDepartureTime = false; // when true, manifest shows train's departure time
277    private boolean switchListDepartureTime = false; // when true, switch list shows train's departure time
278    private boolean switchListRouteComment = true; // when true, switch list have route location comments
279    private boolean trackSummary = true; // when true, print switch list track summary
280    private boolean groupCarMoves = false; // when true, car moves are grouped together
281    private boolean locoLast = false; // when true, loco set outs printed last
282
283    private boolean switchListRealTime = true; // when true switch list only show work for built trains
284    private boolean switchListAllTrains = true; // when true show all trains that visit the location
285    private String switchListPageFormat = PAGE_NORMAL; // how switch lists pages are printed
286
287    private boolean buildReportEditorEnabled = false; // when true use text editor to view build report
288    private boolean buildReportIndentEnabled = true; // when true use text editor to view build report
289    private boolean buildReportAlwaysPreviewEnabled = false; // when true use text editor to view build report
290
291    private boolean enableTrainIconXY = true;
292    private boolean appendTrainIcon = false; // when true, append engine number to train name
293    private String setupComment = NONE;
294
295    private boolean mainMenuEnabled = false; // when true add operations menu to main menu bar
296    private boolean closeWindowOnSave = false; // when true, close window when save button is activated
297    private boolean autoSave = true; // when true, automatically save files if modified
298    private boolean autoBackup = true; // when true, automatically backup files
299    private boolean enableValue = false; // when true show value fields for rolling stock
300    private String labelValue = Bundle.getMessage("Value");
301    private boolean enableRfid = false; // when true show RFID fields for rolling stock
302    private String labelRfid = Bundle.getMessage("RFID");
303
304    private boolean carRoutingEnabled = true; // when true enable car routing
305    private boolean carRoutingYards = false; // when true enable car routing via yard tracks
306    private boolean carRoutingStaging = false; // when true staging tracks can be used for car routing
307    private boolean forwardToYardEnabled = true; // when true forward car to yard if track is full
308    private boolean onlyActiveTrains = false; // when true only active trains are used for routing
309    private boolean checkCarDestination = false; // when true check car's track for valid destination
310
311    private boolean carLogger = false; // when true car logger is enabled
312    private boolean engineLogger = false; // when true engine logger is enabled
313    private boolean trainLogger = false; // when true train logger is enabled
314    private boolean saveTrainManifests = false; // when true save previous train manifest
315
316    private boolean aggressiveBuild = false; // when true subtract car length from track reserve length
317    private int numberPasses = 2; // the number of passes in train builder
318    private boolean onTimeBuild = false;    // when true on time mode
319    private int dwellTime = 60; // time in minutes before allowing track reuse
320    private boolean allowLocalInterchangeMoves = false; // when true local C/I to C/I moves are allowed
321    private boolean allowLocalYardMoves = false; // when true local yard to yard moves are allowed
322    private boolean allowLocalSpurMoves = false; // when true local spur to spur moves are allowed
323
324    private boolean trainIntoStagingCheck = true; // staging track must accept train's rolling stock types and roads
325    private boolean trackImmediatelyAvail = false; // when true staging track is available for other trains
326    private boolean allowCarsReturnStaging = false; // allow cars on a turn to return to staging if necessary (prevent
327                                                    // build failure)
328    private boolean promptFromStaging = false; // prompt user to specify which departure staging track to use
329    private boolean promptToStaging = false; // prompt user to specify which arrival staging track to use
330    private boolean tryNormalModeStaging = true; // try normal build if route length failure using aggressive
331
332    private boolean generateCsvManifest = false; // when true generate csv manifest
333    private boolean generateCsvSwitchList = false; // when true generate csv switch list
334    private boolean enableVsdPhysicalLocations = false;
335
336    private boolean printLocationComments = false; // when true print location comments on the manifest
337    private boolean printRouteComments = false; // when true print route comments on the manifest
338    private boolean printLoadsAndEmpties = false; // when true print Loads and Empties on the manifest
339    private boolean printTrainScheduleName = false; // when true print train schedule name on manifests and switch lists
340    private boolean use12hrFormat = false; // when true use 12hr rather than 24hr format
341    private boolean printValid = true; // when true print out the valid time and date
342    private boolean sortByTrack = false; // when true manifest work is sorted by track names
343    private boolean printHeaders = false; // when true add headers to manifest and switch lists
344    private boolean printNoPageBreaks = true; // when true no page breaks for a location's work
345    private boolean printHeaderLine1 = true; // when true add header line 1 to manifest and switch lists
346    private boolean printHeaderLine2 = true; // when true add header line 2 to manifest and switch lists
347    private boolean printHeaderLine3 = true; // when true add header line 3 to manifest and switch lists
348
349    private boolean printCabooseLoad = false; // when true print caboose load
350    private boolean printPassengerLoad = false; // when true print passenger car load
351    private boolean showTrackMoves = false; // when true show track moves in table
352    
353    private Hashtable<String, String> hashTableDayToName = new Hashtable<>();
354
355    // property changes
356    public static final String SWITCH_LIST_CSV_PROPERTY_CHANGE = "setupSwitchListCSVChange"; // NOI18N
357    public static final String MANIFEST_CSV_PROPERTY_CHANGE = "setupManifestCSVChange"; // NOI18N
358    public static final String REAL_TIME_PROPERTY_CHANGE = "setupSwitchListRealTime"; // NOI18N
359    public static final String SHOW_TRACK_MOVES_PROPERTY_CHANGE = "setupShowTrackMoves"; // NOI18N
360    public static final String SAVE_TRAIN_MANIFEST_PROPERTY_CHANGE = "saveTrainManifestChange"; // NOI18N
361    public static final String ALLOW_CARS_TO_RETURN_PROPERTY_CHANGE = "allowCarsToReturnChange"; // NOI18N
362    public static final String TRAIN_DIRECTION_PROPERTY_CHANGE = "setupTrainDirectionChange"; // NOI18N
363    public static final String ROUTING_STAGING_PROPERTY_CHANGE = "setupRoutingStagingChange"; // NOI18N
364    public static final String TRAVEL_TIME_PROPERTY_CHANGE = "setupTravelTimeChange"; // NOI18N
365
366    public static boolean isMainMenuEnabled() {
367        InstanceManager.getDefault(OperationsSetupXml.class); // load file
368        return getDefault().mainMenuEnabled;
369    }
370
371    public static void setMainMenuEnabled(boolean enabled) {
372        getDefault().mainMenuEnabled = enabled;
373    }
374
375    public static boolean isCloseWindowOnSaveEnabled() {
376        return getDefault().closeWindowOnSave;
377    }
378
379    public static void setCloseWindowOnSaveEnabled(boolean enabled) {
380        getDefault().closeWindowOnSave = enabled;
381    }
382
383    public static boolean isAutoSaveEnabled() {
384        return getDefault().autoSave;
385    }
386
387    public static void setAutoSaveEnabled(boolean enabled) {
388        getDefault().autoSave = enabled;
389        if (enabled) {
390            AutoSave.start();
391        } else {
392            AutoSave.stop();
393        }
394    }
395
396    public static boolean isAutoBackupEnabled() {
397        return getDefault().autoBackup;
398    }
399
400    public static void setAutoBackupEnabled(boolean enabled) {
401        // Do an autoBackup only if we are changing the setting from false to
402        // true.
403        if (enabled && !getDefault().autoBackup) {
404            try {
405                InstanceManager.getDefault(AutoBackup.class).autoBackup();
406            } catch (IOException ex) {
407                log.debug("Autobackup after setting AutoBackup flag true", ex);
408            }
409        }
410
411        getDefault().autoBackup = enabled;
412    }
413
414    public static boolean isValueEnabled() {
415        return getDefault().enableValue;
416    }
417
418    public static void setValueEnabled(boolean enabled) {
419        getDefault().enableValue = enabled;
420    }
421
422    public static String getValueLabel() {
423        return getDefault().labelValue;
424    }
425
426    public static void setValueLabel(String label) {
427        getDefault().labelValue = label;
428    }
429
430    public static boolean isRfidEnabled() {
431        return getDefault().enableRfid;
432    }
433
434    public static void setRfidEnabled(boolean enabled) {
435        getDefault().enableRfid = enabled;
436    }
437
438    public static String getRfidLabel() {
439        return getDefault().labelRfid;
440    }
441
442    public static void setRfidLabel(String label) {
443        getDefault().labelRfid = label;
444    }
445
446    public static boolean isCarRoutingEnabled() {
447        return getDefault().carRoutingEnabled;
448    }
449
450    public static void setCarRoutingEnabled(boolean enabled) {
451        getDefault().carRoutingEnabled = enabled;
452    }
453
454    public static boolean isCarRoutingViaYardsEnabled() {
455        return getDefault().carRoutingYards;
456    }
457
458    public static void setCarRoutingViaYardsEnabled(boolean enabled) {
459        getDefault().carRoutingYards = enabled;
460    }
461
462    public static boolean isCarRoutingViaStagingEnabled() {
463        return getDefault().carRoutingStaging;
464    }
465
466    public static void setCarRoutingViaStagingEnabled(boolean enabled) {
467        boolean old = isCarRoutingViaStagingEnabled();
468        getDefault().carRoutingStaging = enabled;
469        setDirtyAndFirePropertyChange(ROUTING_STAGING_PROPERTY_CHANGE, old, enabled);
470    }
471
472    public static boolean isForwardToYardEnabled() {
473        return getDefault().forwardToYardEnabled;
474    }
475
476    public static void setForwardToYardEnabled(boolean enabled) {
477        getDefault().forwardToYardEnabled = enabled;
478    }
479
480    public static boolean isOnlyActiveTrainsEnabled() {
481        return getDefault().onlyActiveTrains;
482    }
483
484    public static void setOnlyActiveTrainsEnabled(boolean enabled) {
485        getDefault().onlyActiveTrains = enabled;
486    }
487
488    /**
489     * When true, router checks that the car's destination is serviced by departure
490     * track. Very restrictive, not recommended.
491     * 
492     * @return true if enabled.
493     */
494    public static boolean isCheckCarDestinationEnabled() {
495        return getDefault().checkCarDestination;
496    }
497
498    public static void setCheckCarDestinationEnabled(boolean enabled) {
499        getDefault().checkCarDestination = enabled;
500    }
501
502    public static boolean isBuildAggressive() {
503        return getDefault().aggressiveBuild;
504    }
505
506    public static void setBuildAggressive(boolean enabled) {
507        getDefault().aggressiveBuild = enabled;
508    }
509
510    public static int getNumberPasses() {
511        return getDefault().numberPasses;
512    }
513
514    public static void setNumberPasses(int number) {
515        getDefault().numberPasses = number;
516    }
517    
518    public static boolean isBuildOnTime() {
519        return getDefault().onTimeBuild;
520    }
521
522    public static void setBuildOnTime(boolean enabled) {
523        getDefault().onTimeBuild = enabled;
524    }
525    
526    public static int getDwellTime() {
527        return getDefault().dwellTime;
528    }
529
530    public static void setDwellTime(int minutes) {
531        getDefault().dwellTime = minutes;
532    }
533
534    public static boolean isLocalInterchangeMovesEnabled() {
535        return getDefault().allowLocalInterchangeMoves;
536    }
537
538    public static void setLocalInterchangeMovesEnabled(boolean enabled) {
539        getDefault().allowLocalInterchangeMoves = enabled;
540    }
541
542    public static boolean isLocalYardMovesEnabled() {
543        return getDefault().allowLocalYardMoves;
544    }
545
546    public static void setLocalYardMovesEnabled(boolean enabled) {
547        getDefault().allowLocalYardMoves = enabled;
548    }
549
550    public static boolean isLocalSpurMovesEnabled() {
551        return getDefault().allowLocalSpurMoves;
552    }
553
554    public static void setLocalSpurMovesEnabled(boolean enabled) {
555        getDefault().allowLocalSpurMoves = enabled;
556    }
557
558    public static boolean isStagingTrainCheckEnabled() {
559        return getDefault().trainIntoStagingCheck;
560    }
561
562    /**
563     * Controls staging track selection, when true, the terminus staging track has
564     * to have the same characteristics as the train.
565     *
566     * @param enabled when true, the terminal staging track must service the same
567     *                car types, loads, etc. as the train
568     */
569    public static void setStagingTrainCheckEnabled(boolean enabled) {
570        getDefault().trainIntoStagingCheck = enabled;
571    }
572
573    public static boolean isStagingTrackImmediatelyAvail() {
574        return getDefault().trackImmediatelyAvail;
575    }
576
577    public static void setStagingTrackImmediatelyAvail(boolean enabled) {
578        getDefault().trackImmediatelyAvail = enabled;
579    }
580
581    /**
582     * allow cars to return to the same staging location if no other options
583     * (tracks) are available. Also available on a per train basis.
584     * 
585     * @return true if cars are allowed to depart and return to same staging
586     *         location
587     */
588    public static boolean isStagingAllowReturnEnabled() {
589        return getDefault().allowCarsReturnStaging;
590    }
591
592    public static void setStagingAllowReturnEnabled(boolean enabled) {
593        boolean old = getDefault().allowCarsReturnStaging;
594        getDefault().allowCarsReturnStaging = enabled;
595        setDirtyAndFirePropertyChange(ALLOW_CARS_TO_RETURN_PROPERTY_CHANGE, old, enabled);
596    }
597
598    public static boolean isStagingPromptFromEnabled() {
599        return getDefault().promptFromStaging;
600    }
601
602    public static void setStagingPromptFromEnabled(boolean enabled) {
603        getDefault().promptFromStaging = enabled;
604    }
605
606    public static boolean isStagingPromptToEnabled() {
607        return getDefault().promptToStaging;
608    }
609
610    public static void setStagingPromptToEnabled(boolean enabled) {
611        getDefault().promptToStaging = enabled;
612    }
613
614    public static boolean isStagingTryNormalBuildEnabled() {
615        return getDefault().tryNormalModeStaging;
616    }
617
618    public static void setStagingTryNormalBuildEnabled(boolean enabled) {
619        getDefault().tryNormalModeStaging = enabled;
620    }
621
622    public static boolean isGenerateCsvManifestEnabled() {
623        return getDefault().generateCsvManifest;
624    }
625
626    public static void setGenerateCsvManifestEnabled(boolean enabled) {
627        boolean old = getDefault().generateCsvManifest;
628        getDefault().generateCsvManifest = enabled;
629        if (enabled && !old) {
630            InstanceManager.getDefault(TrainManagerXml.class).createDefaultCsvManifestDirectory();
631        }
632        setDirtyAndFirePropertyChange(MANIFEST_CSV_PROPERTY_CHANGE, old, enabled);
633    }
634
635    public static boolean isGenerateCsvSwitchListEnabled() {
636        return getDefault().generateCsvSwitchList;
637    }
638
639    public static void setGenerateCsvSwitchListEnabled(boolean enabled) {
640        boolean old = getDefault().generateCsvSwitchList;
641        getDefault().generateCsvSwitchList = enabled;
642        if (enabled && !old) {
643            InstanceManager.getDefault(TrainManagerXml.class).createDefaultCsvSwitchListDirectory();
644        }
645        setDirtyAndFirePropertyChange(SWITCH_LIST_CSV_PROPERTY_CHANGE, old, enabled);
646    }
647
648    public static boolean isVsdPhysicalLocationEnabled() {
649        return getDefault().enableVsdPhysicalLocations;
650    }
651
652    public static void setVsdPhysicalLocationEnabled(boolean enabled) {
653        getDefault().enableVsdPhysicalLocations = enabled;
654    }
655
656    public static String getRailroadName() {
657        if (getDefault().railroadName.isEmpty()) {
658            return InstanceManager.getDefault(WebServerPreferences.class).getRailroadName();
659        }
660        return getDefault().railroadName;
661    }
662
663    public static void setRailroadName(String name) {
664        String old = getDefault().railroadName;
665        getDefault().railroadName = name;
666        if (old == null || !old.equals(name)) {
667            setDirtyAndFirePropertyChange("Railroad Name Change", old, name); // NOI18N
668        }
669    }
670
671    public static String getHazardousMsg() {
672        return getDefault().hazardousMsg;
673    }
674
675    public static void setHazardousMsg(String message) {
676        getDefault().hazardousMsg = message;
677    }
678
679    public static String getMiaComment() {
680        return getDefault().miaComment;
681    }
682
683    public static void setMiaComment(String comment) {
684        getDefault().miaComment = comment;
685    }
686
687    public static void setTrainDirection(int direction) {
688        int old = getDefault().traindir;
689        getDefault().traindir = direction;
690        if (old != direction) {
691            setDirtyAndFirePropertyChange(TRAIN_DIRECTION_PROPERTY_CHANGE, old, direction);
692        }
693    }
694
695    public static int getTrainDirection() {
696        return getDefault().traindir;
697    }
698
699    public static void setMaxTrainLength(int length) {
700        getDefault().maxTrainLength = length;
701    }
702
703    public static int getMaxTrainLength() {
704        return getDefault().maxTrainLength;
705    }
706
707    public static void setMaxNumberEngines(int value) {
708        getDefault().maxEngineSize = value;
709    }
710
711    public static int getMaxNumberEngines() {
712        return getDefault().maxEngineSize;
713    }
714
715    public static void setHorsePowerPerTon(double value) {
716        getDefault().horsePowerPerTon = value;
717    }
718
719    public static double getHorsePowerPerTon() {
720        return getDefault().horsePowerPerTon;
721    }
722
723    public static void setCarMoves(int moves) {
724        getDefault().carMoves = moves;
725    }
726
727    public static int getCarMoves() {
728        return getDefault().carMoves;
729    }
730
731    public static String getPanelName() {
732        return getDefault().panelName;
733    }
734
735    public static void setPanelName(String name) {
736        getDefault().panelName = name;
737    }
738
739    public static String getLengthUnit() {
740        return getDefault().lengthUnit;
741    }
742
743    /**
744     * Abbreviation unit of length
745     * 
746     * @return symbol for feet or meter
747     */
748    public static String getLengthUnitAbv() {
749        return getDefault().lengthUnitAbv;
750    }
751
752    public static void setLengthUnit(String unit) {
753        getDefault().lengthUnit = unit;
754        if (unit.equals(FEET)) {
755            getDefault().lengthUnitAbv = FEET_ABV;
756        } else {
757            getDefault().lengthUnitAbv = METER_ABV;
758        }
759    }
760
761    public static String getYearModeled() {
762        return getDefault().yearModeled;
763    }
764
765    public static void setYearModeled(String year) {
766        getDefault().yearModeled = year;
767    }
768
769    public static String getCarTypes() {
770        return getDefault().carTypes;
771    }
772
773    public static void setCarTypes(String types) {
774        getDefault().carTypes = types;
775    }
776
777    public static void setTrainIconCordEnabled(boolean enable) {
778        getDefault().enableTrainIconXY = enable;
779    }
780
781    public static boolean isTrainIconCordEnabled() {
782        return getDefault().enableTrainIconXY;
783    }
784
785    public static void setTrainIconAppendEnabled(boolean enable) {
786        getDefault().appendTrainIcon = enable;
787    }
788
789    public static boolean isTrainIconAppendEnabled() {
790        return getDefault().appendTrainIcon;
791    }
792
793    public static void setComment(String comment) {
794        getDefault().setupComment = comment;
795    }
796
797    public static String getComment() {
798        return getDefault().setupComment;
799    }
800
801    public static void setBuildReportLevel(String level) {
802        getDefault().buildReportLevel = level;
803    }
804
805    public static String getBuildReportLevel() {
806        return getDefault().buildReportLevel;
807    }
808
809    /**
810     * Sets the report level for the car router.
811     * 
812     * @param level BUILD_REPORT_NORMAL, BUILD_REPORT_DETAILED,
813     *              BUILD_REPORT_VERY_DETAILED
814     */
815    public static void setRouterBuildReportLevel(String level) {
816        getDefault().routerBuildReportLevel = level;
817    }
818
819    public static String getRouterBuildReportLevel() {
820        return getDefault().routerBuildReportLevel;
821    }
822
823    public static void setManifestEditorEnabled(boolean enable) {
824        getDefault().manifestEditorEnabled = enable;
825    }
826
827    public static boolean isManifestEditorEnabled() {
828        return getDefault().manifestEditorEnabled;
829    }
830
831    public static void setBuildReportEditorEnabled(boolean enable) {
832        getDefault().buildReportEditorEnabled = enable;
833    }
834
835    public static boolean isBuildReportEditorEnabled() {
836        return getDefault().buildReportEditorEnabled;
837    }
838
839    public static void setBuildReportIndentEnabled(boolean enable) {
840        getDefault().buildReportIndentEnabled = enable;
841    }
842
843    public static boolean isBuildReportIndentEnabled() {
844        return getDefault().buildReportIndentEnabled;
845    }
846
847    public static void setBuildReportAlwaysPreviewEnabled(boolean enable) {
848        getDefault().buildReportAlwaysPreviewEnabled = enable;
849    }
850
851    public static boolean isBuildReportAlwaysPreviewEnabled() {
852        return getDefault().buildReportAlwaysPreviewEnabled;
853    }
854
855    public static void setSwitchListFormatSameAsManifest(boolean b) {
856        getDefault().switchListSameManifest = b;
857    }
858
859    public static boolean isSwitchListFormatSameAsManifest() {
860        return getDefault().switchListSameManifest;
861    }
862
863    public static void setPrintTrackSummaryEnabled(boolean b) {
864        getDefault().trackSummary = b;
865    }
866
867    public static boolean isPrintTrackSummaryEnabled() {
868        return getDefault().trackSummary;
869    }
870
871    public static void setSwitchListRouteLocationCommentEnabled(boolean b) {
872        getDefault().switchListRouteComment = b;
873    }
874
875    public static boolean isSwitchListRouteLocationCommentEnabled() {
876        return getDefault().switchListRouteComment;
877    }
878
879    public static void setGroupCarMoves(boolean b) {
880        getDefault().groupCarMoves = b;
881    }
882
883    public static boolean isGroupCarMovesEnabled() {
884        return getDefault().groupCarMoves;
885    }
886
887    public static void setPrintLocoLast(boolean b) {
888        getDefault().locoLast = b;
889    }
890
891    public static boolean isPrintLocoLastEnabled() {
892        return getDefault().locoLast;
893    }
894
895    public static void setSwitchListRealTime(boolean b) {
896        boolean old = getDefault().switchListRealTime;
897        getDefault().switchListRealTime = b;
898        setDirtyAndFirePropertyChange(REAL_TIME_PROPERTY_CHANGE, old, b);
899    }
900
901    public static boolean isSwitchListRealTime() {
902        return getDefault().switchListRealTime;
903    }
904
905    public static void setSwitchListAllTrainsEnabled(boolean b) {
906        boolean old = getDefault().switchListAllTrains;
907        getDefault().switchListAllTrains = b;
908        setDirtyAndFirePropertyChange("Switch List All Trains", old, b); // NOI18N
909    }
910
911    /**
912     * When true switch list shows all trains visiting a location, even if the train
913     * doesn't have any work at that location. When false, switch lists only report
914     * a train if it has work at the location.
915     *
916     * @return When true show all trains visiting a location.
917     */
918    public static boolean isSwitchListAllTrainsEnabled() {
919        return getDefault().switchListAllTrains;
920    }
921
922    /**
923     * Used to determine if there's spaces or form feed between trains and locations
924     * when printing switch lists. see getSwitchListPageFormatComboBox()
925     *
926     * @param format PAGE_NORMAL, PAGE_PER_TRAIN, or PAGE_PER_VISIT
927     */
928    public static void setSwitchListPageFormat(String format) {
929        getDefault().switchListPageFormat = format;
930    }
931
932    public static String getSwitchListPageFormat() {
933        return getDefault().switchListPageFormat;
934    }
935
936    public static void setPrintTruncateManifestEnabled(boolean b) {
937        getDefault().manifestTruncated = b;
938    }
939
940    public static boolean isPrintTruncateManifestEnabled() {
941        return getDefault().manifestTruncated;
942    }
943
944    public static void setUseDepartureTimeEnabled(boolean b) {
945        getDefault().manifestDepartureTime = b;
946    }
947
948    public static boolean isUseDepartureTimeEnabled() {
949        return getDefault().manifestDepartureTime;
950    }
951
952    public static void setUseSwitchListDepartureTimeEnabled(boolean b) {
953        getDefault().switchListDepartureTime = b;
954    }
955
956    public static boolean isUseSwitchListDepartureTimeEnabled() {
957        return getDefault().switchListDepartureTime;
958    }
959
960    public static void setPrintLocationCommentsEnabled(boolean enable) {
961        getDefault().printLocationComments = enable;
962    }
963
964    public static boolean isPrintLocationCommentsEnabled() {
965        return getDefault().printLocationComments;
966    }
967
968    public static void setPrintRouteCommentsEnabled(boolean enable) {
969        getDefault().printRouteComments = enable;
970    }
971
972    public static boolean isPrintRouteCommentsEnabled() {
973        return getDefault().printRouteComments;
974    }
975
976    public static void setPrintLoadsAndEmptiesEnabled(boolean enable) {
977        getDefault().printLoadsAndEmpties = enable;
978    }
979
980    public static boolean isPrintLoadsAndEmptiesEnabled() {
981        return getDefault().printLoadsAndEmpties;
982    }
983
984    public static void setPrintTrainScheduleNameEnabled(boolean enable) {
985        getDefault().printTrainScheduleName = enable;
986    }
987
988    public static boolean isPrintTrainScheduleNameEnabled() {
989        return getDefault().printTrainScheduleName;
990    }
991
992    public static void set12hrFormatEnabled(boolean enable) {
993        getDefault().use12hrFormat = enable;
994    }
995
996    public static boolean is12hrFormatEnabled() {
997        return getDefault().use12hrFormat;
998    }
999
1000    public static void setPrintValidEnabled(boolean enable) {
1001        getDefault().printValid = enable;
1002    }
1003
1004    public static boolean isPrintValidEnabled() {
1005        return getDefault().printValid;
1006    }
1007
1008    public static void setSortByTrackNameEnabled(boolean enable) {
1009        getDefault().sortByTrack = enable;
1010    }
1011
1012    /**
1013     * when true manifest work is sorted by track names.
1014     * 
1015     * @return true if work at a location is to be sorted by track names.
1016     */
1017    public static boolean isSortByTrackNameEnabled() {
1018        return getDefault().sortByTrack;
1019    }
1020
1021    public static void setPrintHeadersEnabled(boolean enable) {
1022        getDefault().printHeaders = enable;
1023    }
1024
1025    public static boolean isPrintHeadersEnabled() {
1026        return getDefault().printHeaders;
1027    }
1028
1029    public static void setPrintNoPageBreaksEnabled(boolean enable) {
1030        getDefault().printNoPageBreaks = enable;
1031    }
1032
1033    public static boolean isPrintNoPageBreaksEnabled() {
1034        return getDefault().printNoPageBreaks;
1035    }
1036
1037    public static void setPrintHeaderLine1Enabled(boolean enable) {
1038        getDefault().printHeaderLine1 = enable;
1039    }
1040
1041    public static boolean isPrintHeaderLine1Enabled() {
1042        return getDefault().printHeaderLine1;
1043    }
1044
1045    public static void setPrintHeaderLine2Enabled(boolean enable) {
1046        getDefault().printHeaderLine2 = enable;
1047    }
1048
1049    public static boolean isPrintHeaderLine2Enabled() {
1050        return getDefault().printHeaderLine2;
1051    }
1052
1053    public static void setPrintHeaderLine3Enabled(boolean enable) {
1054        getDefault().printHeaderLine3 = enable;
1055    }
1056
1057    public static boolean isPrintHeaderLine3Enabled() {
1058        return getDefault().printHeaderLine3;
1059    }
1060
1061    public static void setPrintCabooseLoadEnabled(boolean enable) {
1062        getDefault().printCabooseLoad = enable;
1063    }
1064
1065    public static boolean isPrintCabooseLoadEnabled() {
1066        return getDefault().printCabooseLoad;
1067    }
1068
1069    public static void setPrintPassengerLoadEnabled(boolean enable) {
1070        getDefault().printPassengerLoad = enable;
1071    }
1072
1073    public static boolean isPrintPassengerLoadEnabled() {
1074        return getDefault().printPassengerLoad;
1075    }
1076
1077    public static void setShowTrackMovesEnabled(boolean enable) {
1078        boolean old = getDefault().showTrackMoves;
1079        getDefault().showTrackMoves = enable;
1080        setDirtyAndFirePropertyChange(SHOW_TRACK_MOVES_PROPERTY_CHANGE, old, enable);
1081    }
1082
1083    public static boolean isShowTrackMovesEnabled() {
1084        return getDefault().showTrackMoves;
1085    }
1086
1087    public static void setSwitchTime(int minutes) {
1088        getDefault().carSwitchTime = minutes;
1089    }
1090
1091    public static int getSwitchTime() {
1092        return getDefault().carSwitchTime;
1093    }
1094
1095    public static void setTravelTime(int minutes) {
1096        int old = getTravelTime();
1097        getDefault().travelTime = minutes;
1098        setDirtyAndFirePropertyChange(TRAVEL_TIME_PROPERTY_CHANGE, old, minutes);
1099    }
1100
1101    public static int getTravelTime() {
1102        return getDefault().travelTime;
1103    }
1104
1105    public static void setTrainIconColorNorth(String color) {
1106        getDefault().iconNorthColor = color;
1107    }
1108
1109    public static String getTrainIconColorNorth() {
1110        return getDefault().iconNorthColor;
1111    }
1112
1113    public static void setTrainIconColorSouth(String color) {
1114        getDefault().iconSouthColor = color;
1115    }
1116
1117    public static String getTrainIconColorSouth() {
1118        return getDefault().iconSouthColor;
1119    }
1120
1121    public static void setTrainIconColorEast(String color) {
1122        getDefault().iconEastColor = color;
1123    }
1124
1125    public static String getTrainIconColorEast() {
1126        return getDefault().iconEastColor;
1127    }
1128
1129    public static void setTrainIconColorWest(String color) {
1130        getDefault().iconWestColor = color;
1131    }
1132
1133    public static String getTrainIconColorWest() {
1134        return getDefault().iconWestColor;
1135    }
1136
1137    public static void setTrainIconColorLocal(String color) {
1138        getDefault().iconLocalColor = color;
1139    }
1140
1141    public static String getTrainIconColorLocal() {
1142        return getDefault().iconLocalColor;
1143    }
1144
1145    public static void setTrainIconColorTerminate(String color) {
1146        getDefault().iconTerminateColor = color;
1147    }
1148
1149    public static String getTrainIconColorTerminate() {
1150        return getDefault().iconTerminateColor;
1151    }
1152
1153    public static String getFontName() {
1154        return getDefault().fontName;
1155    }
1156
1157    public static void setFontName(String name) {
1158        getDefault().fontName = name;
1159    }
1160
1161    public static int getManifestFontSize() {
1162        return getDefault().manifestFontSize;
1163    }
1164
1165    public static void setManifestFontSize(int size) {
1166        getDefault().manifestFontSize = size;
1167    }
1168
1169    public static SidesType getPrintDuplexSides() {
1170        return getDefault().sidesType;
1171    }
1172
1173    public static void setPrintDuplexSides(SidesType sidesType) {
1174        getDefault().sidesType = sidesType;
1175    }
1176
1177    public static boolean isPrintPageHeaderEnabled() {
1178        return getDefault().printHeader;
1179    }
1180
1181    public static void setPrintPageHeaderEnabled(boolean enable) {
1182        getDefault().printHeader = enable;
1183    }
1184
1185    public static int getBuildReportFontSize() {
1186        return getDefault().buildReportFontSize;
1187    }
1188
1189    public static void setBuildReportFontSize(int size) {
1190        getDefault().buildReportFontSize = size;
1191    }
1192
1193    public static String getManifestOrientation() {
1194        return getDefault().manifestOrientation;
1195    }
1196
1197    public static void setManifestOrientation(String orientation) {
1198        getDefault().manifestOrientation = orientation;
1199    }
1200
1201    public static String getSwitchListOrientation() {
1202        if (isSwitchListFormatSameAsManifest()) {
1203            return getDefault().manifestOrientation;
1204        } else {
1205            return getDefault().switchListOrientation;
1206        }
1207    }
1208
1209    public static void setSwitchListOrientation(String orientation) {
1210        getDefault().switchListOrientation = orientation;
1211    }
1212
1213    public static boolean isTabEnabled() {
1214        return getDefault().tab;
1215    }
1216
1217    public static void setTabEnabled(boolean enable) {
1218        getDefault().tab = enable;
1219    }
1220
1221    public static int getTab1Length() {
1222        return getDefault().tab1CharLength;
1223    }
1224
1225    public static void setTab1length(int length) {
1226        getDefault().tab1CharLength = length;
1227    }
1228
1229    public static int getTab2Length() {
1230        return getDefault().tab2CharLength;
1231    }
1232
1233    public static void setTab2length(int length) {
1234        getDefault().tab2CharLength = length;
1235    }
1236
1237    public static int getTab3Length() {
1238        return getDefault().tab3CharLength;
1239    }
1240
1241    public static void setTab3length(int length) {
1242        getDefault().tab3CharLength = length;
1243    }
1244
1245    public static String getManifestFormat() {
1246        return getDefault().manifestFormat;
1247    }
1248
1249    /**
1250     * Sets the format for manifests
1251     * 
1252     * @param format STANDARD_FORMAT, TWO_COLUMN_FORMAT, or TWO_COLUMN_TRACK_FORMAT
1253     */
1254    public static void setManifestFormat(String format) {
1255        getDefault().manifestFormat = format;
1256    }
1257
1258    public static boolean isCarLoggerEnabled() {
1259        return getDefault().carLogger;
1260    }
1261
1262    public static void setCarLoggerEnabled(boolean enable) {
1263        getDefault().carLogger = enable;
1264        InstanceManager.getDefault(RollingStockLogger.class).enableCarLogging(enable);
1265    }
1266
1267    public static boolean isEngineLoggerEnabled() {
1268        return getDefault().engineLogger;
1269    }
1270
1271    public static void setEngineLoggerEnabled(boolean enable) {
1272        getDefault().engineLogger = enable;
1273        InstanceManager.getDefault(RollingStockLogger.class).enableEngineLogging(enable);
1274    }
1275
1276    public static boolean isTrainLoggerEnabled() {
1277        return getDefault().trainLogger;
1278    }
1279
1280    public static void setTrainLoggerEnabled(boolean enable) {
1281        getDefault().trainLogger = enable;
1282        InstanceManager.getDefault(TrainLogger.class).enableTrainLogging(enable);
1283    }
1284
1285    public static boolean isSaveTrainManifestsEnabled() {
1286        return getDefault().saveTrainManifests;
1287    }
1288
1289    public static void setSaveTrainManifestsEnabled(boolean enable) {
1290        boolean old = getDefault().saveTrainManifests;
1291        getDefault().saveTrainManifests = enable;
1292        setDirtyAndFirePropertyChange(SAVE_TRAIN_MANIFEST_PROPERTY_CHANGE, old, enable);
1293    }
1294
1295    public static String getPickupEnginePrefix() {
1296        return getDefault().pickupEnginePrefix;
1297    }
1298
1299    public static void setPickupEnginePrefix(String prefix) {
1300        getDefault().pickupEnginePrefix = prefix;
1301    }
1302
1303    public static String getDropEnginePrefix() {
1304        return getDefault().dropEnginePrefix;
1305    }
1306
1307    public static void setDropEnginePrefix(String prefix) {
1308        getDefault().dropEnginePrefix = prefix;
1309    }
1310
1311    public static String getPickupCarPrefix() {
1312        return getDefault().pickupCarPrefix;
1313    }
1314
1315    public static void setPickupCarPrefix(String prefix) {
1316        getDefault().pickupCarPrefix = prefix;
1317    }
1318
1319    public static String getDropCarPrefix() {
1320        return getDefault().dropCarPrefix;
1321    }
1322
1323    public static void setDropCarPrefix(String prefix) {
1324        getDefault().dropCarPrefix = prefix;
1325    }
1326
1327    public static String getLocalPrefix() {
1328        return getDefault().localPrefix;
1329    }
1330
1331    public static void setLocalPrefix(String prefix) {
1332        getDefault().localPrefix = prefix;
1333    }
1334
1335    public static int getManifestPrefixLength() {
1336        int maxLength = getPickupEnginePrefix().length();
1337        if (getDropEnginePrefix().length() > maxLength) {
1338            maxLength = getDropEnginePrefix().length();
1339        }
1340        if (getPickupCarPrefix().length() > maxLength) {
1341            maxLength = getPickupCarPrefix().length();
1342        }
1343        if (getDropCarPrefix().length() > maxLength) {
1344            maxLength = getDropCarPrefix().length();
1345        }
1346        if (getLocalPrefix().length() > maxLength) {
1347            maxLength = getLocalPrefix().length();
1348        }
1349        return maxLength;
1350    }
1351
1352    public static String getSwitchListPickupCarPrefix() {
1353        if (isSwitchListFormatSameAsManifest()) {
1354            return getDefault().pickupCarPrefix;
1355        } else {
1356            return getDefault().switchListPickupCarPrefix;
1357        }
1358    }
1359
1360    public static void setSwitchListPickupCarPrefix(String prefix) {
1361        getDefault().switchListPickupCarPrefix = prefix;
1362    }
1363
1364    public static String getSwitchListDropCarPrefix() {
1365        if (isSwitchListFormatSameAsManifest()) {
1366            return getDefault().dropCarPrefix;
1367        } else {
1368            return getDefault().switchListDropCarPrefix;
1369        }
1370    }
1371
1372    public static void setSwitchListDropCarPrefix(String prefix) {
1373        getDefault().switchListDropCarPrefix = prefix;
1374    }
1375
1376    public static String getSwitchListLocalPrefix() {
1377        if (isSwitchListFormatSameAsManifest()) {
1378            return getDefault().localPrefix;
1379        } else {
1380            return getDefault().switchListLocalPrefix;
1381        }
1382    }
1383
1384    public static void setSwitchListLocalPrefix(String prefix) {
1385        getDefault().switchListLocalPrefix = prefix;
1386    }
1387
1388    public static int getSwitchListPrefixLength() {
1389        int maxLength = getPickupEnginePrefix().length();
1390        if (getDropEnginePrefix().length() > maxLength) {
1391            maxLength = getDropEnginePrefix().length();
1392        }
1393        if (getSwitchListPickupCarPrefix().length() > maxLength) {
1394            maxLength = getSwitchListPickupCarPrefix().length();
1395        }
1396        if (getSwitchListDropCarPrefix().length() > maxLength) {
1397            maxLength = getSwitchListDropCarPrefix().length();
1398        }
1399        if (getSwitchListLocalPrefix().length() > maxLength) {
1400            maxLength = getSwitchListLocalPrefix().length();
1401        }
1402        return maxLength;
1403    }
1404
1405    public static String[] getEngineAttributes() {
1406        return ENGINE_ATTRIBUTES.clone();
1407    }
1408
1409    public static String[] getPickupEngineMessageFormat() {
1410        return getDefault().pickupEngineMessageFormat.clone();
1411    }
1412
1413    public static void setPickupEngineMessageFormat(String[] format) {
1414        getDefault().pickupEngineMessageFormat = format;
1415    }
1416
1417    public static String[] getDropEngineMessageFormat() {
1418        return getDefault().dropEngineMessageFormat.clone();
1419    }
1420
1421    public static void setDropEngineMessageFormat(String[] format) {
1422        getDefault().dropEngineMessageFormat = format;
1423    }
1424
1425    public static String[] getCarAttributes() {
1426        return CAR_ATTRIBUTES.clone();
1427    }
1428
1429    public static String[] getPickupManifestMessageFormat() {
1430        return getDefault().pickupManifestMessageFormat.clone();
1431    }
1432
1433    public static void setPickupManifestMessageFormat(String[] format) {
1434        getDefault().pickupManifestMessageFormat = format;
1435    }
1436
1437    public static String[] getDropManifestMessageFormat() {
1438        return getDefault().dropManifestMessageFormat.clone();
1439    }
1440
1441    public static void setDropManifestMessageFormat(String[] format) {
1442        getDefault().dropManifestMessageFormat = format;
1443    }
1444
1445    public static String[] getLocalManifestMessageFormat() {
1446        return getDefault().localManifestMessageFormat.clone();
1447    }
1448
1449    public static void setLocalManifestMessageFormat(String[] format) {
1450        getDefault().localManifestMessageFormat = format;
1451    }
1452
1453    public static String[] getMissingCarMessageFormat() {
1454        return getDefault().missingCarMessageFormat.clone();
1455    }
1456
1457    public static void setMissingCarMessageFormat(String[] format) {
1458        getDefault().missingCarMessageFormat = format;
1459    }
1460
1461    public static String[] getPickupSwitchListMessageFormat() {
1462        if (isSwitchListFormatSameAsManifest()) {
1463            return getDefault().pickupManifestMessageFormat.clone();
1464        } else {
1465            return getDefault().pickupSwitchListMessageFormat.clone();
1466        }
1467    }
1468
1469    public static void setPickupSwitchListMessageFormat(String[] format) {
1470        getDefault().pickupSwitchListMessageFormat = format;
1471    }
1472
1473    public static String[] getDropSwitchListMessageFormat() {
1474        if (isSwitchListFormatSameAsManifest()) {
1475            return getDefault().dropManifestMessageFormat.clone();
1476        } else {
1477            return getDefault().dropSwitchListMessageFormat.clone();
1478        }
1479    }
1480
1481    public static void setDropSwitchListMessageFormat(String[] format) {
1482        getDefault().dropSwitchListMessageFormat = format;
1483    }
1484
1485    public static String[] getLocalSwitchListMessageFormat() {
1486        if (isSwitchListFormatSameAsManifest()) {
1487            return getDefault().localManifestMessageFormat.clone();
1488        } else {
1489            return getDefault().localSwitchListMessageFormat.clone();
1490        }
1491    }
1492
1493    public static void setLocalSwitchListMessageFormat(String[] format) {
1494        getDefault().localSwitchListMessageFormat = format;
1495    }
1496
1497    /**
1498     * Gets the manifest format for utility cars. The car's road, number, and color
1499     * are not printed.
1500     *
1501     * @return Utility car format
1502     */
1503    public static String[] getPickupUtilityManifestMessageFormat() {
1504        return createUitlityCarMessageFormat(getPickupManifestMessageFormat());
1505    }
1506
1507    public static String[] getDropUtilityManifestMessageFormat() {
1508        return createUitlityCarMessageFormat(getDropManifestMessageFormat());
1509    }
1510
1511    public static String[] getLocalUtilityManifestMessageFormat() {
1512        return createUitlityCarMessageFormat(getLocalManifestMessageFormat());
1513    }
1514
1515    public static String[] getPickupUtilitySwitchListMessageFormat() {
1516        return createUitlityCarMessageFormat(getPickupSwitchListMessageFormat());
1517    }
1518
1519    public static String[] getDropUtilitySwitchListMessageFormat() {
1520        return createUitlityCarMessageFormat(getDropSwitchListMessageFormat());
1521    }
1522
1523    public static String[] getLocalUtilitySwitchListMessageFormat() {
1524        return createUitlityCarMessageFormat(getLocalSwitchListMessageFormat());
1525    }
1526
1527    private static String[] createUitlityCarMessageFormat(String[] format) {
1528        // remove car's road, number, color
1529        for (int i = 0; i < format.length; i++) {
1530            if (format[i].equals(ROAD)) {
1531                format[i] = NO_ROAD;
1532            } else if (format[i].equals(NUMBER)) {
1533                format[i] = NO_NUMBER;
1534            } else if (format[i].equals(COLOR)) {
1535                format[i] = NO_COLOR;
1536            }
1537        }
1538        return format;
1539    }
1540
1541    public static String[] getPickupTruncatedManifestMessageFormat() {
1542        return createTruncatedManifestMessageFormat(getPickupManifestMessageFormat());
1543    }
1544
1545    public static String[] getDropTruncatedManifestMessageFormat() {
1546        return createTruncatedManifestMessageFormat(getDropManifestMessageFormat());
1547    }
1548
1549    public static String[] createTruncatedManifestMessageFormat(String[] format) {
1550        // remove car's destination and location
1551        for (int i = 0; i < format.length; i++) {
1552            if (format[i].equals(DESTINATION)) {
1553                format[i] = NO_DESTINATION;
1554            } else if (format[i].equals(DEST_TRACK)) {
1555                format[i] = NO_DEST_TRACK;
1556            } else if (format[i].equals(LOCATION)) {
1557                format[i] = NO_LOCATION;
1558            } else if (format[i].equals(TRACK)) {
1559                format[i] = NO_TRACK;
1560            }
1561        }
1562        return format;
1563    }
1564
1565    public static String[] getPickupTwoColumnByTrackManifestMessageFormat() {
1566        return createTwoColumnByTrackPickupMessageFormat(getPickupManifestMessageFormat());
1567    }
1568
1569    public static String[] getPickupTwoColumnByTrackSwitchListMessageFormat() {
1570        return createTwoColumnByTrackPickupMessageFormat(getPickupSwitchListMessageFormat());
1571    }
1572
1573    public static String[] getPickupTwoColumnByTrackUtilityManifestMessageFormat() {
1574        return createTwoColumnByTrackPickupMessageFormat(getPickupUtilityManifestMessageFormat());
1575    }
1576
1577    public static String[] getPickupTwoColumnByTrackUtilitySwitchListMessageFormat() {
1578        return createTwoColumnByTrackPickupMessageFormat(getPickupUtilitySwitchListMessageFormat());
1579    }
1580
1581    private static String[] createTwoColumnByTrackPickupMessageFormat(String[] format) {
1582        for (int i = 0; i < format.length; i++) {
1583            if (format[i].equals(LOCATION)) {
1584                format[i] = BLANK;
1585            } else if (format[i].equals(TRACK)) {
1586                format[i] = BLANK;
1587            }
1588        }
1589        return format;
1590    }
1591
1592    public static String[] getDropTwoColumnByTrackManifestMessageFormat() {
1593        return createTwoColumnByTrackDropMessageFormat(getDropManifestMessageFormat());
1594    }
1595
1596    public static String[] getDropTwoColumnByTrackSwitchListMessageFormat() {
1597        return createTwoColumnByTrackDropMessageFormat(getDropSwitchListMessageFormat());
1598    }
1599
1600    public static String[] getDropTwoColumnByTrackUtilityManifestMessageFormat() {
1601        return createTwoColumnByTrackDropMessageFormat(getDropUtilityManifestMessageFormat());
1602    }
1603
1604    public static String[] getDropTwoColumnByTrackUtilitySwitchListMessageFormat() {
1605        return createTwoColumnByTrackDropMessageFormat(getDropUtilitySwitchListMessageFormat());
1606    }
1607
1608    private static String[] createTwoColumnByTrackDropMessageFormat(String[] format) {
1609        for (int i = 0; i < format.length; i++) {
1610            if (format[i].equals(DESTINATION)) {
1611                format[i] = BLANK;
1612            } else if (format[i].equals(TRACK)) {
1613                format[i] = BLANK;
1614            }
1615        }
1616        return format;
1617    }
1618
1619    public static String getDropEngineTextColor() {
1620        return ColorUtil.colorToColorName(getDefault().dropEngineColor);
1621    }
1622
1623    public static void setDropEngineTextColor(String color) {
1624        setDropEngineColor(ColorUtil.stringToColor(color));
1625    }
1626
1627    public static void setDropEngineColor(Color c) {
1628        getDefault().dropEngineColor = c;
1629        JmriColorChooser.addRecentColor(c);
1630    }
1631
1632    public static String getPickupEngineTextColor() {
1633        return ColorUtil.colorToColorName(getDefault().pickupEngineColor);
1634    }
1635
1636    public static void setPickupEngineTextColor(String color) {
1637        setPickupEngineColor(ColorUtil.stringToColor(color));
1638    }
1639
1640    public static void setPickupEngineColor(Color c) {
1641        getDefault().pickupEngineColor = c;
1642        JmriColorChooser.addRecentColor(c);
1643    }
1644
1645    public static String getDropTextColor() {
1646        return ColorUtil.colorToColorName(getDefault().dropColor);
1647    }
1648
1649    public static void setDropTextColor(String color) {
1650        setDropColor(ColorUtil.stringToColor(color));
1651    }
1652
1653    public static void setDropColor(Color c) {
1654        getDefault().dropColor = c;
1655        JmriColorChooser.addRecentColor(c);
1656    }
1657
1658    public static String getPickupTextColor() {
1659        return ColorUtil.colorToColorName(getDefault().pickupColor);
1660    }
1661
1662    public static void setPickupTextColor(String color) {
1663        setPickupColor(ColorUtil.stringToColor(color));
1664    }
1665
1666    public static void setPickupColor(Color c) {
1667        getDefault().pickupColor = c;
1668        JmriColorChooser.addRecentColor(c);
1669    }
1670
1671    public static String getLocalTextColor() {
1672        return ColorUtil.colorToColorName(getDefault().localColor);
1673    }
1674
1675    public static void setLocalTextColor(String color) {
1676        setLocalColor(ColorUtil.stringToColor(color));
1677    }
1678
1679    public static void setLocalColor(Color c) {
1680        getDefault().localColor = c;
1681        JmriColorChooser.addRecentColor(c);
1682    }
1683
1684    public static Color getPickupEngineColor() {
1685        return getDefault().pickupEngineColor;
1686    }
1687
1688    public static Color getDropEngineColor() {
1689        return getDefault().dropEngineColor;
1690    }
1691
1692    public static Color getPickupColor() {
1693        return getDefault().pickupColor;
1694    }
1695
1696    public static Color getDropColor() {
1697        return getDefault().dropColor;
1698    }
1699
1700    public static Color getLocalColor() {
1701        return getDefault().localColor;
1702    }
1703
1704    public static Color getColor(String colorName) {
1705        return ColorUtil.stringToColor(colorName);
1706    }
1707
1708    public static String getManifestLogoURL() {
1709        return getDefault().logoURL;
1710    }
1711
1712    public static void setManifestLogoURL(String pathName) {
1713        getDefault().logoURL = pathName;
1714    }
1715
1716    public static String getOwnerName() {
1717        return getDefault().ownerName;
1718    }
1719
1720    public static void setOwnerName(String name) {
1721        getDefault().ownerName = name;
1722    }
1723
1724    public static int getScaleRatio() {
1725        if (getDefault().scale == 0) {
1726            log.error("Scale not set");
1727        }
1728        return getDefault().ratio;
1729    }
1730
1731    public static int getScaleTonRatio() {
1732        if (getDefault().scale == 0) {
1733            log.error("Scale not set");
1734        }
1735        return getDefault().ratioTons;
1736    }
1737
1738    public static int getInitalWeight() {
1739        if (getDefault().scale == 0) {
1740            log.error("Scale not set");
1741        }
1742        return getDefault().initWeight;
1743    }
1744
1745    public static int getAddWeight() {
1746        if (getDefault().scale == 0) {
1747            log.error("Scale not set");
1748        }
1749        return getDefault().addWeight;
1750    }
1751
1752    public static int getScale() {
1753        return getDefault().scale;
1754    }
1755
1756    public static void setScale(int s) {
1757        getDefault().scale = s;
1758        switch (getDefault().scale) {
1759            case Z_SCALE:
1760                getDefault().ratio = Z_RATIO;
1761                getDefault().initWeight = Z_INITIAL_WEIGHT;
1762                getDefault().addWeight = Z_ADD_WEIGHT;
1763                getDefault().ratioTons = Z_RATIO_TONS;
1764                break;
1765            case N_SCALE:
1766                getDefault().ratio = N_RATIO;
1767                getDefault().initWeight = N_INITIAL_WEIGHT;
1768                getDefault().addWeight = N_ADD_WEIGHT;
1769                getDefault().ratioTons = N_RATIO_TONS;
1770                break;
1771            case TT_SCALE:
1772                getDefault().ratio = TT_RATIO;
1773                getDefault().initWeight = TT_INITIAL_WEIGHT;
1774                getDefault().addWeight = TT_ADD_WEIGHT;
1775                getDefault().ratioTons = TT_RATIO_TONS;
1776                break;
1777            case HOn3_SCALE:
1778                getDefault().ratio = HO_RATIO;
1779                getDefault().initWeight = HOn3_INITIAL_WEIGHT;
1780                getDefault().addWeight = HOn3_ADD_WEIGHT;
1781                getDefault().ratioTons = HOn3_RATIO_TONS;
1782                break;
1783            case OO_SCALE:
1784                getDefault().ratio = OO_RATIO;
1785                getDefault().initWeight = OO_INITIAL_WEIGHT;
1786                getDefault().addWeight = OO_ADD_WEIGHT;
1787                getDefault().ratioTons = OO_RATIO_TONS;
1788                break;
1789            case HO_SCALE:
1790                getDefault().ratio = HO_RATIO;
1791                getDefault().initWeight = HO_INITIAL_WEIGHT;
1792                getDefault().addWeight = HO_ADD_WEIGHT;
1793                getDefault().ratioTons = HO_RATIO_TONS;
1794                break;
1795            case Sn3_SCALE:
1796                getDefault().ratio = S_RATIO;
1797                getDefault().initWeight = Sn3_INITIAL_WEIGHT;
1798                getDefault().addWeight = Sn3_ADD_WEIGHT;
1799                getDefault().ratioTons = Sn3_RATIO_TONS;
1800                break;
1801            case S_SCALE:
1802                getDefault().ratio = S_RATIO;
1803                getDefault().initWeight = S_INITIAL_WEIGHT;
1804                getDefault().addWeight = S_ADD_WEIGHT;
1805                getDefault().ratioTons = S_RATIO_TONS;
1806                break;
1807            case On3_SCALE:
1808                getDefault().ratio = O_RATIO;
1809                getDefault().initWeight = On3_INITIAL_WEIGHT;
1810                getDefault().addWeight = On3_ADD_WEIGHT;
1811                getDefault().ratioTons = On3_RATIO_TONS;
1812                break;
1813            case O_SCALE:
1814                getDefault().ratio = O_RATIO;
1815                getDefault().initWeight = O_INITIAL_WEIGHT;
1816                getDefault().addWeight = O_ADD_WEIGHT;
1817                getDefault().ratioTons = O_RATIO_TONS;
1818                break;
1819
1820            case Gauge1_SCALE:
1821                getDefault().ratio = Gauge1_RATIO;
1822                getDefault().initWeight = G_INITIAL_WEIGHT;
1823                getDefault().addWeight = G_ADD_WEIGHT;
1824                getDefault().ratioTons = G_RATIO_TONS;
1825                break;
1826            case G_24_SCALE:
1827                getDefault().ratio = G_24_RATIO;
1828                getDefault().initWeight = G_INITIAL_WEIGHT;
1829                getDefault().addWeight = G_ADD_WEIGHT;
1830                getDefault().ratioTons = G_RATIO_TONS;
1831                break;
1832            default:
1833                log.error("Unknown scale");
1834        }
1835    }
1836
1837    public static JComboBox<String> getManifestFormatComboBox() {
1838        JComboBox<String> box = new JComboBox<>();
1839        box.addItem(STANDARD_FORMAT);
1840        box.addItem(TWO_COLUMN_FORMAT);
1841        box.addItem(TWO_COLUMN_TRACK_FORMAT);
1842        OperationsPanel.padComboBox(box, TWO_COLUMN_TRACK_FORMAT.length());
1843        return box;
1844    }
1845
1846    public static JComboBox<String> getOrientationComboBox() {
1847        JComboBox<String> box = new JComboBox<>();
1848        box.addItem(PORTRAIT);
1849        box.addItem(LANDSCAPE);
1850        box.addItem(HALFPAGE);
1851        box.addItem(HANDHELD);
1852        OperationsPanel.padComboBox(box, LANDSCAPE.length());
1853        return box;
1854    }
1855
1856    public static JComboBox<String> getSwitchListPageFormatComboBox() {
1857        JComboBox<String> box = new JComboBox<>();
1858        box.addItem(PAGE_NORMAL);
1859        box.addItem(PAGE_PER_TRAIN);
1860        box.addItem(PAGE_PER_VISIT);
1861        OperationsPanel.padComboBox(box, PAGE_PER_TRAIN.length());
1862        return box;
1863    }
1864
1865    public static JComboBox<String> getEngineMessageComboBox() {
1866        JComboBox<String> box = new JComboBox<>();
1867        box.addItem(BLANK);
1868        for (String attribute : getEngineAttributes()) {
1869            box.addItem(attribute);
1870        }
1871        if (isTabEnabled()) {
1872            box.addItem(TAB);
1873            box.addItem(TAB2);
1874            box.addItem(TAB3);
1875        }
1876        return box;
1877    }
1878
1879    public static JComboBox<String> getCarMessageComboBox() {
1880        JComboBox<String> box = new JComboBox<>();
1881        box.addItem(BLANK);
1882        for (String attribute : getCarAttributes()) {
1883            box.addItem(attribute);
1884        }
1885        if (isTabEnabled()) {
1886            box.addItem(TAB);
1887            box.addItem(TAB2);
1888            box.addItem(TAB3);
1889        }
1890        return box;
1891    }
1892
1893    /**
1894     *
1895     * @return JComboBox loaded with the strings (North, South, East, West) showing
1896     *         the available train directions for this railroad
1897     */
1898    public static JComboBox<String> getTrainDirectionComboBox() {
1899        JComboBox<String> box = new JComboBox<>();
1900        for (String direction : getTrainDirectionList()) {
1901            box.addItem(direction);
1902        }
1903        return box;
1904    }
1905
1906    /**
1907     * Get train directions String format
1908     *
1909     * @return List of valid train directions
1910     */
1911    public static List<String> getTrainDirectionList() {
1912        List<String> directions = new ArrayList<>();
1913        if ((getDefault().traindir & EAST) == EAST) {
1914            directions.add(EAST_DIR);
1915        }
1916        if ((getDefault().traindir & WEST) == WEST) {
1917            directions.add(WEST_DIR);
1918        }
1919        if ((getDefault().traindir & NORTH) == NORTH) {
1920            directions.add(NORTH_DIR);
1921        }
1922        if ((getDefault().traindir & SOUTH) == SOUTH) {
1923            directions.add(SOUTH_DIR);
1924        }
1925        return directions;
1926    }
1927
1928    /**
1929     * Converts binary direction to String direction
1930     *
1931     * @param direction EAST, WEST, NORTH, SOUTH
1932     * @return String representation of a direction
1933     */
1934    public static String getDirectionString(int direction) {
1935        switch (direction) {
1936            case EAST:
1937                return EAST_DIR;
1938            case WEST:
1939                return WEST_DIR;
1940            case NORTH:
1941                return NORTH_DIR;
1942            case SOUTH:
1943                return SOUTH_DIR;
1944            default:
1945                return "unknown"; // NOI18N
1946        }
1947    }
1948
1949    /**
1950     * Converts binary direction to a set of String directions
1951     *
1952     * @param directions EAST, WEST, NORTH, SOUTH
1953     * @return String[] representation of a set of directions
1954     */
1955    public static String[] getDirectionStrings(int directions) {
1956        String[] dir = new String[4];
1957        int i = 0;
1958        if ((directions & EAST) == EAST) {
1959            dir[i++] = EAST_DIR;
1960        }
1961        if ((directions & WEST) == WEST) {
1962            dir[i++] = WEST_DIR;
1963        }
1964        if ((directions & NORTH) == NORTH) {
1965            dir[i++] = NORTH_DIR;
1966        }
1967        if ((directions & SOUTH) == SOUTH) {
1968            dir[i++] = SOUTH_DIR;
1969        }
1970        return dir;
1971    }
1972
1973    /**
1974     * Converts String direction to binary direction
1975     *
1976     * @param direction EAST_DIR WEST_DIR NORTH_DIR SOUTH_DIR
1977     * @return integer representation of a direction
1978     */
1979    public static int getDirectionInt(String direction) {
1980        if (direction.equals(EAST_DIR)) {
1981            return EAST;
1982        } else if (direction.equals(WEST_DIR)) {
1983            return WEST;
1984        } else if (direction.equals(NORTH_DIR)) {
1985            return NORTH;
1986        } else if (direction.equals(SOUTH_DIR)) {
1987            return SOUTH;
1988        } else {
1989            return 0; // return unknown
1990        }
1991    }
1992    
1993    public static void setDayToName(String day, String name) {
1994        if (name != null) {
1995            getDefault().hashTableDayToName.put(day, name);
1996        }
1997    }
1998    
1999    public static String getDayToName(String day) {
2000        return getDefault().hashTableDayToName.get(day);
2001    }
2002
2003    // must synchronize changes with operation-config.dtd
2004    public static Element store() {
2005        Element values;
2006        Element e = new Element(Xml.OPERATIONS);
2007
2008        // only store railroad name if it doesn't match the preferences railroad name
2009        if (!InstanceManager.getDefault(WebServerPreferences.class).getRailroadName().equals(getRailroadName())) {
2010            e.addContent(values = new Element(Xml.RAIL_ROAD));
2011            values.setAttribute(Xml.NAME, getRailroadName());
2012        }
2013
2014        e.addContent(values = new Element(Xml.SETUP));
2015        values.setAttribute(Xml.COMMENT, getComment());
2016
2017        e.addContent(values = new Element(Xml.SETTINGS));
2018        values.setAttribute(Xml.MAIN_MENU, isMainMenuEnabled() ? Xml.TRUE : Xml.FALSE);
2019        values.setAttribute(Xml.CLOSE_ON_SAVE, isCloseWindowOnSaveEnabled() ? Xml.TRUE : Xml.FALSE);
2020        values.setAttribute(Xml.AUTO_SAVE, isAutoSaveEnabled() ? Xml.TRUE : Xml.FALSE);
2021        values.setAttribute(Xml.AUTO_BACKUP, isAutoBackupEnabled() ? Xml.TRUE : Xml.FALSE);
2022        values.setAttribute(Xml.TRAIN_DIRECTION, Integer.toString(getTrainDirection()));
2023        values.setAttribute(Xml.TRAIN_LENGTH, Integer.toString(getMaxTrainLength()));
2024        values.setAttribute(Xml.MAX_ENGINES, Integer.toString(getMaxNumberEngines()));
2025        values.setAttribute(Xml.HPT, Double.toString(getHorsePowerPerTon()));
2026        values.setAttribute(Xml.SCALE, Integer.toString(getScale()));
2027        values.setAttribute(Xml.CAR_TYPES, getCarTypes());
2028        values.setAttribute(Xml.SWITCH_TIME, Integer.toString(getSwitchTime()));
2029        values.setAttribute(Xml.TRAVEL_TIME, Integer.toString(getTravelTime()));
2030        values.setAttribute(Xml.SHOW_VALUE, isValueEnabled() ? Xml.TRUE : Xml.FALSE);
2031        values.setAttribute(Xml.VALUE_LABEL, getValueLabel());
2032        values.setAttribute(Xml.SHOW_RFID, isRfidEnabled() ? Xml.TRUE : Xml.FALSE);
2033        values.setAttribute(Xml.RFID_LABEL, getRfidLabel());
2034        values.setAttribute(Xml.LENGTH_UNIT, getLengthUnit());
2035        values.setAttribute(Xml.YEAR_MODELED, getYearModeled());
2036
2037        e.addContent(values = new Element(Xml.PICKUP_ENG_FORMAT));
2038        storeXmlMessageFormat(values, getPickupEnginePrefix(), getPickupEngineMessageFormat());
2039
2040        e.addContent(values = new Element(Xml.DROP_ENG_FORMAT));
2041        storeXmlMessageFormat(values, getDropEnginePrefix(), getDropEngineMessageFormat());
2042
2043        e.addContent(values = new Element(Xml.PICKUP_CAR_FORMAT));
2044        storeXmlMessageFormat(values, getPickupCarPrefix(), getPickupManifestMessageFormat());
2045
2046        e.addContent(values = new Element(Xml.DROP_CAR_FORMAT));
2047        storeXmlMessageFormat(values, getDropCarPrefix(), getDropManifestMessageFormat());
2048
2049        e.addContent(values = new Element(Xml.LOCAL_FORMAT));
2050        storeXmlMessageFormat(values, getLocalPrefix(), getLocalManifestMessageFormat());
2051
2052        e.addContent(values = new Element(Xml.MISSING_CAR_FORMAT));
2053        storeXmlMessageFormat(values, NONE, getMissingCarMessageFormat());
2054
2055        e.addContent(values = new Element(Xml.SWITCH_LIST));
2056        values.setAttribute(Xml.SAME_AS_MANIFEST, isSwitchListFormatSameAsManifest() ? Xml.TRUE : Xml.FALSE);
2057        values.setAttribute(Xml.REAL_TIME, isSwitchListRealTime() ? Xml.TRUE : Xml.FALSE);
2058        values.setAttribute(Xml.ALL_TRAINS, isSwitchListAllTrainsEnabled() ? Xml.TRUE : Xml.FALSE);
2059
2060        // save switch list format
2061        String format = Xml.PAGE_NORMAL;
2062        if (getSwitchListPageFormat().equals(PAGE_PER_TRAIN)) {
2063            format = Xml.PAGE_PER_TRAIN;
2064            values.setAttribute(Xml.PAGE_MODE, Xml.TRUE); // backwards compatible for versions before 3.11
2065        } else if (getSwitchListPageFormat().equals(PAGE_PER_VISIT)) {
2066            format = Xml.PAGE_PER_VISIT;
2067        }
2068        values.setAttribute(Xml.PAGE_FORMAT, format);
2069
2070        values.setAttribute(Xml.PRINT_ROUTE_LOCATION, isSwitchListRouteLocationCommentEnabled() ? Xml.TRUE : Xml.FALSE);
2071        values.setAttribute(Xml.TRACK_SUMMARY, isPrintTrackSummaryEnabled() ? Xml.TRUE : Xml.FALSE);
2072        values.setAttribute(Xml.USE_DEPARTURE_TIME, isUseSwitchListDepartureTimeEnabled() ? Xml.TRUE : Xml.FALSE);
2073
2074        e.addContent(values = new Element(Xml.SWITCH_LIST_PICKUP_CAR_FORMAT));
2075        storeXmlMessageFormat(values, getSwitchListPickupCarPrefix(), getPickupSwitchListMessageFormat());
2076
2077        e.addContent(values = new Element(Xml.SWITCH_LIST_DROP_CAR_FORMAT));
2078        storeXmlMessageFormat(values, getSwitchListDropCarPrefix(), getDropSwitchListMessageFormat());
2079
2080        e.addContent(values = new Element(Xml.SWITCH_LIST_LOCAL_FORMAT));
2081        storeXmlMessageFormat(values, getSwitchListLocalPrefix(), getLocalSwitchListMessageFormat());
2082
2083        e.addContent(values = new Element(Xml.PANEL));
2084        values.setAttribute(Xml.NAME, getPanelName());
2085        values.setAttribute(Xml.TRAIN_ICONXY, isTrainIconCordEnabled() ? Xml.TRUE : Xml.FALSE);
2086        values.setAttribute(Xml.TRAIN_ICON_APPEND, isTrainIconAppendEnabled() ? Xml.TRUE : Xml.FALSE);
2087
2088        e.addContent(values = new Element(Xml.FONT_NAME));
2089        values.setAttribute(Xml.NAME, getFontName());
2090
2091        e.addContent(values = new Element(Xml.FONT_SIZE));
2092        values.setAttribute(Xml.SIZE, Integer.toString(getManifestFontSize()));
2093
2094        e.addContent(values = new Element(Xml.PAGE_ORIENTATION));
2095        values.setAttribute(Xml.MANIFEST, getManifestOrientation());
2096        values.setAttribute(Xml.SWITCH_LIST, getSwitchListOrientation());
2097
2098        e.addContent(values = new Element(Xml.PRINT_DUPLEX));
2099        values.setAttribute(Xml.NAME, getPrintDuplexSides().toString());
2100
2101        e.addContent(values = new Element(Xml.MANIFEST_COLORS));
2102        values.setAttribute(Xml.DROP_ENGINE_COLOR, getDropEngineTextColor());
2103        values.setAttribute(Xml.PICKUP_ENGINE_COLOR, getPickupEngineTextColor());
2104        values.setAttribute(Xml.DROP_COLOR, getDropTextColor());
2105        values.setAttribute(Xml.PICKUP_COLOR, getPickupTextColor());
2106        values.setAttribute(Xml.LOCAL_COLOR, getLocalTextColor());
2107
2108        e.addContent(values = new Element(Xml.TAB));
2109        values.setAttribute(Xml.ENABLED, isTabEnabled() ? Xml.TRUE : Xml.FALSE);
2110        values.setAttribute(Xml.LENGTH, Integer.toString(getTab1Length()));
2111        values.setAttribute(Xml.TAB2_LENGTH, Integer.toString(getTab2Length()));
2112        values.setAttribute(Xml.TAB3_LENGTH, Integer.toString(getTab3Length()));
2113
2114        e.addContent(values = new Element(Xml.MANIFEST));
2115        values.setAttribute(Xml.PRINT_LOC_COMMENTS, isPrintLocationCommentsEnabled() ? Xml.TRUE : Xml.FALSE);
2116        values.setAttribute(Xml.PRINT_ROUTE_COMMENTS, isPrintRouteCommentsEnabled() ? Xml.TRUE : Xml.FALSE);
2117        values.setAttribute(Xml.PRINT_LOADS_EMPTIES, isPrintLoadsAndEmptiesEnabled() ? Xml.TRUE : Xml.FALSE);
2118        values.setAttribute(Xml.PRINT_TRAIN_SCHEDULE, isPrintTrainScheduleNameEnabled() ? Xml.TRUE : Xml.FALSE);
2119        values.setAttribute(Xml.USE12HR_FORMAT, is12hrFormatEnabled() ? Xml.TRUE : Xml.FALSE);
2120        values.setAttribute(Xml.PRINT_VALID, isPrintValidEnabled() ? Xml.TRUE : Xml.FALSE);
2121        values.setAttribute(Xml.SORT_BY_TRACK, isSortByTrackNameEnabled() ? Xml.TRUE : Xml.FALSE);
2122        values.setAttribute(Xml.PRINT_PAGE_HEADER, isPrintPageHeaderEnabled() ? Xml.TRUE : Xml.FALSE);
2123        values.setAttribute(Xml.PRINT_HEADERS, isPrintHeadersEnabled() ? Xml.TRUE : Xml.FALSE);
2124        values.setAttribute(Xml.PRINT_NO_PAGE_BREAKS, isPrintNoPageBreaksEnabled() ? Xml.TRUE : Xml.FALSE);
2125        values.setAttribute(Xml.TRUNCATE, isPrintTruncateManifestEnabled() ? Xml.TRUE : Xml.FALSE);
2126        values.setAttribute(Xml.USE_DEPARTURE_TIME, isUseDepartureTimeEnabled() ? Xml.TRUE : Xml.FALSE);
2127        values.setAttribute(Xml.USE_EDITOR, isManifestEditorEnabled() ? Xml.TRUE : Xml.FALSE);
2128        values.setAttribute(Xml.PRINT_CABOOSE_LOAD, isPrintCabooseLoadEnabled() ? Xml.TRUE : Xml.FALSE);
2129        values.setAttribute(Xml.PRINT_PASSENGER_LOAD, isPrintPassengerLoadEnabled() ? Xml.TRUE : Xml.FALSE);
2130        values.setAttribute(Xml.GROUP_MOVES, isGroupCarMovesEnabled() ? Xml.TRUE : Xml.FALSE);
2131        values.setAttribute(Xml.PRINT_LOCO_LAST, isPrintLocoLastEnabled() ? Xml.TRUE : Xml.FALSE);
2132        values.setAttribute(Xml.HAZARDOUS_MSG, getHazardousMsg());
2133
2134        // new format June 2014
2135        e.addContent(values = new Element(Xml.MANIFEST_FORMAT));
2136
2137        // save manifest format
2138        String value = Xml.STANDARD;
2139        if (getManifestFormat().equals(TWO_COLUMN_FORMAT)) {
2140            value = Xml.TWO_COLUMN;
2141        } else if (getManifestFormat().equals(TWO_COLUMN_TRACK_FORMAT)) {
2142            value = Xml.TWO_COLUMN_TRACK;
2143        }
2144        values.setAttribute(Xml.VALUE, value);
2145
2146        // new format June 2025
2147        e.addContent(values = new Element(Xml.HEADER_LINES));
2148        values.setAttribute(Xml.PRINT_HEADER_LINE1, isPrintHeaderLine1Enabled() ? Xml.TRUE : Xml.FALSE);
2149        values.setAttribute(Xml.PRINT_HEADER_LINE2, isPrintHeaderLine2Enabled() ? Xml.TRUE : Xml.FALSE);
2150        values.setAttribute(Xml.PRINT_HEADER_LINE3, isPrintHeaderLine3Enabled() ? Xml.TRUE : Xml.FALSE);
2151
2152        if (!getManifestLogoURL().equals(NONE)) {
2153            values = new Element(Xml.MANIFEST_LOGO);
2154            values.setAttribute(Xml.NAME, getManifestLogoURL());
2155            e.addContent(values);
2156        }
2157
2158        // manifest save file options
2159        e.addContent(values = new Element(Xml.MANIFEST_FILE_OPTIONS));
2160        values.setAttribute(Xml.MANIFEST_SAVE, isSaveTrainManifestsEnabled() ? Xml.TRUE : Xml.FALSE);
2161
2162        e.addContent(values = new Element(Xml.BUILD_OPTIONS));
2163        values.setAttribute(Xml.AGGRESSIVE, isBuildAggressive() ? Xml.TRUE : Xml.FALSE);
2164        values.setAttribute(Xml.NUMBER_PASSES, Integer.toString(getNumberPasses()));
2165        values.setAttribute(Xml.ON_TIME, isBuildOnTime() ? Xml.TRUE : Xml.FALSE);
2166        values.setAttribute(Xml.DWELL_TIME, Integer.toString(getDwellTime()));
2167
2168        values.setAttribute(Xml.ALLOW_LOCAL_INTERCHANGE, isLocalInterchangeMovesEnabled() ? Xml.TRUE : Xml.FALSE);
2169        values.setAttribute(Xml.ALLOW_LOCAL_SPUR, isLocalSpurMovesEnabled() ? Xml.TRUE : Xml.FALSE);
2170        values.setAttribute(Xml.ALLOW_LOCAL_YARD, isLocalYardMovesEnabled() ? Xml.TRUE : Xml.FALSE);
2171
2172        values.setAttribute(Xml.STAGING_RESTRICTION_ENABLED, isStagingTrainCheckEnabled() ? Xml.TRUE : Xml.FALSE);
2173        values.setAttribute(Xml.STAGING_TRACK_AVAIL, isStagingTrackImmediatelyAvail() ? Xml.TRUE : Xml.FALSE);
2174        values.setAttribute(Xml.ALLOW_RETURN_STAGING, isStagingAllowReturnEnabled() ? Xml.TRUE : Xml.FALSE);
2175        values.setAttribute(Xml.PROMPT_STAGING_ENABLED, isStagingPromptFromEnabled() ? Xml.TRUE : Xml.FALSE);
2176        values.setAttribute(Xml.PROMPT_TO_STAGING_ENABLED, isStagingPromptToEnabled() ? Xml.TRUE : Xml.FALSE);
2177        values.setAttribute(Xml.STAGING_TRY_NORMAL, isStagingTryNormalBuildEnabled() ? Xml.TRUE : Xml.FALSE);
2178
2179        values.setAttribute(Xml.GENERATE_CSV_MANIFEST, isGenerateCsvManifestEnabled() ? Xml.TRUE : Xml.FALSE);
2180        values.setAttribute(Xml.GENERATE_CSV_SWITCH_LIST, isGenerateCsvSwitchListEnabled() ? Xml.TRUE : Xml.FALSE);
2181
2182        e.addContent(values = new Element(Xml.BUILD_REPORT));
2183        values.setAttribute(Xml.LEVEL, getBuildReportLevel());
2184        values.setAttribute(Xml.ROUTER_LEVEL, getRouterBuildReportLevel());
2185        values.setAttribute(Xml.USE_EDITOR, isBuildReportEditorEnabled() ? Xml.TRUE : Xml.FALSE);
2186        values.setAttribute(Xml.INDENT, isBuildReportIndentEnabled() ? Xml.TRUE : Xml.FALSE);
2187        values.setAttribute(Xml.ALWAYS_PREVIEW, isBuildReportAlwaysPreviewEnabled() ? Xml.TRUE : Xml.FALSE);
2188        values.setAttribute(Xml.FONT_SIZE, Integer.toString(getBuildReportFontSize()));
2189
2190        // new format for router options
2191        e.addContent(values = new Element(Xml.ROUTER));
2192        values.setAttribute(Xml.CAR_ROUTING_ENABLED, isCarRoutingEnabled() ? Xml.TRUE : Xml.FALSE);
2193        values.setAttribute(Xml.CAR_ROUTING_VIA_YARDS, isCarRoutingViaYardsEnabled() ? Xml.TRUE : Xml.FALSE);
2194        values.setAttribute(Xml.CAR_ROUTING_VIA_STAGING, isCarRoutingViaStagingEnabled() ? Xml.TRUE : Xml.FALSE);
2195        values.setAttribute(Xml.FORWARD_TO_YARD, isForwardToYardEnabled() ? Xml.TRUE : Xml.FALSE);
2196        values.setAttribute(Xml.ONLY_ACTIVE_TRAINS, isOnlyActiveTrainsEnabled() ? Xml.TRUE : Xml.FALSE);
2197        values.setAttribute(Xml.CHECK_CAR_DESTINATION, isCheckCarDestinationEnabled() ? Xml.TRUE : Xml.FALSE);
2198
2199        // new format for logger options
2200        e.addContent(values = new Element(Xml.LOGGER));
2201        values.setAttribute(Xml.CAR_LOGGER, isCarLoggerEnabled() ? Xml.TRUE : Xml.FALSE);
2202        values.setAttribute(Xml.ENGINE_LOGGER, isEngineLoggerEnabled() ? Xml.TRUE : Xml.FALSE);
2203        values.setAttribute(Xml.TRAIN_LOGGER, isTrainLoggerEnabled() ? Xml.TRUE : Xml.FALSE);
2204
2205        e.addContent(values = new Element(Xml.OWNER));
2206        values.setAttribute(Xml.NAME, getOwnerName());
2207
2208        e.addContent(values = new Element(Xml.ICON_COLOR));
2209        values.setAttribute(Xml.NORTH, getTrainIconColorNorth());
2210        values.setAttribute(Xml.SOUTH, getTrainIconColorSouth());
2211        values.setAttribute(Xml.EAST, getTrainIconColorEast());
2212        values.setAttribute(Xml.WEST, getTrainIconColorWest());
2213        values.setAttribute(Xml.LOCAL, getTrainIconColorLocal());
2214        values.setAttribute(Xml.TERMINATE, getTrainIconColorTerminate());
2215
2216        e.addContent(values = new Element(Xml.COMMENTS));
2217        values.setAttribute(Xml.MISPLACED_CARS, getMiaComment());
2218
2219        e.addContent(values = new Element(Xml.DISPLAY));
2220        values.setAttribute(Xml.SHOW_TRACK_MOVES, isShowTrackMovesEnabled() ? Xml.TRUE : Xml.FALSE);
2221
2222        if (isVsdPhysicalLocationEnabled()) {
2223            e.addContent(values = new Element(Xml.VSD));
2224            values.setAttribute(Xml.ENABLE_PHYSICAL_LOCATIONS, isVsdPhysicalLocationEnabled() ? Xml.TRUE : Xml.FALSE);
2225        }
2226        // Save CATS setting
2227        e.addContent(values = new Element(Xml.CATS));
2228        values.setAttribute(Xml.EXACT_LOCATION_NAME,
2229                AbstractOperationsServer.isExactLoationNameEnabled() ? Xml.TRUE : Xml.FALSE);
2230        // day to name mapping
2231        e.addContent(values = new Element(Xml.DAY_NAME_MAP));
2232        for (int i = 0; i < Control.numberOfDays; i++) {
2233            Element map;
2234            String day = Integer.toString(i);
2235            String name = getDefault().hashTableDayToName.get(day);
2236            if (name != null && !name.isBlank()) {
2237                values.addContent(map = new Element(Xml.MAP));
2238                map.setAttribute(Xml.DAY, day);
2239                map.setAttribute(Xml.NAME, name);
2240            }
2241        }
2242        return e;
2243    }
2244
2245    private static void storeXmlMessageFormat(Element values, String prefix, String[] messageFormat) {
2246        values.setAttribute(Xml.PREFIX, prefix);
2247        StringBuilder buf = new StringBuilder();
2248        stringToTagConversion(messageFormat);
2249        for (String attibute : messageFormat) {
2250            buf.append(attibute).append(",");
2251        }
2252        values.setAttribute(Xml.SETTING, buf.toString());
2253    }
2254
2255    public static void load(Element e) {
2256        if (e.getChild(Xml.OPERATIONS) == null) {
2257            log.warn("OperationsPro settings values not found");
2258            return;
2259        }
2260        Element operations = e.getChild(Xml.OPERATIONS);
2261        org.jdom2.Attribute a;
2262
2263        if ((operations.getChild(Xml.RAIL_ROAD) != null) &&
2264                (a = operations.getChild(Xml.RAIL_ROAD).getAttribute(Xml.NAME)) != null) {
2265            String name = a.getValue();
2266            log.debug("railroadName: {}", name);
2267            // code before 4.11 "useJmriRailroadName" when using the preferences railroad
2268            // name.
2269            // here for backwards compatibility
2270            if (!name.equals(Xml.USE_JMRI_RAILROAD_NAME)) {
2271                getDefault().railroadName = name; // don't set the dirty bit
2272            }
2273        }
2274
2275        if ((operations.getChild(Xml.SETUP) != null) &&
2276                (a = operations.getChild(Xml.SETUP).getAttribute(Xml.COMMENT)) != null) {
2277            String comment = a.getValue();
2278            log.debug("setup comment: {}", comment);
2279            getDefault().setupComment = comment;
2280        }
2281
2282        if (operations.getChild(Xml.SETTINGS) != null) {
2283            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.MAIN_MENU)) != null) {
2284                String enabled = a.getValue();
2285                log.debug("mainMenu: {}", enabled);
2286                setMainMenuEnabled(enabled.equals(Xml.TRUE));
2287            }
2288            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CLOSE_ON_SAVE)) != null) {
2289                String enabled = a.getValue();
2290                log.debug("closeOnSave: {}", enabled);
2291                setCloseWindowOnSaveEnabled(enabled.equals(Xml.TRUE));
2292            }
2293            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.TRAIN_DIRECTION)) != null) {
2294                String dir = a.getValue();
2295                log.debug("direction: {}", dir);
2296                try {
2297                    getDefault().traindir = Integer.parseInt(dir);
2298                } catch (NumberFormatException ee) {
2299                    log.error("Train direction ({}) isn't a valid number", a.getValue());
2300                }
2301            }
2302            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.TRAIN_LENGTH)) != null) {
2303                String length = a.getValue();
2304                log.debug("Max train length: {}", length);
2305                try {
2306                    setMaxTrainLength(Integer.parseInt(length));
2307                } catch (NumberFormatException ee) {
2308                    log.error("Train maximum length ({}) isn't a valid number", a.getValue());
2309                }
2310            }
2311            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.MAX_ENGINES)) != null) {
2312                String size = a.getValue();
2313                log.debug("Max number of engines: {}", size);
2314                try {
2315                    setMaxNumberEngines(Integer.parseInt(size));
2316                } catch (NumberFormatException ee) {
2317                    log.error("Maximum number of engines ({}) isn't a valid number", a.getValue());
2318                }
2319            }
2320            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.HPT)) != null) {
2321                String value = a.getValue();
2322                log.debug("HPT: {}", value);
2323                try {
2324                    setHorsePowerPerTon(Double.parseDouble(value));
2325                } catch (NumberFormatException ee) {
2326                    log.error("Train HPT ({}) isn't a valid number", a.getValue());
2327                }
2328            }
2329            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.SCALE)) != null) {
2330                String scale = a.getValue();
2331                log.debug("scale: {}", scale);
2332                try {
2333                    setScale(Integer.parseInt(scale));
2334                } catch (NumberFormatException ee) {
2335                    log.error("Scale ({}) isn't a valid number", a.getValue());
2336                }
2337            }
2338            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CAR_TYPES)) != null) {
2339                String types = a.getValue();
2340                log.debug("CarTypes: {}", types);
2341                setCarTypes(types);
2342            }
2343            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.SWITCH_TIME)) != null) {
2344                String minutes = a.getValue();
2345                log.debug("switchTime: {}", minutes);
2346                try {
2347                    setSwitchTime(Integer.parseInt(minutes));
2348                } catch (NumberFormatException ee) {
2349                    log.error("Switch time ({}) isn't a valid number", a.getValue());
2350                }
2351            }
2352            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.TRAVEL_TIME)) != null) {
2353                String minutes = a.getValue();
2354                log.debug("travelTime: {}", minutes);
2355                try {
2356                    setTravelTime(Integer.parseInt(minutes));
2357                } catch (NumberFormatException ee) {
2358                    log.error("Travel time ({}) isn't a valid number", a.getValue());
2359                }
2360            }
2361            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.SHOW_VALUE)) != null) {
2362                String enable = a.getValue();
2363                log.debug("showValue: {}", enable);
2364                setValueEnabled(enable.equals(Xml.TRUE));
2365            }
2366            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.VALUE_LABEL)) != null) {
2367                String label = a.getValue();
2368                log.debug("valueLabel: {}", label);
2369                setValueLabel(label);
2370            }
2371            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.SHOW_RFID)) != null) {
2372                String enable = a.getValue();
2373                log.debug("showRfid: {}", enable);
2374                setRfidEnabled(enable.equals(Xml.TRUE));
2375            }
2376            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.RFID_LABEL)) != null) {
2377                String label = a.getValue();
2378                log.debug("rfidLabel: {}", label);
2379                setRfidLabel(label);
2380            }
2381            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.LENGTH_UNIT)) != null) {
2382                String unit = a.getValue();
2383                log.debug("lengthUnit: {}", unit);
2384                setLengthUnit(unit);
2385            }
2386            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.YEAR_MODELED)) != null) {
2387                String year = a.getValue();
2388                log.debug("yearModeled: {}", year);
2389                setYearModeled(year);
2390            }
2391            // next eight attributes are here for backward compatibility
2392            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_LOC_COMMENTS)) != null) {
2393                String enable = a.getValue();
2394                log.debug("printLocComments: {}", enable);
2395                setPrintLocationCommentsEnabled(enable.equals(Xml.TRUE));
2396            }
2397            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_ROUTE_COMMENTS)) != null) {
2398                String enable = a.getValue();
2399                log.debug("printRouteComments: {}", enable);
2400                setPrintRouteCommentsEnabled(enable.equals(Xml.TRUE));
2401            }
2402            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_LOADS_EMPTIES)) != null) {
2403                String enable = a.getValue();
2404                log.debug("printLoadsEmpties: {}", enable);
2405                setPrintLoadsAndEmptiesEnabled(enable.equals(Xml.TRUE));
2406            }
2407            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_TRAIN_SCHEDULE)) != null) {
2408                String enable = a.getValue();
2409                log.debug("printTrainSchedule: {}", enable);
2410                setPrintTrainScheduleNameEnabled(enable.equals(Xml.TRUE));
2411            }
2412            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.USE12HR_FORMAT)) != null) {
2413                String enable = a.getValue();
2414                log.debug("use12hrFormat: {}", enable);
2415                set12hrFormatEnabled(enable.equals(Xml.TRUE));
2416            }
2417            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_VALID)) != null) {
2418                String enable = a.getValue();
2419                log.debug("printValid: {}", enable);
2420                setPrintValidEnabled(enable.equals(Xml.TRUE));
2421            }
2422            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.SORT_BY_TRACK)) != null) {
2423                String enable = a.getValue();
2424                log.debug("sortByTrack: {}", enable);
2425                setSortByTrackNameEnabled(enable.equals(Xml.TRUE));
2426            }
2427            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.PRINT_HEADERS)) != null) {
2428                String enable = a.getValue();
2429                log.debug("printHeaders: {}", enable);
2430                setPrintHeadersEnabled(enable.equals(Xml.TRUE));
2431            }
2432        }
2433        if (operations.getChild(Xml.PICKUP_ENG_FORMAT) != null) {
2434            if ((a = operations.getChild(Xml.PICKUP_ENG_FORMAT).getAttribute(Xml.PREFIX)) != null) {
2435                setPickupEnginePrefix(a.getValue());
2436            }
2437            if ((a = operations.getChild(Xml.PICKUP_ENG_FORMAT).getAttribute(Xml.SETTING)) != null) {
2438                String setting = a.getValue();
2439                log.debug("pickupEngFormat: {}", setting);
2440                String[] keys = setting.split(",");
2441                xmlAttributeToKeyConversion(keys);
2442                keyToStringConversion(keys);
2443                setPickupEngineMessageFormat(keys);
2444            }
2445        }
2446        if (operations.getChild(Xml.DROP_ENG_FORMAT) != null) {
2447            if ((a = operations.getChild(Xml.DROP_ENG_FORMAT).getAttribute(Xml.PREFIX)) != null) {
2448                setDropEnginePrefix(a.getValue());
2449            }
2450            if ((a = operations.getChild(Xml.DROP_ENG_FORMAT).getAttribute(Xml.SETTING)) != null) {
2451                String setting = a.getValue();
2452                log.debug("dropEngFormat: {}", setting);
2453                String[] keys = setting.split(",");
2454                xmlAttributeToKeyConversion(keys);
2455                keyToStringConversion(keys);
2456                setDropEngineMessageFormat(keys);
2457            }
2458        }
2459        if (operations.getChild(Xml.PICKUP_CAR_FORMAT) != null) {
2460            if ((a = operations.getChild(Xml.PICKUP_CAR_FORMAT).getAttribute(Xml.PREFIX)) != null) {
2461                setPickupCarPrefix(a.getValue());
2462            }
2463            if ((a = operations.getChild(Xml.PICKUP_CAR_FORMAT).getAttribute(Xml.SETTING)) != null) {
2464                String setting = a.getValue();
2465                log.debug("pickupCarFormat: {}", setting);
2466                String[] keys = setting.split(",");
2467                replaceOldFormat(keys);
2468                xmlAttributeToKeyConversion(keys);
2469                keyToStringConversion(keys);
2470                setPickupManifestMessageFormat(keys);
2471            }
2472        }
2473        if (operations.getChild(Xml.DROP_CAR_FORMAT) != null) {
2474            if ((a = operations.getChild(Xml.DROP_CAR_FORMAT).getAttribute(Xml.PREFIX)) != null) {
2475                setDropCarPrefix(a.getValue());
2476            }
2477            if ((a = operations.getChild(Xml.DROP_CAR_FORMAT).getAttribute(Xml.SETTING)) != null) {
2478                String setting = a.getValue();
2479                log.debug("dropCarFormat: {}", setting);
2480                String[] keys = setting.split(",");
2481                replaceOldFormat(keys);
2482                xmlAttributeToKeyConversion(keys);
2483                keyToStringConversion(keys);
2484                setDropManifestMessageFormat(keys);
2485            }
2486        }
2487        if (operations.getChild(Xml.LOCAL_FORMAT) != null) {
2488            if ((a = operations.getChild(Xml.LOCAL_FORMAT).getAttribute(Xml.PREFIX)) != null) {
2489                setLocalPrefix(a.getValue());
2490            }
2491            if ((a = operations.getChild(Xml.LOCAL_FORMAT).getAttribute(Xml.SETTING)) != null) {
2492                String setting = a.getValue();
2493                log.debug("localFormat: {}", setting);
2494                String[] keys = setting.split(",");
2495                replaceOldFormat(keys);
2496                xmlAttributeToKeyConversion(keys);
2497                keyToStringConversion(keys);
2498                setLocalManifestMessageFormat(keys);
2499            }
2500        }
2501        if (operations.getChild(Xml.MISSING_CAR_FORMAT) != null) {
2502            if ((a = operations.getChild(Xml.MISSING_CAR_FORMAT).getAttribute(Xml.SETTING)) != null) {
2503                String setting = a.getValue();
2504                log.debug("missingCarFormat: {}", setting);
2505                String[] keys = setting.split(",");
2506                keyToStringConversion(keys);
2507                setMissingCarMessageFormat(keys);
2508            }
2509        }
2510        if (operations.getChild(Xml.SWITCH_LIST) != null) {
2511            if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.SAME_AS_MANIFEST)) != null) {
2512                String b = a.getValue();
2513                log.debug("sameAsManifest: {}", b);
2514                setSwitchListFormatSameAsManifest(b.equals(Xml.TRUE));
2515            }
2516            if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.REAL_TIME)) != null) {
2517                String b = a.getValue();
2518                log.debug("realTime: {}", b);
2519                getDefault().switchListRealTime = b.equals(Xml.TRUE);
2520            }
2521            if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.ALL_TRAINS)) != null) {
2522                String b = a.getValue();
2523                log.debug("allTrains: {}", b);
2524                getDefault().switchListAllTrains = b.equals(Xml.TRUE);
2525            }
2526            if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.PAGE_FORMAT)) != null) {
2527                switch (a.getValue()) {
2528                    case Xml.PAGE_NORMAL:
2529                        getDefault().switchListPageFormat = PAGE_NORMAL;
2530                        break;
2531                    case Xml.PAGE_PER_TRAIN:
2532                        getDefault().switchListPageFormat = PAGE_PER_TRAIN;
2533                        break;
2534                    case Xml.PAGE_PER_VISIT:
2535                        getDefault().switchListPageFormat = PAGE_PER_VISIT;
2536                        break;
2537                    default:
2538                        log.error("Unknown switch list page format {}", a.getValue());
2539                }
2540            } // old way to save switch list page format pre 3.11
2541            else if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.PAGE_MODE)) != null) {
2542                String b = a.getValue();
2543                log.debug("old style pageMode: {}", b);
2544                if (b.equals(Xml.TRUE)) {
2545                    getDefault().switchListPageFormat = PAGE_PER_TRAIN;
2546                }
2547            }
2548            if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.PRINT_ROUTE_LOCATION)) != null) {
2549                String b = a.getValue();
2550                log.debug("print route location comment: {}", b);
2551                setSwitchListRouteLocationCommentEnabled(b.equals(Xml.TRUE));
2552            }
2553            if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.TRACK_SUMMARY)) != null) {
2554                String b = a.getValue();
2555                log.debug("track summary: {}", b);
2556                setPrintTrackSummaryEnabled(b.equals(Xml.TRUE));
2557            }
2558            if ((a = operations.getChild(Xml.SWITCH_LIST).getAttribute(Xml.USE_DEPARTURE_TIME)) != null) {
2559                String b = a.getValue();
2560                log.debug("switch list departure time: {}", b);
2561                setUseSwitchListDepartureTimeEnabled(b.equals(Xml.TRUE));
2562            }
2563        }
2564        if (operations.getChild(Xml.SWITCH_LIST_PICKUP_CAR_FORMAT) != null) {
2565            if ((a = operations.getChild(Xml.SWITCH_LIST_PICKUP_CAR_FORMAT).getAttribute(Xml.PREFIX)) != null) {
2566                setSwitchListPickupCarPrefix(a.getValue());
2567            }
2568            if ((a = operations.getChild(Xml.SWITCH_LIST_PICKUP_CAR_FORMAT).getAttribute(Xml.SETTING)) != null) {
2569                String setting = a.getValue();
2570                log.debug("switchListpickupCarFormat: {}", setting);
2571                String[] keys = setting.split(",");
2572                replaceOldFormat(keys);
2573                xmlAttributeToKeyConversion(keys);
2574                keyToStringConversion(keys);
2575                setPickupSwitchListMessageFormat(keys);
2576            }
2577        }
2578        if (operations.getChild(Xml.SWITCH_LIST_DROP_CAR_FORMAT) != null) {
2579            if ((a = operations.getChild(Xml.SWITCH_LIST_DROP_CAR_FORMAT).getAttribute(Xml.PREFIX)) != null) {
2580                setSwitchListDropCarPrefix(a.getValue());
2581            }
2582            if ((a = operations.getChild(Xml.SWITCH_LIST_DROP_CAR_FORMAT).getAttribute(Xml.SETTING)) != null) {
2583                String setting = a.getValue();
2584                log.debug("switchListDropCarFormat: {}", setting);
2585                String[] keys = setting.split(",");
2586                replaceOldFormat(keys);
2587                xmlAttributeToKeyConversion(keys);
2588                keyToStringConversion(keys);
2589                setDropSwitchListMessageFormat(keys);
2590            }
2591        }
2592        if (operations.getChild(Xml.SWITCH_LIST_LOCAL_FORMAT) != null) {
2593            if ((a = operations.getChild(Xml.SWITCH_LIST_LOCAL_FORMAT).getAttribute(Xml.PREFIX)) != null) {
2594                setSwitchListLocalPrefix(a.getValue());
2595            }
2596            if ((a = operations.getChild(Xml.SWITCH_LIST_LOCAL_FORMAT).getAttribute(Xml.SETTING)) != null) {
2597                String setting = a.getValue();
2598                log.debug("switchListLocalFormat: {}", setting);
2599                String[] keys = setting.split(",");
2600                replaceOldFormat(keys);
2601                xmlAttributeToKeyConversion(keys);
2602                keyToStringConversion(keys);
2603                setLocalSwitchListMessageFormat(keys);
2604            }
2605        }
2606        if (operations.getChild(Xml.PANEL) != null) {
2607            if ((a = operations.getChild(Xml.PANEL).getAttribute(Xml.NAME)) != null) {
2608                String panel = a.getValue();
2609                log.debug("panel: {}", panel);
2610                setPanelName(panel);
2611            }
2612            if ((a = operations.getChild(Xml.PANEL).getAttribute(Xml.TRAIN_ICONXY)) != null) {
2613                String enable = a.getValue();
2614                log.debug("TrainIconXY: {}", enable);
2615                setTrainIconCordEnabled(enable.equals(Xml.TRUE));
2616            }
2617            if ((a = operations.getChild(Xml.PANEL).getAttribute(Xml.TRAIN_ICON_APPEND)) != null) {
2618                String enable = a.getValue();
2619                log.debug("TrainIconAppend: {}", enable);
2620                setTrainIconAppendEnabled(enable.equals(Xml.TRUE));
2621            }
2622        }
2623        if ((operations.getChild(Xml.FONT_NAME) != null) &&
2624                (a = operations.getChild(Xml.FONT_NAME).getAttribute(Xml.NAME)) != null) {
2625            String font = a.getValue();
2626            log.debug("fontName: {}", font);
2627            setFontName(font);
2628        }
2629        if ((operations.getChild(Xml.FONT_SIZE) != null) &&
2630                (a = operations.getChild(Xml.FONT_SIZE).getAttribute(Xml.SIZE)) != null) {
2631            String size = a.getValue();
2632            log.debug("fontsize: {}", size);
2633            try {
2634                setManifestFontSize(Integer.parseInt(size));
2635            } catch (NumberFormatException ee) {
2636                log.error("Manifest font size ({}) isn't a valid number", a.getValue());
2637            }
2638        }
2639        if ((operations.getChild(Xml.PAGE_ORIENTATION) != null)) {
2640            if ((a = operations.getChild(Xml.PAGE_ORIENTATION).getAttribute(Xml.MANIFEST)) != null) {
2641                String orientation = a.getValue();
2642                log.debug("manifestOrientation: {}", orientation);
2643                setManifestOrientation(orientation);
2644            }
2645            if ((a = operations.getChild(Xml.PAGE_ORIENTATION).getAttribute(Xml.SWITCH_LIST)) != null) {
2646                String orientation = a.getValue();
2647                log.debug("switchListOrientation: {}", orientation);
2648                setSwitchListOrientation(orientation);
2649            }
2650        }
2651        if ((operations.getChild(Xml.PRINT_DUPLEX) != null)) {
2652            if ((a = operations.getChild(Xml.PRINT_DUPLEX).getAttribute(Xml.NAME)) != null) {
2653                String sides = a.getValue();
2654                log.debug("Print duplex: {}", sides);
2655                if (sides.equals(SidesType.TWO_SIDED_LONG_EDGE.toString())) {
2656                    setPrintDuplexSides(SidesType.TWO_SIDED_LONG_EDGE);
2657                }
2658                if (sides.equals(SidesType.TWO_SIDED_SHORT_EDGE.toString())) {
2659                    setPrintDuplexSides(SidesType.TWO_SIDED_SHORT_EDGE);
2660                }
2661            }
2662        }
2663        if ((operations.getChild(Xml.MANIFEST_COLORS) != null)) {
2664            if ((a = operations.getChild(Xml.MANIFEST_COLORS).getAttribute(Xml.DROP_COLOR)) != null) {
2665                String dropColor = a.getValue();
2666                log.debug("dropColor: {}", dropColor);
2667                setDropTextColor(dropColor);
2668            }
2669            if ((a = operations.getChild(Xml.MANIFEST_COLORS).getAttribute(Xml.PICKUP_COLOR)) != null) {
2670                String pickupColor = a.getValue();
2671                log.debug("pickupColor: {}", pickupColor);
2672                setPickupTextColor(pickupColor);
2673            }
2674            if ((a = operations.getChild(Xml.MANIFEST_COLORS).getAttribute(Xml.LOCAL_COLOR)) != null) {
2675                String localColor = a.getValue();
2676                log.debug("localColor: {}", localColor);
2677                setLocalTextColor(localColor);
2678            }
2679            if ((a = operations.getChild(Xml.MANIFEST_COLORS).getAttribute(Xml.DROP_ENGINE_COLOR)) != null) {
2680                String dropColor = a.getValue();
2681                log.debug("dropEngineColor: {}", dropColor);
2682                setDropEngineTextColor(dropColor);
2683            } else {
2684                // Engine drop color didn't exist before 5.11.3
2685                setDropEngineTextColor(getDropTextColor());
2686            }
2687            if ((a = operations.getChild(Xml.MANIFEST_COLORS).getAttribute(Xml.PICKUP_ENGINE_COLOR)) != null) {
2688                String pickupColor = a.getValue();
2689                log.debug("pickupEngineColor: {}", pickupColor);
2690                setPickupEngineTextColor(pickupColor);
2691            } else {
2692                // Engine pick up color didn't exist before 5.11.3
2693                setPickupEngineTextColor(getPickupTextColor());
2694            }
2695        }
2696        if ((operations.getChild(Xml.TAB) != null)) {
2697            if ((a = operations.getChild(Xml.TAB).getAttribute(Xml.ENABLED)) != null) {
2698                String enable = a.getValue();
2699                log.debug("tab: {}", enable);
2700                setTabEnabled(enable.equals(Xml.TRUE));
2701            }
2702            if ((a = operations.getChild(Xml.TAB).getAttribute(Xml.LENGTH)) != null) {
2703                String length = a.getValue();
2704                log.debug("tab 1 length: {}", length);
2705                try {
2706                    setTab1length(Integer.parseInt(length));
2707                } catch (NumberFormatException ee) {
2708                    log.error("Tab 1 length ({}) isn't a valid number", a.getValue());
2709                }
2710            }
2711            if ((a = operations.getChild(Xml.TAB).getAttribute(Xml.TAB2_LENGTH)) != null) {
2712                String length = a.getValue();
2713                log.debug("tab 2 length: {}", length);
2714                try {
2715                    setTab2length(Integer.parseInt(length));
2716                } catch (NumberFormatException ee) {
2717                    log.error("Tab 2 length ({}) isn't a valid number", a.getValue());
2718                }
2719            }
2720            if ((a = operations.getChild(Xml.TAB).getAttribute(Xml.TAB3_LENGTH)) != null) {
2721                String length = a.getValue();
2722                log.debug("tab 3 length: {}", length);
2723                try {
2724                    setTab3length(Integer.parseInt(length));
2725                } catch (NumberFormatException ee) {
2726                    log.error("Tab 3 length ({}) isn't a valid number", a.getValue());
2727                }
2728            }
2729        }
2730        if ((operations.getChild(Xml.MANIFEST) != null)) {
2731            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_LOC_COMMENTS)) != null) {
2732                String enable = a.getValue();
2733                log.debug("manifest printLocComments: {}", enable);
2734                setPrintLocationCommentsEnabled(enable.equals(Xml.TRUE));
2735            }
2736            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_ROUTE_COMMENTS)) != null) {
2737                String enable = a.getValue();
2738                log.debug("manifest printRouteComments: {}", enable);
2739                setPrintRouteCommentsEnabled(enable.equals(Xml.TRUE));
2740            }
2741            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_LOADS_EMPTIES)) != null) {
2742                String enable = a.getValue();
2743                log.debug("manifest printLoadsEmpties: {}", enable);
2744                setPrintLoadsAndEmptiesEnabled(enable.equals(Xml.TRUE));
2745            }
2746            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_TRAIN_SCHEDULE)) != null) {
2747                String enable = a.getValue();
2748                log.debug("manifest printTrainSchedule: {}", enable);
2749                setPrintTrainScheduleNameEnabled(enable.equals(Xml.TRUE));
2750            }
2751            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.USE12HR_FORMAT)) != null) {
2752                String enable = a.getValue();
2753                log.debug("manifest use12hrFormat: {}", enable);
2754                set12hrFormatEnabled(enable.equals(Xml.TRUE));
2755            }
2756            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_VALID)) != null) {
2757                String enable = a.getValue();
2758                log.debug("manifest printValid: {}", enable);
2759                setPrintValidEnabled(enable.equals(Xml.TRUE));
2760            }
2761            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.SORT_BY_TRACK)) != null) {
2762                String enable = a.getValue();
2763                log.debug("manifest sortByTrack: {}", enable);
2764                setSortByTrackNameEnabled(enable.equals(Xml.TRUE));
2765            }
2766            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_PAGE_HEADER)) != null) {
2767                String enable = a.getValue();
2768                log.debug("manifest printPageHeader: {}", enable);
2769                setPrintPageHeaderEnabled(enable.equals(Xml.TRUE));
2770            }
2771            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_HEADERS)) != null) {
2772                String enable = a.getValue();
2773                log.debug("manifest print headers: {}", enable);
2774                setPrintHeadersEnabled(enable.equals(Xml.TRUE));
2775            }
2776            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_NO_PAGE_BREAKS)) != null) {
2777                String enable = a.getValue();
2778                log.debug("printNoPageBreaks: {}", enable);
2779                setPrintNoPageBreaksEnabled(enable.equals(Xml.TRUE));
2780            }
2781            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.TRUNCATE)) != null) {
2782                String enable = a.getValue();
2783                log.debug("manifest truncate: {}", enable);
2784                setPrintTruncateManifestEnabled(enable.equals(Xml.TRUE));
2785            }
2786            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.USE_DEPARTURE_TIME)) != null) {
2787                String enable = a.getValue();
2788                log.debug("manifest use departure time: {}", enable);
2789                setUseDepartureTimeEnabled(enable.equals(Xml.TRUE));
2790            }
2791            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.USE_EDITOR)) != null) {
2792                String enable = a.getValue();
2793                log.debug("manifest useEditor: {}", enable);
2794                setManifestEditorEnabled(enable.equals(Xml.TRUE));
2795            }
2796            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_CABOOSE_LOAD)) != null) {
2797                String enable = a.getValue();
2798                log.debug("manifest print caboose load: {}", enable);
2799                setPrintCabooseLoadEnabled(enable.equals(Xml.TRUE));
2800            }
2801            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_PASSENGER_LOAD)) != null) {
2802                String enable = a.getValue();
2803                log.debug("manifest print passenger load: {}", enable);
2804                setPrintPassengerLoadEnabled(enable.equals(Xml.TRUE));
2805            }
2806            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.GROUP_MOVES)) != null) {
2807                String enable = a.getValue();
2808                log.debug("manifest group car moves: {}", enable);
2809                setGroupCarMoves(enable.equals(Xml.TRUE));
2810            }
2811            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.PRINT_LOCO_LAST)) != null) {
2812                String enable = a.getValue();
2813                log.debug("manifest print loco last: {}", enable);
2814                setPrintLocoLast(enable.equals(Xml.TRUE));
2815            }
2816            if ((a = operations.getChild(Xml.MANIFEST).getAttribute(Xml.HAZARDOUS_MSG)) != null) {
2817                String message = a.getValue();
2818                log.debug("manifest hazardousMsg: {}", message);
2819                setHazardousMsg(message);
2820            }
2821        }
2822        if ((operations.getChild(Xml.MANIFEST_FORMAT) != null)) {
2823            if ((a = operations.getChild(Xml.MANIFEST_FORMAT).getAttribute(Xml.VALUE)) != null) {
2824                switch (a.getValue()) {
2825                    case Xml.STANDARD:
2826                        getDefault().manifestFormat = STANDARD_FORMAT;
2827                        break;
2828                    case Xml.TWO_COLUMN:
2829                        getDefault().manifestFormat = TWO_COLUMN_FORMAT;
2830                        break;
2831                    case Xml.TWO_COLUMN_TRACK:
2832                        getDefault().manifestFormat = TWO_COLUMN_TRACK_FORMAT;
2833                        break;
2834                    default:
2835                        log.debug("Unknown manifest format");
2836                }
2837            }
2838        } else if ((operations.getChild(Xml.COLUMN_FORMAT) != null)) {
2839            if ((a = operations.getChild(Xml.COLUMN_FORMAT).getAttribute(Xml.TWO_COLUMNS)) != null) {
2840                String enable = a.getValue();
2841                log.debug("two columns: {}", enable);
2842                if (enable.equals(Xml.TRUE)) {
2843                    setManifestFormat(TWO_COLUMN_FORMAT);
2844                }
2845            }
2846        }
2847        if ((operations.getChild(Xml.HEADER_LINES) != null)) {
2848            if ((a = operations.getChild(Xml.HEADER_LINES).getAttribute(Xml.PRINT_HEADER_LINE1)) != null) {
2849                String enable = a.getValue();
2850                setPrintHeaderLine1Enabled(enable.equals(Xml.TRUE));
2851            }
2852            if ((a = operations.getChild(Xml.HEADER_LINES).getAttribute(Xml.PRINT_HEADER_LINE2)) != null) {
2853                String enable = a.getValue();
2854                setPrintHeaderLine2Enabled(enable.equals(Xml.TRUE));
2855            }
2856            if ((a = operations.getChild(Xml.HEADER_LINES).getAttribute(Xml.PRINT_HEADER_LINE3)) != null) {
2857                String enable = a.getValue();
2858                setPrintHeaderLine3Enabled(enable.equals(Xml.TRUE));
2859            }
2860        }
2861        // get manifest logo
2862        if ((operations.getChild(Xml.MANIFEST_LOGO) != null)) {
2863            if ((a = operations.getChild(Xml.MANIFEST_LOGO).getAttribute(Xml.NAME)) != null) {
2864                setManifestLogoURL(a.getValue());
2865            }
2866        }
2867        // manifest file options
2868        if ((operations.getChild(Xml.MANIFEST_FILE_OPTIONS) != null)) {
2869            if ((a = operations.getChild(Xml.MANIFEST_FILE_OPTIONS).getAttribute(Xml.MANIFEST_SAVE)) != null) {
2870                String enable = a.getValue();
2871                log.debug("manifest file save option: {}", enable);
2872                getDefault().saveTrainManifests = enable.equals(Xml.TRUE);
2873            }
2874        }
2875        if ((operations.getChild(Xml.BUILD_OPTIONS) != null)) {
2876            if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.AGGRESSIVE)) != null) {
2877                String enable = a.getValue();
2878                log.debug("aggressive: {}", enable);
2879                setBuildAggressive(enable.equals(Xml.TRUE));
2880            }
2881            if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.NUMBER_PASSES)) != null) {
2882                String number = a.getValue();
2883                log.debug("number of passes: {}", number);
2884                try {
2885                    setNumberPasses(Integer.parseInt(number));
2886                } catch (NumberFormatException ne) {
2887                    log.debug("Number of passes isn't a number");
2888                }
2889            }
2890            if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ON_TIME)) != null) {
2891                String enable = a.getValue();
2892                log.debug("on time: {}", enable);
2893                setBuildOnTime(enable.equals(Xml.TRUE));
2894            }
2895            if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.DWELL_TIME)) != null) {
2896                String minutes = a.getValue();
2897                log.debug("dwell time: {}", minutes);
2898                try {
2899                    setDwellTime(Integer.parseInt(minutes));
2900                } catch (NumberFormatException ne) {
2901                    log.debug("dwell time isn't a number");
2902                }
2903            }
2904            if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ALLOW_LOCAL_INTERCHANGE)) != null) {
2905                String enable = a.getValue();
2906                log.debug("allowLocalInterchangeMoves: {}", enable);
2907                setLocalInterchangeMovesEnabled(enable.equals(Xml.TRUE));
2908            }
2909            if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ALLOW_LOCAL_SPUR)) != null) {
2910                String enable = a.getValue();
2911                log.debug("allowLocalSpurMoves: {}", enable);
2912                setLocalSpurMovesEnabled(enable.equals(Xml.TRUE));
2913            } else if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ALLOW_LOCAL_SIDING)) != null) {
2914                String enable = a.getValue();
2915                log.debug("allowLocalSidingMoves: {}", enable);
2916                setLocalSpurMovesEnabled(enable.equals(Xml.TRUE));
2917            }
2918            if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ALLOW_LOCAL_YARD)) != null) {
2919                String enable = a.getValue();
2920                log.debug("allowLocalYardMoves: {}", enable);
2921                setLocalYardMovesEnabled(enable.equals(Xml.TRUE));
2922            }
2923            if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.STAGING_RESTRICTION_ENABLED)) != null) {
2924                String enable = a.getValue();
2925                log.debug("stagingRestrictionEnabled: {}", enable);
2926                setStagingTrainCheckEnabled(enable.equals(Xml.TRUE));
2927            }
2928            if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.STAGING_TRACK_AVAIL)) != null) {
2929                String enable = a.getValue();
2930                log.debug("stagingTrackAvail: {}", enable);
2931                setStagingTrackImmediatelyAvail(enable.equals(Xml.TRUE));
2932            }
2933            if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.ALLOW_RETURN_STAGING)) != null) {
2934                String enable = a.getValue();
2935                log.debug("allowReturnStaging: {}", enable);
2936                getDefault().allowCarsReturnStaging = enable.equals(Xml.TRUE);
2937            }
2938            if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.PROMPT_STAGING_ENABLED)) != null) {
2939                String enable = a.getValue();
2940                log.debug("promptStagingEnabled: {}", enable);
2941                setStagingPromptFromEnabled(enable.equals(Xml.TRUE));
2942            }
2943            if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.PROMPT_TO_STAGING_ENABLED)) != null) {
2944                String enable = a.getValue();
2945                log.debug("promptToStagingEnabled: {}", enable);
2946                setStagingPromptToEnabled(enable.equals(Xml.TRUE));
2947            }
2948            if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.STAGING_TRY_NORMAL)) != null) {
2949                String enable = a.getValue();
2950                log.debug("stagingTryNormalEnabled: {}", enable);
2951                setStagingTryNormalBuildEnabled(enable.equals(Xml.TRUE));
2952            }
2953            if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.GENERATE_CSV_MANIFEST)) != null) {
2954                String enable = a.getValue();
2955                log.debug("generateCvsManifest: {}", enable);
2956                getDefault().generateCsvManifest = enable.equals(Xml.TRUE);
2957            }
2958            if ((a = operations.getChild(Xml.BUILD_OPTIONS).getAttribute(Xml.GENERATE_CSV_SWITCH_LIST)) != null) {
2959                String enable = a.getValue();
2960                log.debug("generateCvsSwitchList: {}", enable);
2961                getDefault().generateCsvSwitchList = enable.equals(Xml.TRUE);
2962            }
2963        }
2964        if (operations.getChild(Xml.BUILD_REPORT) != null) {
2965            if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.LEVEL)) != null) {
2966                String level = a.getValue();
2967                log.debug("buildReportLevel: {}", level);
2968                setBuildReportLevel(level);
2969            }
2970            if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.ROUTER_LEVEL)) != null) {
2971                String level = a.getValue();
2972                log.debug("routerBuildReportLevel: {}", level);
2973                setRouterBuildReportLevel(level);
2974            }
2975            if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.USE_EDITOR)) != null) {
2976                String enable = a.getValue();
2977                log.debug("build report useEditor: {}", enable);
2978                setBuildReportEditorEnabled(enable.equals(Xml.TRUE));
2979            }
2980            if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.INDENT)) != null) {
2981                String enable = a.getValue();
2982                log.debug("build report indent: {}", enable);
2983                setBuildReportIndentEnabled(enable.equals(Xml.TRUE));
2984            }
2985            if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.FONT_SIZE)) != null) {
2986                String size = a.getValue();
2987                log.debug("build font size: {}", size);
2988                try {
2989                    setBuildReportFontSize(Integer.parseInt(size));
2990                } catch (NumberFormatException ee) {
2991                    log.error("Build report font size ({}) isn't a valid number", a.getValue());
2992                }
2993            }
2994            if ((a = operations.getChild(Xml.BUILD_REPORT).getAttribute(Xml.ALWAYS_PREVIEW)) != null) {
2995                String enable = a.getValue();
2996                log.debug("build report always preview: {}", enable);
2997                setBuildReportAlwaysPreviewEnabled(enable.equals(Xml.TRUE));
2998            }
2999        }
3000
3001        if (operations.getChild(Xml.ROUTER) != null) {
3002            if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.CAR_ROUTING_ENABLED)) != null) {
3003                String enable = a.getValue();
3004                log.debug("carRoutingEnabled: {}", enable);
3005                setCarRoutingEnabled(enable.equals(Xml.TRUE));
3006            }
3007            if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.CAR_ROUTING_VIA_YARDS)) != null) {
3008                String enable = a.getValue();
3009                log.debug("carRoutingViaYards: {}", enable);
3010                setCarRoutingViaYardsEnabled(enable.equals(Xml.TRUE));
3011            }
3012            if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.CAR_ROUTING_VIA_STAGING)) != null) {
3013                String enable = a.getValue();
3014                log.debug("carRoutingViaStaging: {}", enable);
3015                setCarRoutingViaStagingEnabled(enable.equals(Xml.TRUE));
3016            }
3017            if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.FORWARD_TO_YARD)) != null) {
3018                String enable = a.getValue();
3019                log.debug("forwardToYard: {}", enable);
3020                setForwardToYardEnabled(enable.equals(Xml.TRUE));
3021            }
3022            if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.ONLY_ACTIVE_TRAINS)) != null) {
3023                String enable = a.getValue();
3024                log.debug("onlyActiveTrains: {}", enable);
3025                setOnlyActiveTrainsEnabled(enable.equals(Xml.TRUE));
3026            }
3027            if ((a = operations.getChild(Xml.ROUTER).getAttribute(Xml.CHECK_CAR_DESTINATION)) != null) {
3028                String enable = a.getValue();
3029                log.debug("checkCarDestination: {}", enable);
3030                setCheckCarDestinationEnabled(enable.equals(Xml.TRUE));
3031            }
3032        } else if (operations.getChild(Xml.SETTINGS) != null) {
3033            // the next four items are for backwards compatibility
3034            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CAR_ROUTING_ENABLED)) != null) {
3035                String enable = a.getValue();
3036                log.debug("carRoutingEnabled: {}", enable);
3037                setCarRoutingEnabled(enable.equals(Xml.TRUE));
3038            }
3039            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CAR_ROUTING_VIA_YARDS)) != null) {
3040                String enable = a.getValue();
3041                log.debug("carRoutingViaYards: {}", enable);
3042                setCarRoutingViaYardsEnabled(enable.equals(Xml.TRUE));
3043            }
3044            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CAR_ROUTING_VIA_STAGING)) != null) {
3045                String enable = a.getValue();
3046                log.debug("carRoutingViaStaging: {}", enable);
3047                setCarRoutingViaStagingEnabled(enable.equals(Xml.TRUE));
3048            }
3049            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.FORWARD_TO_YARD)) != null) {
3050                String enable = a.getValue();
3051                log.debug("forwardToYard: {}", enable);
3052                setForwardToYardEnabled(enable.equals(Xml.TRUE));
3053            }
3054        }
3055
3056        if ((operations.getChild(Xml.OWNER) != null) &&
3057                (a = operations.getChild(Xml.OWNER).getAttribute(Xml.NAME)) != null) {
3058            String owner = a.getValue();
3059            log.debug("owner: {}", owner);
3060            setOwnerName(owner);
3061        }
3062        if (operations.getChild(Xml.ICON_COLOR) != null) {
3063            if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.NORTH)) != null) {
3064                String color = a.getValue();
3065                log.debug("north color: {}", color);
3066                setTrainIconColorNorth(color);
3067            }
3068            if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.SOUTH)) != null) {
3069                String color = a.getValue();
3070                log.debug("south color: {}", color);
3071                setTrainIconColorSouth(color);
3072            }
3073            if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.EAST)) != null) {
3074                String color = a.getValue();
3075                log.debug("east color: {}", color);
3076                setTrainIconColorEast(color);
3077            }
3078            if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.WEST)) != null) {
3079                String color = a.getValue();
3080                log.debug("west color: {}", color);
3081                setTrainIconColorWest(color);
3082            }
3083            if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.LOCAL)) != null) {
3084                String color = a.getValue();
3085                log.debug("local color: {}", color);
3086                setTrainIconColorLocal(color);
3087            }
3088            if ((a = operations.getChild(Xml.ICON_COLOR).getAttribute(Xml.TERMINATE)) != null) {
3089                String color = a.getValue();
3090                log.debug("terminate color: {}", color);
3091                setTrainIconColorTerminate(color);
3092            }
3093        }
3094        if (operations.getChild(Xml.COMMENTS) != null) {
3095            if ((a = operations.getChild(Xml.COMMENTS).getAttribute(Xml.MISPLACED_CARS)) != null) {
3096                String comment = a.getValue();
3097                log.debug("Misplaced comment: {}", comment);
3098                setMiaComment(comment);
3099            }
3100        }
3101
3102        if (operations.getChild(Xml.DISPLAY) != null) {
3103            if ((a = operations.getChild(Xml.DISPLAY).getAttribute(Xml.SHOW_TRACK_MOVES)) != null) {
3104                String enable = a.getValue();
3105                log.debug("show track moves: {}", enable);
3106                getDefault().showTrackMoves = enable.equals(Xml.TRUE);
3107            }
3108        }
3109
3110        if (operations.getChild(Xml.VSD) != null) {
3111            if ((a = operations.getChild(Xml.VSD).getAttribute(Xml.ENABLE_PHYSICAL_LOCATIONS)) != null) {
3112                String enable = a.getValue();
3113                setVsdPhysicalLocationEnabled(enable.equals(Xml.TRUE));
3114            }
3115        }
3116        if (operations.getChild(Xml.CATS) != null) {
3117            if ((a = operations.getChild(Xml.CATS).getAttribute(Xml.EXACT_LOCATION_NAME)) != null) {
3118                String enable = a.getValue();
3119                AbstractOperationsServer.setExactLocationName(enable.equals(Xml.TRUE));
3120            }
3121        }
3122
3123        if (operations.getChild(Xml.SETTINGS) != null) {
3124            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.AUTO_SAVE)) != null) {
3125                String enabled = a.getValue();
3126                log.debug("autoSave: {}", enabled);
3127                setAutoSaveEnabled(enabled.equals(Xml.TRUE));
3128            }
3129            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.AUTO_BACKUP)) != null) {
3130                String enabled = a.getValue();
3131                log.debug("autoBackup: {}", enabled);
3132                setAutoBackupEnabled(enabled.equals(Xml.TRUE));
3133            }
3134        }
3135
3136        if (operations.getChild(Xml.LOGGER) != null) {
3137            if ((a = operations.getChild(Xml.LOGGER).getAttribute(Xml.CAR_LOGGER)) != null) {
3138                String enable = a.getValue();
3139                log.debug("carLogger: {}", enable);
3140                getDefault().carLogger = enable.equals(Xml.TRUE);
3141            }
3142            if ((a = operations.getChild(Xml.LOGGER).getAttribute(Xml.ENGINE_LOGGER)) != null) {
3143                String enable = a.getValue();
3144                log.debug("engineLogger: {}", enable);
3145                getDefault().engineLogger = enable.equals(Xml.TRUE);
3146            }
3147            if ((a = operations.getChild(Xml.LOGGER).getAttribute(Xml.TRAIN_LOGGER)) != null) {
3148                String enable = a.getValue();
3149                log.debug("trainLogger: {}", enable);
3150                getDefault().trainLogger = enable.equals(Xml.TRUE);
3151            }
3152        } else if (operations.getChild(Xml.SETTINGS) != null) {
3153            // for backward compatibility
3154            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.CAR_LOGGER)) != null) {
3155                String enable = a.getValue();
3156                log.debug("carLogger: {}", enable);
3157                getDefault().carLogger = enable.equals(Xml.TRUE);
3158            }
3159            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.ENGINE_LOGGER)) != null) {
3160                String enable = a.getValue();
3161                log.debug("engineLogger: {}", enable);
3162                getDefault().engineLogger = enable.equals(Xml.TRUE);
3163            }
3164            if ((a = operations.getChild(Xml.SETTINGS).getAttribute(Xml.TRAIN_LOGGER)) != null) {
3165                String enable = a.getValue();
3166                log.debug("trainLogger: {}", enable);
3167                getDefault().trainLogger = enable.equals(Xml.TRUE);
3168            }
3169        }
3170        if (operations.getChild(Xml.DAY_NAME_MAP) != null) {
3171            List<Element> eMap = operations.getChild(Xml.DAY_NAME_MAP).getChildren(Xml.MAP);
3172            for (Element eDay : eMap) {
3173                if (eDay.getAttribute(Xml.DAY) != null && eDay.getAttribute(Xml.NAME) != null) {
3174                    String day = eDay.getAttribute(Xml.DAY).getValue();
3175                    String name = eDay.getAttribute(Xml.NAME).getValue();
3176                    setDayToName(day, name);
3177                    log.debug("Mapping day: {} to name: {}", day, name);
3178                }
3179            }
3180        }
3181    }
3182
3183    // replace old pickup and drop message keys
3184    // Change happened from 2.11.3 to 2.11.4
3185    // 4/16/2014
3186    private static void replaceOldFormat(String[] format) {
3187        for (int i = 0; i < format.length; i++) {
3188            if (format[i].equals("Pickup Msg")) // NOI18N
3189            {
3190                format[i] = PICKUP_COMMENT;
3191            } else if (format[i].equals("Drop Msg")) // NOI18N
3192            {
3193                format[i] = DROP_COMMENT;
3194            }
3195        }
3196    }
3197
3198    /**
3199     * Converts the xml key to the proper locale text
3200     *
3201     */
3202    private static void keyToStringConversion(String[] keys) {
3203        for (int i = 0; i < keys.length; i++) {
3204            if (keys[i].equals(BLANK)) {
3205                continue;
3206            }
3207            try {
3208                keys[i] = Bundle.getMessage(keys[i]);
3209            } catch (Exception e) {
3210                log.warn("Key {}: ({}) not found", i, keys[i]);
3211            }
3212        }
3213    }
3214
3215    /*
3216     * Converts the strings into English tags for xml storage
3217     *
3218     */
3219    public static void stringToTagConversion(String[] strings) {
3220        for (int i = 0; i < strings.length; i++) {
3221            if (strings[i].equals(BLANK)) {
3222                continue;
3223            }
3224            for (String key : KEYS) {
3225                if (strings[i].equals(Bundle.getMessage(key))) {
3226                    strings[i] = Bundle.getMessage(Locale.ROOT, key);
3227                    break;
3228                }
3229            }
3230            // log.debug("Converted {} to {}", old, strings[i]);
3231        }
3232    }
3233
3234    /*
3235     * The xml attributes stored using the English translation. This converts the
3236     * attribute to the appropriate key for language conversion.
3237     */
3238    private static void xmlAttributeToKeyConversion(String[] format) {
3239        for (int i = 0; i < format.length; i++) {
3240            for (String key : KEYS) {
3241                if (format[i].equals(Bundle.getMessage(Locale.ROOT, key))) {
3242                    format[i] = key;
3243                }
3244            }
3245        }
3246    }
3247
3248    protected static void setDirtyAndFirePropertyChange(String p, Object old, Object n) {
3249        InstanceManager.getDefault(OperationsSetupXml.class).setDirty(true);
3250        getDefault().firePropertyChange(p, old, n);
3251    }
3252
3253    public static Setup getDefault() {
3254        return InstanceManager.getDefault(Setup.class);
3255    }
3256
3257    private static final Logger log = LoggerFactory.getLogger(Setup.class);
3258
3259    @Override
3260    public void dispose() {
3261        AutoSave.stop();
3262    }
3263
3264}