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.mendhak.gpslogger.loggers.LiveTrack24FileLogger.java

/**
 * Sends a packet with a location update
 * @param bloc the location/* w w w  .ja v a2s . c  om*/
 * @return a request handle for the asynchronous request
 */
RequestHandle sendLocationPacket(LocationBuffer.BufferedLocation bloc) {
    HashMap<String, String> params = new HashMap<String, String>();

    params.put("lat", Float.toString((float) bloc.lat));
    params.put("lon", Float.toString((float) bloc.lon));
    params.put("alt", Integer.toString(bloc.altitude));
    params.put("sog", Float.toString(bloc.speed / (float) 3.6)); // Convert to m/s before sending
    params.put("cog", Integer.toString(bloc.bearing));
    params.put("tm", Integer.toString((int) (bloc.timems / 1000)));
    httpAsyncClient.setTimeout(POINT_TIMEOUT);
    httpAsyncClient.setMaxRetriesAndTimeout(POINT_MAX_RETRIES, POINT_RETRIES_TIMEOUT);

    return sendPacket(PACKET_POINT, params, locationPacketHandler, false /* async */);
}

From source file:net.myrrix.common.math.MatrixUtils.java

private static void appendWithPadOrTruncate(float value, StringBuilder to) {
    String stringValue = Float.toString(value);
    if (value >= 0.0f) {
        stringValue = ' ' + stringValue;
    }//from  w  w w. j  a va 2  s.  co m
    appendWithPadOrTruncate(stringValue, to);
}

From source file:blue.soundObject.tracker.Column.java

public String getDecrementValue(String val) {
    String retVal = null;/*from  w  w w .j a  va 2 s .c om*/

    switch (type) {
    case TYPE_PCH:
        float baseTen = ScoreUtilities.getBaseTen(val);

        baseTen -= 1.0f;

        int octave = (int) (baseTen / 12);
        float strPch = (baseTen % 12) / 100;

        retVal = Float.toString(octave + strPch);

        if (retVal.endsWith(".0") || retVal.endsWith(".1")) {
            retVal = retVal + "0";
        }

        break;

    case TYPE_BLUE_PCH:
        String[] parts = val.split("\\.");

        int scaleDegrees = getScale().getNumScaleDegrees();

        int iBaseTen = Integer.parseInt(parts[0]) * scaleDegrees;
        iBaseTen += Integer.parseInt(parts[1]);

        iBaseTen -= 1;

        int iOctave = iBaseTen / scaleDegrees;
        int iScaleDegree = iBaseTen % scaleDegrees;

        retVal = iOctave + "." + iScaleDegree;

        break;
    case TYPE_NUM:

        double dNumVal = Double.parseDouble(val);

        dNumVal -= 1;

        if (usingRange && dNumVal < rangeMin) {
            dNumVal = rangeMin;
        }

        if (restrictedToInteger) {
            retVal = Integer.toString((int) dNumVal);
        } else {
            retVal = Double.toString(dNumVal);
        }
        break;
    case TYPE_MIDI:

        int midiVal = Integer.parseInt(val) - 1;

        if (midiVal < 0) {
            return null;
        }

        retVal = Integer.toString(midiVal);
        break;
    case TYPE_STR:
        retVal = null;
        break;
    }

    return retVal;
}

From source file:eu.itesla_project.online.tools.ListOnlineWorkflowsTool.java

