Example usage for java.lang Float MAX_VALUE

List of usage examples for java.lang Float MAX_VALUE

Introduction

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

Prototype

float MAX_VALUE

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

Click Source Link

Document

A constant holding the largest positive finite value of type float , (2-2-23)·2127.

Usage

From source file:org.seedstack.seed.core.internal.application.ConfigurationMembersInjectorTest.java

@Test
public void injectorConfigfloatTest() {
    injectMembersTest("testConfigfloat", false);
    Assertions.assertThat(testConfigfloat).isNotEqualTo(Float.MAX_VALUE);
    injectMembersTest("testConfigfloat", true);
    Assertions.assertThat(testConfigfloat).isEqualTo(Float.MAX_VALUE);
}

From source file:org.esa.nest.dat.views.polarview.PolarView.java

private void createPlot(int rec) {

    getSpectraMetadata(rec);//  w w w  .  ja  v a2 s . c o  m
    spectrum = getSpectrum(0, rec, graphUnit != Unit.IMAGINARY);

    float minValue = getMinValue(graphUnit != Unit.IMAGINARY);
    float maxValue = getMaxValue(graphUnit != Unit.IMAGINARY);

    if (waveProductType == WaveProductType.WAVE_SPECTRA) {
        if (graphUnit == Unit.INTENSITY) {
            minValue = Float.MAX_VALUE;
            maxValue = Float.MIN_VALUE;
            for (int i = 0; i < spectrum.length; i++) {
                for (int j = 0; j < spectrum[0].length; j++) {
                    final float realVal = spectrum[i][j];
                    final float val = realVal * realVal;
                    spectrum[i][j] = val;
                    minValue = Math.min(minValue, val);
                    maxValue = Math.max(maxValue, val);
                }
            }
        }
    } else if (graphUnit == Unit.AMPLITUDE || graphUnit == Unit.INTENSITY) {
        // complex data
        final float imagSpectrum[][] = getSpectrum(1, rec, false);
        minValue = Float.MAX_VALUE;
        maxValue = Float.MIN_VALUE;
        for (int i = 0; i < spectrum.length; i++) {
            for (int j = 0; j < spectrum[0].length; j++) {
                final float realVal = spectrum[i][j];
                final float imagVal = imagSpectrum[i][j];
                float val;
                if (sign(realVal) == sign(imagVal))
                    val = realVal * realVal + imagVal * imagVal;
                else
                    val = 0.0F;
                if (graphUnit == Unit.AMPLITUDE)
                    val = (float) Math.sqrt(val);
                spectrum[i][j] = val;
                minValue = Math.min(minValue, val);
                maxValue = Math.max(maxValue, val);
            }
        }
    }

    final float rStep = (float) (Math.log(lastWLBin) - Math.log(firstWLBin)) / (float) (numWLBins - 1);
    double logr = Math.log(firstWLBin) - (rStep / 2.0);
    final double colourRange[] = { (double) minValue, (double) maxValue };
    final double radialRange[] = { minRadius, 333.33333333333 };

    final float thFirst;
    final float thStep;
    if (waveProductType == WaveProductType.WAVE_SPECTRA) {
        thFirst = firstDirBins + 5f;
        thStep = -dirBinStep;
    } else {
        thFirst = firstDirBins - 5f;
        thStep = dirBinStep;
    }

    final int nWl = spectrum[0].length;
    final float radii[] = new float[nWl + 1];
    for (int j = 0; j <= nWl; j++) {
        radii[j] = (float) (10000.0 / FastMath.exp(logr));
        logr += rStep;
    }

    final PolarData data = new PolarData(spectrum, 90f + thFirst, thStep, radii);

    final PolarCanvas polarCanvas = polarPanel.getPolarCanvas();
    polarCanvas.setAxisNames("Azimuth", "Range");

    if (waveProductType == WaveProductType.WAVE_SPECTRA) {
        polarCanvas.setWindDirection(windDirection);
        polarCanvas.showWindDirection(true);
        polarCanvas.setAxisNames("North", "East");
    }

    final Axis colourAxis = polarCanvas.getColourAxis();
    final Axis radialAxis = polarCanvas.getRadialAxis();
    colourAxis.setDataRange(colourRange);
    colourAxis.setUnit(unitTypes[graphUnit.ordinal()]);
    radialAxis.setAutoRange(false);
    radialAxis.setDataRange(radialRange);
    radialAxis.setRange(radialRange[0], radialRange[1], 4);
    radialAxis.setTitle("Wavelength (m)");
    polarCanvas.setRings(rings, ringTextStrings);
    data.setColorScale(ColourScale.newCustomScale(colourRange));
    polarCanvas.setData(data);

    repaint();
    controlPanel.updateControls();
}

From source file:de.j4velin.mapsmeasure.Map.java

