Example usage for java.lang Float toString

List of usage examples for java.lang Float toString

Introduction

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

Prototype

public static String toString(float f) 

Source Link

Document

Returns a string representation of the float argument.

Usage

From source file:com.health.openscale.gui.OverviewFragment.java

@Override
public void updateOnView(ArrayList<ScaleData> scaleDataList) {
    ScaleUser scaleUser = OpenScale.getInstance(overviewView.getContext()).getSelectedScaleUser();

    txtOverviewTitle.setText(getResources().getString(R.string.label_overview_title_start) + " "
            + scaleUser.user_name + " " + getResources().getString(R.string.label_overview_title_end));

    List<ArcValue> arcValues = new ArrayList<ArcValue>();

    if (scaleDataList.isEmpty()) {
        lastScaleData = null;/*from   w  ww. j a v a2s .c  o  m*/
        return;
    }

    lastScaleData = scaleDataList.get(0);

    arcValues.add(new ArcValue(lastScaleData.fat, Utils.COLOR_ORANGE));
    arcValues.add(new ArcValue(lastScaleData.water, Utils.COLOR_BLUE));
    arcValues.add(new ArcValue(lastScaleData.muscle, Utils.COLOR_GREEN));

    PieChartData pieChartData = new PieChartData(arcValues);
    pieChartData.setHasLabels(true);
    pieChartData.setFormatter(new SimpleValueFormatter(1, false, null, " %".toCharArray()));
    pieChartData.setHasCenterCircle(true);
    pieChartData.setCenterText1(
            Float.toString(lastScaleData.weight) + " " + ScaleUser.UNIT_STRING[scaleUser.scale_unit]);
    pieChartData.setCenterText2(new SimpleDateFormat("dd. MMM yyyy (EE)").format(lastScaleData.date_time));

    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE
            || (getResources().getConfiguration().screenLayout
                    & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        pieChartData.setCenterText1FontSize(33);
        pieChartData.setCenterText2FontSize(14);
    } else {
        pieChartData.setCenterText1FontSize(12);
        pieChartData.setCenterText2FontSize(8);
        pieChartData.setValueLabelTextSize(8);
    }

    pieChart.setPieChartData(pieChartData);

    double avgWeight = 0;
    double avgFat = 0;
    double avgWater = 0;
    double avgMuscle = 0;

    for (ScaleData scaleData : scaleDataList) {
        avgWeight += scaleData.weight;
        avgFat += scaleData.fat;
        avgWater += scaleData.water;
        avgMuscle += scaleData.muscle;
    }

    avgWeight = avgWeight / scaleDataList.size();
    avgFat = avgFat / scaleDataList.size();
    avgWater = avgWater / scaleDataList.size();
    avgMuscle = avgMuscle / scaleDataList.size();

    txtAvgWeight.setText(String.format("%.1f " + ScaleUser.UNIT_STRING[scaleUser.scale_unit], avgWeight));
    txtAvgFat.setText(String.format("%.1f %%", avgFat));
    txtAvgWater.setText(String.format("%.1f %%", avgWater));
    txtAvgMuscle.setText(String.format("%.1f %%", avgMuscle));
}

From source file:com.koda.integ.hbase.test.BlockStoragePersistenceTest.java