@Override
public void run(CommandLine line) throws Exception {
    OnlineConfig config = OnlineConfig.load();
    OnlineDb onlinedb = config.getOnlineDbFactoryClass().newInstance().create();
    List<OnlineWorkflowDetails> workflows = null;
    if (line.hasOption("basecase")) {
        DateTime basecaseDate = DateTime.parse(line.getOptionValue("basecase"));
        workflows = onlinedb.listWorkflows(basecaseDate);
    } else if (line.hasOption("basecases-interval")) {
        Interval basecasesInterval = Interval.parse(line.getOptionValue("basecases-interval"));
        workflows = onlinedb.listWorkflows(basecasesInterval);
    } else if (line.hasOption("workflow")) {
        String workflowId = line.getOptionValue("workflow");
        OnlineWorkflowDetails workflowDetails = onlinedb.getWorkflowDetails(workflowId);
        workflows = new ArrayList<OnlineWorkflowDetails>();
        if (workflowDetails != null)
            workflows.add(workflowDetails);
    } else//from  www  . java  2 s. c o m
        workflows = onlinedb.listWorkflows();
    boolean printParameters = line.hasOption("parameters");
    DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
    Table table = new Table(2, BorderStyle.CLASSIC_WIDE);
    if (printParameters)
        table = new Table(3, BorderStyle.CLASSIC_WIDE);
    List<Map<String, String>> jsonData = new ArrayList<Map<String, String>>();
    table.addCell("ID", new CellStyle(CellStyle.HorizontalAlign.center));
    table.addCell("Date", new CellStyle(CellStyle.HorizontalAlign.center));
    if (printParameters)
        table.addCell("Parameters", new CellStyle(CellStyle.HorizontalAlign.center));
    for (OnlineWorkflowDetails workflow : workflows) {
        Map<String, String> wfJsonData = new HashMap<String, String>();
        table.addCell(workflow.getWorkflowId());
        wfJsonData.put("id", workflow.getWorkflowId());
        table.addCell(formatter.print(workflow.getWorkflowDate()));
        wfJsonData.put("date", formatter.print(workflow.getWorkflowDate()));
        if (printParameters) {
            OnlineWorkflowParameters parameters = onlinedb.getWorkflowParameters(workflow.getWorkflowId());
            if (parameters != null) {
                table.addCell("Basecase = " + parameters.getBaseCaseDate().toString());
                wfJsonData.put(OnlineWorkflowCommand.BASE_CASE, parameters.getBaseCaseDate().toString());
                table.addCell(" ");
                table.addCell(" ");
                table.addCell("Time Horizon = " + parameters.getTimeHorizon().getName());
                wfJsonData.put(OnlineWorkflowCommand.TIME_HORIZON, parameters.getTimeHorizon().getName());
                table.addCell(" ");
                table.addCell(" ");
                table.addCell("FE Analysis Id = " + parameters.getFeAnalysisId());
                wfJsonData.put(OnlineWorkflowCommand.FEANALYSIS_ID, parameters.getFeAnalysisId());
                table.addCell(" ");
                table.addCell(" ");
                table.addCell("Offline Workflow Id = " + parameters.getOfflineWorkflowId());
                wfJsonData.put(OnlineWorkflowCommand.WORKFLOW_ID, parameters.getOfflineWorkflowId());
                table.addCell(" ");
                table.addCell(" ");
                table.addCell("Historical Interval = " + parameters.getHistoInterval().toString());
                wfJsonData.put(OnlineWorkflowCommand.HISTODB_INTERVAL,
                        parameters.getHistoInterval().toString());
                table.addCell(" ");
                table.addCell(" ");
                table.addCell("States = " + Integer.toString(parameters.getStates()));
                wfJsonData.put(OnlineWorkflowCommand.STATES, Integer.toString(parameters.getStates()));
                table.addCell(" ");
                table.addCell(" ");
                table.addCell(
                        "Rules Purity Threshold = " + Double.toString(parameters.getRulesPurityThreshold()));
                wfJsonData.put(OnlineWorkflowCommand.RULES_PURITY,
                        Double.toString(parameters.getRulesPurityThreshold()));
                table.addCell(" ");
                table.addCell(" ");
                table.addCell("Store States = " + Boolean.toString(parameters.storeStates()));
                wfJsonData.put(OnlineWorkflowCommand.STORE_STATES, Boolean.toString(parameters.storeStates()));
                table.addCell(" ");
                table.addCell(" ");
                table.addCell("Analyse Basecase = " + Boolean.toString(parameters.analyseBasecase()));
                wfJsonData.put(OnlineWorkflowCommand.ANALYSE_BASECASE,
                        Boolean.toString(parameters.analyseBasecase()));
                table.addCell(" ");
                table.addCell(" ");
                table.addCell("Validation = " + Boolean.toString(parameters.validation()));
                wfJsonData.put(OnlineWorkflowCommand.VALIDATION, Boolean.toString(parameters.validation()));
                table.addCell(" ");
                table.addCell(" ");
                String securityRulesString = parameters.getSecurityIndexes() == null ? "ALL"
                        : parameters.getSecurityIndexes().toString();
                table.addCell("Security Rules = " + securityRulesString);
                wfJsonData.put(OnlineWorkflowCommand.SECURITY_INDEXES, securityRulesString);
                table.addCell(" ");
                table.addCell(" ");
                table.addCell("Case Type = " + parameters.getCaseType());
                wfJsonData.put(OnlineWorkflowCommand.CASE_TYPE, parameters.getCaseType().name());
                table.addCell(" ");
                table.addCell(" ");
                table.addCell("Countries = " + parameters.getCountries().toString());
                wfJsonData.put(OnlineWorkflowCommand.COUNTRIES, parameters.getCountries().toString());
                table.addCell(" ");
                table.addCell(" ");
                table.addCell("Limits Reduction = " + Float.toString(parameters.getLimitReduction()));
                wfJsonData.put(OnlineWorkflowCommand.LIMIT_REDUCTION,
                        Float.toString(parameters.getLimitReduction()));
                table.addCell(" ");
                table.addCell(" ");
                table.addCell(
                        "Handle Violations in N = " + Boolean.toString(parameters.isHandleViolationsInN()));
                wfJsonData.put(OnlineWorkflowCommand.HANDLE_VIOLATION_IN_N,
                        Boolean.toString(parameters.isHandleViolationsInN()));
                table.addCell(" ");
                table.addCell(" ");
                table.addCell("Constrain Margin = " + Float.toString(parameters.getConstraintMargin()));
                wfJsonData.put(OnlineWorkflowCommand.CONSTRAINT_MARGIN,
                        Float.toString(parameters.getConstraintMargin()));
                if (parameters.getCaseFile() != null) {
                    table.addCell(" ");
                    table.addCell(" ");
                    table.addCell("Case file = " + parameters.getCaseFile());
                    wfJsonData.put(OnlineWorkflowCommand.CASE_FILE, parameters.getCaseFile());
                }
            } else {
                table.addCell("-");
            }
        }
        jsonData.add(wfJsonData);
    }
    if (line.hasOption("json")) {
        Path jsonFile = Paths.get(line.getOptionValue("json"));
        try (FileWriter jsonFileWriter = new FileWriter(jsonFile.toFile())) {
            //JSONSerializer.toJSON(jsonData).write(jsonFileWriter);
            jsonFileWriter.write(JSONSerializer.toJSON(jsonData).toString(3));
        }
    } else
        System.out.println(table.render());

    onlinedb.close();
}

