Example usage for java.lang Double longBitsToDouble

List of usage examples for java.lang Double longBitsToDouble

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static native double longBitsToDouble(long bits);

Source Link

Document

Returns the double value corresponding to a given bit representation.

Usage

From source file:com.nextgis.woody.fragment.MapFragment.java

@Override
public void onResume() {
    super.onResume();

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());

    if (null != mMap && !mShowSelectLocation) {
        if (prefs.getBoolean(SettingsConstants.KEY_PREF_MAP_FIRST_VIEW, true)) {
            // Zoom to trees extent
            MapDrawable md = mMap.getMap();
            ILayer layer = md.getLayerByName(Constants.KEY_MAIN);
            if (layer instanceof VectorLayer) {
                VectorLayer vectorLayer = (VectorLayer) layer;
                mMap.zoomToExtent(vectorLayer.getExtents());
            }//from   www .  j a  va 2 s  .  co  m

            final SharedPreferences.Editor edit = prefs.edit();
            edit.putBoolean(SettingsConstants.KEY_PREF_MAP_FIRST_VIEW, false);
            edit.commit();
        } else {
            float mMapZoom;
            try {
                mMapZoom = prefs.getFloat(SettingsConstants.KEY_PREF_ZOOM_LEVEL, mMap.getMinZoom());
            } catch (ClassCastException e) {
                mMapZoom = mMap.getMinZoom();
            }

            double mMapScrollX;
            double mMapScrollY;
            try {
                mMapScrollX = Double.longBitsToDouble(prefs.getLong(SettingsConstants.KEY_PREF_SCROLL_X, 0));
                mMapScrollY = Double.longBitsToDouble(prefs.getLong(SettingsConstants.KEY_PREF_SCROLL_Y, 0));
            } catch (ClassCastException e) {
                mMapScrollX = 0;
                mMapScrollY = 0;
            }
            mMap.setZoomAndCenter(mMapZoom, new GeoPoint(mMapScrollX, mMapScrollY));
        }
        mMap.addListener(this);
    }

    resumeGps();

    mCurrentCenter = null;
}

From source file:ac.elements.parser.SimpleDBConverter.java

/**
 * Decodes zero-padded positive double value from the string representation
 * /*from  w w w  . ja v a2 s.  c o m*/
 * com.sleepycat.bind.tuple.TupleInput
 * 
 * @param value
 *            zero-padded string representation of the double
 * @return original double value
 */
private static Double decodeSortedDouble(String value) {

    long val = decodeLong(value);
    val ^= (val < 0) ? 0x8000000000000000L : 0xffffffffffffffffL;
    val = (long) (val ^ 0xffffffffffffffffL);
    return Double.longBitsToDouble(val);
}

From source file:com.infinira.aerospike.dataaccess.model.Entity.java

/**
 * Get Double object for a given field value
 * @param name  field name//from   w w w .j ava  2s . co m
 * @return  Double value
 */
protected Double getDouble(String name) {
    Object value = this.getValue(name);
    if (value == null)
        return null;
    return (value instanceof Double) ? (Double) value : Double.longBitsToDouble((Long) value);
}

From source file:com.tlongdev.bktf.util.Utility.java

/**
 * Convenient method for getting double values from shared preferences.
 *
 * @param prefs        shared preferences
 * @param key          preference key//  www. ja  v  a 2 s  .  c  o  m
 * @param defaultValue default preference value
 * @return the stored double value
 */
public static double getDouble(final SharedPreferences prefs, final String key, final double defaultValue) {
    return Double.longBitsToDouble(prefs.getLong(key, Double.doubleToLongBits(defaultValue)));
}

From source file:com.nextgis.ngm_clink_monitoring.fragments.MapFragment.java

@Override
public void onResume() {
    super.onResume();

    GISApplication app = (GISApplication) getActivity().getApplication();

    if (null != mGpsEventSource) {
        mGpsEventSource.addListener(this);
    }//from  w ww .  j a v a 2s .com

    mCurrentCenter = null;

    if (null != mMapView) {
        mMapView.addListener(this);

        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());

        float mapZoom = prefs.getFloat(FoclSettingsConstantsUI.KEY_PREF_ZOOM_LEVEL, mMapView.getMinZoom());
        double mapScrollX = Double
                .longBitsToDouble(prefs.getLong(FoclSettingsConstantsUI.KEY_PREF_SCROLL_X, 0));
        double mapScrollY = Double
                .longBitsToDouble(prefs.getLong(FoclSettingsConstantsUI.KEY_PREF_SCROLL_Y, 0));
        mMapView.setZoomAndCenter(mapZoom, new GeoPoint(mapScrollX, mapScrollY));

        //change zoom controls visibility
        boolean showControls = prefs.getBoolean(FoclSettingsConstantsUI.KEY_PREF_SHOW_ZOOM_CONTROLS, false);

        if (showControls) {
            addMapButtons();
        } else {
            removeMapButtons();
        }

        if (null != mCurrentLocationOverlay) {
            mCurrentLocationOverlay.updateMode(app.getLocationOverlayMode());
            mCurrentLocationOverlay.startShowingCurrentLocation();
            mMapView.addOverlay(mCurrentLocationOverlay);
        }

        if (null != mGpsEventSource && onMenuMapClicked) {
            onMenuMapClicked = false;
            Location lastLocation = mGpsEventSource.getLastKnownLocation();
            setCurrentCenter(lastLocation);
            locateCurrentPositionAndZoom(false, lastLocation);
        }

        /// TODO: ???
        //             mMapView.drawMapDrawable();
    }
}