@Override
protected void setUp() throws IOException {

    if (region != null)
        return;//  w  w  w  . ja va  2s .c o  m
    // Init columns
    CQQ = new byte[5][];
    for (int i = 0; i < CQQ.length; i++) {
        CQQ[i] = ("cq" + i).getBytes();
    }

    HColumnDescriptor desc = new HColumnDescriptor(CF);
    desc.setCacheDataOnWrite(true);
    desc.setCacheIndexesOnWrite(true);
    desc.setCacheBloomsOnWrite(true);
    desc.setBlocksize(BLOCK_SIZE);
    desc.setBloomFilterType(BloomType.ROW);
    Configuration conf = TEST_UTIL.getConfiguration();
    conf.set(OffHeapBlockCache.BLOCK_CACHE_MEMORY_SIZE, Long.toString(cacheSize));
    conf.set(OffHeapBlockCache.BLOCK_CACHE_IMPL, cacheImplClass);
    conf.set(OffHeapBlockCache.BLOCK_CACHE_YOUNG_GEN_FACTOR, Float.toString(youngGenFactor));
    conf.set(OffHeapBlockCache.BLOCK_CACHE_COMPRESSION, cacheCompression);
    //conf.set(OffHeapBlockCache.BLOCK_CACHE_OVERFLOW_TO_EXT_STORAGE_ENABLED, Boolean.toString(cacheOverflowEnabled));
    conf.set("io.storefile.bloom.block.size", Integer.toString(BLOOM_BLOCK_SIZE));
    conf.set("hfile.block.cache.size", "0.5");

    // Enable File Storage
    conf.set(FileExtStorage.FILE_STORAGE_FILE_SIZE_LIMIT, Integer.toString((int) fileSizeLimit));
    conf.set(FileExtStorage.FILE_STORAGE_MAX_SIZE, Long.toString(fileStoreSize));
    conf.set(OffHeapBlockCache.BLOCK_CACHE_OVERFLOW_TO_EXT_STORAGE_ENABLED, Boolean.toString(true));
    conf.set(OffHeapBlockCache.BLOCK_CACHE_EXT_STORAGE_IMPL, FileExtStorage.class.getName());
    conf.set(FileExtStorage.FILE_STORAGE_BASE_DIR, dataDir);
    conf.set(OffHeapBlockCache.BLOCK_CACHE_TEST_MODE, Boolean.toString(true));
    conf.set(OffHeapBlockCache.BLOCK_CACHE_EXT_STORAGE_MEMORY_SIZE, Long.toString(extRefCacheSize));

    // Enable persistence
    conf.set(OffHeapBlockCache.BLOCK_CACHE_DATA_ROOTS, cacheDataDir);
    conf.set(OffHeapBlockCache.BLOCK_CACHE_PERSISTENT, Boolean.toString(true));

    region = TEST_UTIL.createTestRegion(TABLE_NAME, desc);
    populateData();
    cache = new CacheConfig(conf).getBlockCache();
    LOG.info("Block cache: " + cache.getClass().getName() + "Size=" + cache.getCurrentSize());
    LOG.info("Shutting down the region");
    long startTime = System.currentTimeMillis();
    blockCacheSize = ((OffHeapBlockCache) cache).getExtStorageCache().size();
    cache.shutdown();
    //region.close();
    LOG.info("Done in " + (System.currentTimeMillis() - startTime));

}

From source file:com.ichi2.libanki.sync.HttpSyncer.java

public HttpSyncer(String hkey, Connection con) {
    mHKey = hkey;/*from   w  ww  . j  a  v  a  2  s. com*/
    mSKey = Utils.checksum(Float.toString(new Random().nextFloat())).substring(0, 8);
    mCon = con;
    mPostVars = new HashMap<String, Object>();
}

From source file:org.openhab.binding.maxcube.internal.message.C_Message.java

