Java Code Examples for java.util.prefs.Preferences#getDouble()

The following examples show how to use java.util.prefs.Preferences#getDouble() . 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: StubLocationManager.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
private StubLocationManager() {
    //new york
    Preferences p = Preferences.userNodeForPackage(com.codename1.ui.Component.class);
    double lat = p.getDouble("lastGoodLat", 40.714353);
    double lon = p.getDouble("lastGoodLon", -74.005973);
    loc.setLongitude(lon);
    loc.setLatitude(lat);
    loc.setAccuracy(p.getFloat("accuracy", 55));
    loc.setAltitude(p.getDouble("Altitude",1000));
    loc.setDirection(p.getFloat("direction", 0));
    loc.setVelocity(p.getFloat("velocity",50));
    loc.setStatus(p.getInt("state", AVAILABLE));
    if(locSimulation==null) {
            locSimulation = new LocationSimulation();
    }
    JavaSEPort.locSimulation.setMeasUnit(p.getInt("unit", LocationSimulation.E_MeasUnit_Metric));
    JavaSEPort.locSimulation.setLocation(loc);
}
 
Example 2
Source File: JVMHealthPanel.java    From JPPF with Apache License 2.0 5 votes vote down vote up
/**
 * Load the threshold values from the preferences store.
 */
public void loadThresholds() {
  final Preferences pref = OptionsHandler.getPreferences().node("thresholds");
  final Map<Thresholds.Name, Double> values = getThresholds().getValues();
  final List<Thresholds.Name> list = new ArrayList<>(values.keySet());
  for (final Thresholds.Name name: list) {
    final Double value = pref.getDouble(name.toString().toLowerCase(), -1d);
    if (value <= 0d) continue;
    values.put(name, value);
  }
}
 
Example 3
Source File: PrefMonitorDouble.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent event) {
	Preferences prefs = event.getNode();
	String prop = event.getKey();
	String name = getIdentifier();
	if (prop.equals(name)) {
		double oldValue = value;
		double newValue = prefs.getDouble(name, dflt);
		if (newValue != oldValue) {
			value = newValue;
			AppPreferences.firePropertyChange(name, Double.valueOf(oldValue), Double.valueOf(newValue));
		}
	}
}
 
Example 4
Source File: GridView.java    From swift-k with Apache License 2.0 5 votes vote down vote up
public static Tree load(Preferences p) throws BackingStoreException {
    Tree tree = new Tree();
    tree.splitType = p.getInt("splitType", H);
    tree.splitPosition = p.getDouble("splitPosition", 0.5);
    if (tree.splitType != NONE) {
        tree.first = load(p.node("first"));
        tree.second = load(p.node("second"));
    }
    return tree;
}
 
Example 5
Source File: AstrosoftPref.java    From Astrosoft with GNU General Public License v2.0 5 votes vote down vote up
public Place getPlace() {

		Place defaultPlace = Place.getDefault();

		Preferences placeNode = root.node("Place");

		String city = placeNode.get(Preference.City.name(),defaultPlace.city());
		String state = placeNode.get(Preference.State.name(),defaultPlace.state());
		String country = placeNode.get(Preference.Country.name(),defaultPlace.country());
		double latitude = placeNode.getDouble(Preference.Latitude.name(),defaultPlace.latitude());
		double longitude = placeNode.getDouble(Preference.Longitude.name(),defaultPlace.longitude());
		String timeZone = placeNode.get(Preference.TimeZone.name(),defaultPlace.astrosoftTimeZone().id());

		return new Place(city,state,country, latitude, longitude, timeZone);
	}
 