From source file:org.zenoss.zep.dao.impl.ConfigDaoImpl.java

private static String valueToString(FieldDescriptor field, Object value) throws ZepException {
    if (field.isRepeated()) {
        throw new ZepException("Repeated field not supported");
    }/*from www.  j ava  2 s  .  c  o  m*/
    switch (field.getJavaType()) {
    case BOOLEAN:
        return Boolean.toString((Boolean) value);
    case BYTE_STRING:
        return new String(Base64.encodeBase64(((ByteString) value).toByteArray()), Charset.forName("US-ASCII"));
    case DOUBLE:
        return Double.toString((Double) value);
    case ENUM:
        return Integer.toString(((EnumValueDescriptor) value).getNumber());
    case FLOAT:
        return Float.toString((Float) value);
    case INT:
        return Integer.toString((Integer) value);
    case LONG:
        return Long.toString((Long) value);
    case MESSAGE:
        try {
            return JsonFormat.writeAsString((Message) value);
        } catch (IOException e) {
            throw new ZepException(e.getLocalizedMessage(), e);
        }
    case STRING:
        return (String) value;
    default:
        throw new ZepException("Unsupported type: " + field.getType());
    }
}

From source file:com.music.mybarr.activities.ExampleActivity.java

private Boolean amIThere() {
    try {/* w  ww . j a  v  a  2 s  .  c  om*/
        // get user location
        locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
        criteria = new Criteria();

        // Get the name of the best provider
        provider = locationManager.getBestProvider(criteria, true);

        // Get Current Location
        myLocation = locationManager.getLastKnownLocation(provider);

        myLatLng = new LatLng(myLocation.getLatitude(), myLocation.getLongitude());
        Log.i("lat", String.valueOf(myLocation.getLatitude()));
        Log.i("lon", String.valueOf(myLocation.getLongitude()));

        //distance between me and bar location
        float d = myLocation.distanceTo(barLocation);
        Log.i("distance", Float.toString(d));
        if (d > 200) {
            return false;
        } else {
            return true;
        }
    } catch (Exception e) {
        return false;
    }
}

