use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.
the class TrainIcon method makeTrainRouteMenu.
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "CarManager only provides Car Objects")
private JMenu makeTrainRouteMenu() {
JMenu routeMenu = new JMenu(Bundle.getMessage("Route"));
Route route = _train.getRoute();
if (route == null) {
return routeMenu;
}
List<RollingStock> carList = CarManager.instance().getByTrainList(_train);
for (RouteLocation rl : route.getLocationsBySequenceList()) {
int pickupCars = 0;
int dropCars = 0;
String current = " ";
if (_train.getCurrentLocation() == rl) {
// NOI18N
current = "-> ";
}
for (RollingStock rs : carList) {
Car car = (Car) rs;
if (car.getRouteLocation() == rl && !car.getTrackName().equals(Car.NONE)) {
pickupCars++;
}
if (car.getRouteDestination() == rl) {
dropCars++;
}
}
String rText = "";
String pickups = "";
String drops = "";
if (pickupCars > 0) {
pickups = " " + Bundle.getMessage("Pickup") + " " + pickupCars;
if (dropCars > 0) {
drops = ", " + Bundle.getMessage("SetOut") + " " + dropCars;
}
} else if (dropCars > 0) {
drops = " " + Bundle.getMessage("SetOut") + " " + dropCars;
}
if (pickupCars > 0 || dropCars > 0) {
rText = current + rl.getName() + " (" + pickups + drops + " )";
} else {
rText = current + rl.getName();
}
routeMenu.add(new RouteAction(rText, rl));
}
return routeMenu;
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.
the class TrainByCarTypeFrame method adjustCarsComboBoxSize.
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "CarManager only provides Car Objects")
private void adjustCarsComboBoxSize() {
List<RollingStock> cars = CarManager.instance().getList();
for (RollingStock rs : cars) {
Car car = (Car) rs;
carsComboBox.addItem(car);
}
Dimension boxsize = carsComboBox.getMinimumSize();
if (boxsize != null) {
boxsize.setSize(boxsize.width + 10, boxsize.height);
carsComboBox.setMinimumSize(boxsize);
}
carsComboBox.removeAllItems();
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.
the class TrainByCarTypeFrame method updateCarsComboBox.
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "CarManager only provides Car Objects")
private void updateCarsComboBox() {
log.debug("update car combobox");
carsComboBox.removeAllItems();
String carType = (String) typeComboBox.getSelectedItem();
// load car combobox
carsComboBox.addItem(null);
List<RollingStock> cars = CarManager.instance().getByTypeList(carType);
for (RollingStock rs : cars) {
Car car = (Car) rs;
carsComboBox.addItem(car);
}
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.
the class SimDriverAdapter method configure.
/**
* set up all of the other objects to operate connected to this port
*/
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "Access to 'self' OK until multiple instance pattern installed")
@Override
public void configure() {
// install a traffic controller that doesn't time out
SerialTrafficController tc = new SerialTrafficController() {
// timeout doesn't do anything
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only until multi-connect update done")
@Override
protected void handleTimeout(jmri.jmrix.AbstractMRMessage m, jmri.jmrix.AbstractMRListener l) {
}
};
// connect to the traffic controller
tc.connectPort(this);
((CMRISystemConnectionMemo) getSystemConnectionMemo()).setTrafficController(tc);
((CMRISystemConnectionMemo) getSystemConnectionMemo()).configureManagers();
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.
the class StackMonFrame method requestFunctionStatus.
/*
* Request the momentary/continuous status of functions for the
* current address.
*/
@SuppressWarnings("unused")
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "This is part of work in progress code to allow display of all information about the locomotives in the stack.")
private void requestFunctionStatus() {
int address = 0;
if (!adrTextField.getText().equals("")) {
address = Integer.parseInt(adrTextField.getText());
XNetMessage msg = XNetMessage.getLocomotiveFunctionStatusMsg(address);
tc.sendXNetMessage(msg, this);
}
}
Aggregations