private void parseHeatingThermostatData(byte[] bytes) {
    try {/* w w w . j  ava 2 s  .  co m*/

        int plusDataStart = 18;
        int programDataStart = 11;
        tempComfort = Float.toString(bytes[plusDataStart] / 2);
        tempEco = Float.toString(bytes[plusDataStart + 1] / 2);
        tempSetpointMax = Float.toString(bytes[plusDataStart + 2] / 2);
        tempSetpointMin = Float.toString(bytes[plusDataStart + 3] / 2);

        logger.debug("DeviceType:             {}", deviceType.toString());
        logger.debug("RFAddress:              {}", rfAddress);
        logger.debug("Temp Comfort:           {}", tempComfort);
        logger.debug("TempEco:                {}", tempEco);
        logger.debug("Temp Setpoint Max:      {}", tempSetpointMax);
        logger.debug("Temp Setpoint Min:      {}", tempSetpointMin);

        if (bytes.length < 211) {
            // Device is a WallMountedThermostat
            programDataStart = 4;
            logger.trace("WallThermostat byte {}: {}", bytes.length - 3,
                    Float.toString(bytes[bytes.length - 3] & 0xFF));
            logger.trace("WallThermostat byte {}: {}", bytes.length - 2,
                    Float.toString(bytes[bytes.length - 2] & 0xFF));
            logger.trace("WallThermostat byte {}: {}", bytes.length - 1,
                    Float.toString(bytes[bytes.length - 1] & 0xFF));
        } else {
            // Device is a HeatingThermostat(+)
            tempOffset = Double.toString((bytes[plusDataStart + 4] / 2) - 3.5);
            tempOpenWindow = Float.toString(bytes[plusDataStart + 5] / 2);
            durationOpenWindow = Float.toString(bytes[plusDataStart + 6]);
            boostDuration = Float.toString(bytes[plusDataStart + 7] & 0xFF >> 5);
            boostValve = Float.toString((bytes[plusDataStart + 7] & 0x1F) * 5);
            decalcification = Float.toString(bytes[plusDataStart + 8]);
            valveMaximum = Float.toString(bytes[plusDataStart + 9] & 0xFF * 100 / 255);
            valveOffset = Float.toString(bytes[plusDataStart + 10] & 0xFF * 100 / 255);
            logger.debug("Temp Offset:            {}", tempOffset);
            logger.debug("Temp Open Window:       {}", tempOpenWindow);
            logger.debug("Duration Open Window:   {}", durationOpenWindow);
            logger.debug("Duration Boost:         {}", boostDuration);
            logger.debug("Boost Valve Pos:        {}", boostValve);
            logger.debug("Decalcification:        {}", decalcification);
            logger.debug("ValveMaximum:           {}", valveMaximum);
            logger.debug("ValveOffset:            {}", valveOffset);
        }
        programData = "";
        int ln = 13 * 6; //first day = Sat 
        String startTime = "00:00h";
        for (int char_idx = plusDataStart + programDataStart; char_idx < (plusDataStart + programDataStart
                + 26 * 7); char_idx++) {
            if (ln % 13 == 0) {
                programData += "\r\n Day " + Integer.toString((ln / 13) % 7) + ": ";
                startTime = "00:00h";
            }
            int progTime = (bytes[char_idx + 1] & 0xFF) * 5 + (bytes[char_idx] & 0x01) * 1280;
            int progMinutes = progTime % 60;
            int progHours = (progTime - progMinutes) / 60;
            String endTime = Integer.toString(progHours) + ":" + String.format("%02d", progMinutes) + "h";
            programData += startTime + "-" + endTime + " " + Double.toString(bytes[char_idx] / 4) + "C  ";
            startTime = endTime;
            char_idx++;
            ln++;
        }
        logger.debug("ProgramData:          {}", programData);

    } catch (Exception e) {
        logger.debug(e.getMessage());
        logger.debug(Utils.getStackTrace(e));
    }
    return;
}

From source file:com.github.egonw.ops4j.Structures.java

public String similarity(String smiles, Object... objects)
        throws ClientProtocolException, IOException, HttpException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("searchOptions.Molecule", smiles);
    params.put("resultOptions.Count", "" + Integer.toString(25));
    params.put("searchOptions.SimilarityType", "0"); // Tanimoto
    params.put("searchOptions.Threshold", Float.toString(0.5f));
    return runRequest(server + "structure/similarity", params, objects);
}

From source file:com.clustercontrol.plugin.factory.ModifyDbmsScheduler.java

