Example usage for java.lang Double MAX_VALUE

List of usage examples for java.lang Double MAX_VALUE

Introduction

In this page you can find the example usage for java.lang Double MAX_VALUE.

Prototype

double MAX_VALUE

To view the source code for java.lang Double MAX_VALUE.

Click Source Link

Document

A constant holding the largest positive finite value of type double , (2-2-52)·21023.

Usage

From source file:org.fhcrc.cpl.toolbox.gui.chart.PanelWithScatterPlot.java

public void addDataRedBlueHeatmap(double[] xValues, double[] yValues, double[] zValues, int numShades) {
    int numPoints = xValues.length;
    double minZ = Double.MAX_VALUE;
    double maxZ = Double.MIN_VALUE;
    for (double zValue : zValues) {
        if (zValue < minZ)
            minZ = zValue;/* w w  w .j  av  a  2  s . c  o m*/
        if (zValue > maxZ)
            maxZ = zValue;
    }

    double zRange = maxZ - minZ;

    for (int j = 0; j < numShades; j++) {
        double minZValThisGroup = minZ + j * zRange / numShades;
        double maxZValThisGroup = minZ + (j + 1) * zRange / numShades;
        int red = (255 / numShades) * j;
        int blue = 255 - (255 / numShades) * j;
        Color color = new Color(blue, 10, red);

        java.util.List<Float> thisGroupX = new ArrayList<Float>();
        java.util.List<Float> thisGroupY = new ArrayList<Float>();

        for (int k = 0; k < numPoints; k++) {
            if (zValues[k] <= maxZValThisGroup && zValues[k] >= minZValThisGroup) {
                thisGroupX.add((float) xValues[k]);
                thisGroupY.add((float) yValues[k]);
                //if (Double.isNaN(xValues[k]) || Double.isInfinite(xValues[k]) ||
                //        Double.isNaN(yValues[k]) || Double.isInfinite(yValues[k]))System.err.println(xValues[k] + " , " + yValues[k]);
            }
        }
        addData(thisGroupX, thisGroupY, "" + minZValThisGroup);
        //            setSeriesColor(j, color);
        //                setPointSize(3);
    }

}

From source file:de.perdian.apps.tagtiger.fx.handlers.batchupdate.UpdateFileNamesFromTagsActionEventHandler.java

private Parent createLegendPane() {

    GridPane legendPane = new GridPane();
    legendPane.setPadding(new Insets(5, 5, 5, 5));
    int columnCount = 3;
    int currentRow = 0;
    int currentColumn = 0;
    for (UpdateFileNamesPlaceholder placeholder : UpdateFileNamesPlaceholder.values()) {

        StringBuilder placeholderText = new StringBuilder();
        placeholderText.append("${").append(placeholder.getPlaceholder()).append("}: ");
        placeholderText.append(placeholder.resolveLocalization(this.getLocalization()));

        Label placeholderLabel = new Label(placeholderText.toString());
        placeholderLabel.setMaxWidth(Double.MAX_VALUE);
        placeholderLabel.setPadding(new Insets(3, 3, 3, 3));
        placeholderLabel.setAlignment(Pos.TOP_LEFT);
        legendPane.add(placeholderLabel, currentColumn, currentRow);
        GridPane.setFillWidth(placeholderLabel, Boolean.TRUE);
        GridPane.setHgrow(placeholderLabel, Priority.ALWAYS);

        currentColumn++;/*from   www .ja va 2s .  c  om*/
        if (currentColumn >= columnCount) {
            currentRow++;
            currentColumn = 0;
        }

    }

    TitledPane legendTitlePane = new TitledPane(this.getLocalization().legend(), legendPane);
    legendTitlePane.setCollapsible(false);
    return legendTitlePane;

}

From source file:edu.rice.cs.bioinfo.programs.phylonet.algos.network.NetworkLikelihoodFromGTTBL.java

