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:gov.va.isaac.gui.ConceptNode.java
/** * descriptionReader is optional//from w w w . ja v a 2 s . c o m */ public ConceptNode(ConceptVersionBI initialConcept, boolean flagAsInvalidWhenBlank, ObservableList<SimpleDisplayConcept> dropDownOptions, Function<ConceptVersionBI, String> descriptionReader) { c_ = initialConcept; //We can't simply use the ObservableList from the CommonlyUsedConcepts, because it infinite loops - there doesn't seem to be a way //to change the items in the drop down without changing the selection. So, we have this hack instead. listChangeListener_ = new ListChangeListener<SimpleDisplayConcept>() { @Override public void onChanged(Change<? extends SimpleDisplayConcept> c) { //TODO I still have an infinite loop here. Find and fix. logger.debug("updating concept dropdown"); disableChangeListener_ = true; SimpleDisplayConcept temp = cb_.getValue(); cb_.setItems(FXCollections.observableArrayList(dropDownOptions_)); cb_.setValue(temp); cb_.getSelectionModel().select(temp); disableChangeListener_ = false; } }; descriptionReader_ = (descriptionReader == null ? (conceptVersion) -> { return conceptVersion == null ? "" : OTFUtility.getDescription(conceptVersion); } : descriptionReader); dropDownOptions_ = dropDownOptions == null ? AppContext.getService(CommonlyUsedConcepts.class).getObservableConcepts() : dropDownOptions; dropDownOptions_.addListener(new WeakListChangeListener<SimpleDisplayConcept>(listChangeListener_)); conceptBinding_ = new ObjectBinding<ConceptVersionBI>() { @Override protected ConceptVersionBI computeValue() { return c_; } }; flagAsInvalidWhenBlank_ = flagAsInvalidWhenBlank; cb_ = new ComboBox<>(); cb_.setConverter(new StringConverter<SimpleDisplayConcept>() { @Override public String toString(SimpleDisplayConcept object) { return object == null ? "" : object.getDescription(); } @Override public SimpleDisplayConcept fromString(String string) { return new SimpleDisplayConcept(string, 0); } }); cb_.setValue(new SimpleDisplayConcept("", 0)); cb_.setEditable(true); cb_.setMaxWidth(Double.MAX_VALUE); cb_.setPrefWidth(ComboBox.USE_COMPUTED_SIZE); cb_.setMinWidth(200.0); cb_.setPromptText("Type, drop or select a concept"); cb_.setItems(FXCollections.observableArrayList(dropDownOptions_)); cb_.setVisibleRowCount(11); cm_ = new ContextMenu(); MenuItem copyText = new MenuItem("Copy Description"); copyText.setGraphic(Images.COPY.createImageView()); copyText.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { CustomClipboard.set(cb_.getEditor().getText()); } }); cm_.getItems().add(copyText); CommonMenusNIdProvider nidProvider = new CommonMenusNIdProvider() { @Override public Set<Integer> getNIds() { Set<Integer> nids = new HashSet<>(); if (c_ != null) { nids.add(c_.getNid()); } return nids; } }; CommonMenuBuilderI menuBuilder = CommonMenus.CommonMenuBuilder.newInstance(); menuBuilder.setInvisibleWhenFalse(isValid); CommonMenus.addCommonMenus(cm_, menuBuilder, nidProvider); cb_.getEditor().setContextMenu(cm_); updateGUI(); new LookAheadConceptPopup(cb_); if (cb_.getValue().getNid() == 0) { if (flagAsInvalidWhenBlank_) { isValid.setInvalid("Concept Required"); } } else { isValid.setValid(); } cb_.valueProperty().addListener(new ChangeListener<SimpleDisplayConcept>() { @Override public void changed(ObservableValue<? extends SimpleDisplayConcept> observable, SimpleDisplayConcept oldValue, SimpleDisplayConcept newValue) { if (newValue == null) { logger.debug("Combo Value Changed - null entry"); } else { logger.debug("Combo Value Changed: {} {}", newValue.getDescription(), newValue.getNid()); } if (disableChangeListener_) { logger.debug("change listener disabled"); return; } if (newValue == null) { //This can happen if someone calls clearSelection() - it passes in a null. cb_.setValue(new SimpleDisplayConcept("", 0)); return; } else { if (newValue.shouldIgnoreChange()) { logger.debug("One time change ignore"); return; } //Whenever the focus leaves the combo box editor, a new combo box is generated. But, the new box will have 0 for an id. detect and ignore if (oldValue != null && oldValue.getDescription().equals(newValue.getDescription()) && newValue.getNid() == 0) { logger.debug("Not a real change, ignore"); newValue.setNid(oldValue.getNid()); return; } lookup(); } } }); AppContext.getService(DragRegistry.class).setupDragAndDrop(cb_, new SingleConceptIdProvider() { @Override public String getConceptId() { return cb_.getValue().getNid() + ""; } }, true); pi_ = new ProgressIndicator(ProgressIndicator.INDETERMINATE_PROGRESS); pi_.visibleProperty().bind(isLookupInProgress_); pi_.setPrefHeight(16.0); pi_.setPrefWidth(16.0); pi_.setMaxWidth(16.0); pi_.setMaxHeight(16.0); lookupFailImage_ = Images.EXCLAMATION.createImageView(); lookupFailImage_.visibleProperty().bind(isValid.not().and(isLookupInProgress_.not())); Tooltip t = new Tooltip(); t.textProperty().bind(isValid.getReasonWhyInvalid()); Tooltip.install(lookupFailImage_, t); StackPane sp = new StackPane(); sp.setMaxWidth(Double.MAX_VALUE); sp.getChildren().add(cb_); sp.getChildren().add(lookupFailImage_); sp.getChildren().add(pi_); StackPane.setAlignment(cb_, Pos.CENTER_LEFT); StackPane.setAlignment(lookupFailImage_, Pos.CENTER_RIGHT); StackPane.setMargin(lookupFailImage_, new Insets(0.0, 30.0, 0.0, 0.0)); StackPane.setAlignment(pi_, Pos.CENTER_RIGHT); StackPane.setMargin(pi_, new Insets(0.0, 30.0, 0.0, 0.0)); hbox_ = new HBox(); hbox_.setSpacing(5.0); hbox_.setAlignment(Pos.CENTER_LEFT); hbox_.getChildren().add(sp); HBox.setHgrow(sp, Priority.SOMETIMES); }
From source file:com.github.cambierr.lorawanpacket.semtech.Stat.java
public JSONObject toJson() { JSONObject output = new JSONObject(); if (time != null) { output.put("time", time); }/*from ww w. j a v a 2 s .c om*/ if (lati != Double.MAX_VALUE) { output.put("lati", lati); } if (longi != Double.MAX_VALUE) { output.put("longi", longi); } if (alti != Integer.MAX_VALUE) { output.put("alti", alti); } if (rxnb != Integer.MAX_VALUE) { output.put("rxnb", rxnb); } if (rxok != Integer.MAX_VALUE) { output.put("rxok", rxok); } if (rxfw != Integer.MAX_VALUE) { output.put("rxfw", rxfw); } if (ackr != Integer.MAX_VALUE) { output.put("ackr", ackr); } if (ackr != Integer.MAX_VALUE) { output.put("ackr", ackr); } if (dwnb != Integer.MAX_VALUE) { output.put("dwnb", dwnb); } if (txnb != Integer.MAX_VALUE) { output.put("txnb", txnb); } return output; }
From source file:net.sf.javaml.tools.DatasetTools.java
/** * Finds the double[][] array where the first index reflects the attributes * and the second index the minimum (index 0) and maximum (index 1) of the * attributes.//from w ww.j a v a 2 s . c o m * * @param data * data set to compute this array for * * @return a two-dimensional array with the minimum and maximum values per * attribute */ private static double[][] getMinMax(Dataset data) { final int noAttributes = data.get(0).noAttributes(); final int noInstances = data.size(); final int MIN_INDEX = 0; final int MAX_INDEX = 1; // second index contains min and max -> therefore size = 2 double[][] ret = new double[noAttributes][2]; // reset min and max indices to Double.MAX_VALUE and Double.MIN_VALUE // resp; for (int a = 0; a < noAttributes; a++) { ret[a][MIN_INDEX] = Double.MAX_VALUE; ret[a][MAX_INDEX] = Double.MIN_VALUE; } // find min and max for each attribute double attrVal; Instance instance = null; for (int i = 0; i < noInstances; i++) { // for each instance instance = data.get(i); for (int a = 0; a < noAttributes; a++) { // for each attribute attrVal = instance.value(a); if (attrVal < ret[a][MIN_INDEX]) ret[a][MIN_INDEX] = attrVal; if (attrVal > ret[a][MAX_INDEX]) ret[a][MAX_INDEX] = attrVal; } } return ret; }
From source file:edu.stanford.slac.archiverappliance.PB.data.StatusSeverityTest.java
private DBR getJCASampleValue(ArchDBRTypes type, int value, int severity, int status) { switch (type) { case DBR_SCALAR_STRING: DBR_TIME_String retvalss = new DBR_TIME_String(new String[] { Integer.toString(value) }); retvalss.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value)); retvalss.setSeverity(severity);/*from ww w .j a v a 2 s . c o m*/ retvalss.setStatus(status); return retvalss; case DBR_SCALAR_SHORT: DBR_TIME_Short retvalsh; if (0 <= value && value < 1000) { // Check for some numbers around the minimum value retvalsh = new DBR_TIME_Short(new short[] { (short) (Short.MIN_VALUE + value) }); } else if (1000 <= value && value < 2000) { // Check for some numbers around the maximum value retvalsh = new DBR_TIME_Short(new short[] { (short) (Short.MAX_VALUE - (value - 1000)) }); } else { // Check for some numbers around 0 retvalsh = new DBR_TIME_Short(new short[] { (short) (value - 2000) }); } retvalsh.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value)); retvalsh.setSeverity(severity); retvalsh.setStatus(status); return retvalsh; case DBR_SCALAR_FLOAT: DBR_TIME_Float retvalfl; if (0 <= value && value < 1000) { // Check for some numbers around the minimum value retvalfl = new DBR_TIME_Float(new float[] { Float.MIN_VALUE + value }); } else if (1000 <= value && value < 2000) { // Check for some numbers around the maximum value retvalfl = new DBR_TIME_Float(new float[] { Float.MAX_VALUE - (value - 1000) }); } else { // Check for some numbers around 0. Divide by a large number to make sure we cater to the number of precision digits retvalfl = new DBR_TIME_Float(new float[] { (value - 2000.0f) / value }); } retvalfl.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value)); retvalfl.setSeverity(severity); retvalfl.setStatus(status); return retvalfl; case DBR_SCALAR_ENUM: DBR_TIME_Enum retvalen; retvalen = new DBR_TIME_Enum(new short[] { (short) (value) }); retvalen.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value)); retvalen.setSeverity(severity); retvalen.setStatus(status); return retvalen; case DBR_SCALAR_BYTE: DBR_TIME_Byte retvalby; retvalby = new DBR_TIME_Byte(new byte[] { ((byte) (value % 255)) }); retvalby.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value)); retvalby.setSeverity(severity); retvalby.setStatus(status); return retvalby; case DBR_SCALAR_INT: DBR_TIME_Int retvalint; if (0 <= value && value < 1000) { // Check for some numbers around the minimum value retvalint = new DBR_TIME_Int(new int[] { Integer.MIN_VALUE + value }); } else if (1000 <= value && value < 2000) { // Check for some numbers around the maximum value retvalint = new DBR_TIME_Int(new int[] { Integer.MAX_VALUE - (value - 1000) }); } else { // Check for some numbers around 0 retvalint = new DBR_TIME_Int(new int[] { (value - 2000) }); } retvalint.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value)); retvalint.setSeverity(severity); retvalint.setStatus(status); return retvalint; case DBR_SCALAR_DOUBLE: DBR_TIME_Double retvaldb; if (0 <= value && value < 1000) { // Check for some numbers around the minimum value retvaldb = new DBR_TIME_Double(new double[] { (Double.MIN_VALUE + value) }); } else if (1000 <= value && value < 2000) { // Check for some numbers around the maximum value retvaldb = new DBR_TIME_Double(new double[] { (Double.MAX_VALUE - (value - 1000)) }); } else { // Check for some numbers around 0. Divide by a large number to make sure we cater to the number of precision digits retvaldb = new DBR_TIME_Double(new double[] { ((value - 2000.0) / (value * 1000000)) }); } retvaldb.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value)); retvaldb.setSeverity(severity); retvaldb.setStatus(status); return retvaldb; case DBR_WAVEFORM_STRING: DBR_TIME_String retvst; // Varying number of copies of a typical value retvst = new DBR_TIME_String( Collections.nCopies(value, Integer.toString(value)).toArray(new String[0])); retvst.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value)); retvst.setSeverity(severity); retvst.setStatus(status); return retvst; case DBR_WAVEFORM_SHORT: DBR_TIME_Short retvsh; retvsh = new DBR_TIME_Short( ArrayUtils.toPrimitive(Collections.nCopies(1, (short) value).toArray(new Short[0]))); retvsh.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value)); retvsh.setSeverity(severity); retvsh.setStatus(status); return retvsh; case DBR_WAVEFORM_FLOAT: DBR_TIME_Float retvf; // Varying number of copies of a typical value retvf = new DBR_TIME_Float(ArrayUtils.toPrimitive( Collections.nCopies(value, (float) Math.cos(value * Math.PI / 3600)).toArray(new Float[0]))); retvf.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value)); retvf.setSeverity(severity); retvf.setStatus(status); return retvf; case DBR_WAVEFORM_ENUM: DBR_TIME_Enum retven; retven = new DBR_TIME_Enum( ArrayUtils.toPrimitive(Collections.nCopies(1024, (short) value).toArray(new Short[0]))); retven.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value)); retven.setSeverity(severity); retven.setStatus(status); return retven; case DBR_WAVEFORM_BYTE: DBR_TIME_Byte retvb; // Large number of elements in the array retvb = new DBR_TIME_Byte(ArrayUtils .toPrimitive(Collections.nCopies(65536 * value, ((byte) (value % 255))).toArray(new Byte[0]))); retvb.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value)); retvb.setSeverity(severity); retvb.setStatus(status); return retvb; case DBR_WAVEFORM_INT: DBR_TIME_Int retvint; // Varying number of copies of a typical value retvint = new DBR_TIME_Int( ArrayUtils.toPrimitive(Collections.nCopies(value, value * value).toArray(new Integer[0]))); retvint.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value)); retvint.setSeverity(severity); retvint.setStatus(status); return retvint; case DBR_WAVEFORM_DOUBLE: DBR_TIME_Double retvd; // Varying number of copies of a typical value retvd = new DBR_TIME_Double(ArrayUtils.toPrimitive( Collections.nCopies(value, Math.sin(value * Math.PI / 3600)).toArray(new Double[0]))); retvd.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(value)); retvd.setSeverity(severity); retvd.setStatus(status); return retvd; case DBR_V4_GENERIC_BYTES: throw new RuntimeException("Currently don't support " + type + " when generating sample data"); default: throw new RuntimeException("We seemed to have missed a DBR type when generating sample data"); } }
From source file:com.net2plan.internal.sim.SimStats.java
private void checkAndCreateDemand(long layerId, long demandId) { if (!accum_avgDemandOfferedTraffic.get(layerId).containsKey(demandId)) { /* Initialize demand information */ accum_avgDemandOfferedTraffic.get(layerId).put(demandId, new MutableDouble()); minDemandOfferedTraffic.get(layerId).put(demandId, new MutableDouble(Double.MAX_VALUE)); maxDemandOfferedTraffic.get(layerId).put(demandId, new MutableDouble()); accum_avgDemandCarriedTraffic.get(layerId).put(demandId, new MutableDouble()); minDemandCarriedTraffic.get(layerId).put(demandId, new MutableDouble(Double.MAX_VALUE)); maxDemandCarriedTraffic.get(layerId).put(demandId, new MutableDouble()); accum_avgDemandBlockedTraffic.get(layerId).put(demandId, new MutableDouble()); minDemandBlockedTraffic.get(layerId).put(demandId, new MutableDouble(Double.MAX_VALUE)); maxDemandBlockedTraffic.get(layerId).put(demandId, new MutableDouble()); accum_avgExcessCarriedTraffic.get(layerId).put(demandId, new MutableDouble()); minDemandExcessCarriedTraffic.get(layerId).put(demandId, new MutableDouble(Double.MAX_VALUE)); maxDemandExcessCarriedTraffic.get(layerId).put(demandId, new MutableDouble()); accum_demandAvailabilityClassic.get(layerId).put(demandId, new MutableDouble()); accum_demandAvailabilityWeighted.get(layerId).put(demandId, new MutableDouble()); excessDemandCarriedTrafficTime.get(layerId).put(demandId, new MutableDouble()); demandTotalTime.get(layerId).put(demandId, new MutableDouble()); }/*from w ww . j a va2s . c o m*/ }
From source file:classif.Prototyper.java
public double evalErrorRate(ClassedSequence[] testSequences) { int nbCorrectlyClassified = 0; for (int s = 0; s < testSequences.length; s++) { Sequence seq = testSequences[s].sequence; double minD = Double.MAX_VALUE; String classValue = null; for (ClassedSequence proto : prototypes) { double tmpD = seq.distance(proto.sequence); if (tmpD < minD) { minD = tmpD;/*from ww w . j a v a 2 s. c o m*/ classValue = proto.classValue; } } if (classValue.equals(testSequences[s].classValue)) { nbCorrectlyClassified++; } } return 1.0 - 1.0 * nbCorrectlyClassified / (testSequences.length); }
From source file:gov.va.isaac.gui.listview.operations.RefsetValueUtils.java
protected void setup(GridPane gp, int startRow) { gp.add(refsetTypeLabel_, 0, startRow); gp.add(refsetType_, 1, startRow);/*from w w w . j a va 2 s. com*/ refsetType_.setMaxWidth(Double.MAX_VALUE); gp.add(valueLabel_, 0, startRow + 1); gp.add(swappable, 1, startRow + 1); swappable.setMaxWidth(Double.MAX_VALUE); }
From source file:de.biomedical_imaging.ij.nanotrackj.WalkerMethodEstimator.java
/** * // ww w . j a v a 2 s.c o m * @return Histogram [i][j]: i = bin, j = density */ public double[][] estimate() { double[] dens = new double[binNumber]; java.util.Arrays.fill(dens, 1.0 / binNumber); Sum sum = new Sum(); //IJ.log(""+dens[2]); lastChiSquared = getChiSquared(dens); double changeChiSquared = Double.MAX_VALUE; IJ.showStatus("Size Distribution Estimation by Walker's Method"); while (changeChiSquared > 0.01) { IJ.showProgress((int) ((1 - changeChiSquared) * 100), 99); for (int m = 0; m < dens.length; m++) { double sumpm = sum.evaluate(dens); double help2 = 0; for (int k = 0; k < data.length; k++) { double help1 = 0; double prob = probMSD(data[k][0], data[k][1], (m + 1) * deltaR); for (int l = 0; l < dens.length; l++) { double prob2 = probMSD(data[k][0], data[k][1], (l + 1) * deltaR); help1 += prob2 * dens[l] / sumpm; } help2 = help2 + prob / help1; } dens[m] = dens[m] * 1.0 / data.length * help2; } double newChiSquared = getChiSquared(dens); changeChiSquared = Math.abs(newChiSquared - lastChiSquared) / lastChiSquared; lastChiSquared = newChiSquared; } IJ.showProgress(99, 99); //Normalize double sumdens = sum.evaluate(dens); double[][] densxy = new double[dens.length][2]; for (int i = 0; i < dens.length; i++) { densxy[i][0] = binSizeInnm * (i + 1) * 2.0; //To Diamter in [nm] dens[i] = dens[i] / sumdens; //Normalize densxy[i][1] = dens[i]; } return densxy; }
From source file:net.bither.util.ChartsUtil.java
private static double getMinValue(List<IStickEntity> ohlc) { double minValue = Double.MAX_VALUE; for (IStickEntity biEntity : ohlc) { OHLCEntity ohlcEntity = (OHLCEntity) biEntity; if (ohlcEntity.getClose() < minValue) { minValue = ohlcEntity.getClose(); }/*ww w. jav a 2s . c o m*/ } return minValue; }
From source file:cn.edu.suda.core.stats.StatsUtils.java
public static int indexOfMin(double[] data) { double min = Double.MAX_VALUE; int index = 0; for (int i = 0; i < data.length; i++) { if (data[i] < min) { min = data[i];// w ww . ja v a 2 s.co m index = i; } } return index; }