private void setEntityInfo(DbmsSchedulerEntity entity, JobDetail jobDetail, Trigger trigger)
        throws InvalidClassException {

    entity.setMisfireInstr(trigger.getMisfireInstruction());
    entity.setDurable(jobDetail.isDurable());
    entity.setJobClassName(jobDetail.getJobDataMap().getString(ReflectionInvokerJob.KEY_CLASS_NAME));
    entity.setJobMethodName(jobDetail.getJobDataMap().getString(ReflectionInvokerJob.KEY_METHOD_NAME));

    if (trigger instanceof CronTrigger) {
        entity.setTriggerType(SchedulerPlugin.TriggerType.CRON.name());
        entity.setCronExpression(((CronTrigger) trigger).getCronExpression());
    } else if (trigger instanceof SimpleTrigger) {
        entity.setTriggerType(SchedulerPlugin.TriggerType.SIMPLE.name());
        entity.setRepeatInterval(((SimpleTrigger) trigger).getPeriod());
    }// ww  w .  j a v  a  2s . c  om

    entity.setTriggerState(TriggerState.VIRGIN.name());
    entity.setStartTime(trigger.getStartTime());
    entity.setEndTime(trigger.getEndTime());
    entity.setNextFireTime(trigger.getNextFireTime());
    entity.setPrevFireTime(trigger.getPreviousFireTime());

    @SuppressWarnings("unchecked")
    Class<? extends Serializable>[] argsType = (Class<? extends Serializable>[]) jobDetail.getJobDataMap()
            .get(ReflectionInvokerJob.KEY_ARGS_TYPE);
    Object[] args = (Object[]) jobDetail.getJobDataMap().get(ReflectionInvokerJob.KEY_ARGS);

    entity.setJobArgNum(args.length);
    for (int i = 0; i < args.length; i++) {

        String arg = "";
        if (m_log.isDebugEnabled())
            m_log.debug("arg[" + i + "]:" + args[i]);

        if (argsType[i] == String.class) {
            arg = (String) args[i];
        } else if (argsType[i] == Boolean.class) {
            arg = Boolean.toString((Boolean) args[i]);
        } else if (argsType[i] == Integer.class) {
            arg = Integer.toString((Integer) args[i]);
        } else if (argsType[i] == Long.class) {
            arg = Long.toString((Long) args[i]);
        } else if (argsType[i] == Short.class) {
            arg = Short.toString((Short) args[i]);
        } else if (argsType[i] == Float.class) {
            arg = Float.toString((Float) args[i]);
        } else if (argsType[i] == Double.class) {
            arg = Double.toString((Double) args[i]);
        } else {
            m_log.error("not support class");
            throw new InvalidClassException(argsType[i].getName());
        }
        String typeArg = argsType[i].getSimpleName() + ":" + arg;
        if (arg == null) {
            typeArg = "nullString";
        }
        if (m_log.isDebugEnabled())
            m_log.debug("typeArg[" + i + "]:" + typeArg);

        switch (i) {
        case 0:
            entity.setJobArg00(typeArg);
            break;
        case 1:
            entity.setJobArg01(typeArg);
            break;
        case 2:
            entity.setJobArg02(typeArg);
            break;
        case 3:
            entity.setJobArg03(typeArg);
            break;
        case 4:
            entity.setJobArg04(typeArg);
            break;
        case 5:
            entity.setJobArg05(typeArg);
            break;
        case 6:
            entity.setJobArg06(typeArg);
            break;
        case 7:
            entity.setJobArg07(typeArg);
            break;
        case 8:
            entity.setJobArg08(typeArg);
            break;
        case 9:
            entity.setJobArg09(typeArg);
            break;
        case 10:
            entity.setJobArg10(typeArg);
            break;
        case 11:
            entity.setJobArg11(typeArg);
            break;
        case 12:
            entity.setJobArg12(typeArg);
            break;
        case 13:
            entity.setJobArg13(typeArg);
            break;
        case 14:
            entity.setJobArg14(typeArg);
            break;
        default:
            m_log.error("arg count ng.");
        }
    }
}

From source file:com.koda.integ.hbase.test.BlockCacheBaseTest.java

@Override
public void setUp() throws Exception {

    if (initDone)
        return;/*  w w w  .  j a v a  2s . c o  m*/

    ConsoleAppender console = new ConsoleAppender(); // create appender
    // configure the appender
    String PATTERN = "%d [%p|%c|%C{1}] %m%n";
    console.setLayout(new PatternLayout(PATTERN));
    console.setThreshold(Level.WARN);

    console.activateOptions();
    // add appender to any Logger (here is root)
    Logger.getRootLogger().removeAllAppenders();
    Logger.getRootLogger().addAppender(console);
    Configuration conf = UTIL.getConfiguration();
    conf.set("hbase.zookeeper.useMulti", "false");

    // Cache configuration
    conf.set(OffHeapBlockCache.BLOCK_CACHE_MEMORY_SIZE, Long.toString(cacheSize));
    conf.set(OffHeapBlockCache.BLOCK_CACHE_IMPL, cacheImplClass);
    //conf.set(OffHeapBlockCache.BLOCK_CACHE_YOUNG_GEN_FACTOR, Float.toString(youngGenFactor));
    conf.set(OffHeapBlockCache.BLOCK_CACHE_COMPRESSION, cacheCompression);
    conf.set(OffHeapBlockCache.BLOCK_CACHE_OVERFLOW_TO_EXT_STORAGE_ENABLED,
            Boolean.toString(cacheOverflowEnabled));
    conf.set("io.storefile.bloom.block.size", Integer.toString(BLOOM_BLOCK_SIZE));
    conf.set("hfile.index.block.max.size", Integer.toString(INDEX_BLOCK_SIZE));
    conf.set(OffHeapBlockCache.HEAP_BLOCK_CACHE_MEMORY_RATIO, Float.toString(onHeapCacheRatio));

    // Enable snapshot
    UTIL.startMiniCluster(1);
    initDone = true;
    if (data != null)
        return;
    data = generateData(N);
    cluster = UTIL.getMiniHBaseCluster();
    createTables(VERSIONS);
    createHBaseTables();
    putAllData(_tableA, N);

}