Example 6
Source File: Regression.java    From openccg with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** Shows realizer settings for current test. */
static void showRealizerSettings() {
    // get, show prefs
    Preferences prefs = Preferences.userNodeForPackage(TextCCG.class);
    boolean useIndexing = prefs.getBoolean(EdgeFactory.USE_INDEXING, true);
    boolean useChunks = prefs.getBoolean(EdgeFactory.USE_CHUNKS, true);
    boolean useLicensing = prefs.getBoolean(EdgeFactory.USE_FEATURE_LICENSING, true);
    boolean useCombos = prefs.getBoolean(opennlp.ccg.realize.Chart.USE_COMBOS, true);
    boolean usePacking = prefs.getBoolean(opennlp.ccg.realize.Chart.USE_PACKING, false);
    int timeLimit = prefs.getInt(opennlp.ccg.realize.Chart.TIME_LIMIT, opennlp.ccg.realize.Chart.NO_TIME_LIMIT);
    double nbTimeLimit = prefs.getDouble(opennlp.ccg.realize.Chart.NEW_BEST_TIME_LIMIT, opennlp.ccg.realize.Chart.NO_TIME_LIMIT);
    int pruningVal = prefs.getInt(opennlp.ccg.realize.Chart.PRUNING_VALUE, opennlp.ccg.realize.Chart.NO_PRUNING);
    int cellPruningVal = prefs.getInt(opennlp.ccg.realize.Chart.CELL_PRUNING_VALUE, opennlp.ccg.realize.Chart.NO_PRUNING);
    String msg = "Timing realization with index filtering " + ((useIndexing) ? "on" : "off") + ", "; 
    msg += "chunks " + ((useChunks) ? "on" : "off") + ", "; 
    msg += "licensing " + ((useLicensing) ? "on" : "off") + ", ";
    if (usePacking) msg += "packing on, ";
    else {
        msg += "combos " + ((useCombos) ? "on" : "off") + ", ";
        if (timeLimit == opennlp.ccg.realize.Chart.NO_TIME_LIMIT) msg += "no time limit, ";
        else msg += "a time limit of " + timeLimit + " ms, ";
        if (nbTimeLimit == opennlp.ccg.realize.Chart.NO_TIME_LIMIT) msg += "no new best time limit, ";
        else {
            msg += "a new best time limit of ";
            if (nbTimeLimit >= 1) msg += ((int)nbTimeLimit) + " ms, ";
            else msg += nbTimeLimit + " of first, ";
        }
    }
    if (pruningVal == opennlp.ccg.realize.Chart.NO_PRUNING) msg += "no pruning, ";
    else msg += "a pruning value of " + pruningVal + ", ";
    msg += "and ";
    if (cellPruningVal == opennlp.ccg.realize.Chart.NO_PRUNING) msg += "no cell pruning";
    else msg += "a cell pruning value of " + cellPruningVal;
    System.out.println(msg);
    System.out.println();
}
 
Example 7
Source File: MainWindow.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 4 votes vote down vote up
MainWindow() {
	fileEditorTabPane = new FileEditorTabPane(this);
	fileEditorManager = new FileEditorManager(fileEditorTabPane);
	projectPane = new ProjectPane(fileEditorManager);

	Preferences state = MarkdownWriterFXApp.getState();
	double dividerPosition = state.getDouble("projectPaneDividerPosition", 0.2);

	SplitPane splitPane = new SplitPane(projectPane.getNode(), fileEditorTabPane.getNode()) {
		private int layoutCount;

		@Override
		protected void layoutChildren() {
			super.layoutChildren();
			if (layoutCount < 2) {
				layoutCount++;
				setDividerPosition(0, dividerPosition);
				super.layoutChildren();
			}
		}
	};
	SplitPane.setResizableWithParent(projectPane.getNode(), false);
	splitPane.setDividerPosition(0, dividerPosition);
	splitPane.getDividers().get(0).positionProperty().addListener((ob, o, n) -> {
		Utils.putPrefsDouble(state, "projectPaneDividerPosition", n.doubleValue(), 0.2);
	});

	BorderPane borderPane = new BorderPane();
	borderPane.getStyleClass().add("main");
	borderPane.setPrefSize(800, 800);
	borderPane.setTop(createMenuBarAndToolBar());
	borderPane.setCenter(splitPane);

	scene = new Scene(borderPane);
	scene.getStylesheets().add("org/markdownwriterfx/MarkdownWriter.css");
	scene.windowProperty().addListener((observable, oldWindow, newWindow) -> {
		newWindow.setOnCloseRequest(e -> {
			if (!fileEditorTabPane.canCloseAllEditos())
				e.consume();
		});

		// workaround for a bug in JavaFX: unselect menubar if window looses focus
		newWindow.focusedProperty().addListener((obs, oldFocused, newFocused) -> {
			if (!newFocused) {
				// send an ESC key event to the menubar
				menuBar.fireEvent(new KeyEvent(KeyEvent.KEY_PRESSED,
						KeyEvent.CHAR_UNDEFINED, "", KeyCode.ESCAPE,
						false, false, false, false));
			}
		});
	});

	Utils.fixSpaceAfterDeadKey(scene);

	// workaround for a bad JavaFX behavior: menu bar always grabs focus when ALT key is pressed,
	// but should grab it when ALT key is releases (as all other UI toolkits do) to give other
	// controls the chance to use Alt+Key shortcuts.
	scene.addEventHandler(KeyEvent.KEY_PRESSED, e -> {
		if (e.isAltDown())
			e.consume();
	});

	// open markdown files dropped to main window
	scene.setOnDragOver(e -> {
		if (e.getDragboard().hasFiles())
			e.acceptTransferModes(TransferMode.COPY);
		e.consume();
	});
	scene.setOnDragDropped(e -> {
		boolean success = false;
		if (e.getDragboard().hasFiles()) {
			fileEditorTabPane.openEditors(e.getDragboard().getFiles(), 0, -1);
			success = true;
		}
		e.setDropCompleted(success);
		e.consume();
	});

	Platform.runLater(() -> stageFocusedProperty.bind(scene.getWindow().focusedProperty()));
}