/** * Put the simulation that has just been opened into the Simulation menu's recently opened file * list. * * @param newSelected the newly opened simulation */ private void saveToRecent(final String newSelected) { String[] recent = siafuConfig.getStringArray("ui.recentsimulation"); String[] newRecent = new String[AMOUNT_OF_RECENT_ITEMS]; newRecent[0] = newSelected; for (int i = 0; i < AMOUNT_OF_RECENT_ITEMS - 1 && i < recent.length; i++) { if (newSelected.equals(recent[i])) { continue; } else { newRecent[i + 1] = recent[i]; } } siafuConfig.setProperty("ui.recentsimulation", newRecent); try { siafuConfig.save(); } catch (ConfigurationException e) { throw new RuntimeException("Can not save the configuration file", e); } }
public void setProperty(String key, String value) { if (config != null) { System.out.printf("XXX: set prop %s %s%n", key, value); // debug config.setProperty(key, value); } }
private void writeVehiclesAndTheirTypes(XMLConfiguration xmlConfig) { // vehicles String vehiclePathString = Schema.VEHICLES + "." + Schema.VEHICLE; int counter = 0; for (Vehicle vehicle : vrp.getVehicles()) { xmlConfig.setProperty(vehiclePathString + "(" + counter + ").id", vehicle.getId()); xmlConfig.setProperty( vehiclePathString + "(" + counter + ").typeId", vehicle.getType().getTypeId()); xmlConfig.setProperty( vehiclePathString + "(" + counter + ").startLocation.id", vehicle.getStartLocation().getId()); if (vehicle.getStartLocation().getCoordinate() != null) { xmlConfig.setProperty( vehiclePathString + "(" + counter + ").startLocation.coord[@x]", vehicle.getStartLocation().getCoordinate().getX()); xmlConfig.setProperty( vehiclePathString + "(" + counter + ").startLocation.coord[@y]", vehicle.getStartLocation().getCoordinate().getY()); } if (vehicle.getStartLocation().getIndex() != Location.NO_INDEX) { xmlConfig.setProperty( vehiclePathString + "(" + counter + ").startLocation.index", vehicle.getStartLocation().getIndex()); } xmlConfig.setProperty( vehiclePathString + "(" + counter + ").endLocation.id", vehicle.getEndLocation().getId()); if (vehicle.getEndLocation().getCoordinate() != null) { xmlConfig.setProperty( vehiclePathString + "(" + counter + ").endLocation.coord[@x]", vehicle.getEndLocation().getCoordinate().getX()); xmlConfig.setProperty( vehiclePathString + "(" + counter + ").endLocation.coord[@y]", vehicle.getEndLocation().getCoordinate().getY()); } if (vehicle.getEndLocation().getIndex() != Location.NO_INDEX) { xmlConfig.setProperty( vehiclePathString + "(" + counter + ").endLocation.index", vehicle.getEndLocation().getId()); } xmlConfig.setProperty( vehiclePathString + "(" + counter + ").timeSchedule.start", vehicle.getEarliestDeparture()); xmlConfig.setProperty( vehiclePathString + "(" + counter + ").timeSchedule.end", vehicle.getLatestArrival()); xmlConfig.setProperty( vehiclePathString + "(" + counter + ").returnToDepot", vehicle.isReturnToDepot()); // write skills String skillString = getSkillString(vehicle); xmlConfig.setProperty(vehiclePathString + "(" + counter + ").skills", skillString); counter++; } // types String typePathString = Schema.builder().append(Schema.TYPES).dot(Schema.TYPE).build(); int typeCounter = 0; for (VehicleType type : vrp.getTypes()) { xmlConfig.setProperty(typePathString + "(" + typeCounter + ").id", type.getTypeId()); for (int i = 0; i < type.getCapacityDimensions().getNuOfDimensions(); i++) { xmlConfig.setProperty( typePathString + "(" + typeCounter + ").capacity-dimensions.dimension(" + i + ")[@index]", i); xmlConfig.setProperty( typePathString + "(" + typeCounter + ").capacity-dimensions.dimension(" + i + ")", type.getCapacityDimensions().get(i)); } xmlConfig.setProperty( typePathString + "(" + typeCounter + ").costs.fixed", type.getVehicleCostParams().fix); xmlConfig.setProperty( typePathString + "(" + typeCounter + ").costs.distance", type.getVehicleCostParams().perDistanceUnit); xmlConfig.setProperty( typePathString + "(" + typeCounter + ").costs.time", type.getVehicleCostParams().perTimeUnit); typeCounter++; } }
private void writeProblemType(XMLConfiguration xmlConfig) { xmlConfig.setProperty("problemType.fleetSize", vrp.getFleetSize()); }