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