From source file:org.lwes.serializer.Deserializer.java

public static Double deserializeDOUBLE(DeserializerState myState, byte[] bytes) {
    int off = myState.currentIndex();
    long j = ((bytes[off + 7] & 0xFFL) << 0) + ((bytes[off + 6] & 0xFFL) << 8)
            + ((bytes[off + 5] & 0xFFL) << 16) + ((bytes[off + 4] & 0xFFL) << 24)
            + ((bytes[off + 3] & 0xFFL) << 32) + ((bytes[off + 2] & 0xFFL) << 40)
            + ((bytes[off + 1] & 0xFFL) << 48) + (((long) bytes[off + 0]) << 56);
    myState.incr(8);//from   w w  w . ja v a2 s . co  m
    return Double.longBitsToDouble(j);
}

From source file:chibi.gemmaanalysis.LinkMatrix.java

/**
 * Create from a matrix stored in a file.
 * /*w  w w  .  j av a2s .  c o m*/
 * @param matrixFile
 * @param eeMapFile
 * @param eeService
 * @param geneService
 * @throws IOException
 */
public LinkMatrix(String matrixFile, String eeMapFile, ExpressionExperimentService eeService,
        GeneService geneService, GeneOntologyService goService) throws IOException {
    this.goService = goService;
    try (BufferedReader in = new BufferedReader(new FileReader(new File(matrixFile)));) {
        String row = null;
        int i;
        boolean hasConfig = false, hasRowNames = false, hasColNames = false;
        Collection<Long> geneIds = new HashSet<Long>();
        while ((row = in.readLine()) != null) {
            row = row.trim();
            if (StringUtils.isBlank(row))
                continue;
            String[] subItems = row.split("\t");
            for (i = 0; i < subItems.length; i++)
                if (StringUtils.isBlank(subItems[i]))
                    break;
            if (i != subItems.length) {
                String mesg = "The empty Element is not allowed: " + row;
                log.info(mesg);
                in.close();
                throw new IOException(mesg);
            }
            if (!hasConfig) {
                if (subItems.length != 3) {
                    String mesg = "Data File Format Error for configuration " + row;
                    log.info(mesg);
                    throw new IOException(mesg);
                }
                linkCountMatrix = new CompressedBitMatrix<Long, Long>(Integer.valueOf(subItems[0]),
                        Integer.valueOf(subItems[1]), Integer.valueOf(subItems[2]));
                hasConfig = true;
            } else if (!hasRowNames) {
                if (subItems.length != linkCountMatrix.rows()) {
                    String mesg = "Data File Format Error for Row Names " + row;
                    log.info(mesg);
                    throw new IOException(mesg);
                }
                for (i = 0; i < subItems.length; i++) {
                    linkCountMatrix.addRowName(new Long(subItems[i].trim()));
                    geneIds.add(new Long(subItems[i].trim()));
                }
                hasRowNames = true;
            } else if (!hasColNames) {
                if (subItems.length != linkCountMatrix.columns()) {
                    String mesg = "Data File Format Error for Col Names " + row;
                    log.info(mesg);
                    throw new IOException(mesg);
                }
                for (i = 0; i < subItems.length; i++) {
                    linkCountMatrix.addColumnName(new Long(subItems[i].trim()));
                    geneIds.add(new Long(subItems[i].trim()));
                }
                hasColNames = true;
            } else {
                int rowIndex = Integer.valueOf(subItems[0]);
                int colIndex = Integer.valueOf(subItems[1]);
                double values[] = new double[subItems.length - 2];
                for (i = 2; i < subItems.length; i++)
                    values[i - 2] = Double.longBitsToDouble(Long.parseLong(subItems[i], 16));
                linkCountMatrix.set(rowIndex, colIndex, values);
            }
        }

        Collection<Gene> allGenes = geneService.loadMultiple(geneIds);
        for (Gene gene : allGenes) {
            geneMap.put(gene.getId(), gene);
        }
        if (eeMapFile != null) {
            try (BufferedReader in2 = new BufferedReader(new FileReader(new File(eeMapFile)));) {
                this.eeIndexMap = new HashMap<Long, Integer>();
                int vectorSize = 0;
                while ((row = in2.readLine()) != null) {
                    row = row.trim();
                    if (StringUtils.isBlank(row))
                        continue;
                    String[] subItems = row.split("\t");
                    if (subItems.length != 2)
                        continue;
                    for (i = 0; i < subItems.length; i++)
                        if (StringUtils.isBlank(subItems[i]))
                            break;
                    if (i != subItems.length) {
                        String mesg = "Data File Format Error for ee Map " + row;
                        log.info(mesg);
                        in2.close();
                        throw new IOException(mesg);
                    }
                    this.eeIndexMap.put(new Long(subItems[0].trim()), new Integer(subItems[1].trim()));
                    if (Integer.valueOf(subItems[1].trim()).intValue() > vectorSize)
                        vectorSize = Integer.valueOf(subItems[1].trim()).intValue();
                }
                eeMap = new HashMap<Integer, ExpressionExperiment>();
                for (Long iter : this.eeIndexMap.keySet()) {
                    ExpressionExperiment ee = eeService.load(iter);
                    eeMap.put(this.eeIndexMap.get(iter), ee);
                }
                log.info("Got " + this.eeIndexMap.size() + " in EE MAP");

            }
        }
        computeShift();
    }
}

