// test Track drop support public void testTrackDropSupport() { Location l = new Location("Location Test Drop id", "Location Test Name"); Track t = new Track("Test id", "Test Name", "Test Type", l); Assert.assertEquals("Location Track Car id", "Test id", t.getId()); Assert.assertEquals("Location Track Car Name", "Test Name", t.getName()); Assert.assertEquals("Location Track Car Type", "Test Type", t.getTrackType()); Assert.assertEquals("Location", l, t.getLocation()); Assert.assertEquals("Location Track Drops Start", 0, t.getDropRS()); Assert.assertEquals("Location Track Drops Start Reserved", 0, t.getReserved()); Car c1 = new Car("TESTROAD", "TESTNUMBER1"); c1.setLength("40"); t.addDropRS(c1); Assert.assertEquals("Location Track Drops 1st", 1, t.getDropRS()); Assert.assertEquals("Location Track Drops 1st Reserved", 40 + 4, t.getReserved()); Car c2 = new Car("TESTROAD", "TESTNUMBER2"); c2.setLength("50"); t.addDropRS(c2); Assert.assertEquals("Location Track Drops 2nd", 2, t.getDropRS()); Assert.assertEquals("Location Track Drops 2nd Reserved", 40 + 4 + 50 + 4, t.getReserved()); t.deleteDropRS(c2); Assert.assertEquals("Location Track Drops 3rd", 1, t.getDropRS()); Assert.assertEquals("Location Track Drops 3rd Reserved", 40 + 4, t.getReserved()); t.deleteDropRS(c1); Assert.assertEquals("Location Track Drops 4th", 0, t.getDropRS()); Assert.assertEquals("Location Track Drops 4th Reserved", 0, t.getReserved()); }
// test Track load support public void testTrackLoadSupport() { Location l = new Location("Location Test Load id", "Location Test Name"); Track t = new Track("Test id", "Test Name", "Test Type", l); Assert.assertEquals("Location Track Car id", "Test id", t.getId()); Assert.assertEquals("Location Track Car Name", "Test Name", t.getName()); Assert.assertEquals("Location Track Car Type", "Test Type", t.getTrackType()); Assert.assertEquals("Location", l, t.getLocation()); /* Test Load Swapable */ Assert.assertEquals("Location Track Load Swapable default", false, t.isLoadSwapEnabled()); t.setLoadSwapEnabled(true); Assert.assertEquals("Location Track Load Swapable true", true, t.isLoadSwapEnabled()); t.setLoadSwapEnabled(false); Assert.assertEquals("Location Track Load Swapable false", false, t.isLoadSwapEnabled()); /* Test Remove Loads */ Assert.assertEquals( "Location Track Remove Loads default", false, t.isRemoveCustomLoadsEnabled()); t.setRemoveCustomLoadsEnabled(true); Assert.assertEquals("Location Track Remove Loads true", true, t.isRemoveCustomLoadsEnabled()); t.setRemoveCustomLoadsEnabled(false); Assert.assertEquals("Location Track Remove Loads false", false, t.isRemoveCustomLoadsEnabled()); /* Test Add Loads */ Assert.assertEquals("Location Track Add Loads default", false, t.isAddCustomLoadsEnabled()); t.setAddCustomLoadsEnabled(true); Assert.assertEquals("Location Track Add Loads true", true, t.isAddCustomLoadsEnabled()); t.setAddCustomLoadsEnabled(false); Assert.assertEquals("Location Track Add Loads false", false, t.isAddCustomLoadsEnabled()); }
public void testStagingTrackOrder() { Location l = LocationManager.instance().newLocation("TestOrder"); Track t = l.addTrack("New track 3", Track.STAGING); Assert.assertEquals("Location", l, t.getLocation()); t.setServiceOrder(Track.FIFO); Assert.assertEquals("Track Order", Track.NORMAL, t.getServiceOrder()); t.setServiceOrder(Track.LIFO); Assert.assertEquals("Track Order", Track.NORMAL, t.getServiceOrder()); }
public void testInterchangeTrackOrder() { Location l = LocationManager.instance().newLocation("TestOrder"); Track t = l.addTrack("New track 4", Track.INTERCHANGE); Assert.assertEquals("Location", l, t.getLocation()); // yards and interchanges do support this feature t.setServiceOrder(Track.FIFO); Assert.assertEquals("Track Order", Track.FIFO, t.getServiceOrder()); t.setServiceOrder(Track.LIFO); Assert.assertEquals("Track Order", Track.LIFO, t.getServiceOrder()); }
public void testSpurTrackOrder() { Location l = LocationManager.instance().newLocation("TestOrder"); Track t = l.addTrack("New track 1", Track.SPUR); Assert.assertEquals("Location", l, t.getLocation()); // sidings and staging don't support this feature t.setServiceOrder(Track.FIFO); Assert.assertEquals("Track Order", Track.NORMAL, t.getServiceOrder()); t.setServiceOrder(Track.LIFO); Assert.assertEquals("Track Order", Track.NORMAL, t.getServiceOrder()); }
public ScheduleOptionsFrame(ScheduleEditFrame sef) { super(); // the following code sets the frame's initial state getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); _track = sef._track; // load the panel // row 1 JPanel pFactor = new JPanel(); pFactor.setLayout(new GridBagLayout()); pFactor.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("ScheduleFactor"))); addItem(pFactor, factorTextField, 0, 0); factorTextField.setToolTipText(Bundle.getMessage("TipScheduleFactor")); factorTextField.setText(Integer.toString(_track.getReservationFactor())); // row 2 JPanel pAlternate = new JPanel(); pAlternate.setLayout(new GridBagLayout()); pAlternate.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("AlternateTrack"))); addItem(pAlternate, trackBox, 0, 0); _track.getLocation().updateComboBox(trackBox); trackBox.removeItem(_track); // remove this track from consideration trackBox.setSelectedItem(_track.getAlternateTrack()); JPanel pControls = new JPanel(); pControls.add(saveButton); // button action addButtonAction(saveButton); getContentPane().add(pFactor); getContentPane().add(pAlternate); getContentPane().add(pControls); setTitle(Bundle.getMessage("MenuItemScheduleOptions")); pack(); setMinimumSize(new Dimension(Control.panelWidth300, Control.panelHeight200)); setVisible(true); }
// test Track schedule support public void testTrackScheduleSupport() { Location l = new Location("Location Test Schedule id", "Location Test Name"); Track t = new Track("Test id", "Test Name", Track.SPUR, l); Assert.assertEquals("Location Track Car id", "Test id", t.getId()); Assert.assertEquals("Location Track Car Name", "Test Name", t.getName()); Assert.assertEquals("Location Track Car Type", Track.SPUR, t.getTrackType()); Assert.assertEquals("Location", l, t.getLocation()); t.setScheduleId("Test Schedule Id"); Assert.assertEquals("Location Track set Schedule Name", "Test Schedule Id", t.getScheduleId()); t.setScheduleItemId("Test Schedule Item Id"); Assert.assertEquals( "Location Track set Schedule Item Id", "Test Schedule Item Id", t.getScheduleItemId()); t.setScheduleCount(2); Assert.assertEquals("Location Track set Schedule Count", 2, t.getScheduleCount()); t.setScheduleMode(Track.SEQUENTIAL); Assert.assertEquals("Track mode sequential", Track.SEQUENTIAL, t.getScheduleMode()); t.setScheduleMode(Track.MATCH); Assert.assertEquals("Track mode sequential", Track.MATCH, t.getScheduleMode()); }
// test Track pickup support public void testTrackPickUpSupport() { Location l = new Location("Location Test Pickup id", "Location Test Name"); Track t = new Track("Test id", "Test Name", "Test Type", l); Assert.assertEquals("Location Track Car id", "Test id", t.getId()); Assert.assertEquals("Location Track Car Name", "Test Name", t.getName()); Assert.assertEquals("Location Track Car Type", "Test Type", t.getTrackType()); Assert.assertEquals("Location", l, t.getLocation()); Assert.assertEquals("Location Track Pick Ups Start", 0, t.getPickupRS()); Car c1 = new Car("TESTROAD", "TESTNUMBER1"); c1.setLength("40"); t.addPickupRS(c1); Assert.assertEquals("Location Track Pick Ups 1st", 1, t.getPickupRS()); t.addPickupRS(c1); Assert.assertEquals("Location Track Pick Ups 2nd", 2, t.getPickupRS()); t.deletePickupRS(c1); Assert.assertEquals("Location Track Pick Ups 3rd", 1, t.getPickupRS()); t.deletePickupRS(c1); Assert.assertEquals("Location Track Pick Ups 4th", 0, t.getPickupRS()); }
// test Track attributes public void testTrackAttributes() { Location l = new Location("Location Test Attridutes id", "Location Test Name"); Track t = new Track("Test id", "Test Name", "Test Type", l); Assert.assertEquals("Location Track id", "Test id", t.getId()); Assert.assertEquals("Location Track Name", "Test Name", t.getName()); Assert.assertEquals("Location Track Type", "Test Type", t.getTrackType()); Assert.assertEquals("Location", l, t.getLocation()); t.setName("New Test Name"); Assert.assertEquals("Location Track set Name", "New Test Name", t.getName()); t.setComment("New Test Comment"); Assert.assertEquals("Location Track set Comment", "New Test Comment", t.getComment()); t.setMoves(40); Assert.assertEquals("Location Track Moves", 40, t.getMoves()); t.setLength(400); Assert.assertEquals("Location Track Length", 400, t.getLength()); t.setReserved(200); Assert.assertEquals("Location Track Reserved", 200, t.getReserved()); t.setUsedLength(100); Assert.assertEquals("Location Track Used Length", 100, t.getUsedLength()); t.setTrainDirections(Track.NORTH); Assert.assertEquals("Location Track Direction North", Track.NORTH, t.getTrainDirections()); t.setTrainDirections(Track.SOUTH); Assert.assertEquals("Location Track Direction South", Track.SOUTH, t.getTrainDirections()); t.setTrainDirections(Track.EAST); Assert.assertEquals("Location Track Direction East", Track.EAST, t.getTrainDirections()); t.setTrainDirections(Track.WEST); Assert.assertEquals("Location Track Direction West", Track.WEST, t.getTrainDirections()); t.setTrainDirections(Track.NORTH + Track.SOUTH); Assert.assertEquals( "Location Track Direction North+South", Track.NORTH + Track.SOUTH, t.getTrainDirections()); t.setTrainDirections(Track.EAST + Track.WEST); Assert.assertEquals( "Location Track Direction East+West", Track.EAST + Track.WEST, t.getTrainDirections()); t.setTrainDirections(Track.NORTH + Track.SOUTH + Track.EAST + Track.WEST); Assert.assertEquals( "Location Track Direction North+South+East+West", Track.NORTH + Track.SOUTH + Track.EAST + Track.WEST, t.getTrainDirections()); t.setRoadOption("New Test Road Option"); Assert.assertEquals( "Location Track set Road Option", "New Test Road Option", t.getRoadOption()); t.setDropOption("New Test Drop Option"); Assert.assertEquals( "Location Track set Drop Option", "New Test Drop Option", t.getDropOption()); t.setPickupOption("New Test Pickup Option"); Assert.assertEquals( "Location Track set Pickup Option", "New Test Pickup Option", t.getPickupOption()); }
// test Track typename support public void testTrackTypeNameSupport() { Location l = new Location("Location Test Name id", "Location Test Name"); Track t = new Track("Test id", "Test Name", "Test Type", l); Assert.assertEquals("Location Track id", "Test id", t.getId()); Assert.assertEquals("Location Track Name", "Test Name", t.getName()); Assert.assertEquals("Location Track Type", "Test Type", t.getTrackType()); Assert.assertEquals("Location", l, t.getLocation()); /* Test Type Name */ Assert.assertEquals( "Location Track Accepts Type Name undefined", false, t.acceptsTypeName("TestTypeName")); t.addTypeName("TestTypeName"); Assert.assertEquals( "Location Track Accepts Type Name defined", false, t.acceptsTypeName("TestTypeName")); // now add to car types CarTypes ct = CarTypes.instance(); ct.addName("TestTypeName"); t.addTypeName("TestTypeName"); Assert.assertEquals( "Location Track Accepts Type Name defined after ct", false, t.acceptsTypeName("TestTypeName")); // location must also accept the same type l.addTypeName("TestTypeName"); Assert.assertEquals( "Location Track Accepts Type Name defined after location", true, t.acceptsTypeName("TestTypeName")); t.deleteTypeName("TestTypeName"); Assert.assertEquals( "Location Track Accepts Type Name deleted", false, t.acceptsTypeName("TestTypeName")); /* Needed so later tests will behave correctly */ ct.deleteName("TestTypeName"); ct.addName("Baggager"); t.addTypeName("Baggager"); l.addTypeName("Baggager"); Assert.assertEquals( "Location Track Accepts Type Name Baggager", true, t.acceptsTypeName("Baggager")); /* Test Road Name */ t.setRoadOption(Track.INCLUDE_ROADS); Assert.assertEquals( "Location Track set Road Option INCLUDEROADS", "Include", t.getRoadOption()); Assert.assertEquals( "Location Track Accepts Road Name undefined", false, t.acceptsRoadName("TestRoadName")); t.addRoadName("TestRoadName"); Assert.assertEquals( "Location Track Accepts Road Name defined", true, t.acceptsRoadName("TestRoadName")); t.addRoadName("TestOtherRoadName"); Assert.assertEquals( "Location Track Accepts Road Name other defined", true, t.acceptsRoadName("TestRoadName")); t.deleteRoadName("TestRoadName"); Assert.assertEquals( "Location Track Accepts Road Name deleted", false, t.acceptsRoadName("TestRoadName")); t.setRoadOption(Track.ALL_ROADS); Assert.assertEquals("Location Track set Road Option AllROADS", "All", t.getRoadOption()); Assert.assertEquals( "Location Track Accepts All Road Names", true, t.acceptsRoadName("TestRoadName")); t.setRoadOption(Track.EXCLUDE_ROADS); Assert.assertEquals( "Location Track set Road Option EXCLUDEROADS", "Exclude", t.getRoadOption()); Assert.assertEquals( "Location Track Excludes Road Names", true, t.acceptsRoadName("TestRoadName")); t.addRoadName("TestRoadName"); Assert.assertEquals( "Location Track Excludes Road Names 2", false, t.acceptsRoadName("TestRoadName")); /* Test Drop IDs */ Assert.assertEquals( "Location Track Accepts Drop ID undefined", false, t.containsDropId("TestDropId")); t.addDropId("TestDropId"); Assert.assertEquals( "Location Track Accepts Drop ID defined", true, t.containsDropId("TestDropId")); t.addDropId("TestOtherDropId"); Assert.assertEquals( "Location Track Accepts Drop ID other defined", true, t.containsDropId("TestDropId")); t.deleteDropId("TestDropId"); Assert.assertEquals( "Location Track Accepts Drop ID deleted", false, t.containsDropId("TestDropId")); /* Test Pickup IDs */ Assert.assertEquals( "Location Track Accepts Pickup ID undefined", false, t.containsPickupId("TestPickupId")); t.addPickupId("TestPickupId"); Assert.assertEquals( "Location Track Accepts Pickup ID defined", true, t.containsPickupId("TestPickupId")); t.addPickupId("TestOtherPickupId"); Assert.assertEquals( "Location Track Accepts Pickup ID other defined", true, t.containsPickupId("TestPickupId")); t.deletePickupId("TestPickupId"); Assert.assertEquals( "Location Track Accepts Pickup ID deleted", false, t.containsPickupId("TestPickupId")); }
// test Track car support public void testTrackCarSupport() { Location l = new Location("Location Test Car id", "Location Test Name"); Track t = new Track("Test id", "Test Name", "Test Type", l); Assert.assertEquals("Location Track Car id", "Test id", t.getId()); Assert.assertEquals("Location Track Car Name", "Test Name", t.getName()); Assert.assertEquals("Location Track Car Type", "Test Type", t.getTrackType()); Assert.assertEquals("Location", l, t.getLocation()); Assert.assertEquals("Location Track Car Start Used Length", 0, t.getUsedLength()); Assert.assertEquals("Location Track Car Start Number of Rolling Stock", 0, t.getNumberRS()); Assert.assertEquals("Location Track Car Start Number of Cars", 0, t.getNumberCars()); Assert.assertEquals("Location Track Car Start Number of Engines", 0, t.getNumberEngines()); Car c1 = new Car("TESTROAD", "TESTNUMBER1"); c1.setLength("40"); t.addRS(c1); Assert.assertEquals("Location Track Car First Number of Rolling Stock", 1, t.getNumberRS()); Assert.assertEquals("Location Track Car First Number of Cars", 1, t.getNumberCars()); Assert.assertEquals("Location Track Car First Number of Engines", 0, t.getNumberEngines()); Assert.assertEquals( "Location Track Car First Used Length", 40 + 4, t.getUsedLength()); // Drawbar length is 4 Car c2 = new Car("TESTROAD", "TESTNUMBER2"); c2.setLength("33"); t.addRS(c2); Assert.assertEquals("Location Track Car 2nd Number of Rolling Stock", 2, t.getNumberRS()); Assert.assertEquals("Location Track Car 2nd Number of Cars", 2, t.getNumberCars()); Assert.assertEquals("Location Track Car 2nd Number of Engines", 0, t.getNumberEngines()); Assert.assertEquals("Location Track Car 2nd Used Length", 40 + 4 + 33 + 4, t.getUsedLength()); jmri.jmrit.operations.rollingstock.engines.Engine e1 = new jmri.jmrit.operations.rollingstock.engines.Engine("TESTROAD", "TESTNUMBERE1"); e1.setModel("E8"); // Default length == 70 t.addRS(e1); Assert.assertEquals("Location Track Car 3rd Number of Rolling Stock", 3, t.getNumberRS()); Assert.assertEquals("Location Track Car 3rd Number of Cars", 2, t.getNumberCars()); Assert.assertEquals("Location Track Car 3rd Number of Engines", 1, t.getNumberEngines()); Assert.assertEquals( "Location Track Car 3rd Used Length", 40 + 4 + 33 + 4 + 70 + 4, t.getUsedLength()); Car c3 = new Car("TESTROAD", "TESTNUMBER3"); c3.setLength("50"); t.addRS(c3); Assert.assertEquals("Location Track Car 4th Number of Rolling Stock", 4, t.getNumberRS()); Assert.assertEquals("Location Track Car 4th Number of Cars", 3, t.getNumberCars()); Assert.assertEquals("Location Track Car 4th Number of Engines", 1, t.getNumberEngines()); Assert.assertEquals( "Location Track Car 4th Used Length", 40 + 4 + 33 + 4 + 70 + 4 + 50 + 4, t.getUsedLength()); Engine e2 = new Engine("TESTROAD", "TESTNUMBERE2"); e2.setModel("E8"); // Default length == 70 t.addRS(e2); Assert.assertEquals("Location Track Car 5th Number of Rolling Stock", 5, t.getNumberRS()); Assert.assertEquals("Location Track Car 5th Number of Cars", 3, t.getNumberCars()); Assert.assertEquals("Location Track Car 5th Number of Engines", 2, t.getNumberEngines()); Assert.assertEquals( "Location Track Car 5th Used Length", 40 + 4 + 33 + 4 + 70 + 4 + 50 + 4 + 70 + 4, t.getUsedLength()); // Drawbar length is 4 t.deleteRS(c2); Assert.assertEquals("Location Track Car 6th Number of Rolling Stock", 4, t.getNumberRS()); Assert.assertEquals("Location Track Car 6th Number of Cars", 2, t.getNumberCars()); Assert.assertEquals("Location Track Car 6th Number of Engines", 2, t.getNumberEngines()); Assert.assertEquals( "Location Track Car 6th Used Length", 40 + 4 + 70 + 4 + 50 + 4 + 70 + 4, t.getUsedLength()); t.deleteRS(c1); Assert.assertEquals("Location Track Car 7th Number of Rolling Stock", 3, t.getNumberRS()); Assert.assertEquals("Location Track Car 7th Number of Cars", 1, t.getNumberCars()); Assert.assertEquals("Location Track Car 7th Number of Engines", 2, t.getNumberEngines()); Assert.assertEquals( "Location Track Car 7th Used Length", 70 + 4 + 50 + 4 + 70 + 4, t.getUsedLength()); t.deleteRS(e2); Assert.assertEquals("Location Track Car 8th Number of Rolling Stock", 2, t.getNumberRS()); Assert.assertEquals("Location Track Car 8th Number of Cars", 1, t.getNumberCars()); Assert.assertEquals("Location Track Car 8th Number of Engines", 1, t.getNumberEngines()); Assert.assertEquals("Location Track Car 8th Used Length", 70 + 4 + 50 + 4, t.getUsedLength()); t.deleteRS(e1); Assert.assertEquals("Location Track Car 9th Number of Rolling Stock", 1, t.getNumberRS()); Assert.assertEquals("Location Track Car 9th Number of Cars", 1, t.getNumberCars()); Assert.assertEquals("Location Track Car 9th Number of Engines", 0, t.getNumberEngines()); Assert.assertEquals( "Location Track Car 9th Used Length", 50 + 4, t.getUsedLength()); // Drawbar length is 4 t.deleteRS(c3); Assert.assertEquals("Location Track Car Last Number of Rolling Stock", 0, t.getNumberRS()); Assert.assertEquals("Location Track Car Last Number of Cars", 0, t.getNumberCars()); Assert.assertEquals("Location Track Car Last Number of Engines", 0, t.getNumberEngines()); Assert.assertEquals( "Location Track Car Last Used Length", 0, t.getUsedLength()); // Drawbar length is 4 }
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings( value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "CarManager only provides Car Objects") private void runUpdate() { log.debug("run update"); removePropertyChangeListerners(); trainCommon.clearUtilityCarTypes(); // reset the utility car counts carCheckBoxes.clear(); pTrack.removeAll(); boolean pickup = false; boolean setout = false; if (_track != null) { pTrackPane.setBorder(BorderFactory.createTitledBorder(_track.getName())); textTrackCommentPane.setText(_track.getComment()); textTrackCommentPane.setVisible(!_track.getComment().equals(Track.NONE)); textTrackCommentWorkPane.setText(""); for (Train train : trainManager.getTrainsArrivingThisLocationList(_track.getLocation())) { JPanel pTrain = new JPanel(); pTrain.setLayout(new BoxLayout(pTrain, BoxLayout.Y_AXIS)); pTrain.setBorder( BorderFactory.createTitledBorder( MessageFormat.format( TrainSwitchListText.getStringScheduledWork(), new Object[] {train.getName(), train.getDescription()}))); // List locos first List<Engine> engList = engManager.getByTrainBlockingList(train); if (Setup.isPrintHeadersEnabled()) { for (Engine engine : engList) { if (engine.getTrack() == _track) { JLabel header = new JLabel(Tab + trainCommon.getPickupEngineHeader()); setLabelFont(header); pTrain.add(header); break; } } } for (Engine engine : engList) { if (engine.getTrack() == _track) { engine.addPropertyChangeListener(this); rollingStock.add(engine); JCheckBox checkBox = new JCheckBox(trainCommon.pickupEngine(engine)); setCheckBoxFont(checkBox); pTrain.add(checkBox); carCheckBoxes.put(engine.getId(), checkBox); pTrack.add(pTrain); } } if (Setup.isPrintHeadersEnabled()) { for (Engine engine : engList) { if (engine.getDestinationTrack() == _track) { JLabel header = new JLabel(Tab + trainCommon.getDropEngineHeader()); setLabelFont(header); pTrain.add(header); break; } } } for (Engine engine : engList) { if (engine.getDestinationTrack() == _track) { engine.addPropertyChangeListener(this); rollingStock.add(engine); JCheckBox checkBox = new JCheckBox(trainCommon.dropEngine(engine)); setCheckBoxFont(checkBox); pTrain.add(checkBox); carCheckBoxes.put(engine.getId(), checkBox); pTrack.add(pTrain); } } List<Car> carList = carManager.getByTrainDestinationList(train); if (Setup.isPrintHeadersEnabled()) { for (Car car : carList) { if (car.getTrack() == _track && car.getRouteDestination() != car.getRouteLocation()) { JLabel header = new JLabel( Tab + trainCommon.getPickupCarHeader( !IS_MANIFEST, !TrainCommon.IS_TWO_COLUMN_TRACK)); setLabelFont(header); pTrain.add(header); break; } } } // sort car pick ups by their destination List<RouteLocation> routeList = train.getRoute().getLocationsBySequenceList(); for (RouteLocation rl : routeList) { for (Car car : carList) { if (car.getTrack() == _track && car.getRouteDestination() != car.getRouteLocation() && car.getRouteDestination() == rl) { car.addPropertyChangeListener(this); rollingStock.add(car); String text; if (car.isUtility()) { text = trainCommon.pickupUtilityCars( carList, car, !IS_MANIFEST, !TrainCommon.IS_TWO_COLUMN_TRACK); if (text == null) { continue; // this car type has already been processed } } else { text = trainCommon.pickupCar(car, !IS_MANIFEST, !TrainCommon.IS_TWO_COLUMN_TRACK); } pickup = true; JCheckBox checkBox = new JCheckBox(text); setCheckBoxFont(checkBox); pTrain.add(checkBox); carCheckBoxes.put(car.getId(), checkBox); pTrack.add(pTrain); } } } // now do car set outs if (Setup.isPrintHeadersEnabled()) { for (Car car : carList) { if (car.getDestinationTrack() == _track && car.getRouteDestination() != car.getRouteLocation()) { JLabel header = new JLabel( Tab + trainCommon.getDropCarHeader( !IS_MANIFEST, !TrainCommon.IS_TWO_COLUMN_TRACK)); setLabelFont(header); pTrain.add(header); break; } } } for (Car car : carList) { if (car.getDestinationTrack() == _track && car.getRouteLocation() != car.getRouteDestination()) { car.addPropertyChangeListener(this); rollingStock.add(car); String text; if (car.isUtility()) { text = trainCommon.setoutUtilityCars(carList, car, !TrainCommon.LOCAL, !IS_MANIFEST); if (text == null) { continue; // this car type has already been processed } } else { text = trainCommon.dropCar(car, !IS_MANIFEST, !TrainCommon.IS_TWO_COLUMN_TRACK); } setout = true; JCheckBox checkBox = new JCheckBox(text); setCheckBoxFont(checkBox); pTrain.add(checkBox); carCheckBoxes.put(car.getId(), checkBox); pTrack.add(pTrain); } } // now do local car moves if (Setup.isPrintHeadersEnabled()) { for (Car car : carList) { if ((car.getTrack() == _track || car.getDestinationTrack() == _track) && car.getRouteDestination() == car.getRouteLocation()) { JLabel header = new JLabel(Tab + trainCommon.getLocalMoveHeader(!IS_MANIFEST)); setLabelFont(header); pTrain.add(header); break; } } } for (Car car : carList) { if ((car.getTrack() == _track || car.getDestinationTrack() == _track) && car.getRouteLocation() != null && car.getRouteLocation() == car.getRouteDestination()) { car.addPropertyChangeListener(this); rollingStock.add(car); String text; if (car.isUtility()) { text = trainCommon.setoutUtilityCars(carList, car, TrainCommon.LOCAL, !IS_MANIFEST); if (text == null) { continue; // this car type has already been processed } } else { text = trainCommon.localMoveCar(car, !IS_MANIFEST); } setout = true; JCheckBox checkBox = new JCheckBox(text); setCheckBoxFont(checkBox); pTrain.add(checkBox); carCheckBoxes.put(car.getId(), checkBox); pTrack.add(pTrain); } } } // now do car holds // we only need the cars on this track List<RollingStock> rsList = carManager.getByTrainList(); List<Car> carList = new ArrayList<Car>(); for (RollingStock rs : rsList) { if (rs.getTrack() != _track || rs.getRouteLocation() != null) continue; carList.add((Car) rs); } JPanel pHoldCars = new JPanel(); pHoldCars.setLayout(new BoxLayout(pHoldCars, BoxLayout.Y_AXIS)); pHoldCars.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("HoldCars"))); for (Car car : carList) { String text; if (car.isUtility()) { String s = trainCommon.pickupUtilityCars( carList, car, !IS_MANIFEST, !TrainCommon.IS_TWO_COLUMN_TRACK); if (s == null) continue; text = TrainSwitchListText.getStringHoldCar().split("\\{")[0] + s.trim(); } else { text = MessageFormat.format( TrainSwitchListText.getStringHoldCar(), new Object[] { TrainCommon.padAndTruncateString( car.getRoadName(), CarRoads.instance().getMaxNameLength()), TrainCommon.padAndTruncateString( car.getNumber(), Control.max_len_string_print_road_number), TrainCommon.padAndTruncateString( car.getTypeName().split("-")[0], CarTypes.instance().getMaxNameLength()), TrainCommon.padAndTruncateString( car.getLength() + TrainCommon.LENGTHABV, Control.max_len_string_length_name), TrainCommon.padAndTruncateString( car.getLoadName(), CarLoads.instance().getMaxNameLength()), TrainCommon.padAndTruncateString( _track.getName(), LocationManager.instance().getMaxTrackNameLength()), TrainCommon.padAndTruncateString( car.getColor(), CarColors.instance().getMaxNameLength()) }); } JCheckBox checkBox = new JCheckBox(text); setCheckBoxFont(checkBox); pHoldCars.add(checkBox); carCheckBoxes.put(car.getId(), checkBox); pTrack.add(pHoldCars); } pTrackPane.validate(); if (pickup && !setout) { textTrackCommentWorkPane.setText(_track.getCommentPickup()); } else if (!pickup && setout) { textTrackCommentWorkPane.setText(_track.getCommentSetout()); } else if (pickup && setout) { textTrackCommentWorkPane.setText(_track.getCommentBoth()); } textTrackCommentWorkPane.setVisible(!textTrackCommentWorkPane.getText().equals("")); } else { pTrackPane.setBorder(BorderFactory.createTitledBorder("")); textTrackCommentPane.setVisible(false); textTrackCommentWorkPane.setVisible(false); } }