List of usage examples for java.lang Double intValue
public int intValue()
From source file:Main.java
public static void main(String[] args) { Double doubleObject = new Double("10.01"); int i = doubleObject.intValue(); System.out.println("int:" + i); }
From source file:Main.java
public static void main(String[] args) throws ScriptException { ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine rhino = manager.getEngineByName("JavaScript"); Double result = (Double) rhino.eval("1 + 2"); Integer i = result.intValue(); System.out.println(i);/* w ww .j a v a 2s. c o m*/ }
From source file:GetSeriesId.java
public static void main(String[] args) throws Exception { XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); Double result = (Double) xPath.evaluate("/schedule/@seriesId", new InputSource(new FileReader("tds.xml")), XPathConstants.NUMBER); System.out.println(result.intValue()); }
From source file:Main.java
public static void main(String[] args) { Double dObj = new Double("10.50"); byte b = dObj.byteValue(); System.out.println(b);// w w w . j a v a2 s . c o m short s = dObj.shortValue(); System.out.println(s); int i = dObj.intValue(); System.out.println(i); float f = dObj.floatValue(); System.out.println(f); double d = dObj.doubleValue(); System.out.println(d); }
From source file:Main.java
public static void main(String[] args) { Integer intObj = Integer.valueOf(100); // Gets byte from Integer byte b = intObj.byteValue(); // Gets double from Integer double dd = intObj.doubleValue(); System.out.println("intObj = " + intObj); System.out.println("byte from intObj = " + b); System.out.println("double from intObj = " + dd); // Creates a Double object Double doubleObj = Double.valueOf("123.45"); // Gets different types of primitive values from Double double d = doubleObj.doubleValue(); float f = doubleObj.floatValue(); int i = doubleObj.intValue(); long l = doubleObj.longValue(); System.out.println("doubleObj = " + doubleObj); System.out.println("double from doubleObj = " + d); System.out.println("float from doubleObj = " + f); System.out.println("int from doubleObj = " + i); System.out.println("long from doubleObj = " + l); }
From source file:org.eclipse.swt.snippets.Snippet372.java
public static void main(String[] args) { int maximumWidth = 200; int maximumHeight = 2000; String html = "<HTML><HEAD><TITLE>HTML Test</TITLE></HEAD><BODY>"; for (int i = 0; i < 15; i++) html += "<P>This is line " + i + "</P>"; html += "</BODY></HTML>"; Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 372"); shell.setLayout(new FillLayout()); Browser browser;//from w w w . j ava 2s . c om try { browser = new Browser(shell, SWT.NONE); } catch (SWTError e) { System.out.println("Could not instantiate Browser: " + e.getMessage()); display.dispose(); return; } browser.setText(html); browser.addProgressListener(ProgressListener.completedAdapter(event -> { // Set the display to something known to be smaller than the content shell.setSize(50, 50); browser.execute("document.getElementsByTagName(\"html\")[0].style.whiteSpace = \"nowrap\""); //$NON-NLS-1$ // Save the width to either be a decided maximum or the browser's content width plus the margin Double width = Math.min(maximumWidth, 10 + (Double) browser.evaluate("return document.body.scrollWidth;")); //$NON-NLS-1$ shell.setSize(width.intValue(), 0); browser.execute("document.getElementsByTagName(\"html\")[0].style.whiteSpace = \"normal\""); //$NON-NLS-1$ shell.layout(); // Set the height to either be a decided maximum or the browser's content height plus the margin Double height = Math.min(maximumHeight, 5 + (Double) browser.evaluate("return document.body.scrollHeight;")); //$NON-NLS-1$ shell.setSize(width.intValue(), height.intValue()); })); shell.open(); while (!shell.isDisposed()) { shell.layout(); if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:android.databinding.tool.MakeCopy.java
public static void main(String[] args) { if (args.length < 5) { System.out.println("required parameters: [-l] manifest adk-dir src-out-dir xml-out-dir " + "res-out-dir res-in-dir..."); System.out.println("Creates an android data binding class and copies resources from"); System.out.println("res-source to res-target and modifies binding layout files"); System.out.println("in res-target. Binding data is extracted into XML files"); System.out.println("and placed in xml-out-dir."); System.out.println(" -l indicates that this is a library"); System.out.println(" manifest path to AndroidManifest.xml file"); System.out.println(" src-out-dir path to where generated source goes"); System.out.println(" xml-out-dir path to where generated binding XML goes"); System.out.println(" res-out-dir path to the where modified resources should go"); System.out.println(//from w ww .j a va2 s . co m " res-in-dir path to source resources \"res\" directory. One" + " or more are allowed."); System.exit(1); } final boolean isLibrary = args[0].equals("-l"); final int indexOffset = isLibrary ? 1 : 0; final String applicationPackage; final int minSdk; final Document androidManifest = readAndroidManifest(new File(args[MANIFEST_INDEX + indexOffset])); try { final XPathFactory xPathFactory = XPathFactory.newInstance(); final XPath xPath = xPathFactory.newXPath(); applicationPackage = xPath.evaluate("string(/manifest/@package)", androidManifest); final Double minSdkNumber = (Double) xPath.evaluate("number(/manifest/uses-sdk/@android:minSdkVersion)", androidManifest, XPathConstants.NUMBER); minSdk = minSdkNumber == null ? 1 : minSdkNumber.intValue(); } catch (XPathExpressionException e) { e.printStackTrace(); System.exit(6); return; } final File srcDir = new File(args[SRC_INDEX + indexOffset], APP_SUBPATH); if (!makeTargetDir(srcDir)) { System.err.println("Could not create source directory " + srcDir); System.exit(2); } final File resTarget = new File(args[RES_OUT_INDEX + indexOffset]); if (!makeTargetDir(resTarget)) { System.err.println("Could not create resource directory: " + resTarget); System.exit(4); } final File xmlDir = new File(args[XML_INDEX + indexOffset]); if (!makeTargetDir(xmlDir)) { System.err.println("Could not create xml output directory: " + xmlDir); System.exit(5); } System.out.println("Application Package: " + applicationPackage); System.out.println("Minimum SDK: " + minSdk); System.out.println("Target Resources: " + resTarget.getAbsolutePath()); System.out.println("Target Source Dir: " + srcDir.getAbsolutePath()); System.out.println("Target XML Dir: " + xmlDir.getAbsolutePath()); System.out.println("Library? " + isLibrary); boolean foundSomeResources = false; for (int i = RES_IN_INDEX + indexOffset; i < args.length; i++) { final File resDir = new File(args[i]); if (!resDir.exists()) { System.out.println("Could not find resource directory: " + resDir); } else { System.out.println("Source Resources: " + resDir.getAbsolutePath()); try { FileUtils.copyDirectory(resDir, resTarget); addFromFile(resDir, resTarget); foundSomeResources = true; } catch (IOException e) { System.err.println("Could not copy resources from " + resDir + " to " + resTarget + ": " + e.getLocalizedMessage()); System.exit(3); } } } if (!foundSomeResources) { System.err.println("No resource directories were found."); System.exit(7); } processLayoutFiles(applicationPackage, resTarget, srcDir, xmlDir, minSdk, isLibrary); }
From source file:playground.johannes.studies.ivt.DensityPlotBiTree.java
public static void main(String[] args) throws IOException, FactoryException { SocialSampledGraphProjection<SocialSparseGraph, SocialSparseVertex, SocialSparseEdge> graph = GraphReaderFacade .read("/Users/jillenberger/Work/socialnets/data/ivt2009/11-2011/graph/graph.graphml"); SocialSampledGraphProjectionBuilder<SocialSparseGraph, SocialSparseVertex, SocialSparseEdge> builder = new SocialSampledGraphProjectionBuilder<SocialSparseGraph, SocialSparseVertex, SocialSparseEdge>(); SpatialSparseGraph popData = new Population2SpatialGraph(CRSUtils.getCRS(21781)) .read("/Users/jillenberger/Work/socialnets/data/schweiz/complete/plans/plans.0.10.xml"); SimpleFeature feature = FeatureSHP//from w ww. jav a2 s . co m .readFeatures("/Users/jillenberger/Work/socialnets/data/schweiz/complete/zones/G1L08.shp") .iterator().next(); Geometry chBorder = (Geometry) feature.getDefaultGeometry(); chBorder.setSRID(21781); graph.getDelegate().transformToCRS(CRSUtils.getCRS(21781)); logger.info("Applying spatial filter..."); SpatialFilter filter = new SpatialFilter((GraphBuilder) builder, chBorder); graph = (SocialSampledGraphProjection<SocialSparseGraph, SocialSparseVertex, SocialSparseEdge>) filter .apply(graph); Set<Point> points = new HashSet<Point>(); for (SpatialVertex v : graph.getVertices()) { points.add(v.getPoint()); } GeometryFactory factory = new GeometryFactory(); Point zrh = factory.createPoint(new Coordinate(8.55, 47.36)); zrh = CRSUtils.transformPoint(zrh, CRS.findMathTransform(DefaultGeographicCRS.WGS84, CRSUtils.getCRS(21781))); // graph.getDelegate().transformToCRS(DefaultGeographicCRS.WGS84); // graph2.transformToCRS(DefaultGeographicCRS.WGS84); logger.info("Segmenting tiles..."); // BiTreeGrid<Double> sampleGrid = BiTreeGridBuilder.createEqualCountGrid(points, 200, 1000); Envelope env = PointUtils.envelope(points); SpatialGrid<Double> sampleGrid = new SpatialGrid<Double>(env.getMinX(), env.getMinY(), env.getMaxX(), env.getMaxY(), 5000); DistanceCalculator calc = new CartesianDistanceCalculator(); Discretizer disc = new LinearDiscretizer(1000.0); logger.info("Creating survey grid..."); for (Point p : points) { // Tile<Double> tile = sampleGrid.getTile(p.getCoordinate()); Double data = sampleGrid.getValue(p); double val = 0; // if(tile.data != null) // val = tile.data; if (data != null) val = data.doubleValue(); double d = disc.discretize(calc.distance(p, zrh)); d = Math.max(1, d); double proba = Math.pow(d, -1.4); // val += 1/proba; val++; // tile.data = new Double(val); sampleGrid.setValue(val, p); } logger.info("Creating population grid..."); // BiTreeGrid<Integer> popGrid = new BiTreeGrid<Integer>(sampleGrid); SpatialGrid<Integer> popGrid = new SpatialGrid<Integer>(sampleGrid); for (SpatialVertex v : popData.getVertices()) { // Tile<Integer> tile = popGrid.getTile(v.getPoint().getCoordinate()); Integer data = popGrid.getValue(v.getPoint()); // if (tile != null) { // int val = 0; // if (tile.data != null) // val = tile.data; // val++; // tile.data = new Integer(val); // } int val = 0; if (data != null) { val = data.intValue(); } val++; popGrid.setValue(val, v.getPoint()); } logger.info("Creating density grid..."); // BiTreeGrid<Double> densityGrid = new BiTreeGrid<Double>(sampleGrid); SpatialGrid<Double> densityGrid = new SpatialGrid<Double>(sampleGrid); // Set<Tile<Double>> tiles = densityGrid.tiles(); // for(Tile<Double> tile : tiles) { // Tile<Double> surveyTile = sampleGrid.getTile(tile.envelope.centre()); // Tile<Integer> popTile = popGrid.getTile(tile.envelope.centre()); // // if(surveyTile != null && popTile != null) { // if(surveyTile.data != null && popTile.data != null) // tile.data = surveyTile.data/(double)popTile.data; // else // tile.data = new Double(0); // } else // tile.data = new Double(0); // } for (int row = 0; row < densityGrid.getNumRows(); row++) { for (int col = 0; col < densityGrid.getNumCols(row); col++) { Integer inhabitants = popGrid.getValue(row, col); Double samples = sampleGrid.getValue(row, col); if (inhabitants != null && samples != null) { double density = samples / (double) inhabitants; densityGrid.setValue(row, col, density); } else { densityGrid.setValue(row, col, 0.0); } } } ZoneLayer<Double> layer = ZoneUtils.createGridLayer(5000, chBorder); layer.overwriteCRS(CRSUtils.getCRS(21781)); DescriptiveStatistics stats = new DescriptiveStatistics(); for (int row = 0; row < densityGrid.getNumRows(); row++) { for (int col = 0; col < densityGrid.getNumCols(row); col++) { Point p = makeCoordinate(densityGrid, row, col); p.setSRID(21781); Zone<Double> z = layer.getZone(p); if (z != null) { double val = densityGrid.getValue(row, col); if (val > 0) { stats.addValue(val); } z.setAttribute(val); } } } // double min = stats.getMin(); // double max = stats.getPercentile(80); // double bins = 20; // double width = (max-min)/bins; // Discretizer discretizer = new BoundedLinearDiscretizer(width, min, max); // for(Zone<Double> z : layer.getZones()) { // Double val = z.getAttribute(); // if(val != null && val > 0) { // val = discretizer.index(val-min); // z.setAttribute(val); // } // } ZoneLayerSHP.write(layer, "/Users/jillenberger/Work/socialnets/data/ivt2009/11-2011/graph/density.grid.shp"); // logger.info("Writing KML..."); // SpatialGridKMLWriter writer = new SpatialGridKMLWriter(); // writer.write(densityGrid, CRSUtils.getCRS(21781), "/Users/jillenberger/Work/socialnets/data/ivt2009/11-2011/graph/density.grid.kml"); // writer.write(densityGrid, "/Users/jillenberger/Work/socialnets/data/ivt2009/11-2011/graph/density.grid.kml"); // GeometryFactory factory = new GeometryFactory(); // Set<Geometry> geometries = new HashSet<Geometry>(); // TObjectDoubleHashMap values = new TObjectDoubleHashMap(); //// tiles = sampleGrid.tiles(); // for(Tile<Double> n : tiles) { // Coordinate[] coords = new Coordinate[5]; // coords[0] = new Coordinate(n.envelope.getMinX(), n.envelope.getMinY()); // coords[1] = new Coordinate(n.envelope.getMinX(), n.envelope.getMaxY()); // coords[2] = new Coordinate(n.envelope.getMaxX(), n.envelope.getMaxY()); // coords[3] = new Coordinate(n.envelope.getMaxX(), n.envelope.getMinY()); // coords[4] = new Coordinate(n.envelope.getMinX(), n.envelope.getMinY()); // LinearRing shell = factory.createLinearRing(coords); // shell.setSRID(21781); // geometries.add(shell); // values.put(shell, n.data); // } // // NumericAttributeColorizer colorizer = new NumericAttributeColorizer(values); // colorizer.setLogscale(true); // FeatureKMLWriter writer = new FeatureKMLWriter(); // writer.setColorizable(colorizer); // writer.write(geometries, "/Users/jillenberger/Work/socialnets/data/ivt2009/11-2011/graph/density.kml"); }
From source file:Main.java
private static void setPrice(TextView text, Double amount) { int i = amount.intValue(); text.setText("$" + i); }
From source file:Main.java
public static Integer stringToInteger(String s) { final Double d = Double.parseDouble(s); return d.intValue(); }