List of usage examples for java.lang Double intValue
public int intValue()
From source file:com.nts.alphamale.handler.DeviceHandler.java
/** * Dumpsys Input Diagnostics ? ? ?? ?? . 1) Touch Screen? * width height 2) Touch Screen? Scaling Factors - XScale, YScale 3) * SurfaceOrientation? ? ? Orientation 4) FocusedWindow? ? * ? Activity //from ww w . j a v a 2s . c om * * @see <a href="https://source.android.com/devices/input/diagnostics.html"> * Dumpsys Input Diagnostics</a> * @param serial * @return */ public static Map<String, Object> getInputManager(String serial) { Map<String, Object> rtnValue = new HashMap<String, Object>(); final String activity_regex = "((\\S+)/(\\S+))[\\s|\\}]"; final String dispaly_regex = "[X|Y]: min=\\d, max=(\\d+),"; final String orientation_regex = "(\\d)"; final String scaling_regex = "[X|Y]Scale:\\s(.*)"; //final String touchscreen_regex = "Device\\s\\d+:\\s(\\S+)"; final String touchscreen_regex = "DeviceType: touchScreen"; final String pointerVelocityControlParameters_regex = "PointerVelocityControlParameters:\\s(.*)"; final String tabInterval_regex = "TapInterval:\\s(.*)ms"; final String tapDragInterval_regex = "TapDragInterval:\\s(.*)ms"; final String multitouchSettleInterval_regex = "MultitouchSettleInterval:\\s(.*)ms"; final String swipeMaxWidthRatio_regex = "SwipeMaxWidthRatio:\\s(.*)"; final String movementSpeedRatio_regex = "MovementSpeedRatio:\\s(.*)"; final String zoomSpeedRatio_regex = "ZoomSpeedRatio:\\s(.*)"; final String velocity_scale_regex = "scale=(.*), lowThreshold"; final String velocity_lowThreshold_regex = "lowThreshold=(.*), highThreshold"; final String velocity_highThreshold_regex = "highThreshold=(.*), acceleration"; final String velocity_acceleration_regex = "acceleration=(.*)"; boolean isTouchScreen = false; Map<String, Object> executorMap = new AdbShellExecutor() .execute(AdbShellCommand.cmd(serial, "cmd_dumpsys_input"), false, Settings.EXECUTOR_TIMEOUT); if (executorMap.isEmpty()) { return null; } LineIterator li = Utils.getLineIterator(executorMap.get("stdOut")); while (li.hasNext()) { String output = li.nextLine().trim(); if (output.contains(touchscreen_regex)) { isTouchScreen = true; } if (isTouchScreen && output.contains("Last Cooked Touch")) { isTouchScreen = false; } if (isTouchScreen && output.contains("X: min=0, max=")) { if (!rtnValue.containsKey("width")) rtnValue.put("width", (Integer.valueOf(Utils.convertRegex(dispaly_regex, output, 1)) + 1) + ""); } if (isTouchScreen && output.contains("Y: min=0, max=")) { if (!rtnValue.containsKey("height")) rtnValue.put("height", (Integer.valueOf(Utils.convertRegex(dispaly_regex, output, 1)) + 1) + ""); } if (isTouchScreen && output.contains("XScale:") && !output.contains("TiltXScale")) { if (!rtnValue.containsKey("xScale")) rtnValue.put("xScale", Utils.convertRegex(scaling_regex, output, 1)); } if (isTouchScreen && output.contains("YScale:") && !output.contains("TiltYScale")) { if (!rtnValue.containsKey("yScale")) rtnValue.put("yScale", Utils.convertRegex(scaling_regex, output, 1)); } if (output.contains("SwipeMaxWidthRatio")) { if (!rtnValue.containsKey("SwipeMaxWidthRatio")) { log.info("width : " + String.valueOf(rtnValue.get("width")) + " height : " + String.valueOf(rtnValue.get("height"))); String swipeMaxWidthRatio = Utils.convertRegex(swipeMaxWidthRatio_regex, output, 1); Integer width = Integer.valueOf((String) rtnValue.get("width")); Integer height = Integer.valueOf((String) rtnValue.get("height")); //Double swipe_distance = (Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)) * Double.valueOf(swipeMaxWidthRatio)); Double swipe_distance = (Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)) * Double.valueOf(swipeMaxWidthRatio)); Settings.SWIPE_AREA_THRESHOLD = swipe_distance.intValue(); } } if (output.contains("SurfaceOrientation:")) DataQueue.CURRENT_ORIENTATION = Integer.valueOf(Utils.convertRegex(orientation_regex, output, 1)); /* * String output = li.nextLine().trim(); if (output.contains("TOUCH_MAJOR")) isTouchScreen = true; if (isTouchScreen && output.contains("Input Dispatcher State:")) isTouchScreen = false; if (isTouchScreen && output.contains("X: min=0, max=")) { if (!rtnValue.containsKey("width")) rtnValue.put("width", (Integer.valueOf(Utils.convertRegex(dispaly_regex, output, 1)) + 1) + ""); } if (isTouchScreen && output.contains("Y: min=0, max=")) { if (!rtnValue.containsKey("height")) rtnValue.put("height", (Integer.valueOf(Utils.convertRegex(dispaly_regex, output, 1)) + 1) + ""); } if (isTouchScreen && output.contains("XScale:") && !output.contains("TiltXScale")) { if (!rtnValue.containsKey("xScale")) rtnValue.put("xScale", Utils.convertRegex(scaling_regex, output, 1)); } if (isTouchScreen && output.contains("YScale:") && !output.contains("TiltYScale")) { if (!rtnValue.containsKey("yScale")) rtnValue.put("yScale", Utils.convertRegex(scaling_regex, output, 1)); } if (isTouchScreen && output.contains("PointerVelocityControlParameters")) { if (!rtnValue.containsKey("pointerVelocityControlParameters")){ String velocityInfo = Utils.convertRegex(pointerVelocityControlParameters_regex, output, 1); Map<String,String> detailInfo = new HashMap<String,String>(); detailInfo.put("scale", Utils.convertRegex(velocity_scale_regex, velocityInfo, 1)); detailInfo.put("lowThreshold", Utils.convertRegex(velocity_lowThreshold_regex, velocityInfo, 1)); detailInfo.put("highThreshold", Utils.convertRegex(velocity_highThreshold_regex, velocityInfo, 1)); detailInfo.put("acceleration", Utils.convertRegex(velocity_acceleration_regex, velocityInfo, 1)); rtnValue.put("pointerVelocityControlParameters",detailInfo); } } if (isTouchScreen && output.contains("TapInterval")) { if (!rtnValue.containsKey("tapInterval")) rtnValue.put("tapInterval", Utils.convertRegex(tabInterval_regex, output, 1)); } if (isTouchScreen && output.contains("TapDragInterval")) { if (!rtnValue.containsKey("tapDragInterval")) rtnValue.put("tapDragInterval", Utils.convertRegex(tapDragInterval_regex, output, 1)); } if (isTouchScreen && output.contains("MultitouchSettleInterval")) { if (!rtnValue.containsKey("multitouchSettleInterval")) rtnValue.put("multitouchSettleInterval", Utils.convertRegex(multitouchSettleInterval_regex, output, 1)); } if (isTouchScreen && output.contains("SwipeMaxWidthRatio")) { if (!rtnValue.containsKey("swipeMaxWidthRatio")) rtnValue.put("swipeMaxWidthRatio", Utils.convertRegex(swipeMaxWidthRatio_regex, output, 1)); } if (isTouchScreen && output.contains("MovementSpeedRatio")) { if (!rtnValue.containsKey("movementSpeedRatio")) rtnValue.put("movementSpeedRatio", Utils.convertRegex(movementSpeedRatio_regex, output, 1)); } if (isTouchScreen && output.contains("ZoomSpeedRatio")) { if (!rtnValue.containsKey("zoomSpeedRatio")) rtnValue.put("zoomSpeedRatio", Utils.convertRegex(zoomSpeedRatio_regex, output, 1)); }*/ if (output.contains("SurfaceOrientation:")) DataQueue.CURRENT_ORIENTATION = Integer.valueOf(Utils.convertRegex(orientation_regex, output, 1)); } Utils.destoryExecutor(executorMap.get("executor")); return rtnValue; }
From source file:de.walware.statet.r.core.rsource.ast.RAst.java
public static Integer toJavaInt(RAstNode node) { while (node != null) { switch (node.getNodeType()) { case NUM_CONST: switch (node.getOperator(0)) { case NUM_NUM: { final Double num = parseNum(node.getText()); if (num != null && num.doubleValue() == Math.rint(num.doubleValue())) { return num.intValue(); }/*from w w w . ja va 2 s . co m*/ break; } case NUM_INT: return parseInt(node.getText()); case TRUE: return 1; case FALSE: return 0; default: break; } return null; case F_CALL_ARG: node = ((FCall.Arg) node).getValueChild(); continue; default: return null; } } return null; }
From source file:com.comcast.cdn.traffic_control.traffic_router.core.dns.ZoneManager.java
protected static void initZoneCache(final TrafficRouter tr) { synchronized (ZoneManager.class) { final CacheRegister cacheRegister = tr.getCacheRegister(); final JSONObject config = cacheRegister.getConfig(); int poolSize = 1; final double scale = config.optDouble("zonemanager.threadpool.scale", 0.75); final int cores = Runtime.getRuntime().availableProcessors(); if (cores > 2) { final Double s = Math.floor((double) cores * scale); if (s.intValue() > 1) { poolSize = s.intValue(); }/*from w w w . java 2 s. c o m*/ } final ExecutorService initExecutor = Executors.newFixedThreadPool(poolSize); final ExecutorService ze = Executors.newFixedThreadPool(poolSize); final ScheduledExecutorService me = Executors.newScheduledThreadPool(2); // 2 threads, one for static, one for dynamic, threads to refresh zones final int maintenanceInterval = config.optInt("zonemanager.cache.maintenance.interval", 300); // default 5 minutes final String dspec = "expireAfterAccess=" + config.optString("zonemanager.dynamic.response.expiration", "300s"); // default to 5 minutes final LoadingCache<ZoneKey, Zone> dzc = createZoneCache(ZoneCacheType.DYNAMIC, CacheBuilderSpec.parse(dspec)); final LoadingCache<ZoneKey, Zone> zc = createZoneCache(ZoneCacheType.STATIC); initZoneDirectory(); try { LOGGER.info("Generating zone data"); generateZones(tr, zc, dzc, initExecutor); initExecutor.shutdown(); initExecutor.awaitTermination(5, TimeUnit.MINUTES); LOGGER.info("Zone generation complete"); } catch (final InterruptedException ex) { LOGGER.warn("Initialization of zone data exceeded time limit of 5 minutes; continuing", ex); } catch (IOException ex) { LOGGER.fatal("Caught fatal exception while generating zone data!", ex); } me.scheduleWithFixedDelay(getMaintenanceRunnable(dzc, ZoneCacheType.DYNAMIC, maintenanceInterval), 0, maintenanceInterval, TimeUnit.SECONDS); me.scheduleWithFixedDelay(getMaintenanceRunnable(zc, ZoneCacheType.STATIC, maintenanceInterval), 0, maintenanceInterval, TimeUnit.SECONDS); final ExecutorService tze = ZoneManager.zoneExecutor; final ScheduledExecutorService tme = ZoneManager.zoneMaintenanceExecutor; final LoadingCache<ZoneKey, Zone> tzc = ZoneManager.zoneCache; final LoadingCache<ZoneKey, Zone> tdzc = ZoneManager.dynamicZoneCache; ZoneManager.zoneExecutor = ze; ZoneManager.zoneMaintenanceExecutor = me; ZoneManager.dynamicZoneCache = dzc; ZoneManager.zoneCache = zc; if (tze != null) { tze.shutdownNow(); } if (tme != null) { tme.shutdownNow(); } if (tzc != null) { tzc.invalidateAll(); } if (tdzc != null) { tdzc.invalidateAll(); } } }
From source file:de.iteratec.iteraplan.businesslogic.exchange.legacyExcel.importer.ExcelImportUtilities.java
private static String getNumericCellContentAsString(Cell cell, ProcessingLog processingLog) { // for numeric cells / dates we have to look at the cell format to tell if it's a date cell // If so, we retrieve the value as a date and convert it to ISO String notation if (HSSFDateUtil.isCellDateFormatted(cell)) { // is it a date-formatted number? then return the ISO-formatted date instead of the number Date cellDate = contentAsDate(cell); final SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); return dateformatter.format(cellDate); }/*from w w w . jav a2 s .co m*/ Double d = null; try { d = contentAsDouble(cell); } catch (NumberFormatException ex) { processingLog.warn("Cell [{0}] {1}; ignoring the value", getCellRef(cell), ex.getMessage()); } catch (IllegalStateException e) { processingLog.warn("Cell [{0}] {1}; ignoring the value", getCellRef(cell), e.getMessage()); } if (d != null) { // cut off *.0 double i = d.doubleValue() - d.intValue(); if (i == 0) { Integer j = Integer.valueOf(d.intValue()); return j.toString(); } else { return d.toString(); } } return ""; }
From source file:org.castor.cpa.test.test356.IntAndDoubleEntity.java
public void setProperty(final Double property) { LOG.debug("setProperty(Double)"); _property = new Integer(property.intValue()); }
From source file:com.enonic.cms.core.search.ElasticSearchIndexedFieldsTranslator.java
private int getFieldAsInt(GetField field) { final Double valueNum = (Double) field.getValue(); return valueNum.intValue(); }
From source file:com.nikolak.weatherapp.ForecastIO.Hour.java
public String getProbabilityPerc() { Double percentage = this.precipProbability * 100; return String.valueOf(percentage.intValue()) + "%"; }
From source file:com.nikolak.weatherapp.ForecastIO.Currently.java
public String getHumidityPerc() { Double percentage = this.humidity * 100; return String.valueOf(percentage.intValue()) + "%"; }
From source file:ml.shifu.shifu.udf.EvalScoreUDFTest.java
private void check(Tuple result, Object[] expectVals) throws ExecException { for (int i = 0; i < expectVals.length; i++) { Object obj = result.get(i); String value = obj.toString(); if (obj instanceof Double) { Double actualVal = (Double) obj; value = Integer.toString(actualVal.intValue()); }//from www . j av a 2s .c o m Assert.assertEquals(value, expectVals[i]); } }
From source file:org.apache.hadoop.hive.ql.udf.UDFToInteger.java
public Integer evaluate(Double i) { if (i == null) { return null; } else {/*from w w w . j ava 2 s . c o m*/ return Integer.valueOf(i.intValue()); } }