private void initializeNetwork(Network<Object> speciesNetwork, Map<NetNode, Double> node2constraints,
        Map<NetNode<Object>, Double> node2height) {
    Map<NetNode, Integer> node2depth = new Hashtable<NetNode, Integer>();
    Map<NetNode, Integer> node2ID = new Hashtable<NetNode, Integer>();
    int id = 0;//from  w w w.  ja  va2  s .  co  m

    for (NetNode<Object> node : Networks.postTraversal(speciesNetwork)) {
        node2ID.put(node, id++);
        if (node.isLeaf()) {
            node2height.put(node, 0.0);
            node2depth.put(node, 0);
            continue;
        }
        double upperBound = -1;
        if (node2constraints.get(node) != Double.POSITIVE_INFINITY) {
            upperBound = node2constraints.get(node);
        }
        node2height.put(node, upperBound);
        int maxDepth = 0;
        for (NetNode child : node.getChildren()) {
            maxDepth = Math.max(maxDepth, node2depth.get(child));
        }
        node2depth.put(node, maxDepth + 1);
    }
    boolean updated;
    do {
        updated = false;
        for (NetNode<Object> node : speciesNetwork.bfs()) {
            double minParentHeight = Double.MAX_VALUE;
            for (NetNode<Object> parent : node.getParents()) {
                double parentHeight = node2height.get(parent);
                if (parentHeight > 0) {
                    minParentHeight = Math.min(minParentHeight, parentHeight);
                }
            }
            if (node2height.get(node) > minParentHeight) {
                node2height.put(node, minParentHeight);
                updated = true;
            }
        }

    } while (updated);

    boolean[][] M = computeM(speciesNetwork, node2ID);

    for (NetNode<Object> node : Networks.postTraversal(speciesNetwork)) {
        int nodeID = node2ID.get(node);
        double minParent = Double.MAX_VALUE;
        int maxParentDepth = 0;
        double maxChild = 0;
        for (NetNode<Object> relateNode : edu.rice.cs.bioinfo.programs.phylonet.structs.network.util.Networks
                .postTraversal(speciesNetwork)) {
            int relateNodeID = node2ID.get(relateNode);
            if (M[relateNodeID][nodeID]) {
                double parentHeight = node2height.get(relateNode);
                if (parentHeight >= 0) {
                    if (minParent > parentHeight) {
                        minParent = parentHeight;
                        maxParentDepth = node2depth.get(relateNode);
                    } else if (minParent == parentHeight) {
                        maxParentDepth = Math.max(maxParentDepth, node2depth.get(relateNode));
                    }
                }
            } else if (M[nodeID][relateNodeID]) {
                double childHeight = node2height.get(relateNode);
                if (childHeight >= 0) {
                    maxChild = Math.max(maxChild, childHeight);
                } else {
                    throw new RuntimeException();
                }
            }
        }
        double currentHeight = node2height.get(node);
        if (currentHeight >= minParent || (currentHeight == -1 && minParent != Double.MAX_VALUE)) {
            int depthDiff = maxParentDepth - node2depth.get(node) + 1;
            currentHeight = maxChild + (minParent - maxChild) / depthDiff;
            //currentHeight = Math.round((maxChild + (minParent - maxChild)/depthDiff)*1000000)/1000000.0;
            node2height.put(node, currentHeight);
        } else if (currentHeight == -1 && minParent == Double.MAX_VALUE) {
            currentHeight = maxChild + 1;
            node2height.put(node, currentHeight);
        }
    }

    double overallMin = 0;

    for (NetNode<Object> node : edu.rice.cs.bioinfo.programs.phylonet.structs.network.util.Networks
            .postTraversal(speciesNetwork)) {
        if (node.isLeaf())
            continue;
        double updatedHeight = node2height.get(node) - overallMin;
        double maxChild = 0;
        for (NetNode child : node.getChildren()) {
            maxChild = Math.max(maxChild, node2height.get(child));
        }
        if (updatedHeight == maxChild) {
            updatedHeight = maxChild + overallMin;
        }
        node2height.put(node, updatedHeight);
        for (NetNode child : node.getChildren()) {
            child.setParentDistance(node, updatedHeight - node2height.get(child));
            if (child.isNetworkNode()) {
                child.setParentProbability(node, 0.5);
            }
        }
    }

    //System.out.println(speciesNetwork);

    for (NetNode<Object> node : speciesNetwork.bfs()) {
        double height = node2height.get(node);
        if (height < 0) {
            throw new RuntimeException();
        }
        for (NetNode child : node.getChildren()) {
            if (height < node2height.get(child)) {
                throw new RuntimeException();
            }
        }
    }

}

