Java Code Examples for java.util.prefs.Preferences#putDouble()
The following examples show how to use
java.util.prefs.Preferences#putDouble() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestXMLStore.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Before public void setup() throws IOException { storeFile = tempFolder.newFile().getAbsolutePath(); XMLStore store = XMLStore.createFromFile(storeFile, null); PreferencesExt prefs = store.getPreferences(); prefs.putDouble("testD", 3.14157); prefs.putFloat("testF", 1.23456F); prefs.putLong("testL", 12345678900L); prefs.putInt("testI", 123456789); prefs.put("testS", "youdBeDeadbyNow"); prefs.putBoolean("testB", true); byte[] barr = new byte[3]; barr[0] = 1; barr[1] = 2; barr[2] = 3; prefs.putByteArray("testBA", barr); Preferences subnode = prefs.node("SemperUbi"); subnode.putDouble("testD", 3.14158); subnode.putFloat("testF", 1.23457F); subnode.putLong("testL", 12345678901L); subnode.putInt("testI", 123456780); subnode.put("testS", "youdBeLivebyNow"); subnode.putBoolean("testB", false); byte[] barr2 = new byte[3]; barr2[0] = 2; barr2[1] = 3; barr2[2] = 4; subnode.putByteArray("testBA", barr2); store.save(); }
Example 2
Source File: FormattingCustomizerPanel.java From netbeans with Apache License 2.0 | 5 votes |
private static void deepCopy(Preferences from, Preferences to) throws BackingStoreException { for(String kid : from.childrenNames()) { Preferences fromKid = from.node(kid); Preferences toKid = to.node(kid); deepCopy(fromKid, toKid); } for(String key : from.keys()) { String value = from.get(key, null); if (value == null) continue; Class type = guessType(value); if (Integer.class == type) { to.putInt(key, from.getInt(key, -1)); } else if (Long.class == type) { to.putLong(key, from.getLong(key, -1L)); } else if (Float.class == type) { to.putFloat(key, from.getFloat(key, -1f)); } else if (Double.class == type) { to.putDouble(key, from.getDouble(key, -1D)); } else if (Boolean.class == type) { to.putBoolean(key, from.getBoolean(key, false)); } else if (String.class == type) { to.put(key, value); } else /* byte [] */ { to.putByteArray(key, from.getByteArray(key, new byte [0])); } } }
Example 3
Source File: AbstractUiContext.java From triplea with GNU General Public License v3.0 | 5 votes |
@Override public void setScale(final double scale) { this.scale = scale; final Preferences prefs = getPreferencesMapOrSkin(getMapDir()); prefs.putDouble(MAP_SCALE_PREF, scale); try { prefs.flush(); } catch (final BackingStoreException e) { log.log(Level.SEVERE, "Failed to flush preferences: " + prefs.absolutePath(), e); } }
Example 4
Source File: HeadedUiContext.java From triplea with GNU General Public License v3.0 | 5 votes |
@Override public void setUnitScaleFactor(final double scaleFactor) { unitImageFactory = unitImageFactory.withScaleFactor(scaleFactor); final Preferences prefs = getPreferencesMapOrSkin(getMapDir()); prefs.putDouble(UNIT_SCALE_PREF, scaleFactor); try { prefs.flush(); } catch (final BackingStoreException e) { log.log(Level.SEVERE, "Failed to flush preferences: " + prefs.absolutePath(), e); } }
Example 5
Source File: GridView.java From swift-k with Apache License 2.0 | 5 votes |
public void store(Preferences p) { p.putInt("splitType", splitType); p.putDouble("splitPosition", splitPosition); if (first != null) { Preferences p1 = p.node("first"); first.store(p1); } if (second != null) { Preferences p2 = p.node("second"); second.store(p2); } }
Example 6
Source File: JVMHealthPanel.java From JPPF with Apache License 2.0 | 4 votes |
/** * Save the threshold values to the preferences store. */ public void saveThresholds() { final Preferences pref = OptionsHandler.getPreferences().node("thresholds"); for (final Map.Entry<Thresholds.Name, Double> entry: getThresholds().getValues().entrySet()) pref.putDouble(entry.getKey().toString().toLowerCase(), entry.getValue()); }
Example 7
Source File: Utils.java From markdown-writer-fx with BSD 2-Clause "Simplified" License | 4 votes |
public static void putPrefsDouble(Preferences prefs, String key, double value, double def) { if (value != def) prefs.putDouble(key, value); else prefs.remove(key); }