From source file:caveworld.core.Config.java

public static void syncGeneralCfg() {
    String category = Configuration.CATEGORY_GENERAL;
    Property prop;/*from  www. ja va2  s. c  o  m*/
    List<String> propOrder = Lists.newArrayList();

    if (generalCfg == null) {
        generalCfg = loadConfig(category);
    }

    if (side.isClient()) {
        prop = generalCfg.get(category, "caveMusicVolume", Float.toString(0.5F));
        prop.setMinValue(0.0F).setMaxValue(1.0F)
                .setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName());
        prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
        prop.comment += " [range: " + prop.getMinValue() + " ~ " + prop.getMaxValue() + ", default: "
                + prop.getDefault() + "]";
        propOrder.add(prop.getName());
        caveMusicVolume = Float.parseFloat(prop.getString()) < 0.0F ? 0.0F
                : Float.parseFloat(prop.getString()) > 1.0F ? 1.0F : Float.parseFloat(prop.getString());
    }

    prop = generalCfg.get(category, "versionNotify", true);
    prop.setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName());
    prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
    prop.comment += " [default: " + prop.getDefault() + "]";
    prop.comment += Configuration.NEW_LINE;
    prop.comment += "Note: If multiplayer, does not have to match client-side and server-side.";
    propOrder.add(prop.getName());
    versionNotify = prop.getBoolean(versionNotify);
    prop = generalCfg.get(category, "veinsAutoRegister", true);
    prop.setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName()).setRequiresMcRestart(true);
    prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
    prop.comment += " [default: " + prop.getDefault() + "]";
    prop.comment += Configuration.NEW_LINE;
    prop.comment += "Note: If multiplayer, server-side only.";
    propOrder.add(prop.getName());
    veinsAutoRegister = prop.getBoolean(veinsAutoRegister);
    prop = generalCfg.get(category, "deathLoseMiningPoint", false);
    prop.setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName());
    prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
    prop.comment += " [default: " + prop.getDefault() + "]";
    prop.comment += Configuration.NEW_LINE;
    prop.comment += "Note: If multiplayer, server-side only.";
    propOrder.add(prop.getName());
    deathLoseMiningPoint = prop.getBoolean(deathLoseMiningPoint);
    prop = generalCfg.get(category, "deathLoseMinerRank", false);
    prop.setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName());
    prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
    prop.comment += " [default: " + prop.getDefault() + "]";
    prop.comment += Configuration.NEW_LINE;
    prop.comment += "Note: If multiplayer, server-side only.";
    propOrder.add(prop.getName());
    deathLoseMinerRank = prop.getBoolean(deathLoseMinerRank);

    if (side.isClient()) {
        prop = generalCfg.get(category, "miningPointRenderType", 0);
        prop.setMinValue(0).setMaxValue(4)
                .setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName())
                .setConfigEntryClass(cycleInteger);
        prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
        prop.comment += " [range: " + prop.getMinValue() + " ~ " + prop.getMaxValue() + ", default: "
                + prop.getDefault() + "]";

        for (int i = Integer.parseInt(prop.getMinValue()); i <= Integer.parseInt(prop.getMaxValue()); ++i) {
            prop.comment += Configuration.NEW_LINE;

            if (i == Integer.parseInt(prop.getMaxValue())) {
                prop.comment += i + ": " + StatCollector.translateToLocal(prop.getLanguageKey() + "." + i);
            } else {
                prop.comment += i + ": " + StatCollector.translateToLocal(prop.getLanguageKey() + "." + i)
                        + ", ";
            }
        }

        propOrder.add(prop.getName());
        miningPointRenderType = MathHelper.clamp_int(prop.getInt(miningPointRenderType),
                Integer.parseInt(prop.getMinValue()), Integer.parseInt(prop.getMaxValue()));
    }

    prop = generalCfg.get(category, "showMinerRank", true);
    prop.setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName());
    prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
    prop.comment += " [default: " + prop.getDefault() + "]";
    prop.comment += Configuration.NEW_LINE;
    prop.comment += "Note: If multiplayer, does not have to match client-side and server-side.";
    propOrder.add(prop.getName());
    showMinerRank = prop.getBoolean(showMinerRank);
    prop = generalCfg.get(category, "miningPoints", new String[0]);
    prop.setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName())
            .setConfigEntryClass(pointsEntry);
    prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
    prop.comment += Configuration.NEW_LINE;
    prop.comment += "Note: If multiplayer, server-side only.";
    propOrder.add(prop.getName());
    miningPoints = prop.getStringList();
    prop = generalCfg.get(category, "miningPointValidItems", new String[0]);
    prop.setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName())
            .setConfigEntryClass(selectItems);
    prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
    propOrder.add(prop.getName());
    miningPointValidItems = prop.getStringList();
    prop = generalCfg.get(category, "randomiteDrops", new String[0]);
    prop.setMaxListLength(500).setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName())
            .setConfigEntryClass(selectItemsWithBlocks);
    prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
    propOrder.add(prop.getName());
    randomiteDrops = prop.getStringList();
    prop = generalCfg.get(category, "randomitePotions", new int[0]);
    prop.setMaxListLength(100).setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName())
            .setConfigEntryClass(selectPotions);
    prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
    propOrder.add(prop.getName());
    randomitePotions = prop.getIntList();

    if (side.isClient()) {
        prop = generalCfg.get(category, "oreRenderOverlay", false);
        prop.setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName());
        prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
        prop.comment += " [default: " + prop.getDefault() + "]";
        propOrder.add(prop.getName());
        oreRenderOverlay = prop.getBoolean(oreRenderOverlay);
        prop = generalCfg.get(category, "fakeMiningPickaxe", false);
        prop.setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName());
        prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
        prop.comment += " [default: " + prop.getDefault() + "]";
        propOrder.add(prop.getName());
        fakeMiningPickaxe = prop.getBoolean(fakeMiningPickaxe);
        prop = generalCfg.get(category, "fakeLumberingAxe", false);
        prop.setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName());
        prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
        prop.comment += " [default: " + prop.getDefault() + "]";
        propOrder.add(prop.getName());
        fakeLumberingAxe = prop.getBoolean(fakeLumberingAxe);
        prop = generalCfg.get(category, "fakeDiggingShovel", false);
        prop.setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName());
        prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
        prop.comment += " [default: " + prop.getDefault() + "]";
        propOrder.add(prop.getName());
        fakeDiggingShovel = prop.getBoolean(fakeDiggingShovel);
        prop = generalCfg.get(category, "fakeFarmingHoe", false);
        prop.setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName());
        prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
        prop.comment += " [default: " + prop.getDefault() + "]";
        propOrder.add(prop.getName());
        fakeFarmingHoe = prop.getBoolean(fakeFarmingHoe);
        prop = generalCfg.get(category, "modeDisplayTime", 2200);
        prop.setMinValue(0).setMaxValue(Integer.MAX_VALUE)
                .setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName());
        prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
        prop.comment += " [range: " + prop.getMinValue() + " ~ " + prop.getMaxValue() + ", default: "
                + prop.getDefault() + "]";
        propOrder.add(prop.getName());
        modeDisplayTime = MathHelper.clamp_int(prop.getInt(modeDisplayTime),
                Integer.parseInt(prop.getMinValue()), Integer.parseInt(prop.getMaxValue()));
    }

    prop = generalCfg.get(category, "quickBreakLimit", 100);
    prop.setMinValue(0).setMaxValue(1000)
            .setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName());
    prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
    prop.comment += " [range: " + prop.getMinValue() + " ~ " + prop.getMaxValue() + ", default: "
            + prop.getDefault() + "]";
    prop.comment += Configuration.NEW_LINE;
    prop.comment += "Note: If multiplayer, server-side only.";
    propOrder.add(prop.getName());
    quickBreakLimit = MathHelper.clamp_int(prop.getInt(quickBreakLimit), Integer.parseInt(prop.getMinValue()),
            Integer.parseInt(prop.getMaxValue()));
    prop = generalCfg.get(category, "portalCache", true);
    prop.setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName());
    prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
    prop.comment += " [default: " + prop.getDefault() + "]";
    prop.comment += Configuration.NEW_LINE;
    prop.comment += "Note: If multiplayer, server-side only.";
    propOrder.add(prop.getName());
    portalCache = prop.getBoolean(portalCache);

    generalCfg.setCategoryPropertyOrder(category, propOrder);

    category = "options";
    propOrder = Lists.newArrayList();

    prop = generalCfg.get(category, "hardcore", false);
    prop.setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName());
    prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
    prop.comment += " [default: " + prop.getDefault() + "]";
    prop.comment += Configuration.NEW_LINE;
    prop.comment += "Note: If multiplayer, server-side only.";
    propOrder.add(prop.getName());
    hardcore = prop.getBoolean(hardcore);
    prop = generalCfg.get(category, "caveborn", 0);
    prop.setMinValue(0).setMaxValue(4).setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName())
            .setConfigEntryClass(cycleInteger);
    prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
    prop.comment += " [range: " + prop.getMinValue() + " ~ " + prop.getMaxValue() + ", default: "
            + prop.getDefault() + "]";

    for (int i = Integer.parseInt(prop.getMinValue()); i <= Integer.parseInt(prop.getMaxValue()); ++i) {
        prop.comment += Configuration.NEW_LINE;

        if (i == Integer.parseInt(prop.getMaxValue())) {
            prop.comment += i + ": " + StatCollector.translateToLocal(prop.getLanguageKey() + "." + i);
        } else {
            prop.comment += i + ": " + StatCollector.translateToLocal(prop.getLanguageKey() + "." + i) + ", ";
        }
    }

    prop.comment += Configuration.NEW_LINE;
    prop.comment += "Note: If multiplayer, server-side only.";
    propOrder.add(prop.getName());
    caveborn = MathHelper.clamp_int(prop.getInt(caveborn), Integer.parseInt(prop.getMinValue()),
            Integer.parseInt(prop.getMaxValue()));
    boolean flag = !generalCfg.getCategory(category).containsKey("cavebornItems");
    prop = generalCfg.get(category, "cavebornItems", new String[0]);
    prop.setMaxListLength(36).setLanguageKey(Caveworld.CONFIG_LANG + category + '.' + prop.getName())
            .setConfigEntryClass(selectItemsWithBlocks);
    prop.comment = StatCollector.translateToLocal(prop.getLanguageKey() + ".tooltip");
    propOrder.add(prop.getName());
    cavebornItems = prop.getStringList();

    if (flag) {
        List<ItemStack> items = Lists.newArrayList();

        items.add(new ItemStack(Items.stone_pickaxe));
        items.add(new ItemStack(Items.stone_sword));
        items.add(new ItemStack(Blocks.torch));
        items.add(new ItemStack(Items.bread));

        for (int i = 0; i < 3; ++i) {
            items.add(new ItemStack(CaveBlocks.perverted_sapling, 1, i));
        }

        items.add(new ItemStack(Blocks.crafting_table));
        items.add(new ItemStack(Blocks.dirt));
        items.add(new ItemStack(CaveItems.acresia));

        cavebornItems = ConfigHelper.getStringsFromItems(items);
        prop.set(cavebornItems);
    }

    generalCfg.setCategoryPropertyOrder(category, propOrder);

    saveConfig(generalCfg);
}

