List of usage examples for org.apache.commons.lang3.math NumberUtils isParsable
public static boolean isParsable(final String str)
Checks whether the given String is a parsable number.
Parsable numbers include those Strings understood by Integer#parseInt(String) , Long#parseLong(String) , Float#parseFloat(String) or Double#parseDouble(String) .
From source file:dingwen.Command.java
public static void containsCmd(String command, ShapeCache shapeCache) { String x_coordinate = command.substring(command.indexOf(" ") + 1, command.lastIndexOf(" ")); String y_coordinate = command.substring(command.lastIndexOf(" ") + 1); if (!NumberUtils.isParsable(x_coordinate) || !NumberUtils.isParsable(y_coordinate)) { System.out.println(CommonStatement.INPUT_INVALID); return;// w w w .j a va 2 s . co m } double x = Double.parseDouble(command.substring(command.indexOf(" "), command.lastIndexOf(" "))); double y = Double.parseDouble(command.substring(command.lastIndexOf(" "))); Point p = new Point(x, y); double totalArea = 0; Iterator it = shapeCache.getShapes().entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); BigInteger id = (BigInteger) pair.getKey(); Shape shape = (Shape) pair.getValue(); if (shape.contains(p)) { System.out.println("shape " + id + " " + shape); System.out.println("area is " + shape.area()); totalArea += shape.area(); } } System.out.println("total area is " + totalArea); }
From source file:dingwen.Command.java
public static void listShapesCmd(String command, ShapeCache shapeCache) { BigInteger id = null;//w ww . ja va2s.c o m if (NumberUtils.isParsable(command.substring(command.indexOf(" ") + 1))) { id = new BigInteger(command.substring(command.indexOf(" ") + 1)); } if (id == null) { Iterator it = shapeCache.getShapes().entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); System.out.println("shape " + pair.getKey() + " " + (Shape) pair.getValue()); } } else if (shapeCache.getShape(id) != null) { System.out.println("shape " + id + " " + shapeCache.getShape(id)); } else { System.out.println(CommonStatement.SHAPE_NOT_EXISTS); } }
From source file:com.nridge.core.base.field.data.DataFieldAnalyzer.java
private void scanType(String aValue) { if (isNumberType()) { if (NumberUtils.isParsable(aValue)) { int offset = aValue.indexOf(StrUtl.CHAR_DOT); if ((mIsInteger) && (offset != -1)) mIsInteger = false;/* w w w . j a v a 2s .com*/ } else { if (mIsInteger) mIsInteger = false; if (mIsFloat) mIsFloat = false; } } if (mIsDate) { Date fieldDate = DatUtl.detectCreateDate(aValue); if (fieldDate == null) mIsDate = false; } if (mIsBoolean) { if ((!aValue.equalsIgnoreCase(StrUtl.STRING_TRUE)) && (!aValue.equalsIgnoreCase(StrUtl.STRING_YES)) && (!aValue.equalsIgnoreCase(StrUtl.STRING_FALSE)) && (!aValue.equalsIgnoreCase(StrUtl.STRING_NO))) mIsBoolean = false; } }
From source file:dsfixgui.view.DSFSavesPane.java
private void initializeEventHandlers() { applySettingsButton.setOnAction(e -> { ui.applyDSFConfig();/*from ww w . java 2s. c om*/ }); restoreDefaultsButton.setOnAction(e -> { ContinueDialog cD = new ContinueDialog(300.0, 80.0, DIALOG_TITLE_RESET, DIALOG_MSG_RESTORE_SETTINGS, DIALOG_BUTTON_TEXTS[2], DIALOG_BUTTON_TEXTS[1]); if (cD.show()) { config.restoreDefaultSaveOptions(); ui.refreshUI(); } }); saveBackupsPicker.setOnAction(e -> { if (saveBackupsPicker.getValue().equals(DISABLE_ENABLE[0])) { saveIntervalField.setDisable(true); maxSavesField.setDisable(true); config.enableBackups.set(0); } else { saveIntervalField.setDisable(false); maxSavesField.setDisable(false); config.enableBackups.set(1); } }); saveIntervalField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || Integer.parseInt(newText) < 600) { saveIntervalField.pseudoClassStateChanged(INVALID_INPUT, true); saveIntervalField.setTooltip(new Tooltip(INPUT_GREATER_THAN_EQ + "600")); } else { saveIntervalField.pseudoClassStateChanged(INVALID_INPUT, false); saveIntervalField.setTooltip(new Tooltip("")); config.backupInterval.set(Integer.parseInt(newText)); } } catch (NumberFormatException nFE) { ui.printConsole(INPUT_TOO_LARGE); saveIntervalField.setText(""); } } }); maxSavesField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || Integer.parseInt(newText) < 1) { maxSavesField.pseudoClassStateChanged(INVALID_INPUT, true); maxSavesField.setTooltip(new Tooltip(INPUT_GREATER_THAN_EQ + "1")); } else { maxSavesField.pseudoClassStateChanged(INVALID_INPUT, false); maxSavesField.setTooltip(new Tooltip("")); config.maxBackups.set(Integer.parseInt(newText)); } } catch (NumberFormatException nFE) { ui.printConsole(INPUT_TOO_LARGE); maxSavesField.setText(""); } } }); }
From source file:com.omertron.omdbapi.model.OmdbVideoFull.java
public void setMetascore(String metascore) { if (NumberUtils.isParsable(metascore)) { this.metascore = NumberUtils.toInt(metascore); } }
From source file:dsfixgui.view.DSFUnsafeSettingsPane.java
private void initializeEventHandlers() { applySettingsButton.setOnAction(e -> { ui.applyDSFConfig();/* ww w . j a v a 2 s . c om*/ }); restoreDefaultsButton.setOnAction(e -> { ContinueDialog cD = new ContinueDialog(300.0, 80.0, DIALOG_TITLE_RESET, DIALOG_MSG_RESTORE_SETTINGS, DIALOG_BUTTON_TEXTS[2], DIALOG_BUTTON_TEXTS[1]); if (cD.show()) { config.restoreDefaultUnsafeOptions(); ui.refreshUI(); } }); neitherWindowMode.setOnAction(e -> { config.forceFullscreen.set(0); config.forceWindowed.set(0); }); forceFullscreen.setOnAction(e -> { config.forceFullscreen.set(1); config.forceWindowed.set(0); }); forceWindowed.setOnAction(e -> { config.forceFullscreen.set(0); config.forceWindowed.set(1); }); vsyncPicker.setOnAction(e -> { if (vsyncPicker.getValue().equals(DISABLE_ENABLE[0])) { config.enableVsync.set(0); } else { config.enableVsync.set(1); } }); refreshRateField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || Integer.parseInt(newText) < 1) { refreshRateField.pseudoClassStateChanged(INVALID_INPUT, true); refreshRateField.setTooltip(new Tooltip(INPUT_GREATER_THAN_EQ + "1")); } else { refreshRateField.pseudoClassStateChanged(INVALID_INPUT, false); refreshRateField.setTooltip(new Tooltip("")); config.fullscreenHz.set(Integer.parseInt(newText)); } } catch (NumberFormatException nFE) { ui.printConsole(INPUT_TOO_LARGE); refreshRateField.setText(""); } } }); }
From source file:dsfixgui.view.DSFHudPane.java
private void initializeEventHandlers() { applySettingsButton.setOnAction(e -> { ui.applyDSFConfig();/*from w w w . j a v a 2s. c o m*/ }); restoreDefaultsButton.setOnAction(e -> { ContinueDialog cD = new ContinueDialog(300.0, 80.0, DIALOG_TITLE_RESET, DIALOG_MSG_RESTORE_SETTINGS, DIALOG_BUTTON_TEXTS[2], DIALOG_BUTTON_TEXTS[1]); if (cD.show()) { config.restoreDefaultHUDOptions(); ui.refreshUI(); } }); hudModsPicker.setOnAction(e -> { if (hudModsPicker.getValue().equals(DISABLE_ENABLE[0])) { minimalHUDPicker.setDisable(true); hudScaleField.setDisable(true); topLeftHUDOpField.setDisable(true); bottomLeftHUDOpField.setDisable(true); bottomRightHUDOpField.setDisable(true); config.enableHudMod.set(0); } else { minimalHUDPicker.setDisable(false); hudScaleField.setDisable(false); topLeftHUDOpField.setDisable(false); bottomLeftHUDOpField.setDisable(false); bottomRightHUDOpField.setDisable(false); config.enableHudMod.set(1); } }); minimalHUDPicker.setOnAction(e -> { if (minimalHUDPicker.getValue().equals(DISABLE_ENABLE[0])) { config.enableMinimalHud.set(0); } else { config.enableMinimalHud.set(1); } }); hudScaleField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || Double.parseDouble(newText) < 0.0 || Double.parseDouble(newText) > 1.0) { hudScaleField.pseudoClassStateChanged(INVALID_INPUT, true); hudScaleField.setTooltip(new Tooltip(INVALID_DOUBLE_0_1)); } else { hudScaleField.pseudoClassStateChanged(INVALID_INPUT, false); hudScaleField.setTooltip(new Tooltip("")); config.hudScaleFactor.replace(0, config.hudScaleFactor.length(), Double.parseDouble(decimalFormat.format(Double.parseDouble(newText))) + ""); } } catch (NumberFormatException nFE) { ui.printConsole(INPUT_TOO_LARGE); hudScaleField.setText(""); } } }); topLeftHUDOpField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || Double.parseDouble(newText) < 0.0 || Double.parseDouble(newText) > 1.0) { topLeftHUDOpField.pseudoClassStateChanged(INVALID_INPUT, true); topLeftHUDOpField.setTooltip(new Tooltip(INVALID_DOUBLE_0_1)); } else { topLeftHUDOpField.pseudoClassStateChanged(INVALID_INPUT, false); topLeftHUDOpField.setTooltip(new Tooltip("")); config.hudTopLeftOpacity.replace(0, config.hudTopLeftOpacity.length(), decimalFormat.format(Double.parseDouble(newText)) + "f"); } } catch (NumberFormatException nFE) { ui.printConsole(INPUT_TOO_LARGE); topLeftHUDOpField.setText(""); } } }); bottomLeftHUDOpField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || Double.parseDouble(newText) < 0.0 || Double.parseDouble(newText) > 1.0) { bottomLeftHUDOpField.pseudoClassStateChanged(INVALID_INPUT, true); bottomLeftHUDOpField.setTooltip(new Tooltip(INVALID_DOUBLE_0_1)); } else { bottomLeftHUDOpField.pseudoClassStateChanged(INVALID_INPUT, false); bottomLeftHUDOpField.setTooltip(new Tooltip("")); config.hudBottomLeftOpacity.replace(0, config.hudBottomLeftOpacity.length(), decimalFormat.format(Double.parseDouble(newText)) + "f"); } } catch (NumberFormatException nFE) { ui.printConsole(INPUT_TOO_LARGE); bottomLeftHUDOpField.setText(""); } } }); bottomRightHUDOpField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || Double.parseDouble(newText) < 0.0 || Double.parseDouble(newText) > 1.0) { bottomRightHUDOpField.pseudoClassStateChanged(INVALID_INPUT, true); bottomRightHUDOpField.setTooltip(new Tooltip(INVALID_DOUBLE_0_1)); } else { bottomRightHUDOpField.pseudoClassStateChanged(INVALID_INPUT, false); bottomRightHUDOpField.setTooltip(new Tooltip("")); config.hudBottomRightOpacity.replace(0, config.hudBottomRightOpacity.length(), decimalFormat.format(Double.parseDouble(newText)) + "f"); } } catch (NumberFormatException nFE) { ui.printConsole(INPUT_TOO_LARGE); bottomRightHUDOpField.setText(""); } } }); }
From source file:dsfixgui.view.DSFGraphicsPane.java
private void initializeEventHandlers() { applySettingsButton.setOnAction(e -> { ui.applyDSFConfig();//from w ww .j ava2s . co m }); restoreDefaultsButton.setOnAction(e -> { ContinueDialog cD = new ContinueDialog(300.0, 80.0, DIALOG_TITLE_RESET, DIALOG_MSG_RESTORE_SETTINGS, DIALOG_BUTTON_TEXTS[2], DIALOG_BUTTON_TEXTS[1]); if (cD.show()) { config.restoreDefaultGraphicsOptions(); ui.refreshUI(); } }); renderWidthField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) { renderWidthField.pseudoClassStateChanged(INVALID_INPUT, true); renderWidthField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else if (Integer.parseInt(newText) >= 1280) { if (NumberUtils.isParsable(presentWidthField.getText()) && (Integer.parseInt(newText) == Integer.parseInt(presentWidthField.getText()))) { renderWidthField.pseudoClassStateChanged(INVALID_INPUT, true); renderWidthField.setTooltip(new Tooltip(SAME_RESOLUTIONS)); } else { renderWidthField.pseudoClassStateChanged(INVALID_INPUT, false); renderWidthField.setTooltip(new Tooltip("")); config.setRenderWidth(Integer.parseInt(newText)); if (config.disableDOF) { config.setPresentWidth(Integer.parseInt(newText)); } } //If input is a positive integer that is less than 1280, present width comes into play } else if (NumberUtils.isParsable(presentWidthField.getText()) && Integer.parseInt(presentWidthField.getText()) >= 1280) { renderWidthField.pseudoClassStateChanged(INVALID_INPUT, false); renderWidthField.setTooltip(new Tooltip("")); config.setRenderWidth(Integer.parseInt(newText)); } else { renderWidthField.pseudoClassStateChanged(INVALID_INPUT, true); renderWidthField.setTooltip(new Tooltip(PRES_WIDTH_TOO_LOW)); } recheckTextInput(presentWidthField); } catch (NumberFormatException nFE) { config.setRenderWidth(1920); ui.printConsole(INPUT_TOO_LARGE); renderWidthField.setText(""); renderWidthField.appendText(config.getRenderWidth() + ""); } } }); renderHeightField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) { renderHeightField.pseudoClassStateChanged(INVALID_INPUT, true); renderHeightField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else if (Integer.parseInt(newText) >= 720) { if (NumberUtils.isParsable(presentHeightField.getText()) && (Integer.parseInt(newText) == Integer.parseInt(presentHeightField.getText()))) { renderHeightField.pseudoClassStateChanged(INVALID_INPUT, true); renderHeightField.setTooltip(new Tooltip(SAME_RESOLUTIONS)); } else { renderHeightField.pseudoClassStateChanged(INVALID_INPUT, false); renderHeightField.setTooltip(new Tooltip("")); config.setRenderHeight(Integer.parseInt(newText)); if (config.disableDOF) { config.setPresentHeight(Integer.parseInt(newText)); config.setDOFOverride(Integer.parseInt(newText)); } } //If input is a positive integer that is less than 720, present height comes into play } else if (NumberUtils.isParsable(presentHeightField.getText()) && Integer.parseInt(presentHeightField.getText()) >= 720) { renderHeightField.pseudoClassStateChanged(INVALID_INPUT, false); renderHeightField.setTooltip(new Tooltip("")); config.setRenderHeight(Integer.parseInt(newText)); } else { renderHeightField.pseudoClassStateChanged(INVALID_INPUT, true); renderHeightField.setTooltip(new Tooltip(PRES_HEIGHT_TOO_LOW)); } recheckTextInput(presentHeightField); } catch (NumberFormatException nFE) { config.setRenderHeight(1080); ui.printConsole(INPUT_TOO_LARGE); renderHeightField.setText(""); renderHeightField.appendText(config.getRenderHeight() + ""); } } }); setWindowsRenderRes.setOnAction(e -> { renderWidthField.setText(""); renderHeightField.setText(""); renderWidthField.appendText((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() + ""); renderHeightField.appendText((int) Toolkit.getDefaultToolkit().getScreenSize().getHeight() + ""); }); presentWidthField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) { presentWidthField.pseudoClassStateChanged(INVALID_INPUT, true); presentWidthField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else if (Integer.parseInt(newText) < 1280) { presentWidthField.pseudoClassStateChanged(INVALID_INPUT, true); presentWidthField.setTooltip(new Tooltip(INPUT_GREATER_THAN + 1280)); } else if (Integer.parseInt(newText) >= 1280) { if (NumberUtils.isParsable(renderWidthField.getText()) && (Integer.parseInt(newText) == Integer.parseInt(renderWidthField.getText()))) { presentWidthField.pseudoClassStateChanged(INVALID_INPUT, true); presentWidthField.setTooltip(new Tooltip(SAME_RESOLUTIONS)); } else { presentWidthField.pseudoClassStateChanged(INVALID_INPUT, false); presentWidthField.setTooltip(null); config.setPresentWidth(Integer.parseInt(newText)); } } recheckTextInput(renderWidthField); } catch (NumberFormatException nFE) { config.setPresentWidth(0); ui.printConsole(INPUT_TOO_LARGE); presentWidthField.setText(""); presentWidthField.appendText(config.getPresentWidth() + ""); } } }); presentHeightField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) { presentHeightField.pseudoClassStateChanged(INVALID_INPUT, true); presentHeightField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else if (Integer.parseInt(newText) < 720) { presentHeightField.pseudoClassStateChanged(INVALID_INPUT, true); presentHeightField.setTooltip(new Tooltip(INPUT_GREATER_THAN + 720)); } else if (Integer.parseInt(newText) >= 720) { if (NumberUtils.isParsable(renderHeightField.getText()) && (Integer.parseInt(newText) == Integer.parseInt(renderHeightField.getText()))) { presentHeightField.pseudoClassStateChanged(INVALID_INPUT, true); presentHeightField.setTooltip(new Tooltip(SAME_RESOLUTIONS)); } else { presentHeightField.pseudoClassStateChanged(INVALID_INPUT, false); presentHeightField.setTooltip(null); config.setPresentHeight(Integer.parseInt(newText)); } } recheckTextInput(renderHeightField); } catch (NumberFormatException nFE) { config.setPresentHeight(0); ui.printConsole(INPUT_TOO_LARGE); presentHeightField.setText(""); presentHeightField.appendText(config.getPresentHeight() + ""); } } }); setWindowsPresentRes.setOnAction(e -> { presentWidthField.setText(""); presentHeightField.setText(""); presentWidthField.appendText((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() + ""); presentHeightField.appendText((int) Toolkit.getDefaultToolkit().getScreenSize().getHeight() + ""); }); usePresentRes.setOnAction(e -> { presentWidthField.setDisable(false); presentHeightField.setDisable(false); setWindowsPresentRes.setDisable(false); presentWidthField.setText(presentRes[0]); presentHeightField.setText(presentRes[1]); recheckTextInput(presentWidthField); recheckTextInput(presentHeightField); recheckTextInput(renderWidthField); recheckTextInput(renderHeightField); }); dontUsePresentRes.setOnAction(e -> { presentWidthField.setDisable(true); presentHeightField.setDisable(true); setWindowsPresentRes.setDisable(true); config.setPresentWidth(0); config.setPresentHeight(0); presentRes[0] = presentWidthField.getText(); presentRes[1] = presentHeightField.getText(); presentWidthField.setText(config.getPresentWidth() + ""); presentHeightField.setText(config.getPresentHeight() + ""); recheckTextInput(renderWidthField); recheckTextInput(renderHeightField); presentWidthField.pseudoClassStateChanged(INVALID_INPUT, false); presentWidthField.setTooltip(null); presentHeightField.pseudoClassStateChanged(INVALID_INPUT, false); presentHeightField.setTooltip(null); }); aaQualityPicker.setOnAction(e -> { if (aaQualityPicker.getValue().equals(AAQUALITIES[0])) { config.aaQuality.set(0); aaTypePicker.setDisable(true); } else { aaTypePicker.setDisable(false); config.aaQuality.set(aaQualityPicker.getItems().indexOf(aaQualityPicker.getValue())); } }); aaTypePicker.setOnAction(e -> { config.aaType.replace(0, config.aaType.length(), aaTypePicker.getValue()); }); ssaoStrengthPicker.setOnAction(e -> { if (ssaoStrengthPicker.getValue().equals(SSAOSTRENGTHS[0])) { config.ssaoStrength.set(0); ssaoScalePicker.setDisable(true); ssaoTypePicker.setDisable(true); } else { ssaoScalePicker.setDisable(false); ssaoTypePicker.setDisable(false); config.ssaoStrength.set(ssaoStrengthPicker.getItems().indexOf(ssaoStrengthPicker.getValue())); } }); ssaoScalePicker.setOnAction(e -> { config.ssaoScale.set(ssaoScalePicker.getItems().indexOf(ssaoScalePicker.getValue()) + 1); }); ssaoTypePicker.setOnAction(e -> { config.ssaoType.replace(0, config.ssaoType.length(), ssaoTypePicker.getValue()); }); //DOF Override picker is a special case with its own method setDOFOverrideEventHandler(); dofScalingEnabled.setOnAction(e -> { config.disableDofScaling.set(0); }); dofScalingDisabled.setOnAction(e -> { config.disableDofScaling.set(1); }); dofAddPicker.setOnAction(e -> { config.dofBlurAmount.replace(0, config.dofBlurAmount.length(), DOF_ADDITIONAL_BLUR_OPTIONS[dofAddPicker.getItems().indexOf(dofAddPicker.getValue())]); }); fpsLocked.setOnAction(e -> { config.unlockFPS.set(0); fpsLimitField.setDisable(true); recheckTextInput(fpsLimitField); }); fpsUnlocked.setOnAction(e -> { config.unlockFPS.set(1); fpsLimitField.setDisable(false); recheckTextInput(fpsLimitField); }); fpsFixKeyPicker.setOnAction(e -> { String fpsFixKeyNew = FPS_FIX_KEYS_HEX[FPS_FIX_KEYS_ARRAY_LIST.indexOf(fpsFixKeyPicker.getValue())] .substring(2); setFPSFixKey(fpsFixKeyNew); fpsFixKey = FPS_FIX_KEYS_HEX[FPS_FIX_KEYS_ARRAY_LIST.indexOf(fpsFixKeyPicker.getValue())].substring(2); }); fpsLimitField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || Integer.parseInt(newText) < 1) { fpsLimitField.pseudoClassStateChanged(INVALID_INPUT, true); fpsLimitField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else if (Integer.parseInt(newText) > 70) { fpsLimitField.pseudoClassStateChanged(INVALID_INPUT, true); fpsLimitField.setTooltip(new Tooltip(INPUT_FPS_TOO_HIGH)); } else { fpsLimitField.pseudoClassStateChanged(INVALID_INPUT, false); fpsLimitField.setTooltip( new Tooltip(FPS_LIMIT_LABEL.substring(0, FPS_LIMIT_LABEL.length() - 2))); config.FPSlimit.set(Integer.parseInt(newText)); } } catch (NumberFormatException nFE) { ui.printConsole(INPUT_TOO_LARGE); fpsLimitField.setText(""); } } }); fpsThresholdField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || Integer.parseInt(newText) < 1) { fpsThresholdField.pseudoClassStateChanged(INVALID_INPUT, true); fpsThresholdField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else { fpsThresholdField.pseudoClassStateChanged(INVALID_INPUT, false); fpsThresholdField.setTooltip( new Tooltip(FPS_LIMIT_LABEL.substring(0, FPS_LIMIT_LABEL.length() - 2))); config.FPSthreshold.set(Integer.parseInt(newText)); } } catch (NumberFormatException nFE) { ui.printConsole(INPUT_TOO_LARGE); fpsThresholdField.setText(""); } } }); texOverridePicker.setOnAction(e -> { config.filteringOverride.set(texOverridePicker.getItems().indexOf(texOverridePicker.getValue())); }); }
From source file:dsfixgui.view.DSPWPane.java
private void initializeEventHandlers() { applySettingsButton.setOnAction(e -> { ui.applyDSPWConfig();/*from w ww . j a v a 2s.com*/ }); restoreDefaultsButton.setOnAction(e -> { ContinueDialog cD = new ContinueDialog(300.0, 80.0, DIALOG_TITLE_RESET, DIALOG_MSG_RESTORE_SETTINGS, DIALOG_BUTTON_TEXTS[2], DIALOG_BUTTON_TEXTS[1]); if (cD.show()) { config.restoreDefaults(); ui.refreshUI(); } }); versionBannerOn.setOnAction(e -> { config.ShowVersionBanner.replace(0, config.ShowVersionBanner.length(), TRUE_FALSE[0]); }); versionBannerOff.setOnAction(e -> { config.ShowVersionBanner.replace(0, config.ShowVersionBanner.length(), TRUE_FALSE[1]); }); overlayOn.setOnAction(e -> { config.ShowOverlay.replace(0, config.ShowOverlay.length(), TRUE_FALSE[0]); }); overlayOff.setOnAction(e -> { config.ShowOverlay.replace(0, config.ShowOverlay.length(), TRUE_FALSE[1]); }); invasionNotifOn.setOnAction(e -> { config.InvasionSoundNotification.replace(0, config.InvasionSoundNotification.length(), TRUE_FALSE[0]); }); invasionNotifOff.setOnAction(e -> { config.InvasionSoundNotification.replace(0, config.InvasionSoundNotification.length(), TRUE_FALSE[1]); }); cheaterNotifOn.setOnAction(e -> { config.CheaterSoundNotification.replace(0, config.CheaterSoundNotification.length(), TRUE_FALSE[0]); }); cheaterNotifOff.setOnAction(e -> { config.CheaterSoundNotification.replace(0, config.CheaterSoundNotification.length(), TRUE_FALSE[1]); }); blockArenaFreezeOn.setOnAction(e -> { config.BlockArenaFreeze.replace(0, config.BlockArenaFreeze.length(), TRUE_FALSE[0]); }); blockArenaFreezeOff.setOnAction(e -> { config.BlockArenaFreeze.replace(0, config.BlockArenaFreeze.length(), TRUE_FALSE[1]); }); nodeCountOn.setOnAction(e -> { config.ShowNodeDbCount.replace(0, config.ShowNodeDbCount.length(), TRUE_FALSE[0]); }); nodeCountOff.setOnAction(e -> { config.ShowNodeDbCount.replace(0, config.ShowNodeDbCount.length(), TRUE_FALSE[1]); }); increaseNodesOn.setOnAction(e -> { config.IncreaseNodeDbLimit.replace(0, config.IncreaseNodeDbLimit.length(), TRUE_FALSE[0]); }); increaseNodesOff.setOnAction(e -> { config.IncreaseNodeDbLimit.replace(0, config.IncreaseNodeDbLimit.length(), TRUE_FALSE[1]); }); dateOn.setOnAction(e -> { config.DisplayDate.replace(0, config.DisplayDate.length(), TRUE_FALSE[0]); }); dateOff.setOnAction(e -> { config.DisplayDate.replace(0, config.DisplayDate.length(), TRUE_FALSE[1]); }); timeOn.setOnAction(e -> { config.DisplayClock.replace(0, config.DisplayClock.length(), TRUE_FALSE[0]); }); timeOff.setOnAction(e -> { config.DisplayClock.replace(0, config.DisplayClock.length(), TRUE_FALSE[1]); }); updateOn.setOnAction(e -> { config.CheckForUpdates.replace(0, config.CheckForUpdates.length(), TRUE_FALSE[0]); }); updateOff.setOnAction(e -> { config.CheckForUpdates.replace(0, config.CheckForUpdates.length(), TRUE_FALSE[1]); }); textAlignmentLeft.setOnAction(e -> { config.TextAlignment.replace(0, config.TextAlignment.length(), DSPW_TEXT_ALIGNMENT_OPTIONS[0]); }); textAlignmentCenter.setOnAction(e -> { config.TextAlignment.replace(0, config.TextAlignment.length(), DSPW_TEXT_ALIGNMENT_OPTIONS[1]); }); textAlignmentRight.setOnAction(e -> { config.TextAlignment.replace(0, config.TextAlignment.length(), DSPW_TEXT_ALIGNMENT_OPTIONS[2]); }); fontSizeField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || Integer.parseInt(newText) > 72 || Integer.parseInt(newText) < 15) { fontSizeField.pseudoClassStateChanged(INVALID_INPUT, true); } else { fontSizeField.pseudoClassStateChanged(INVALID_INPUT, false); config.FontSize.replace(0, config.FontSize.length(), "" + Integer.parseInt(newText)); } } catch (NumberFormatException nFE) { ui.printConsole(INPUT_TOO_LARGE); fontSizeField.setText(""); } } }); dllChainButton.setOnAction(e -> { FileChooser dllChooser = new FileChooser(); dllChooser.setTitle(DIALOG_TITLE_DLL); if (ui.getDataFolder() != null) { dllChooser.setInitialDirectory(ui.getDataFolder()); } ExtensionFilter dllFilter = new ExtensionFilter(DLL_EXT_FILTER[0], DLL_EXT_FILTER[1]); dllChooser.getExtensionFilters().add(dllFilter); File dll = dllChooser.showOpenDialog(ui.getStage()); if (dll != null && ui.getDataFolder() != null) { File checkDLL = new File(ui.getDataFolder() + "\\" + dll.getName()); if (!checkDLL.exists()) { AlertDialog aD = new AlertDialog(300.0, 80.0, DIALOG_TITLE_WRONG_FOLDER, DLL_MUST_BE_IN_DATA, DIALOG_BUTTON_TEXTS[0]); } else { if (dll.getName().equals(DSM_FILES[0])) { AlertDialog aD = new AlertDialog(300.0, 80.0, INVALID_DLL, CANT_CHAIN_DLL_WITH_DSM, DIALOG_BUTTON_TEXTS[0]); } else if (dll.getName().equals(DSF_FILES[0])) { AlertDialog aD = new AlertDialog(300.0, 80.0, INVALID_DLL, CANT_CHAIN_DLL_WITH_DSF, DIALOG_BUTTON_TEXTS[0]); } else if (dll.getName().equals(DS_DEFAULT_DLLS[0]) || dll.getName().equals(DS_DEFAULT_DLLS[1]) || dll.getName().equals(DS_DEFAULT_DLLS[2])) { AlertDialog aD = new AlertDialog(300.0, 80.0, INVALID_DLL, CANT_CHAIN_DLL_WITH_DEFAULT, DIALOG_BUTTON_TEXTS[0]); } else if (dll.getName().equals(DSPW_FILES[1]) || dll.getName().equals(DSPW_FILES[4]) || dll.getName().equals(DSPW_FILES[5])) { AlertDialog aD = new AlertDialog(300.0, 80.0, INVALID_DLL, CANT_CHAIN_DSPW_WITH_DSPW, DIALOG_BUTTON_TEXTS[0]); } else { config.d3d9dllWrapper.replace(0, config.d3d9dllWrapper.length(), dll.getName()); dllChainField.setText(dll.getName()); dllChainField.setStyle("-fx-text-fill: black;"); noChainButton.setDisable(false); } } } }); noChainButton.setOnAction(e -> { dllChainField.setText(NONE); noChainButton.setDisable(true); dllChainField.setStyle("-fx-text-fill: gray;"); config.d3d9dllWrapper.replace(0, config.d3d9dllWrapper.length(), NONE); }); banPicker.setOnAction(e -> { config.key_BanPhantom.replace(0, config.key_BanPhantom.length(), keybindsHex.get(keybinds.indexOf(banPicker.getValue()))); }); ignorePicker.setOnAction(e -> { config.key_IgnorePhantom.replace(0, config.key_IgnorePhantom.length(), keybindsHex.get(keybinds.indexOf(ignorePicker.getValue()))); }); toggleOverlayPicker.setOnAction(e -> { config.key_HideOverlay.replace(0, config.key_HideOverlay.length(), keybindsHex.get(keybinds.indexOf(toggleOverlayPicker.getValue()))); }); aboutPicker.setOnAction(e -> { config.key_AboutDSPW.replace(0, config.key_AboutDSPW.length(), keybindsHex.get(keybinds.indexOf(aboutPicker.getValue()))); }); }
From source file:dsfixgui.view.DSFGraphicsPane.java
private void recheckTextInput(TextField field) { String newText = field.getText(); if (field.equals(renderWidthField)) { if (!NumberUtils.isParsable(newText) || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) { renderWidthField.pseudoClassStateChanged(INVALID_INPUT, true); renderWidthField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else if (Integer.parseInt(newText) >= 1280) { if (NumberUtils.isParsable(presentWidthField.getText()) && (Integer.parseInt(newText) == Integer.parseInt(presentWidthField.getText()))) { renderWidthField.pseudoClassStateChanged(INVALID_INPUT, true); renderWidthField.setTooltip(new Tooltip(SAME_RESOLUTIONS)); } else { renderWidthField.pseudoClassStateChanged(INVALID_INPUT, false); renderWidthField.setTooltip(new Tooltip("")); config.setRenderWidth(Integer.parseInt(newText)); if (config.disableDOF) { config.setPresentWidth(Integer.parseInt(newText)); }//from w ww . j a v a2 s . c o m } //If input is a positive integer that is less than 1280, present width comes into play } else if (NumberUtils.isParsable(presentWidthField.getText()) && Integer.parseInt(presentWidthField.getText()) >= 1280) { renderWidthField.pseudoClassStateChanged(INVALID_INPUT, false); renderWidthField.setTooltip(new Tooltip("")); config.setRenderWidth(Integer.parseInt(newText)); } else { renderWidthField.pseudoClassStateChanged(INVALID_INPUT, true); renderWidthField.setTooltip(new Tooltip(PRES_WIDTH_TOO_LOW)); } } else if (field.equals(renderHeightField)) { if (!NumberUtils.isParsable(newText) || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) { renderHeightField.pseudoClassStateChanged(INVALID_INPUT, true); renderHeightField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else if (Integer.parseInt(newText) >= 720) { if (NumberUtils.isParsable(presentHeightField.getText()) && (Integer.parseInt(newText) == Integer.parseInt(presentHeightField.getText()))) { renderHeightField.pseudoClassStateChanged(INVALID_INPUT, true); renderHeightField.setTooltip(new Tooltip(SAME_RESOLUTIONS)); } else { renderHeightField.pseudoClassStateChanged(INVALID_INPUT, false); renderHeightField.setTooltip(new Tooltip("")); config.setRenderHeight(Integer.parseInt(newText)); if (config.disableDOF) { config.setPresentHeight(Integer.parseInt(newText)); config.setDOFOverride(Integer.parseInt(newText)); } } //If input is a positive integer that is less than 720, present height comes into play } else if (NumberUtils.isParsable(presentHeightField.getText()) && Integer.parseInt(presentHeightField.getText()) >= 720) { renderHeightField.pseudoClassStateChanged(INVALID_INPUT, false); renderHeightField.setTooltip(new Tooltip("")); config.setRenderHeight(Integer.parseInt(newText)); } else { renderHeightField.pseudoClassStateChanged(INVALID_INPUT, true); renderHeightField.setTooltip(new Tooltip(PRES_HEIGHT_TOO_LOW)); } } else if (field.equals(presentWidthField) && !presentWidthField.isDisabled()) { if (!NumberUtils.isParsable(newText) || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) { presentWidthField.pseudoClassStateChanged(INVALID_INPUT, true); presentWidthField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else if (Integer.parseInt(newText) < 1280) { presentWidthField.pseudoClassStateChanged(INVALID_INPUT, true); presentWidthField.setTooltip(new Tooltip(INPUT_GREATER_THAN + 1280)); } else if (Integer.parseInt(newText) >= 1280) { if (NumberUtils.isParsable(renderWidthField.getText()) && (Integer.parseInt(newText) == Integer.parseInt(renderWidthField.getText()))) { presentWidthField.pseudoClassStateChanged(INVALID_INPUT, true); presentWidthField.setTooltip(new Tooltip(SAME_RESOLUTIONS)); } else { presentWidthField.pseudoClassStateChanged(INVALID_INPUT, false); presentWidthField.setTooltip(null); config.setPresentWidth(Integer.parseInt(newText)); } } } else if (field.equals(presentWidthField) && presentWidthField.isDisabled()) { presentWidthField.pseudoClassStateChanged(INVALID_INPUT, false); presentWidthField.setTooltip(null); } else if (field.equals(presentHeightField) && !presentHeightField.isDisabled()) { if (!NumberUtils.isParsable(newText) || (NumberUtils.isParsable(newText) && Integer.parseInt(newText) < 1)) { presentHeightField.pseudoClassStateChanged(INVALID_INPUT, true); presentHeightField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else if (Integer.parseInt(newText) < 720) { presentHeightField.pseudoClassStateChanged(INVALID_INPUT, true); presentHeightField.setTooltip(new Tooltip(INPUT_GREATER_THAN + 720)); } else if (Integer.parseInt(newText) >= 720) { if (NumberUtils.isParsable(renderHeightField.getText()) && (Integer.parseInt(newText) == Integer.parseInt(renderHeightField.getText()))) { presentHeightField.pseudoClassStateChanged(INVALID_INPUT, true); presentHeightField.setTooltip(new Tooltip(SAME_RESOLUTIONS)); } else { presentHeightField.pseudoClassStateChanged(INVALID_INPUT, false); presentHeightField.setTooltip(null); config.setPresentHeight(Integer.parseInt(newText)); } } } else if (field.equals(presentHeightField) && presentHeightField.isDisabled()) { presentHeightField.pseudoClassStateChanged(INVALID_INPUT, false); presentHeightField.setTooltip(null); } else if (field.equals(fpsLimitField) && !fpsLimitField.isDisabled()) { if (!NumberUtils.isParsable(newText) || Integer.parseInt(newText) < 1) { fpsLimitField.pseudoClassStateChanged(INVALID_INPUT, true); fpsLimitField.setTooltip(new Tooltip(POSITIVE_INTEGER)); } else if (Integer.parseInt(newText) > 70) { fpsLimitField.pseudoClassStateChanged(INVALID_INPUT, true); fpsLimitField.setTooltip(new Tooltip(INPUT_FPS_TOO_HIGH)); } else { fpsLimitField.pseudoClassStateChanged(INVALID_INPUT, false); fpsLimitField.setTooltip(new Tooltip(FPS_LIMIT_LABEL.substring(0, FPS_LIMIT_LABEL.length() - 2))); config.FPSlimit.set(Integer.parseInt(newText)); } } else if (field.equals(fpsLimitField) && fpsLimitField.isDisabled()) { fpsLimitField.pseudoClassStateChanged(INVALID_INPUT, false); fpsLimitField.setTooltip(new Tooltip("")); } }