From source file:edu.stanford.cfuller.imageanalysistools.filter.ConvexHullByLabelFilter.java

/**
 * Applies the convex hull filter to the supplied mask.
 * @param im    The Image to process-- a mask whose regions will be replaced by their filled convex hulls.
 *//*w  w  w.j a  va 2s. co m*/
@Override
public void apply(WritableImage im) {

    RelabelFilter RLF = new RelabelFilter();

    RLF.apply(im);

    Histogram h = new Histogram(im);

    java.util.Hashtable<Integer, java.util.Vector<Integer>> xLists = new java.util.Hashtable<Integer, java.util.Vector<Integer>>();
    java.util.Hashtable<Integer, java.util.Vector<Integer>> yLists = new java.util.Hashtable<Integer, java.util.Vector<Integer>>();

    java.util.Vector<Integer> minValues = new java.util.Vector<Integer>(h.getMaxValue() + 1);
    java.util.Vector<Integer> minIndices = new java.util.Vector<Integer>(h.getMaxValue() + 1);

    for (int i = 0; i < h.getMaxValue() + 1; i++) {
        minValues.add(im.getDimensionSizes().get(ImageCoordinate.X));
        minIndices.add(0);
    }

    for (ImageCoordinate i : im) {

        int value = (int) im.getValue(i);

        if (value == 0)
            continue;

        if (!xLists.containsKey(value)) {
            xLists.put(value, new java.util.Vector<Integer>());
            yLists.put(value, new java.util.Vector<Integer>());
        }

        xLists.get(value).add(i.get(ImageCoordinate.X));
        yLists.get(value).add(i.get(ImageCoordinate.Y));

        if (i.get(ImageCoordinate.X) < minValues.get(value)) {
            minValues.set(value, i.get(ImageCoordinate.X));
            minIndices.set(value, xLists.get(value).size() - 1);
        }

    }

    java.util.Vector<Integer> hullPointsX = new java.util.Vector<Integer>();
    java.util.Vector<Integer> hullPointsY = new java.util.Vector<Integer>();

    ImageCoordinate ic = ImageCoordinate.createCoordXYZCT(0, 0, 0, 0, 0);

    for (int k = 1; k < h.getMaxValue() + 1; k++) {
        hullPointsX.clear();
        hullPointsY.clear();

        java.util.Vector<Integer> xList = xLists.get(k);
        java.util.Vector<Integer> yList = yLists.get(k);

        int minIndex = (int) minIndices.get(k);

        //start at the leftmost point

        int currentIndex = minIndex;
        int currentX = xList.get(currentIndex);
        int currentY = yList.get(currentIndex);

        hullPointsX.add(currentX);
        hullPointsY.add(currentY);

        org.apache.commons.math3.linear.RealVector angles = new org.apache.commons.math3.linear.ArrayRealVector(
                xList.size());

        Vector3D currentVector = new Vector3D(0, -1, 0);

        java.util.HashSet<Integer> visited = new java.util.HashSet<Integer>();

        do {

            visited.add(currentIndex);

            int maxIndex = 0;
            double maxAngle = -2 * Math.PI;
            double dist = Double.MAX_VALUE;
            for (int i = 0; i < xList.size(); i++) {
                if (i == currentIndex)
                    continue;
                Vector3D next = new Vector3D(xList.get(i) - xList.get(currentIndex),
                        yList.get(i) - yList.get(currentIndex), 0);

                double angle = Vector3D.angle(currentVector, next);
                angles.setEntry(i, angle);
                if (angle > maxAngle) {
                    maxAngle = angle;
                    maxIndex = i;
                    dist = next.getNorm();
                } else if (angle == maxAngle) {
                    double tempDist = next.getNorm();
                    if (tempDist < dist) {
                        dist = tempDist;
                        maxAngle = angle;
                        maxIndex = i;
                    }
                }
            }

            currentX = xList.get(maxIndex);
            currentY = yList.get(maxIndex);

            currentVector = new Vector3D(xList.get(currentIndex) - currentX, yList.get(currentIndex) - currentY,
                    0);

            hullPointsX.add(currentX);
            hullPointsY.add(currentY);

            currentIndex = maxIndex;

        } while (!visited.contains(currentIndex));

        //hull vertices have now been determined .. need to fill in the lines
        //between them so I can apply a fill filter

        //approach: x1, y1 to x0, y0:
        //start at min x, min y, go to max x, max y
        // if x_i, y_i = x0, y0  + slope to within 0.5 * sqrt(2), then add to hull

        double eps = Math.sqrt(2);

        for (int i = 0; i < hullPointsX.size() - 1; i++) {

            int x0 = hullPointsX.get(i);
            int y0 = hullPointsY.get(i);

            int x1 = hullPointsX.get(i + 1);
            int y1 = hullPointsY.get(i + 1);

            int xmin = (x0 < x1) ? x0 : x1;
            int ymin = (y0 < y1) ? y0 : y1;
            int xmax = (x0 > x1) ? x0 : x1;
            int ymax = (y0 > y1) ? y0 : y1;

            x1 -= x0;
            y1 -= y0;

            double denom = (x1 * x1 + y1 * y1);

            for (int x = xmin; x <= xmax; x++) {
                for (int y = ymin; y <= ymax; y++) {

                    int rel_x = x - x0;
                    int rel_y = y - y0;

                    double projLength = (x1 * rel_x + y1 * rel_y) / denom;

                    double projPoint_x = x1 * projLength;
                    double projPoint_y = y1 * projLength;

                    if (Math.hypot(rel_x - projPoint_x, rel_y - projPoint_y) < eps) {
                        ic.set(ImageCoordinate.X, x);
                        ic.set(ImageCoordinate.Y, y);
                        im.setValue(ic, k);
                    }

                }
            }

        }

    }

    ic.recycle();

    FillFilter ff = new FillFilter();

    ff.apply(im);

}

