List of usage examples for java.lang Double MAX_VALUE
double MAX_VALUE
To view the source code for java.lang Double MAX_VALUE.
Click Source Link
From source file:com.offbynull.peernetic.debug.visualizer.VisualizerUtils.java
/** * Creates a random point within a rectangle. * @param width rectangle width/*from www. j a v a 2 s .c o m*/ * @param height rectangle height * @return new random point within rectangle specified by {@code width} and {@code height} * @throws IllegalArgumentException if any argument is negative or a special double value (e.g. NaN/infinite/etc..) */ public static Point randomPointInRectangle(double width, double height) { Validate.inclusiveBetween(0.0, Double.MAX_VALUE, width); Validate.inclusiveBetween(0.0, Double.MAX_VALUE, height); return new Point((int) (Math.random() * width), (int) (Math.random() * height)); }
From source file:Main.java
/** * Iterate over supported camera preview sizes to see which one best fits the * dimensions of the given view while maintaining the aspect ratio. If none can, * be lenient with the aspect ratio.//from w w w . ja v a2s . c o m * * @param sizes Camera sizes. * @param w The width of the view. * @param h The height of the view. * @return Best match camera preview size to fit in the view. */ public static Camera.Size getOptimalPreviewSize(List<Camera.Size> sizes, int w, int h) { final double ASPECT_TOLERANCE = 0.1; double targetRatio = w > h ? (double) w / h : (double) h / w; if (sizes == null) return null; Camera.Size optimalSize = null; double minDiff = Double.MAX_VALUE; // Try to find an size match aspect ratio and size for (Camera.Size size : sizes) { double ratio = (double) size.width / size.height; if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue; if (Math.abs(size.height - h) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - h); } } // Cannot find the one match the aspect ratio, ignore the requirement if (optimalSize == null) { minDiff = Double.MAX_VALUE; for (Camera.Size size : sizes) { if (Math.abs(size.height - h) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - h); } } } return optimalSize; }
From source file:Main.java
public static Camera.Size getOptimalPreviewSize(List<Camera.Size> sizes, int w, int h) { final double ASPECT_TOLERANCE = 0.1; double targetRatio = (double) w / h; if (sizes == null) { return null; }/*from w w w.j ava 2s .c o m*/ Camera.Size optimalSize = null; double minDiff = Double.MAX_VALUE; int targetHeight = h; for (Camera.Size size : sizes) { double ratio = (double) size.width / size.height; if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue; if (Math.abs(size.height - targetHeight) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - targetHeight); } } if (optimalSize == null) { minDiff = Double.MAX_VALUE; for (Camera.Size size : sizes) { if (Math.abs(size.height - targetHeight) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - targetHeight); } } } return optimalSize; }
From source file:net.dontdrinkandroot.utils.collections.CollectionUtils.java
public static <T extends Number> AggregationResult aggregate(final Collection<T> collection) { if (collection.isEmpty()) { throw new IllegalArgumentException("Collection must not be empty"); }//from w w w . j a v a2 s . com final AggregationResult result = new AggregationResult(); result.setSize(collection.size()); double sum = 0; double min = Double.MAX_VALUE; double max = Double.MIN_VALUE; /* Determine min, max, sum */ for (final T entry : collection) { if (entry != null) { final double value = entry.doubleValue(); max = Math.max(max, value); min = Math.min(min, value); sum += value; } } result.setMin(min); result.setMax(max); result.setSum(sum); result.setAvg(sum / result.getSize()); result.setMean(CollectionUtils.getMean(collection)); return result; }
From source file:Main.java
/** * Iterate over supported camera preview sizes to see which one best fits the * dimensions of the given view while maintaining the aspect ratio. If none can, * be lenient with the aspect ratio.//from www .j a v a2s .c om * * @param sizes Supported camera preview sizes. * @param w The width of the view. * @param h The height of the view. * @return Best match camera preview size to fit in the view. */ public static Size getOptimalPreviewSize(List<Size> sizes, int w, int h) { // Use a very small tolerance because we want an exact match. final double ASPECT_TOLERANCE = 0.1; double targetRatio = (double) w / h; if (sizes == null) return null; Size optimalSize = null; // Start with max value and refine as we iterate over available preview sizes. This is the // minimum difference between view and camera height. double minDiff = Double.MAX_VALUE; // Target view height int targetHeight = h; // Try to find a preview size that matches aspect ratio and the target view size. // Iterate over all available sizes and pick the largest size that can fit in the view and // still maintain the aspect ratio. for (Size size : sizes) { double ratio = (double) size.width / size.height; if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue; if (Math.abs(size.height - targetHeight) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - targetHeight); } } // Cannot find preview size that matches the aspect ratio, ignore the requirement if (optimalSize == null) { minDiff = Double.MAX_VALUE; for (Size size : sizes) { if (Math.abs(size.height - targetHeight) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - targetHeight); } } } return optimalSize; }
From source file:Main.java
/** * Iterate over supported camera preview sizes to see which one best fits the * dimensions of the given view while maintaining the aspect ratio. If none can, * be lenient with the aspect ratio./*from w ww . j av a 2 s. c o m*/ * * @param sizes Supported camera preview sizes. * @param w The width of the view. * @param h The height of the view. * @return Best match camera preview size to fit in the view. */ public static Camera.Size getOptimalPreviewSize(List<Camera.Size> sizes, int w, int h) { // Use a very small tolerance because we want an exact match. final double ASPECT_TOLERANCE = 0.1; double targetRatio = (double) w / h; if (sizes == null) return null; Camera.Size optimalSize = null; // Start with max value and refine as we iterate over available preview sizes. This is the // minimum difference between view and camera height. double minDiff = Double.MAX_VALUE; // Target view height int targetHeight = h; // Try to find a preview size that matches aspect ratio and the target view size. // Iterate over all available sizes and pick the largest size that can fit in the view and // still maintain the aspect ratio. for (Camera.Size size : sizes) { double ratio = (double) size.width / size.height; if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue; if (Math.abs(size.height - targetHeight) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - targetHeight); } } // Cannot find preview size that matches the aspect ratio, ignore the requirement if (optimalSize == null) { minDiff = Double.MAX_VALUE; for (Camera.Size size : sizes) { if (Math.abs(size.height - targetHeight) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - targetHeight); } } } return optimalSize; }
From source file:Main.java
/** * Iterate over supported camera preview sizes to see which one best fits the * dimensions of the given view while maintaining the aspect ratio. If none can, * be lenient with the aspect ratio.//from w ww . j a v a 2s . c om * * @param sizes Supported camera preview sizes. * @param w The width of the view. * @param h The height of the view. * @return Best match camera preview size to fit in the view. */ public static Camera.Size getOptimalSize(List<Camera.Size> sizes, int w, int h) { // Use a very small tolerance because we want an exact match. final double ASPECT_TOLERANCE = 0.1; double targetRatio = (double) w / h; if (sizes == null) return null; Camera.Size optimalSize = null; // Start with max value and refine as we iterate over available preview sizes. This is the // minimum difference between view and camera height. double minDiff = Double.MAX_VALUE; // Target view height int targetHeight = h; // Try to find a preview size that matches aspect ratio and the target view size. // Iterate over all available sizes and pick the largest size that can fit in the view and // still maintain the aspect ratio. for (Camera.Size size : sizes) { double ratio = (double) size.width / size.height; if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue; if (Math.abs(size.height - targetHeight) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - targetHeight); } } // Cannot find preview size that matches the aspect ratio, ignore the requirement if (optimalSize == null) { minDiff = Double.MAX_VALUE; for (Camera.Size size : sizes) { if (Math.abs(size.height - targetHeight) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - targetHeight); } } } return optimalSize; }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 300, 250, Color.WHITE); HBox hbox = new HBox(); Button button1 = new Button("Add"); Button button2 = new Button("Remove"); HBox.setHgrow(button1, Priority.ALWAYS); HBox.setHgrow(button2, Priority.ALWAYS); button1.setMaxWidth(Double.MAX_VALUE); button2.setMaxWidth(Double.MAX_VALUE); hbox.getChildren().addAll(button1, button2); hbox.setPrefWidth(400);//from w w w. j av a 2 s . c om System.out.println(HBox.getMargin(button1)); root.getChildren().add(hbox); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 300, 250, Color.WHITE); HBox hbox = new HBox(); Button button1 = new Button("Add"); Button button2 = new Button("Remove"); HBox.setHgrow(button1, Priority.ALWAYS); HBox.setHgrow(button2, Priority.ALWAYS); button1.setMaxWidth(Double.MAX_VALUE); button2.setMaxWidth(Double.MAX_VALUE); hbox.getChildren().addAll(button1, button2); hbox.setPrefWidth(400);/*from ww w . j a v a 2s. c o m*/ System.out.println(HBox.getHgrow(button1)); root.getChildren().add(hbox); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 300, 250, Color.WHITE); HBox hbox = new HBox(); Button button1 = new Button("Add"); Button button2 = new Button("Remove"); HBox.setHgrow(button1, Priority.ALWAYS); HBox.setHgrow(button2, Priority.ALWAYS); button1.setMaxWidth(Double.MAX_VALUE); button2.setMaxWidth(Double.MAX_VALUE); hbox.getChildren().addAll(button1, button2); hbox.setPrefWidth(400);/*w ww . ja v a2 s. com*/ System.out.println(hbox.isFillHeight()); root.getChildren().add(hbox); primaryStage.setScene(scene); primaryStage.show(); }