/**
 * Get the formatted string for the valueTextView.
 * <p/>//from   w  w w .j  a  v  a 2 s. c o m
 * Depending on whether 'showArea' is set, the returned string shows the
 * distance of the trace or the area between them. If 'showArea' is set,
 * this call might be expensive as the area is computed here and not cached.
 *
 * @return the formatted text for the valueTextView
 */
private String getFormattedString() {
    if (type == MeasureType.DISTANCE) {
        if (metric) {
            if (distance > 1000)
                return formatter_two_dec.format(distance / 1000) + " km";
            else
                return formatter_two_dec.format(Math.max(0, distance)) + " m";
        } else {
            if (distance > 1609)
                return formatter_two_dec.format(distance / 1609.344f) + " mi";
            else
                return formatter_two_dec.format(Math.max(0, distance / 0.3048f)) + " ft";
        }
    } else if (type == MeasureType.AREA) {
        double area;
        if (areaOverlay != null)
            areaOverlay.remove();
        if (trace.size() >= 3) {
            area = SphericalUtil.computeArea(trace);
            areaOverlay = mMap
                    .addPolygon(new PolygonOptions().addAll(trace).strokeWidth(0).fillColor(COLOR_POINT));
        } else {
            area = 0;
        }
        if (metric) {
            if (area > 1000000)
                return formatter_two_dec.format(Math.max(0, area / 1000000d)) + " km";
            else
                return formatter_no_dec.format(Math.max(0, area)) + " m";
        } else {
            if (area >= 2589989)
                return formatter_two_dec.format(Math.max(0, area / 2589988.110336d)) + " mi";
            else
                return formatter_no_dec.format(Math.max(0, area / 0.09290304d)) + " ft";
        }
    } else if (type == MeasureType.ELEVATION) {
        if (altitude == null) {
            final Handler h = new Handler();
            new Thread(new Runnable() {
                @Override
                public void run() {
                    altitude = Util.getElevation(trace);
                    h.post(new Runnable() {
                        @Override
                        public void run() {
                            if (isFinishing())
                                return;
                            if (altitude == null) {
                                Dialogs.getElevationErrorDialog(Map.this).show();
                                changeType(MeasureType.DISTANCE);
                            } else {
                                updateValueText();
                            }
                        }
                    });
                }
            }).start();
            return "Loading...";
        } else {
            String re = metric
                    ? formatter_two_dec.format(altitude.first) + " m\u2B06, "
                            + formatter_two_dec.format(-1 * altitude.second) + " m\u2B07"
                    : formatter_two_dec.format(altitude.first / 0.3048f) + " ft\u2B06"
                            + formatter_two_dec.format(-1 * altitude.second / 0.3048f) + " ft\u2B07";
            if (!trace.isEmpty()) {
                try {
                    float lastPoint = Util.getAltitude(trace.peek(), null, null);
                    if (lastPoint > -Float.MAX_VALUE) {
                        re += "\n" + (metric ? formatter_two_dec.format(lastPoint) + " m"
                                : formatter_two_dec.format(lastPoint / 0.3048f) + " ft");
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            altitude = null;
            return re;
        }
    } else {
        return "not yet supported";
    }
}

From source file:edu.stanford.slac.archiverappliance.PB.data.BoundaryConditionsSimulationValueGenerator.java

public DBR getJCASampleValue(ArchDBRTypes type, int secondsIntoYear) {
    switch (type) {
    case DBR_SCALAR_STRING:
        DBR_TIME_String retvalss = new DBR_TIME_String(new String[] { Integer.toString(secondsIntoYear) });
        retvalss.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvalss.setSeverity(1);//www. java 2  s  .c  om
        retvalss.setStatus(0);
        return retvalss;
    case DBR_SCALAR_SHORT:
        DBR_TIME_Short retvalsh;
        if (0 <= secondsIntoYear && secondsIntoYear < 1000) {
            // Check for some numbers around the minimum value
            retvalsh = new DBR_TIME_Short(new short[] { (short) (Short.MIN_VALUE + secondsIntoYear) });
        } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) {
            // Check for some numbers around the maximum value
            retvalsh = new DBR_TIME_Short(new short[] { (short) (Short.MAX_VALUE - (secondsIntoYear - 1000)) });
        } else {
            // Check for some numbers around 0
            retvalsh = new DBR_TIME_Short(new short[] { (short) (secondsIntoYear - 2000) });
        }
        retvalsh.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvalsh.setSeverity(1);
        retvalsh.setStatus(0);
        return retvalsh;
    case DBR_SCALAR_FLOAT:
        DBR_TIME_Float retvalfl;
        if (0 <= secondsIntoYear && secondsIntoYear < 1000) {
            // Check for some numbers around the minimum value
            retvalfl = new DBR_TIME_Float(new float[] { Float.MIN_VALUE + secondsIntoYear });
        } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) {
            // Check for some numbers around the maximum value
            retvalfl = new DBR_TIME_Float(new float[] { Float.MAX_VALUE - (secondsIntoYear - 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[] { (secondsIntoYear - 2000.0f) / secondsIntoYear });
        }
        retvalfl.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvalfl.setSeverity(1);
        retvalfl.setStatus(0);
        return retvalfl;
    case DBR_SCALAR_ENUM:
        DBR_TIME_Enum retvalen;
        retvalen = new DBR_TIME_Enum(new short[] { (short) (secondsIntoYear) });
        retvalen.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvalen.setSeverity(1);
        retvalen.setStatus(0);
        return retvalen;
    case DBR_SCALAR_BYTE:
        DBR_TIME_Byte retvalby;
        retvalby = new DBR_TIME_Byte(new byte[] { ((byte) (secondsIntoYear % 255)) });
        retvalby.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvalby.setSeverity(1);
        retvalby.setStatus(0);
        return retvalby;
    case DBR_SCALAR_INT:
        DBR_TIME_Int retvalint;
        if (0 <= secondsIntoYear && secondsIntoYear < 1000) {
            // Check for some numbers around the minimum value
            retvalint = new DBR_TIME_Int(new int[] { Integer.MIN_VALUE + secondsIntoYear });
        } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) {
            // Check for some numbers around the maximum value
            retvalint = new DBR_TIME_Int(new int[] { Integer.MAX_VALUE - (secondsIntoYear - 1000) });
        } else {
            // Check for some numbers around 0
            retvalint = new DBR_TIME_Int(new int[] { (secondsIntoYear - 2000) });
        }
        retvalint.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvalint.setSeverity(1);
        retvalint.setStatus(0);
        return retvalint;
    case DBR_SCALAR_DOUBLE:
        DBR_TIME_Double retvaldb;
        if (0 <= secondsIntoYear && secondsIntoYear < 1000) {
            // Check for some numbers around the minimum value
            retvaldb = new DBR_TIME_Double(new double[] { (Double.MIN_VALUE + secondsIntoYear) });
        } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) {
            // Check for some numbers around the maximum value
            retvaldb = new DBR_TIME_Double(new double[] { (Double.MAX_VALUE - (secondsIntoYear - 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[] { ((secondsIntoYear - 2000.0) / (secondsIntoYear * 1000000)) });
        }
        retvaldb.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvaldb.setSeverity(1);
        retvaldb.setStatus(0);
        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(secondsIntoYear, Integer.toString(secondsIntoYear)).toArray(new String[0]));
        retvst.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvst.setSeverity(1);
        retvst.setStatus(0);
        return retvst;
    case DBR_WAVEFORM_SHORT:
        DBR_TIME_Short retvsh;
        retvsh = new DBR_TIME_Short(
                ArrayUtils.toPrimitive(Collections.nCopies(1, (short) secondsIntoYear).toArray(new Short[0])));
        retvsh.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvsh.setSeverity(1);
        retvsh.setStatus(0);
        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(secondsIntoYear, (float) Math.cos(secondsIntoYear * Math.PI / 3600))
                        .toArray(new Float[0])));
        retvf.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvf.setSeverity(1);
        retvf.setStatus(0);
        return retvf;
    case DBR_WAVEFORM_ENUM:
        DBR_TIME_Enum retven;
        retven = new DBR_TIME_Enum(ArrayUtils
                .toPrimitive(Collections.nCopies(1024, (short) secondsIntoYear).toArray(new Short[0])));
        retven.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retven.setSeverity(1);
        retven.setStatus(0);
        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 * secondsIntoYear, ((byte) (secondsIntoYear % 255))).toArray(new Byte[0])));
        retvb.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvb.setSeverity(1);
        retvb.setStatus(0);
        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(secondsIntoYear, secondsIntoYear * secondsIntoYear).toArray(new Integer[0])));
        retvint.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvint.setSeverity(1);
        retvint.setStatus(0);
        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(secondsIntoYear, Math.sin(secondsIntoYear * Math.PI / 3600)).toArray(new Double[0])));
        retvd.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear));
        retvd.setSeverity(1);
        retvd.setStatus(0);
        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:chenyoufu.hciprojectes10.MyGLSurfaceView.java