From source file:be.makercafe.apps.makerbench.editors.JFXScadEditor.java

public JFXScadEditor(String tabText, Path path) {
    super(tabText);

    this.viewGroup = new Group();
    this.editorContainer = new BorderPane();
    this.viewContainer = new Pane();

    this.caCodeArea = new CodeArea("");
    this.caCodeArea.setEditable(true);
    this.caCodeArea.setParagraphGraphicFactory(LineNumberFactory.get(caCodeArea));
    this.caCodeArea.setPrefSize(Double.MAX_VALUE, Double.MAX_VALUE);

    this.caCodeArea.getStylesheets().add(this.getClass().getResource("java-keywords.css").toExternalForm());
    this.caCodeArea.richChanges().subscribe(change -> {
        caCodeArea.setStyleSpans(0, computeHighlighting(caCodeArea.getText()));
    });//from w w  w . j  a  v a2s  .  com

    addContextMenu(this.caCodeArea);
    EventStream<Change<String>> textEvents = EventStreams.changesOf(caCodeArea.textProperty());

    textEvents.reduceSuccessions((a, b) -> b, Duration.ofMillis(3000)).subscribe(code -> {
        if (autoCompile) {
            compile(code.getNewValue());
        }
    });

    if (path == null) {
        this.caCodeArea.replaceText("CSG cube = new Cube(2).toCSG()\n"
                + "CSG sphere = new Sphere(1.25).toCSG()\n" + "\n" + "cube.difference(sphere)");
    } else {
        try {
            this.caCodeArea.replaceText(FileUtils.readFileToString(path.toFile()));
        } catch (IOException ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Error reading file.", ex);
        }

    }

    //editorContainer.setCenter(this.codeArea);

    subScene = new SubScene(viewGroup, 100, 100, true, SceneAntialiasing.BALANCED);

    subScene.widthProperty().bind(viewContainer.widthProperty());
    subScene.heightProperty().bind(viewContainer.heightProperty());

    PerspectiveCamera subSceneCamera = new PerspectiveCamera(false);
    subScene.setCamera(subSceneCamera);

    viewContainer.getChildren().add(subScene);

    SplitPane editorPane = new SplitPane(caCodeArea, viewContainer);
    editorPane.setOrientation(Orientation.HORIZONTAL);
    BorderPane rootPane = new BorderPane();

    BorderPane pane = (BorderPane) this.getTab().getContent();
    toolBar = createToolBar();
    rootPane.setTop(toolBar);
    rootPane.setCenter(editorPane);
    this.getTab().setContent(rootPane);

    subScene.setOnScroll(new EventHandler<ScrollEvent>() {
        @Override
        public void handle(ScrollEvent event) {
            System.out
                    .println(String.format("deltaX: %.3f deltaY: %.3f", event.getDeltaX(), event.getDeltaY()));

            double z = subSceneCamera.getTranslateZ();
            double newZ = z + event.getDeltaY();
            subSceneCamera.setTranslateZ(newZ);

        }
    });

}