From source file:br.bireme.mlts.MoreLikeThatServlet.java

/**
 * Processes requests for both HTTP/* w ww .j a v  a  2 s. co  m*/
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest2(final HttpServletRequest request, final HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("application/json; charset=UTF-8");
    PrintWriter out = response.getWriter();

    try {
        final String content = request.getParameter("content");
        final String fieldsName = request.getParameter("fieldsName");
        final String getDocument = request.getParameter("getDocument");

        if (content == null) {
            throw new ServletException("missing 'content' parameter");
        }
        if (fieldsName == null) {
            throw new ServletException("missing 'fieldsName' parameter");
        }
        final String[] fldsName = fieldsName.trim().split(" *, *");
        final boolean getDocContent = (getDocument == null) ? false : Boolean.parseBoolean(getDocument);
        final StringReader reader = new StringReader(content);
        final TreeSet<MoreLikeThat.DocX> docs = mlt.moreLikeThat(reader, fldsName, getDocContent);
        final int size = docs.size();
        int cur = 0;

        if (size == 1) {
            out.println("{");
        } else {
            out.println("{ [");
        }
        for (MoreLikeThat.DocX doc : docs) {
            final List<String> _ids = doc.doc.get("id");
            final String _id = ((_ids == null) || (_ids.isEmpty()) ? Integer.toString(doc.id) : _ids.get(0));
            out.print("    {\"id\" : ");
            out.print(_id);
            out.print(", \"score\" : ");
            out.print(Float.toString(doc.qscore));
            if (getDocContent) {
                final int msize = doc.doc.size();
                int mcur = 0;

                out.print(", \"doc\" : {");
                for (Map.Entry<String, List<String>> entry : doc.doc.entrySet()) {
                    final List<String> list = entry.getValue();
                    final int lSize = list.size();
                    int lcur = 0;

                    out.print("\"");
                    out.print(entry.getKey());
                    out.print("\" : ");
                    if (lSize > 1) {
                        out.print("[");
                    }
                    for (String con : list) {
                        out.print("\"");
                        out.print(con);
                        out.print("\"");
                        if (++lcur < lSize) {
                            out.print(", ");
                        }
                    }
                    if (lSize > 1) {
                        out.print("]");
                    }
                    if (++mcur < msize) {
                        out.print(", ");
                    }
                }
                out.print("}");
            }
            if (++cur < size) {
                out.println("},");
            } else {
                out.println("}");
            }
        }
        if (size == 1) {
            out.println("}");
        } else {
            out.println("] }");
        }
    } finally {
        out.close();
    }
}

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

