List of usage examples for com.google.common.math DoubleMath isMathematicalInteger
@GwtIncompatible("java.lang.Math.getExponent, com.google.common.math.DoubleUtils") public static boolean isMathematicalInteger(double x)
From source file:com.google.javascript.jscomp.parsing.TypeTransformationParser.java
/** * A template type of expression must be of the form * templateTypeOf(TTLExp, index)/*w w w .j a va 2s . com*/ */ private boolean validTemplateTypeOfExpression(Node expr) { // The expression must have three children. The templateTypeOf keyword, a // templatized type and an index if (!checkParameterCount(expr, Keywords.TEMPLATETYPEOF)) { return false; } // The parameter must be a valid type expression if (!validTypeTransformationExpression(getCallArgument(expr, 0))) { warnInvalidInside(Keywords.TEMPLATETYPEOF.name, expr); return false; } if (!getCallArgument(expr, 1).isNumber()) { warnInvalid("index", expr); warnInvalidInside(Keywords.TEMPLATETYPEOF.name, expr); return false; } double index = getCallArgument(expr, 1).getDouble(); if (!DoubleMath.isMathematicalInteger(index) || index < 0) { warnInvalid("index", expr); warnInvalidInside(Keywords.TEMPLATETYPEOF.name, expr); return false; } return true; }
From source file:org.openmicroscopy.shoola.agents.util.EditorUtil.java
/** * Transforms the specified channel information. * * @param data The object to transform./*from www .j av a2 s .co m*/ * @return The map whose keys are the field names, and the values * the corresponding fields' values. */ public static Map<String, Object> transformChannelData(ChannelData data) { LinkedHashMap<String, Object> details = new LinkedHashMap<String, Object>(10); List<String> notSet = new ArrayList<String>(); details.put(NAME, ""); details.put(EXCITATION, Integer.valueOf(0)); details.put(EMISSION, Integer.valueOf(0)); details.put(ND_FILTER, NF.format(Float.valueOf(0))); details.put(PIN_HOLE_SIZE, NF.format(Float.valueOf(0))); details.put(FLUOR, ""); details.put(ILLUMINATION, ""); details.put(CONTRAST_METHOD, ""); details.put(MODE, ""); details.put(POCKEL_CELL_SETTINGS, Integer.valueOf(0)); if (data == null) { notSet.add(NAME); notSet.add(EMISSION); notSet.add(EXCITATION); notSet.add(ND_FILTER); notSet.add(PIN_HOLE_SIZE); notSet.add(FLUOR); notSet.add(ILLUMINATION); notSet.add(CONTRAST_METHOD); notSet.add(MODE); notSet.add(POCKEL_CELL_SETTINGS); details.put(NOT_SET, notSet); return details; } String s = data.getName(); if (CommonsLangUtils.isBlank(s)) notSet.add(NAME); details.put(NAME, s); Length wl = null; try { wl = data.getEmissionWavelength(null); } catch (BigResult e) { // can't happen as null is passed to the method } if (wl == null) { notSet.add(EMISSION); } else { double wave = wl.getValue(); if (wave <= 100) { notSet.add(EMISSION); } else { //First check if the wave is a int if (DoubleMath.isMathematicalInteger(wave)) { details.put(EMISSION, (int) wave + NONBRSPACE + wl.getSymbol()); } else { details.put(EMISSION, NF.format(wave) + NONBRSPACE + wl.getSymbol()); } } } try { wl = data.getExcitationWavelength(null); } catch (BigResult e) { // can't happen as null is passed to the method } if (wl == null) { notSet.add(EXCITATION); } else { double wave = wl.getValue(); if (wave <= 100) { notSet.add(EXCITATION); } else { //First check if the wave is a int if (DoubleMath.isMathematicalInteger(wave)) { details.put(EXCITATION, ((int) wave) + NONBRSPACE + wl.getSymbol()); } else { details.put(EXCITATION, NF.format(wave) + NONBRSPACE + wl.getSymbol()); } } } double f = data.getNDFilter(); if (f < 0) notSet.add(ND_FILTER); else details.put(ND_FILTER, NF.format(f * 100)); Length ph = null; try { ph = data.getPinholeSize(null); } catch (BigResult e) { // can't happen as null is passed to the method } if (ph == null) { notSet.add(PIN_HOLE_SIZE); } else { f = ph.getValue(); details.put(PIN_HOLE_SIZE, NF.format(f) + NONBRSPACE + ph.getSymbol()); } s = data.getFluor(); if (CommonsLangUtils.isBlank(s)) notSet.add(FLUOR); details.put(FLUOR, s); s = data.getIllumination(); if (CommonsLangUtils.isBlank(s)) notSet.add(ILLUMINATION); details.put(ILLUMINATION, s); s = data.getContrastMethod(); if (CommonsLangUtils.isBlank(s)) notSet.add(CONTRAST_METHOD); details.put(CONTRAST_METHOD, s); s = data.getMode(); if (CommonsLangUtils.isBlank(s)) notSet.add(MODE); details.put(MODE, s); int i = data.getPockelCell(); if (i < 0) { i = 0; notSet.add(POCKEL_CELL_SETTINGS); } details.put(POCKEL_CELL_SETTINGS, i); details.put(NOT_SET, notSet); return details; }