From source file:com.musicg.api.DetectionApi.java

protected void normalizeSpectrogramData(double[][] spectrogramData) {

    // normalization of absoultSpectrogram
    // set max and min amplitudes
    double maxAmp = Double.MIN_VALUE;
    double minAmp = Double.MAX_VALUE;
    for (int i = 0; i < spectrogramData.length; i++) {
        for (int j = 0; j < spectrogramData[i].length; j++) {
            if (spectrogramData[i][j] > maxAmp) {
                maxAmp = spectrogramData[i][j];
            } else if (spectrogramData[i][j] < minAmp) {
                minAmp = spectrogramData[i][j];
            }/*from   w  w w. j  a va2  s.co  m*/
        }
    }
    // end set max and min amplitudes

    // normalization
    // avoiding divided by zero
    double minValidAmp = 0.00000000001F;
    if (minAmp == 0) {
        minAmp = minValidAmp;
    }

    double diff = Math.log10(maxAmp / minAmp); // perceptual difference
    for (int i = 0; i < spectrogramData.length; i++) {
        for (int j = 0; j < spectrogramData[i].length; j++) {
            if (spectrogramData[i][j] < minValidAmp) {
                spectrogramData[i][j] = 0;
            } else {
                spectrogramData[i][j] = (Math.log10(spectrogramData[i][j] / minAmp)) / diff;
            }
        }
    }
    // end normalization
}

From source file:com.stratio.ingestion.sink.cassandra.EventParserTest.java