private static String valueToString(double v, int exponent) {
    if (exponent != 0) {
        final float vm = (float) (v * FastMath.pow(10D, -exponent));
        if (vm != 0.0F)
            return Float.toString(vm) + 'e' + exponent;
    }/*from w  w w .  j  a va  2  s  .c o m*/
    return Float.toString((float) v);
}

From source file:org.deegree.tools.rendering.manager.buildings.BuildingManager.java

private List<WorldRenderableObject> readVRML(String fileName, CommandLine commandLine) throws IOException {
    Map<String, String> params = new HashMap<String, String>();
    String id = buildingID;//from  ww  w .  j a v a  2 s  . c  o  m
    if (buildingID == null) {
        id = FileUtils.getFilename(new File(fileName));
        id = id.replaceAll("\\s", "_");
    }
    params.put("id", id);
    if (textureDir != null) {
        params.put(VRMLImporter.TEX_DIR, textureDir.getAbsolutePath());
    }

    String value = commandLine.getOptionValue(DataManager.OPT_VRML_TRANSLATION_X);
    if (value != null) {
        float x = Float.parseFloat(value);
        float rX = (float) (x + wpvsTranslationVector[0]);
        params.put(VRMLImporter.XTRANS, Float.toString(rX));
    }

    value = commandLine.getOptionValue(DataManager.OPT_VRML_TRANSLATION_Y);
    if (value != null) {
        float y = Float.parseFloat(value);
        float rY = (float) (y + wpvsTranslationVector[1]);
        params.put(VRMLImporter.YTRANS, Float.toString(rY));
    }

    value = commandLine.getOptionValue(DataManager.OPT_VRML_TRANSLATION_Z);
    if (value != null) {
        float z = Float.parseFloat(value);
        float rZ = z;
        params.put(VRMLImporter.ZTRANS, Float.toString(rZ));
    }

    boolean flip = commandLine.hasOption(DataManager.OPT_VRML_FLIP_Y_Z);
    params.put(VRMLImporter.INV_YZ, (flip ? "y" : "n"));

    value = commandLine.getOptionValue(DataManager.OPT_VRML_ROTATION_AXIS);
    if (value != null) {
        params.put(VRMLImporter.ROT_ANGLE, value);
    }

    params.put(VRMLImporter.MAX_TEX_DIM, commandLine.getOptionValue(DataManager.OPT_VRML_MAX_TEX_DIM));

    VRMLImporter exp = new VRMLImporter(params);
    List<WorldRenderableObject> lwro = exp.importFromFile(fileName, numberOfqualityLevels, qualityLevel);
    return lwro;
}