import java.awt.Point;
import java.io.File;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.prefs.Preferences;
import net.sf.openrocket.arch.SystemInfo;
+import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.document.Simulation;
import net.sf.openrocket.logging.LogHelper;
import net.sf.openrocket.material.Material;
+import net.sf.openrocket.preset.ComponentPreset;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.simulation.FlightDataType;
import net.sf.openrocket.simulation.RK4SimulationStepper;
private static final List<Locale> SUPPORTED_LOCALES;
static {
List<Locale> list = new ArrayList<Locale>();
- for (String lang : new String[] { "en", "de", "es", "fr", "it", "ru" }) {
+ for (String lang : new String[] { "en", "de", "es", "fr", "it", "ru","cs","pl" }) {
list.add(new Locale(lang));
}
SUPPORTED_LOCALES = Collections.unmodifiableList(list);
}
public Simulation getBackgroundSimulation(Rocket rocket) {
- Simulation s = new Simulation(rocket);
+ Simulation s = new Simulation(new OpenRocketDocument(rocket), rocket);
SimulationOptions cond = s.getOptions();
cond.setTimeStep(RK4SimulationStepper.RECOMMENDED_TIME_STEP * 2);
*
* @param m the material to add.
*/
+ @Override
public void addUserMaterial(Material m) {
Preferences prefs = PREFNODE.node("userMaterials");
*
* @param m the material to remove.
*/
+ @Override
public void removeUserMaterial(Material m) {
Preferences prefs = PREFNODE.node("userMaterials");
String value = prefs.get(key, null);
try {
- Material existing = Material.fromStorableString(value, true);
+ Material existing = Material.fromStorableString(value);
if (existing.equals(m)) {
prefs.remove(key);
}
*
* @return a set of all user-defined materials.
*/
+ @Override
public Set<Material> getUserMaterials() {
Preferences prefs = PREFNODE.node("userMaterials");
String value = prefs.get(key, null);
try {
- Material m = Material.fromStorableString(value, true);
+ Material m = Material.fromStorableString(value);
materials.add(m);
} catch (IllegalArgumentException e) {
return materials;
}
+ @Override
+ public void setComponentFavorite( ComponentPreset preset, ComponentPreset.Type type, boolean favorite ) {
+ Preferences prefs = PREFNODE.node("favoritePresets").node(type.name());
+ if ( favorite ) {
+ prefs.putBoolean(preset.preferenceKey(), true);
+ } else {
+ prefs.remove(preset.preferenceKey());
+ }
+ }
+ @Override
+ public Set<String> getComponentFavorites( ComponentPreset.Type type) {
+ Preferences prefs = PREFNODE.node("favoritePresets").node(type.name());
+ Set<String> collection = new HashSet<String>();
+ try {
+ collection.addAll( Arrays.asList(prefs.keys()));
+ } catch ( BackingStoreException bex ) {
+
+ }
+ return collection;
+ }
//// Helper methods
}