@Test
public void shouldParsePrimitiveTypes() throws Exception {
    Object integer = EventParser.parseValue("1", DataType.Name.INT);
    assertThat(integer).isInstanceOf(Integer.class).isEqualTo(1);
    integer = EventParser.parseValue(Integer.toString(Integer.MAX_VALUE), DataType.Name.INT);
    assertThat(integer).isInstanceOf(Integer.class).isEqualTo(Integer.MAX_VALUE);
    integer = EventParser.parseValue(Integer.toString(Integer.MIN_VALUE), DataType.Name.INT);
    assertThat(integer).isInstanceOf(Integer.class).isEqualTo(Integer.MIN_VALUE);
    integer = EventParser.parseValue(" 1 2 ", DataType.Name.INT);
    assertThat(integer).isInstanceOf(Integer.class).isEqualTo(12);

    Object counter = EventParser.parseValue("1", DataType.Name.COUNTER);
    assertThat(counter).isEqualTo(1L);/*from   ww  w  .  j a  v  a  2 s  .  c  om*/
    counter = EventParser.parseValue(Long.toString(Long.MAX_VALUE), DataType.Name.COUNTER);
    assertThat(counter).isEqualTo(Long.MAX_VALUE);
    counter = EventParser.parseValue(Long.toString(Long.MIN_VALUE), DataType.Name.COUNTER);
    assertThat(counter).isEqualTo(Long.MIN_VALUE);
    counter = EventParser.parseValue(" 1 2 ", DataType.Name.COUNTER);
    assertThat(counter).isEqualTo(12L);

    Object _float = EventParser.parseValue("1", DataType.Name.FLOAT);
    assertThat(_float).isInstanceOf(Float.class).isEqualTo(1f);
    _float = EventParser.parseValue("1.0", DataType.Name.FLOAT);
    assertThat(_float).isInstanceOf(Float.class).isEqualTo(1f);
    _float = EventParser.parseValue(Float.toString(Float.MAX_VALUE), DataType.Name.FLOAT);
    assertThat(_float).isInstanceOf(Float.class).isEqualTo(Float.MAX_VALUE);
    _float = EventParser.parseValue(Float.toString(Float.MIN_VALUE), DataType.Name.FLOAT);
    assertThat(_float).isInstanceOf(Float.class).isEqualTo(Float.MIN_VALUE);
    _float = EventParser.parseValue(" 1 . 0 ", DataType.Name.FLOAT);
    assertThat(_float).isInstanceOf(Float.class).isEqualTo(1f);

    Object _double = EventParser.parseValue("1", DataType.Name.DOUBLE);
    assertThat(_double).isInstanceOf(Double.class).isEqualTo(1.0);
    _double = EventParser.parseValue("0", DataType.Name.DOUBLE);
    assertThat(_double).isInstanceOf(Double.class).isEqualTo(0.0);
    _double = EventParser.parseValue(Double.toString(Double.MAX_VALUE), DataType.Name.DOUBLE);
    assertThat(_double).isInstanceOf(Double.class).isEqualTo(Double.MAX_VALUE);
    _double = EventParser.parseValue(Double.toString(Double.MIN_VALUE), DataType.Name.DOUBLE);
    assertThat(_double).isInstanceOf(Double.class).isEqualTo(Double.MIN_VALUE);
    _double = EventParser.parseValue(" 1 . 0 ", DataType.Name.DOUBLE);
    assertThat(_double).isInstanceOf(Double.class).isEqualTo(1.0);

    for (DataType.Name type : Arrays.asList(DataType.Name.BIGINT)) {
        Object bigInteger = EventParser.parseValue("1", type);
        assertThat(bigInteger).isInstanceOf(Long.class).isEqualTo(1L);
        bigInteger = EventParser.parseValue("0", type);
        assertThat(bigInteger).isInstanceOf(Long.class).isEqualTo(0L);
        bigInteger = EventParser.parseValue(Long.toString(Long.MAX_VALUE), type);
        assertThat(bigInteger).isInstanceOf(Long.class).isEqualTo(Long.MAX_VALUE);
        bigInteger = EventParser.parseValue(Long.toString(Long.MIN_VALUE), type);
        assertThat(bigInteger).isInstanceOf(Long.class).isEqualTo(Long.MIN_VALUE);
    }

    for (DataType.Name type : Arrays.asList(DataType.Name.VARINT)) {
        Object bigInteger = EventParser.parseValue("1", type);
        assertThat(bigInteger).isInstanceOf(BigInteger.class).isEqualTo(BigInteger.ONE);
        bigInteger = EventParser.parseValue("0", type);
        assertThat(bigInteger).isInstanceOf(BigInteger.class).isEqualTo(BigInteger.ZERO);
        bigInteger = EventParser.parseValue(
                BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.valueOf(2L)).toString(), type);
        assertThat(bigInteger).isInstanceOf(BigInteger.class)
                .isEqualTo(BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.valueOf(2L)));
        bigInteger = EventParser.parseValue(
                BigInteger.valueOf(Long.MIN_VALUE).multiply(BigInteger.valueOf(2L)).toString(), type);
        assertThat(bigInteger).isInstanceOf(BigInteger.class)
                .isEqualTo(BigInteger.valueOf(Long.MIN_VALUE).multiply(BigInteger.valueOf(2L)));
    }

    Object bigDecimal = EventParser.parseValue("1", DataType.Name.DECIMAL);
    assertThat(bigDecimal).isInstanceOf(BigDecimal.class).isEqualTo(BigDecimal.valueOf(1));
    bigDecimal = EventParser.parseValue("0", DataType.Name.DECIMAL);
    assertThat(bigDecimal).isInstanceOf(BigDecimal.class).isEqualTo(BigDecimal.valueOf(0));
    bigDecimal = EventParser.parseValue(
            BigDecimal.valueOf(Double.MAX_VALUE).multiply(BigDecimal.valueOf(2)).toString(),
            DataType.Name.DECIMAL);
    assertThat(bigDecimal).isInstanceOf(BigDecimal.class)
            .isEqualTo(BigDecimal.valueOf(Double.MAX_VALUE).multiply(BigDecimal.valueOf(2)));
    bigDecimal = EventParser.parseValue(
            BigDecimal.valueOf(Double.MIN_VALUE).multiply(BigDecimal.valueOf(2)).toString(),
            DataType.Name.DECIMAL);
    assertThat(bigDecimal).isInstanceOf(BigDecimal.class)
            .isEqualTo(BigDecimal.valueOf(Double.MIN_VALUE).multiply(BigDecimal.valueOf(2)));
    bigDecimal = EventParser.parseValue(" 1 2 ", DataType.Name.DECIMAL);
    assertThat(bigDecimal).isInstanceOf(BigDecimal.class).isEqualTo(BigDecimal.valueOf(12));

    Object string = EventParser.parseValue("string", DataType.Name.TEXT);
    assertThat(string).isInstanceOf(String.class).isEqualTo("string");

    Object bool = EventParser.parseValue("true", DataType.Name.BOOLEAN);
    assertThat(bool).isInstanceOf(Boolean.class).isEqualTo(true);

    Object addr = EventParser.parseValue("192.168.1.1", DataType.Name.INET);
    assertThat(addr).isInstanceOf(InetAddress.class).isEqualTo(InetAddress.getByName("192.168.1.1"));

    UUID randomUUID = UUID.randomUUID();
    Object uuid = EventParser.parseValue(randomUUID.toString(), DataType.Name.UUID);
    assertThat(uuid).isInstanceOf(UUID.class).isEqualTo(randomUUID);
}

