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:be.makercafe.apps.makerbench.editors.TextEditor.java
public TextEditor(String tabText, Path path) { super(tabText); this.caCodeArea = new CodeArea(""); this.caCodeArea.setEditable(true); this.caCodeArea.setParagraphGraphicFactory(LineNumberFactory.get(caCodeArea)); this.caCodeArea.setPrefSize(Double.MAX_VALUE, Double.MAX_VALUE); addContextMenu(this.caCodeArea); try {/*www. ja v a 2 s . c o m*/ this.caCodeArea.replaceText(FileUtils.readFileToString(path.toFile())); } catch (IOException ex) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Error reading file.", ex); } BorderPane rootPane = new BorderPane(); toolBar = createToolBar(); rootPane.setTop(toolBar); rootPane.setCenter(caCodeArea); this.getTab().setContent(rootPane); }
From source file:com.liferay.alloy.util.DefaultValueUtil.java
public static String getDefaultValue(String className, String value) { String defaultValue = StringPool.BLANK; if (className.equals(ArrayList.class.getName()) || className.equals(HashMap.class.getName()) || className.equals(Object.class.getName()) || className.equals(String.class.getName())) { if (!isValidStringValue(value)) { return defaultValue; }/*from w w w . ja v a 2s . co m*/ if (_EMPTY_STRINGS.contains(value)) { value = StringPool.BLANK; } else if (className.equals(ArrayList.class.getName()) && !StringUtil.startsWith(value.trim(), StringPool.OPEN_BRACKET)) { value = "[]"; } else if (className.equals(HashMap.class.getName()) && !StringUtil.startsWith(value.trim(), StringPool.OPEN_CURLY_BRACE)) { value = "{}"; } defaultValue = StringUtil.unquote(value); } else if (className.equals(boolean.class.getName()) || className.equals(Boolean.class.getName())) { defaultValue = String.valueOf(GetterUtil.getBoolean(value)); } else if (className.equals(int.class.getName()) || className.equals(Integer.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Integer.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getInteger(value)); } else if (className.equals(double.class.getName()) || className.equals(Double.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Double.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getDouble(value)); } else if (className.equals(float.class.getName()) || className.equals(Float.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Float.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getFloat(value)); } else if (className.equals(long.class.getName()) || className.equals(Long.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Long.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getLong(value)); } else if (className.equals(short.class.getName()) || className.equals(Short.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Short.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getShort(value)); } else if (className.equals(Number.class.getName())) { if (_INFINITY.contains(value)) { value = String.valueOf(Integer.MAX_VALUE); } defaultValue = String.valueOf(GetterUtil.getNumber(value)); } return defaultValue; }
From source file:edu.ucsf.valelab.saim.calculations.SaimFunctionWithBounds.java
/** * Calculates the Saim function using established wavelength, angle, * refractive index of the sample, and thickness of the oxide layer * @param h - height above the oxide layer in nm * @return - Field Strength (arbitrary units) *//*from w w w . j av a2 s . c o m*/ @Override public double value(double h) { if (h < 0) { return Double.MAX_VALUE; } return super.value(h); }
From source file:com.almende.eve.algorithms.DAA.java
/** * Sets this nodes new value./*from w w w. j a v a2 s .c o m*/ * * @param value * the new new value */ public void setNewValue(final double value) { localValue = new DAAValueBean(width, evictionFactor); localValue.generate(value).setTTL(DateTime.now().plus(100).getMillis()); if (currentEstimate == null) { currentEstimate = new DAAValueBean(width, evictionFactor); Arrays.fill(currentEstimate.valueArray, Double.MAX_VALUE); } currentEstimate.minimum(localValue); }
From source file:com.github.cambierr.lorawanpacket.semtech.Stat.java
private Stat() { time = null;//from w ww. j av a2s .c o m lati = Double.MAX_VALUE; longi = Double.MAX_VALUE; alti = Integer.MAX_VALUE; rxnb = Integer.MAX_VALUE; rxok = Integer.MAX_VALUE; rxfw = Integer.MAX_VALUE; ackr = Integer.MAX_VALUE; dwnb = Integer.MAX_VALUE; txnb = Integer.MAX_VALUE; }
From source file:br.unicamp.ic.recod.gpsi.measures.gpsiClusterSilhouetteScore.java
@Override public double score(double[][][] samples) { ManhattanDistance distance = new ManhattanDistance(); double score = 0.0; int m = 0, i, j, k; for (i = 0; i < samples.length; i++) m += samples[i].length;//from w ww. j a v a 2s . c om byte[] clusterAssignment = new byte[m]; double[][] values = new double[m][]; double[][] distances = new double[m - 1][]; for (i = 0; i < m - 1; i++) distances[i] = new double[m - i - 1]; int mIndex = 0; for (byte label = 0; label < samples.length; label++) for (i = 0; i < samples[label].length; i++) { values[mIndex] = samples[label][i]; clusterAssignment[mIndex] = label; for (j = 0; j < mIndex; j++) distances[mIndex - j - 1][j] = distance.compute(values[mIndex], values[mIndex - j - 1]); mIndex++; } double dissimilarity[] = new double[samples.length]; double a, b; for (i = 0; i < m; i++) { Arrays.fill(dissimilarity, 0.0); for (j = 0; j < m; j++) if (i != j) { k = Math.min(i, j); dissimilarity[clusterAssignment[j]] += distances[k][Math.max(i, j) - 1 - k]; } a = dissimilarity[clusterAssignment[i]] / (samples[clusterAssignment[i]].length - 1); b = Double.MAX_VALUE; for (j = 0; j < dissimilarity.length; j++) if (clusterAssignment[i] != j) b = Math.min(b, dissimilarity[j] / samples[j].length); score += Math.max(a, b) == 0.0 ? -1.0 : (b - a) / Math.max(a, b); } return score / m; }
From source file:analysis.SilhouetteIndex.java
public double calculateIndex(SimpleKMeans sk, Instances inst, int c) throws Exception { //Map<Integer, Instances> clustermap = sk.clusterInstance; sk.setNumClusters(c);// ww w .j a v a 2 s .c om sk.buildClusterer(inst); EuclideanDistance ed = new EuclideanDistance(); double avgSilhouetteOverAllPoints = 0.d; if (sk.getNumClusters() == 1) { //Index is not defined for k=1. needs at least 2 clusters return Double.NaN; } for (int i = 0; i < inst.numInstances(); i++) { //for the current element get its cluster int currentcluster = sk.clusterInstance(inst.instance(i)); //System.out.println(inst.instance(i).value(2)); double[] current_attr = new double[inst.numAttributes()]; double[] other_attr = new double[inst.numAttributes()]; //get attributes of the current instance for (int attr = 0; attr < inst.numAttributes(); attr++) { current_attr[attr] = inst.instance(i).value(attr); } // int counter double[] distances = new double[sk.getNumClusters()]; int[] counters = new int[sk.getNumClusters()]; //System.out.println("distances: "+distances.length); double avgInClusterDist = 0, dist = 0; int countsamecluster = 0; distances[currentcluster] = Double.MAX_VALUE; for (int j = 0; j < inst.numInstances(); j++) { for (int attr = 0; attr < inst.numAttributes(); attr++) { other_attr[attr] = inst.instance(j).value(attr); } //get cluster number of j th element int clusternumber = sk.clusterInstance(inst.instance(j)); //check if j and i in the same cluster if (clusternumber == currentcluster) { if (inst.instance(i) != inst.instance(j)) { //calculate average dist to other elements in the cluster //inst. dist = ed.compute(current_attr, other_attr); avgInClusterDist = avgInClusterDist + dist; countsamecluster++; } } else { dist = ed.compute(current_attr, other_attr); distances[clusternumber] = distances[clusternumber] + dist; counters[clusternumber]++; } } //calculate value ai if (countsamecluster > 0) { avgInClusterDist = avgInClusterDist / countsamecluster; //this is value ai } //find average distances to other clusters for (int k = 0; k < distances.length; k++) { if (k != currentcluster) { distances[k] = distances[k] / counters[k]; } } //Find the min value of average distance to other clusters double min = distances[0]; for (int k = 1; k < distances.length; k++) { if (min > distances[k]) { min = distances[k]; } } //si for current element: double si; // if we only have one element in our cluster it makes sense to set // si = 0 if (countsamecluster == 1) { si = 0.0d; } else { si = (min - avgInClusterDist) / Math.max(min, avgInClusterDist); } avgSilhouetteOverAllPoints = avgSilhouetteOverAllPoints + si; } //System.out.println(inst.numInstances()); return avgSilhouetteOverAllPoints / inst.numInstances(); }
From source file:Main.java
@Override public void start(Stage stage) throws Exception { genderFld.getItems().addAll("Male", "Fenale", "Unknwon"); dataFld.setPrefColumnCount(30);/*from ww w . j ava 2 s . c om*/ dataFld.setPrefRowCount(5); GridPane grid = new GridPane(); grid.setHgap(5); grid.setVgap(5); // Place the controls in the grid grid.add(fNameLbl, 0, 0); // column=0, row=0 grid.add(lNameLbl, 0, 1); // column=0, row=1 grid.add(bDateLbl, 0, 2); // column=0, row=2 grid.add(genderLbl, 0, 3); // column=0, row=3 grid.add(fNameFld, 1, 0); // column=1, row=0 grid.add(lNameFld, 1, 1); // column=1, row=1 grid.add(bDateFld, 1, 2); // column=1, row=2 grid.add(genderFld, 1, 3); // column=1, row=3 grid.add(dataFld, 1, 4, 3, 2); // column=1, row=4, colspan=3, rowspan=3 VBox buttonBox = new VBox(saveBtn, closeBtn); saveBtn.setMaxWidth(Double.MAX_VALUE); closeBtn.setMaxWidth(Double.MAX_VALUE); grid.add(buttonBox, 2, 0, 1, 2); // column=2, row=0, colspan=1, rowspan=2 saveBtn.setOnAction(e -> showData()); closeBtn.setOnAction(e -> stage.hide()); Scene scene = new Scene(grid); stage.setScene(scene); stage.setTitle("Person Details"); stage.sizeToScene(); stage.show(); }
From source file:gate.termraider.output.CloudGenerator.java
private void findRange() { min = Double.MAX_VALUE; max = Double.MIN_VALUE;/* w w w. ja v a 2s .c o m*/ for (Map.Entry<Term, ? extends Number> entry : termNumbers.entrySet()) { if ((languages == null || languages.contains(entry.getKey().getLanguageCode()) && (types == null || types.contains(entry.getKey().getType())))) { max = Math.max(max, entry.getValue().doubleValue()); min = Math.min(min, entry.getValue().doubleValue()); } } }
From source file:Main.java
/** * Fills the array with random doubles. Values will be between min (inclusive) and * max (inclusive).//from w ww . j a v a 2s .c om */ public static void genRandomDoubles(long seed, double min, double max, double array[], boolean includeExtremes) { Random r = new Random(seed); int minExponent = Math.min(Math.getExponent(min), 0); int maxExponent = Math.max(Math.getExponent(max), 0); if (minExponent < -6 || maxExponent > 6) { // Use an exponential distribution int exponentDiff = maxExponent - minExponent; for (int i = 0; i < array.length; i++) { double mantissa = r.nextDouble(); int exponent = minExponent + r.nextInt(maxExponent - minExponent); int sign = (min >= 0) ? 1 : 1 - r.nextInt(2) * 2; // -1 or 1 double rand = sign * mantissa * Math.pow(2.0, exponent); if (rand < min || rand > max) { continue; } array[i] = rand; } } else { // Use a linear distribution for (int i = 0; i < array.length; i++) { double rand = r.nextDouble(); array[i] = min + rand * (max - min); } } // Seed a few special numbers we want to be sure to test. for (int i = 0; i < sInterestingDoubles.length; i++) { double d = sInterestingDoubles[i]; if (min <= d && d <= max) { array[r.nextInt(array.length)] = d; } } array[r.nextInt(array.length)] = min; array[r.nextInt(array.length)] = max; if (includeExtremes) { array[r.nextInt(array.length)] = Double.NaN; array[r.nextInt(array.length)] = Double.POSITIVE_INFINITY; array[r.nextInt(array.length)] = Double.NEGATIVE_INFINITY; array[r.nextInt(array.length)] = Double.MIN_VALUE; array[r.nextInt(array.length)] = Double.MIN_NORMAL; array[r.nextInt(array.length)] = Double.MAX_VALUE; array[r.nextInt(array.length)] = -Double.MIN_VALUE; array[r.nextInt(array.length)] = -Double.MIN_NORMAL; array[r.nextInt(array.length)] = -Double.MAX_VALUE; } }