private void readMesh() {
    try {/*  www . j  a v  a  2s . com*/
        InputStream meshIS = getResources().openRawResource(R.raw.eight);
        BufferedReader meshReader = new BufferedReader(new InputStreamReader(meshIS, "UTF-8"));
        String line;
        boolean isVertex = false;
        boolean isFace = false;
        while ((line = meshReader.readLine()) != null) {
            if (!isVertex && !isFace) {
                if (line.charAt(0) == 'V') {
                    Global.verticesCount++;
                    isVertex = true;
                }
            } else if (isFace) {
                Global.facesCount++;
            } else {
                if (line.charAt(0) == 'F') {
                    Global.facesCount++;
                    isFace = true;
                } else {
                    Global.verticesCount++;
                }
            }
        }
        meshReader.close();
        meshIS.close();

        Global.edgesCount = 3 * Global.facesCount;

        //vertices.setSize(verticesCount);
        //faces.setSize(facesCount);
        //edges.setSize(edgesCount);
        for (int i = 0; i < Global.edgesCount; i++)
            Global.edges.add(new HEEdge(null, null, null, null, null));

        // main loop, to assign elements to lists.
        //int vertexNum=0; // count from 1
        int faceNum = 0; // count from 1
        //int edgeNum=0; // count from 1
        // restore loop state
        isVertex = false;
        isFace = false;

        meshIS = getResources().openRawResource(R.raw.eight);
        meshReader = new BufferedReader(new InputStreamReader(meshIS, "UTF-8"));
        while ((line = meshReader.readLine()) != null) {
            if (!isFace && !isVertex) {
                if (line.charAt(0) == 'V') {
                    float x = 0, y = 0, z = 0;
                    // fist vertex
                    String[] split = line.split("\\s+");
                    x = Float.parseFloat(split[2]);
                    y = Float.parseFloat(split[3]);
                    z = Float.parseFloat(split[4]);
                    Global.vertices.add(new HEVert(x, y, z, null));
                    // loop
                    isVertex = true;
                }
            } else if (isFace) {
                int v1 = 0, v2 = 0, v3 = 0;
                String[] split = line.split("\\s+");
                faceNum = Integer.parseInt(split[1]);
                v1 = Integer.parseInt(split[2]);
                v2 = Integer.parseInt(split[3]);
                v3 = Integer.parseInt(split[4]);

                Global.faces.add(new HEFace(Global.edges.get(faceNum * 3 - 3)));

                Global.vertices.get(v1 - 1).edge = Global.edges.get(faceNum * 3 - 3);
                Global.vertices.get(v2 - 1).edge = Global.edges.get(faceNum * 3 - 2);
                Global.vertices.get(v3 - 1).edge = Global.edges.get(faceNum * 3 - 1);

                Global.edges.get(faceNum * 3 - 3).vert = Global.vertices.get(v1 - 1);
                Global.edges.get(faceNum * 3 - 3).face = Global.faces.get(faceNum - 1);
                Global.edges.get(faceNum * 3 - 3).prev = Global.edges.get(faceNum * 3 - 1);
                Global.edges.get(faceNum * 3 - 3).next = Global.edges.get(faceNum * 3 - 2);

                Global.edges.get(faceNum * 3 - 2).vert = Global.vertices.get(v2 - 1);
                Global.edges.get(faceNum * 3 - 2).face = Global.faces.get(faceNum - 1);
                Global.edges.get(faceNum * 3 - 2).prev = Global.edges.get(faceNum * 3 - 3);
                Global.edges.get(faceNum * 3 - 2).next = Global.edges.get(faceNum * 3 - 1);

                Global.edges.get(faceNum * 3 - 1).vert = Global.vertices.get(v3 - 1);
                Global.edges.get(faceNum * 3 - 1).face = Global.faces.get(faceNum - 1);
                Global.edges.get(faceNum * 3 - 1).prev = Global.edges.get(faceNum * 3 - 2);
                Global.edges.get(faceNum * 3 - 1).next = Global.edges.get(faceNum * 3 - 3);

                Global.edgesTemp.put((v1 - 1) + "-" + (v2 - 1), faceNum * 3 - 3);
                Global.edgesTemp.put((v2 - 1) + "-" + (v3 - 1), faceNum * 3 - 2);
                Global.edgesTemp.put((v3 - 1) + "-" + (v1 - 1), faceNum * 3 - 1);

                // dealing with pair edge

                Integer value = Global.edgesTemp.get("" + (v2 - 1) + "-" + (v1 - 1));
                if (value != null) {
                    Global.edges.get(faceNum * 3 - 3).pair = Global.edges.get(value);
                    Global.edges.get(value).pair = Global.edges.get(faceNum * 3 - 3);
                }
                value = Global.edgesTemp.get("" + (v3 - 1) + "-" + (v2 - 1));
                if (value != null) {
                    Global.edges.get(faceNum * 3 - 2).pair = Global.edges.get(value);
                    Global.edges.get(value).pair = Global.edges.get(faceNum * 3 - 2);
                }
                value = Global.edgesTemp.get("" + (v1 - 1) + "-" + (v3 - 1));
                if (value != null) {
                    Global.edges.get(faceNum * 3 - 1).pair = Global.edges.get(value);
                    Global.edges.get(value).pair = Global.edges.get(faceNum * 3 - 1);
                }
            } else { // is_vertex
                if (line.charAt(0) == 'F') {
                    // first face
                    int v1 = 0, v2 = 0, v3 = 0;
                    String[] split = line.split("\\s+");
                    faceNum = Integer.parseInt(split[1]);
                    v1 = Integer.parseInt(split[2]);
                    v2 = Integer.parseInt(split[3]);
                    v3 = Integer.parseInt(split[4]);

                    Global.faces.add(new HEFace(Global.edges.get(faceNum * 3 - 3)));

                    Global.vertices.get(v1 - 1).edge = Global.edges.get(faceNum * 3 - 3);
                    Global.vertices.get(v2 - 1).edge = Global.edges.get(faceNum * 3 - 2);
                    Global.vertices.get(v3 - 1).edge = Global.edges.get(faceNum * 3 - 1);

                    Global.edges.get(faceNum * 3 - 3).vert = Global.vertices.get(v1 - 1);
                    Global.edges.get(faceNum * 3 - 3).face = Global.faces.get(faceNum - 1);
                    Global.edges.get(faceNum * 3 - 3).prev = Global.edges.get(faceNum * 3 - 1);
                    Global.edges.get(faceNum * 3 - 3).next = Global.edges.get(faceNum * 3 - 2);

                    Global.edges.get(faceNum * 3 - 2).vert = Global.vertices.get(v2 - 1);
                    Global.edges.get(faceNum * 3 - 2).face = Global.faces.get(faceNum - 1);
                    Global.edges.get(faceNum * 3 - 2).prev = Global.edges.get(faceNum * 3 - 3);
                    Global.edges.get(faceNum * 3 - 2).next = Global.edges.get(faceNum * 3 - 1);

                    Global.edges.get(faceNum * 3 - 1).vert = Global.vertices.get(v3 - 1);
                    Global.edges.get(faceNum * 3 - 1).face = Global.faces.get(faceNum - 1);
                    Global.edges.get(faceNum * 3 - 1).prev = Global.edges.get(faceNum * 3 - 2);
                    Global.edges.get(faceNum * 3 - 1).next = Global.edges.get(faceNum * 3 - 3);

                    Global.edgesTemp.put((v1 - 1) + "-" + (v2 - 1), faceNum * 3 - 3);
                    Global.edgesTemp.put((v2 - 1) + "-" + (v3 - 1), faceNum * 3 - 2);
                    Global.edgesTemp.put((v3 - 1) + "-" + (v1 - 1), faceNum * 3 - 1);
                    // loop
                    isFace = true;
                } else {
                    float x = 0, y = 0, z = 0;
                    String[] split = line.split("\\s+");
                    x = Float.parseFloat(split[2]);
                    y = Float.parseFloat(split[3]);
                    z = Float.parseFloat(split[4]);
                    Global.vertices.add(new HEVert(x, y, z, null));
                }
            }
        }
        meshReader.close();
        meshIS.close();

        // Calculate bounding box
        float tempMinX = Float.MAX_VALUE, tempMinY = Float.MAX_VALUE, tempMinZ = Float.MAX_VALUE;
        float tempMaxX = Float.MIN_VALUE, tempMaxY = Float.MIN_VALUE, tempMaxZ = Float.MIN_VALUE;
        for (int i = 0; i < Global.verticesCount; i++) {
            if (Global.vertices.get(i).x > tempMaxX)
                tempMaxX = Global.vertices.get(i).x;
            if (Global.vertices.get(i).y > tempMaxY)
                tempMaxY = Global.vertices.get(i).y;
            if (Global.vertices.get(i).z > tempMaxZ)
                tempMaxZ = Global.vertices.get(i).z;
            if (Global.vertices.get(i).x < tempMinX)
                tempMinX = Global.vertices.get(i).x;
            if (Global.vertices.get(i).y < tempMinY)
                tempMinY = Global.vertices.get(i).y;
            if (Global.vertices.get(i).z < tempMinZ)
                tempMinZ = Global.vertices.get(i).z;
        }
        Global.maxX = tempMaxX;
        Global.minX = tempMinX;
        Global.maxY = tempMaxY;
        Global.minY = tempMinY;
        Global.maxZ = tempMaxZ;
        Global.minZ = tempMinZ;

        // Normalize the vertex coordinates (in the range of 0~2)
        float centroidX = (Global.maxX + Global.minX) / 2;
        float rangeX = Global.maxX - centroidX;
        float centroidY = (Global.maxY + Global.minY) / 2;
        float rangeY = Global.maxY - centroidY;
        float centroidZ = (Global.maxZ + Global.minZ) / 2;
        float rangeZ = Global.maxZ - centroidZ;
        float tempRange;
        float maxRatio = (tempRange = rangeX > rangeY ? rangeX : rangeY) > rangeZ ? tempRange : rangeZ;
        for (int i = 0; i < Global.verticesCount; i++) {
            Global.vertices.get(i).x = (Global.vertices.get(i).x - (Global.minX + Global.maxX) / 2) / maxRatio;
            Global.vertices.get(i).y = (Global.vertices.get(i).y - (Global.minY + Global.maxY) / 2) / maxRatio;
            Global.vertices.get(i).z = (Global.vertices.get(i).z - (Global.minZ + Global.maxZ) / 2) / maxRatio;
        }

        /*for (int i=0; i< Global.verticesCount; i++) {
        System.out.println(i+" "+Global.vertices.get(i).edge.face.edge.vert.x);
        }*/

        /*Global.maxX=(Global.maxX-Global.minX)/maxRatio;Global.minX=0;
        Global.maxY=(Global.maxY-Global.minY)/maxRatio;Global.minY=0;
        Global.maxZ=(Global.maxZ-Global.minZ)/maxRatio;Global.minZ=0;*/

        // Compute face normals & vertex normals
        for (int i = 0; i < Global.facesCount; i++) {
            Tuple3 v1 = new Tuple3(Global.faces.get(i).edge.vert);
            Tuple3 v2 = new Tuple3(Global.faces.get(i).edge.next.vert);
            Tuple3 v3 = new Tuple3(Global.faces.get(i).edge.prev.vert);
            Tuple3 e1 = new Tuple3(v2.x - v1.x, v2.y - v1.y, v2.z - v1.z);
            Tuple3 e2 = new Tuple3(v3.x - v1.x, v3.y - v1.y, v3.z - v1.z);
            Tuple3 tempNormal = new Tuple3(e1.y * e2.z - e1.z * e2.y, e1.z * e2.x - e1.x * e2.z,
                    e1.x * e2.y - e1.y * e2.x);
            float tempArea = (float) Math.sqrt(
                    tempNormal.x * tempNormal.x + tempNormal.y * tempNormal.y + tempNormal.z * tempNormal.z);
            Global.faceInfos.put(Global.faces.get(i), new FaceInfo(tempArea, tempNormal));
        }
        for (int i = 0; i < Global.verticesCount; i++) {

            HEFace faceNow = Global.vertices.get(i).edge.face;
            float totalArea = Global.faceInfos.get(faceNow).area;
            Tuple3 tempNormal = Global.faceInfos.get(faceNow).normal.mul(totalArea);
            Global.vertexNormals.put(Global.vertices.get(i), tempNormal);
            HEEdge edgeNow = Global.vertices.get(i).edge;
            boolean isReverse = false;
            while (true) {
                if (!isReverse) {
                    if (edgeNow.pair != null) {
                        if (edgeNow.pair.next != Global.vertices.get(i).edge) {
                            edgeNow = edgeNow.pair.next;
                            Global.vertexNormals
                                    .get(Global.vertices.get(i)).x += Global.faceInfos.get(edgeNow.face).area
                                            * Global.faceInfos.get(edgeNow.face).normal.x;
                            Global.vertexNormals
                                    .get(Global.vertices.get(i)).y += Global.faceInfos.get(edgeNow.face).area
                                            * Global.faceInfos.get(edgeNow.face).normal.y;
                            Global.vertexNormals
                                    .get(Global.vertices.get(i)).z += Global.faceInfos.get(edgeNow.face).area
                                            * Global.faceInfos.get(edgeNow.face).normal.z;
                            totalArea += Global.faceInfos.get(edgeNow.face).area;
                        } else
                            break;
                    } else {
                        isReverse = true;
                        edgeNow = Global.vertices.get(i).edge;
                    }
                } else {
                    if (edgeNow.prev.pair != null) {
                        edgeNow = edgeNow.prev.pair;
                        Global.vertexNormals
                                .get(Global.vertices.get(i)).x += Global.faceInfos.get(edgeNow.face).area
                                        * Global.faceInfos.get(edgeNow.face).normal.x;
                        Global.vertexNormals
                                .get(Global.vertices.get(i)).y += Global.faceInfos.get(edgeNow.face).area
                                        * Global.faceInfos.get(edgeNow.face).normal.y;
                        Global.vertexNormals
                                .get(Global.vertices.get(i)).z += Global.faceInfos.get(edgeNow.face).area
                                        * Global.faceInfos.get(edgeNow.face).normal.z;
                        totalArea += Global.faceInfos.get(edgeNow.face).area;
                    } else
                        break;
                }
            }
            Global.vertexNormals.get(Global.vertices.get(i)).x /= totalArea;
            Global.vertexNormals.get(Global.vertices.get(i)).y /= totalArea;
            Global.vertexNormals.get(Global.vertices.get(i)).z /= totalArea;

            //Global.normalize(Global.vertexNormals.get(Global.vertices.get(i)));
        }

        /*for (int i=0; i< Global.verticesCount;i++) {
        System.out.println(Math.sqrt(Global.vertexNormals.get(Global.vertices.get(i)).x*Global.vertexNormals.get(Global.vertices.get(i)).x+Global.vertexNormals.get(Global.vertices.get(i)).y*Global.vertexNormals.get(Global.vertices.get(i)).y+Global.vertexNormals.get(Global.vertices.get(i)).z*Global.vertexNormals.get(Global.vertices.get(i)).z));
        }*/
        /*for (int i=0; i< Global.verticesCount; i++){
        System.out.println(i+" "+Global.vertexNormals.get(Global.vertices.get(i)).x+" "+Global.vertexNormals.get(Global.vertices.get(i)).y+" "+Global.vertexNormals.get(Global.vertices.get(i)).z);
        }*/

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:ddf.catalog.data.dynamic.impl.DynamicMetacardImplTest.java

@Test
public void testGetAttribute() throws Exception {
    Attribute attribute = null;/*from   w ww .j  a  v a  2 s  . c  o m*/
    baseBean.set(STRING, "abc");
    attribute = metacard.getAttribute(STRING);
    assertEquals("abc", attribute.getValue());

    baseBean.set(BOOLEAN, true);
    attribute = metacard.getAttribute(BOOLEAN);
    assertEquals(true, attribute.getValue());

    Date d = new Date(System.currentTimeMillis());
    baseBean.set(DATE, d);
    attribute = metacard.getAttribute(DATE);
    assertEquals(d, attribute.getValue());

    baseBean.set(SHORT, Short.MAX_VALUE);
    attribute = metacard.getAttribute(SHORT);
    assertEquals(Short.MAX_VALUE, attribute.getValue());

    baseBean.set(INTEGER, Integer.MAX_VALUE);
    attribute = metacard.getAttribute(INTEGER);
    assertEquals(Integer.MAX_VALUE, attribute.getValue());

    baseBean.set(LONG, Long.MAX_VALUE);
    attribute = metacard.getAttribute(LONG);
    assertEquals(Long.MAX_VALUE, attribute.getValue());

    baseBean.set(FLOAT, Float.MAX_VALUE);
    attribute = metacard.getAttribute(FLOAT);
    assertEquals(Float.MAX_VALUE, attribute.getValue());

    baseBean.set(DOUBLE, Double.MAX_VALUE);
    attribute = metacard.getAttribute(DOUBLE);
    assertEquals(Double.MAX_VALUE, attribute.getValue());

    Byte[] bytes = new Byte[] { 0x00, 0x01, 0x02, 0x03 };
    baseBean.set(BINARY, bytes);
    attribute = metacard.getAttribute(BINARY);
    assertEquals(bytes, attribute.getValue());

    baseBean.set(XML, XML_STRING);
    attribute = metacard.getAttribute(XML);
    assertEquals(XML_STRING, attribute.getValue());

    baseBean.set(OBJECT, XML_STRING);
    attribute = metacard.getAttribute(OBJECT);
    assertEquals(XML_STRING, attribute.getValue());
}

From source file:org.seedstack.seed.core.internal.application.ConfigurationMembersInjectorTest.java

@Test
public void injectorConfigfloatArrayTest() {
    injectMembersTest("testConfigfloatArray", false);
    Assertions.assertThat(testConfigfloatArray).isNull();
    injectMembersTest("testConfigfloatArray", true);
    Assertions.assertThat(testConfigfloatArray).isNotNull();
    Assertions.assertThat(testConfigfloatArray.length).isEqualTo(1);
    Assertions.assertThat(testConfigfloatArray[0]).isEqualTo(Float.MAX_VALUE);
}

From source file:edu.snu.leader.hidden.builder.AssertivenessAndDirectionIndividualBuilder.java

/**
 * Creates a assertiveness using a random value drawn from a
 * Gaussian distribution//from  w  ww  .j  a  v a2s.  c  om
 *
 * @return The assertiveness value
 */
protected float createGaussianAssertiveness() {
    int tries = 0;
    float assertiveness = Float.MAX_VALUE;
    while (((_minAssertiveness > assertiveness) || (_maxAssertiveness < assertiveness))
            && (_maxTries > tries)) {
        assertiveness = _assertivenessMean
                + ((float) _simState.getRandom().nextGaussian() * _assertivenessStdDev);
        tries++;
    }
    if (_maxAssertiveness < assertiveness) {
        assertiveness = _maxAssertiveness;
    } else if (_minAssertiveness > assertiveness) {
        assertiveness = _minAssertiveness;
    }

    return assertiveness;
}

From source file:edu.fullerton.viewerplugin.PluginSupport.java

public static void getRangeLimits(XYSeriesCollection mtds, Double[] rng, int skip) {
    getRangeLimits(mtds, rng, skip, -Float.MAX_VALUE, Float.MAX_VALUE);
}

From source file:com.taobao.weex.ui.animation.TransformParser.java

public static Map<Property<View, Float>, Float> parseTransForm(@Nullable String rawTransform, final int width,
        final int height, final int viewportW) {
    if (!TextUtils.isEmpty(rawTransform)) {
        FunctionParser<Property<View, Float>, Float> parser = new FunctionParser<>(rawTransform,
                new FunctionParser.Mapper<Property<View, Float>, Float>() {
                    @Override/*  w w w . ja  v a 2s .  c  o m*/
                    public Map<Property<View, Float>, Float> map(String functionName, List<String> raw) {
                        if (raw != null && !raw.isEmpty()) {
                            if (wxToAndroidMap.containsKey(functionName)) {
                                return convertParam(width, height, viewportW, wxToAndroidMap.get(functionName),
                                        raw);
                            }
                        }
                        return new HashMap<>();
                    }

                    private Map<Property<View, Float>, Float> convertParam(int width, int height, int viewportW,
                            @NonNull List<Property<View, Float>> propertyList, @NonNull List<String> rawValue) {

                        Map<Property<View, Float>, Float> result = WXDataStructureUtil
                                .newHashMapWithExpectedSize(propertyList.size());
                        List<Float> convertedList = new ArrayList<>(propertyList.size());
                        if (propertyList.contains(View.ROTATION) || propertyList.contains(View.ROTATION_X)
                                || propertyList.contains(View.ROTATION_Y)) {
                            convertedList.addAll(parseRotationZ(rawValue));
                        } else if (propertyList.contains(View.TRANSLATION_X)
                                || propertyList.contains(View.TRANSLATION_Y)) {
                            convertedList
                                    .addAll(parseTranslation(propertyList, width, height, rawValue, viewportW));
                        } else if (propertyList.contains(View.SCALE_X) || propertyList.contains(View.SCALE_Y)) {
                            convertedList.addAll(parseScale(propertyList.size(), rawValue));
                        } else if (propertyList.contains(CameraDistanceProperty.getInstance())) {
                            convertedList.add(parseCameraDistance(rawValue));
                        }
                        if (propertyList.size() == convertedList.size()) {
                            for (int i = 0; i < propertyList.size(); i++) {
                                result.put(propertyList.get(i), convertedList.get(i));
                            }
                        }
                        return result;
                    }

                    private List<Float> parseScale(int size, @NonNull List<String> rawValue) {
                        List<Float> convertedList = new ArrayList<>(rawValue.size() * 2);
                        List<Float> rawFloat = new ArrayList<>(rawValue.size());
                        for (String item : rawValue) {
                            rawFloat.add(WXUtils.fastGetFloat(item));
                        }
                        convertedList.addAll(rawFloat);
                        if (size != 1 && rawValue.size() == 1) {
                            convertedList.addAll(rawFloat);
                        }
                        return convertedList;
                    }

                    private @NonNull List<Float> parseRotationZ(@NonNull List<String> rawValue) {
                        List<Float> convertedList = new ArrayList<>(1);
                        int suffix;
                        for (String raw : rawValue) {
                            if ((suffix = raw.lastIndexOf(DEG)) != -1) {
                                convertedList.add(WXUtils.fastGetFloat(raw.substring(0, suffix)));
                            } else {
                                convertedList.add((float) Math.toDegrees(Double.parseDouble(raw)));
                            }
                        }
                        return convertedList;
                    }

                    /**
                     * As "translate(50%, 25%)" or "translate(25px, 30px)" both are valid,
                     * parsing translate is complicated than other method.
                     * Add your waste time here if you try to optimize this method like {@link #parseScale(int, List)}
                     * Time: 0.5h
                     */
                    private List<Float> parseTranslation(List<Property<View, Float>> propertyList, int width,
                            int height, @NonNull List<String> rawValue, int viewportW) {
                        List<Float> convertedList = new ArrayList<>(2);
                        String first = rawValue.get(0);
                        if (propertyList.size() == 1) {
                            parseSingleTranslation(propertyList, width, height, convertedList, first,
                                    viewportW);
                        } else {
                            parseDoubleTranslation(width, height, rawValue, convertedList, first, viewportW);
                        }
                        return convertedList;
                    }

                    private void parseSingleTranslation(List<Property<View, Float>> propertyList, int width,
                            int height, List<Float> convertedList, String first, int viewportW) {
                        if (propertyList.contains(View.TRANSLATION_X)) {
                            convertedList.add(parsePercentOrPx(first, width, viewportW));
                        } else if (propertyList.contains(View.TRANSLATION_Y)) {
                            convertedList.add(parsePercentOrPx(first, height, viewportW));
                        }
                    }

                    private void parseDoubleTranslation(int width, int height, @NonNull List<String> rawValue,
                            List<Float> convertedList, String first, int viewportW) {
                        String second;
                        if (rawValue.size() == 1) {
                            second = first;
                        } else {
                            second = rawValue.get(1);
                        }
                        convertedList.add(parsePercentOrPx(first, width, viewportW));
                        convertedList.add(parsePercentOrPx(second, height, viewportW));
                    }

                    private Float parseCameraDistance(List<String> rawValue) {
                        float ret = Float.MAX_VALUE;
                        if (rawValue.size() == 1) {
                            float value = WXViewUtils.getRealPxByWidth(WXUtils.getFloat(rawValue.get(0)),
                                    viewportW);
                            float scale = WXEnvironment.getApplication().getResources()
                                    .getDisplayMetrics().density;
                            if (!Float.isNaN(value) && value > 0) {
                                ret = value * scale;
                            }
                        }
                        return ret;
                    }
                });
        return parser.parse();
    }
    return new LinkedHashMap<>();
}