From source file:com.joptimizer.util.Utils.java

/**
   * Get the index of the maximum entry.
   *///from  w  w  w  .  ja  v a2s . c om
public static int getMaxIndex(double[] v) {
    int maxIndex = -1;
    double maxValue = -Double.MAX_VALUE;
    for (int i = 0; i < v.length; i++) {
        if (v[i] > maxValue) {
            maxIndex = i;
            maxValue = v[i];
        }
    }
    return maxIndex;
}

From source file:com.flowpowered.api.geo.discrete.Point.java

/**
 * Gets the square of the distance between two points.
 *
 * This will return Double.MAX_VALUE if the other Point is null, either world is null, or the two points are in different worlds.
 *
 * Otherwise, it returns the Manhattan distance.
 *///w w w. ja  va 2  s . co m
public double getSquaredDistance(Point other) {
    if (other == null || world == null || other.world == null || !world.equals(other.world)) {
        return Double.MAX_VALUE;
    }
    double dx = getX() - other.getX();
    double dy = getY() - other.getY();
    double dz = getZ() - other.getZ();
    return dx * dx + dy * dy + dz * dz;
}

From source file:org.uma.jmetal.util.point.impl.ArrayPointTest.java

@Test
public void shouldSetDimensionValueAssignTheCorrectValue() {
    int dimension = 5;
    Point point = new ArrayPoint(dimension);
    point.setDimensionValue(0, 1.0);//from   w ww.ja  v  a  2s  . c o  m
    point.setDimensionValue(1, -2.0);
    point.setDimensionValue(2, 45.5);
    point.setDimensionValue(3, -323.234);
    point.setDimensionValue(4, Double.MAX_VALUE);

    double[] array = { 1.0, -2.0, 45.5, -323.234, Double.MAX_VALUE };

    assertArrayEquals(array, (double[]) ReflectionTestUtils.getField(point, "point"), EPSILON);
}