From source file:org.apache.ignite.GridTestIoUtils.java

/**
 * Gets double value from byte array assuming that value stored in little-endian byte order.
 *
 * @param arr Byte array./*from w w  w  .jav  a2s .c  om*/
 * @param off Offset.
 */
public static double getDoubleByByteLE(byte[] arr, int off) {
    return Double.longBitsToDouble(getLongByByteLE(arr, off));
}

From source file:com.nextgis.forestinspector.fragment.MapFragment.java

@Override
public void onResume() {
    super.onResume();

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());

    boolean showControls = prefs.getBoolean(SettingsConstants.KEY_PREF_SHOW_ZOOM_CONTROLS, false);
    showMapButtons(showControls, mMapRelativeLayout);

    Log.d(Constants.TAG, "KEY_PREF_SHOW_ZOOM_CONTROLS: " + (showControls ? "ON" : "OFF"));

    if (null != mMap) {
        float mMapZoom;
        try {//from  ww  w.ja va 2  s  .  c  om
            mMapZoom = prefs.getFloat(SettingsConstants.KEY_PREF_ZOOM_LEVEL, mMap.getMinZoom());
        } catch (ClassCastException e) {
            mMapZoom = mMap.getMinZoom();
        }

        double mMapScrollX;
        double mMapScrollY;
        try {
            mMapScrollX = Double.longBitsToDouble(prefs.getLong(SettingsConstants.KEY_PREF_SCROLL_X, 0));
            mMapScrollY = Double.longBitsToDouble(prefs.getLong(SettingsConstants.KEY_PREF_SCROLL_Y, 0));
        } catch (ClassCastException e) {
            mMapScrollX = 0;
            mMapScrollY = 0;
        }
        mMap.setZoomAndCenter(mMapZoom, new GeoPoint(mMapScrollX, mMapScrollY));

        mMap.addListener(this);
    }

    mCoordinatesFormat = prefs.getInt(SettingsConstants.KEY_PREF_COORD_FORMAT + "_int",
            Location.FORMAT_DEGREES);

    if (null != mCurrentLocationOverlay) {
        mCurrentLocationOverlay.updateMode(PreferenceManager.getDefaultSharedPreferences(getActivity())
                .getString(SettingsConstantsUI.KEY_PREF_SHOW_CURRENT_LOC, "3"));
        mCurrentLocationOverlay.startShowingCurrentLocation();
    }
    if (null != mGpsEventSource) {
        mGpsEventSource.addListener(this);
    }

    mShowStatusPanel = prefs.getBoolean(SettingsConstantsUI.KEY_PREF_SHOW_STATUS_PANEL, true);

    if (null != mStatusPanel) {
        if (mShowStatusPanel) {
            mStatusPanel.setVisibility(View.VISIBLE);
            fillStatusPanel(null);
        } else {
            mStatusPanel.removeAllViews();
        }
    }

    mCurrentCenter = null;
}

From source file:io.github.gsantner.opoc.util.AppSettingsBase.java

public double getDouble(SharedPreferences pref, @StringRes int keyResId, double defaultValue) {
    return Double.longBitsToDouble(prefApp.getLong(rstr(keyResId), Double.doubleToLongBits(defaultValue)));
}