From source file:byps.BBufferJson.java

public void putFloat(String name, float v) {
    putJsonValueAscii(name, Float.toString(v), STRING_WITHOUT_QUOTE);
}

From source file:com.choicemaker.cm.modelmaker.gui.panels.StatisticsHistogramPanel.java

private void buildPanel() {
    final PlotOrientation orientation = PlotOrientation.VERTICAL;
    data = new HistoCategoryDataset(SERIES, getNumBins());
    histogram = ChartFactory.createBarChart(
            ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.histogram.cm.accuracy"),
            ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.histogram.cm.matchprob"),
            ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.histogram.cm.numpairs"), data,
            orientation, true, true, true);
    histogram.setBackgroundPaint(getBackground());
    CategoryPlot plot = (CategoryPlot) histogram.getPlot();
    plot.setForegroundAlpha(0.9f);//from w ww.j ava 2s .  c o m
    //      HorizontalCategoryAxis axis = (HorizontalCategoryAxis) plot.getDomainAxis();
    CategoryAxis axis = plot.getDomainAxis();
    axis.setLowerMargin(0.02);
    axis.setUpperMargin(0.02);
    axis.setCategoryMargin(0.2);
    //      axis.setVerticalCategoryLabels(true);
    CategoryItemRenderer renderer = plot.getRenderer();
    whSeriesPaint = new Paint[3];
    for (int i = 0; i < whSeriesPaint.length; ++i) {
        //         whSeriesPaint[i] = renderer.getSeriesPaint(0, i);
        whSeriesPaint[i] = renderer.getSeriesPaint(i);
    }
    wohSeriesPaint = new Paint[2];
    wohSeriesPaint[0] = whSeriesPaint[0];
    wohSeriesPaint[1] = whSeriesPaint[2];
    //   plot.setRangeAxis(new VerticalLogarithmicAxis());
    histoPanel = new HistoChartPanel(histogram, false, false, false, true, true, parent.getModelMaker());
    //   histoPanel.setEnabled(false);

    binWidthLabel = new JLabel(
            ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.histogram.binwidth"));
    binWidthField = new JTextField(Float.toString(binWidth), 4);
    binWidthField.setMinimumSize(new Dimension(50, 20));
}

From source file:nl.sogeti.android.gpstracker.streaming.CustomUpload.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.d(this, "onReceive(Context, Intent)");
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    String prefUrl = preferences.getString(Constants.CUSTOMUPLOAD_URL, "http://www.example.com");
    Integer prefBacklog = Integer
            .valueOf(preferences.getString(Constants.CUSTOMUPLOAD_BACKLOG, CUSTOM_UPLOAD_BACKLOG_DEFAULT));
    Location loc = intent.getParcelableExtra(ExternalConstants.EXTRA_LOCATION);
    Uri trackUri = intent.getParcelableExtra(ExternalConstants.EXTRA_TRACK);
    String buildUrl = prefUrl;/*from  w  ww  .j a  v a  2 s  . com*/
    buildUrl = buildUrl.replace("@LAT@", Double.toString(loc.getLatitude()));
    buildUrl = buildUrl.replace("@LON@", Double.toString(loc.getLongitude()));
    buildUrl = buildUrl.replace("@ID@", trackUri.getLastPathSegment());
    buildUrl = buildUrl.replace("@TIME@", Long.toString(loc.getTime()));
    buildUrl = buildUrl.replace("@SPEED@", Float.toString(loc.getSpeed()));
    buildUrl = buildUrl.replace("@ACC@", Float.toString(loc.getAccuracy()));
    buildUrl = buildUrl.replace("@ALT@", Double.toString(loc.getAltitude()));
    buildUrl = buildUrl.replace("@BEAR@", Float.toString(loc.getBearing()));

    URL uploadUri;
    try {
        uploadUri = new URL(buildUrl);
        if (uploadUri.getHost() != null
                && ("http".equals(uploadUri.getProtocol()) || "https".equals(uploadUri.getProtocol()))) {
            sRequestBacklog.add(uploadUri);
        } else {
            Log.e(this, "URL does not have correct scheme or host " + uploadUri);
        }
        if (sRequestBacklog.size() > prefBacklog) {
            sRequestBacklog.poll();
        }
        new Uploader(context).execute();
    } catch (IOException e) {
        notifyError(context, e);
    }
}