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:org.ecoinformatics.seek.datasource.darwincore.DarwinCoreDataSource.java

/**
 * Checks for a valid string for a numerical type, empty is NOT valid if not
 * valid then return the MAX_VALUE for the number
 * /*from   w w  w .j  a va 2  s  .c o m*/
 * @param aValue
 *            the value to be checked
 * @param aType
 *            the type of number it is
 * @return the new value
 */
private String getValidStringValueForType(String aValue, String aType) {
    String valueStr = aValue;
    Integer iVal = (Integer) mType2IntHash.get(aType);
    switch (iVal.intValue()) {
    case 0:
        try {
            Integer.parseInt(aValue);
        } catch (Exception e) {
            valueStr = Integer.toString(Integer.MAX_VALUE);
        }
        break;

    case 1:
        try {
            Float.parseFloat(aValue);
        } catch (Exception e) {
            valueStr = Float.toString(Float.MAX_VALUE);
        }
        break;

    case 2:
        try {
            Double.parseDouble(aValue);
        } catch (Exception e) {
            valueStr = Double.toString(Double.MAX_VALUE);
        }
        break;

    case 3:
        try {
            Long.parseLong(aValue);
        } catch (Exception e) {
            valueStr = Long.toString(Long.MAX_VALUE);
        }
        break;

    case 4:
        // no-op
        break;
    }
    return valueStr;
}

From source file:org.piwik.SimplePiwikTracker.java

/**
 * Returns the uery part for the url with all parameters from all given informations set to this tracker. This
 * function is called in the defined URL for the tacking purpose.
 * /*  w w  w . ja  v a 2s  .c  o  m*/
 * @return the query part for the URL as string object
 */
public final String getGeneralQuery() {
    final URL rootURL = this.apiurl;
    final String rootQuery = rootURL.getQuery();

    final String eventCategory = this.addParameter(rootQuery, "e_c", this.eventCategory);
    final String eventAction = this.addParameter(eventCategory, "e_a", this.eventAction);
    final String eventName = this.addParameter(eventAction, "e_n", this.eventName);
    String value = null;
    if (this.eventValue != null) {
        value = Float.toString(this.eventValue);
    }
    final String eventValue = this.addParameter(eventName, "e_v", value);

    final String withIdsite = this.addParameter(eventValue, "idsite", this.idSite);
    final String withRec = this.addParameter(withIdsite, "rec", 1); // what ever this is
    final String withApiVersion = this.addParameter(withRec, "apiv", SimplePiwikTracker.VERSION);
    final String withURL = this.addParameter(withApiVersion, "url", this.pageUrl);
    final String withURLReferrer = this.addParameter(withURL, "urlref", this.urlReferrer);
    final String withVisitorId = this.addParameter(withURLReferrer, "_id", this.visitorId);
    final String withReferrer = this.addParameter(withVisitorId, "ref", this.urlReferrer);
    final String withReferrerForcedTimestamp = this.addParameter(withReferrer, "_refts", this.forcedDatetime);
    final String withIp = this.addParameter(withReferrerForcedTimestamp, "cip", this.ip);
    final String withForcedTimestamp = this.addParameter(withIp, "cdt",
            forcedDatetime == null ? null : new SimpleDateFormat("yyyyMMdd HH:mm:ssZ").format(forcedDatetime));
    final String withAuthtoken = this.addParameter(withForcedTimestamp, "token_auth", this.tokenAuth);
    String withPlugins = withAuthtoken;
    for (final Map.Entry<BrowserPlugins, Boolean> entry : this.plugins.entrySet()) {
        withPlugins = this.addParameter(withPlugins, entry.getKey().toString(), entry.getValue());
    }
    final String withLocalTime;
    if (this.localTime == null) {
        withLocalTime = withPlugins;
    } else {
        final Calendar c = new GregorianCalendar();
        c.setTime(this.localTime);
        final String withHour = this.addParameter(withPlugins, "h", c.get(Calendar.HOUR_OF_DAY));
        final String withMinute = this.addParameter(withHour, "m", c.get(Calendar.MINUTE));
        withLocalTime = this.addParameter(withMinute, "s", c.get(Calendar.SECOND));
    }
    final String withResolution;
    if (this.width > 0 && this.height > 0) {
        withResolution = this.addParameter(withLocalTime, "res", this.width + "x" + this.height);
    } else {
        withResolution = withLocalTime;
    }
    final String withCookieInfo = this.addParameter(withResolution, "cookie", this.requestCookie != null);
    final String withVisitorCustomData = this.addParameter(withCookieInfo, "data", this.visitorCustomData);

    /* ADD VISITOR CUSTOM VARIABLES */

    final String withVisitorCustomVar;
    if (this.visitorCustomVar.isEmpty()) {
        withVisitorCustomVar = withVisitorCustomData;
    } else {
        final Map<String, List<String>> customVariables = new HashMap<String, List<String>>();
        int i = 0;
        for (final Map.Entry<String, String> entry : this.visitorCustomVar.entrySet()) {
            i++;
            final List<String> list = new ArrayList<String>();
            list.add(entry.getKey());
            list.add(entry.getValue());
            customVariables.put(Integer.toString(i), list);
        }

        final JSONArray json = new JSONArray();
        json.put(customVariables);

        // remove unnecessary parent square brackets from JSON-string
        String jsonString = json.toString().substring(1, json.toString().length() - 1);

        // visitor custom variables: _cvar
        withVisitorCustomVar = this.addParameter(withVisitorCustomData, "_cvar", jsonString);
    }

    /* ADD PAGE CUSTOM VARIABLES */

    final String withPageCustomData = this.addParameter(withVisitorCustomVar, "data", this.pageCustomData);
    final String withPageCustomVar;
    if (this.pageCustomVar.isEmpty()) {
        withPageCustomVar = withPageCustomData;
    } else {
        final Map<String, List<String>> customVariables = new HashMap<String, List<String>>();
        int i = 0;
        for (final Map.Entry<String, String> entry : this.pageCustomVar.entrySet()) {
            i++;
            final List<String> list = new ArrayList<String>();
            list.add(entry.getKey());
            list.add(entry.getValue());
            customVariables.put(Integer.toString(i), list);
        }

        final JSONArray json = new JSONArray();
        json.put(customVariables);

        // remove unnecessary parent square brackets from JSON-string
        String jsonString = json.toString().substring(1, json.toString().length() - 1);

        // page custom variables: cvar
        withPageCustomVar = this.addParameter(withPageCustomData, "cvar", jsonString);
    }

    final String withRand = this.addParameter(withPageCustomVar, "r",
            String.valueOf(random.nextDouble()).substring(2, 8));
    return (withRand + this.debugAppendUrl);
}

From source file:co.foldingmap.mapImportExport.SvgExporter.java

private void writePath(BufferedWriter outputStream, String id, CoordinateList<Coordinate> coordinates,
        ColorStyle style, boolean closePath) {

    Coordinate c;/* www  .j a va 2 s.  c  o m*/
    String styleString;

    try {
        styleString = generateStyleString(style);

        outputStream.write(getIndent());
        outputStream.write("<path\n");
        addIndent();

        outputStream.write(getIndent());
        outputStream.write("style=\"");
        outputStream.write(styleString);
        outputStream.write("\"\n");

        //write out points
        outputStream.write(getIndent());
        outputStream.write("d=\"M ");

        for (int i = 0; i < coordinates.size(); i++) {
            c = coordinates.get(i);

            if (i > 0) {
                outputStream.write("L ");
            }

            outputStream.write(Float.toString(c.getCenterPoint().x));
            outputStream.write(" ");
            outputStream.write(Float.toString(c.getCenterPoint().y));

            if (i + 1 < coordinates.size())
                outputStream.write(" ");
        }

        if (closePath)
            outputStream.write(" Z");

        outputStream.write("\"\n");

        //write out id
        outputStream.write(getIndent());
        outputStream.write("id=\"");
        outputStream.write(id);
        outputStream.write("\"");

        //close tag
        outputStream.write(" />\n");
        removeIndent();
    } catch (Exception e) {
        Logger.log(Logger.ERR,
                "Error in SvgExporter.writePath(BufferedWriter, String, CoordinateList, ColorStyle - " + e);
    }
}

From source file:org.apache.hadoop.mapreduce.TestMapCollection.java

@Test
public void testRandomCompress() throws Exception {
    Configuration conf = new Configuration();
    conf.setInt(Job.COMPLETION_POLL_INTERVAL_KEY, 100);
    Job job = Job.getInstance(conf);/*from   w ww  .ja  v a 2s .c  o  m*/
    conf = job.getConfiguration();
    conf.setInt(MRJobConfig.IO_SORT_MB, 1);
    conf.setBoolean(MRJobConfig.MAP_OUTPUT_COMPRESS, true);
    conf.setClass("test.mapcollection.class", RandomFactory.class, RecordFactory.class);
    final Random r = new Random();
    final long seed = r.nextLong();
    LOG.info("SEED: " + seed);
    r.setSeed(seed);
    conf.set(MRJobConfig.MAP_SORT_SPILL_PERCENT, Float.toString(Math.max(0.1f, r.nextFloat())));
    RandomFactory.setLengths(conf, r, 1 << 14);
    conf.setInt("test.spillmap.records", r.nextInt(500));
    conf.setLong("test.randomfactory.seed", r.nextLong());
    runTest("randomCompress", job);
}

From source file:org.canova.api.conf.Configuration.java

/**
 * Set the value of the <code>name</code> property to a <code>float</code>.
 *
 * @param name property name./*from   w  w  w  . j  ava 2 s  .  co m*/
 * @param value property value.
 */
public void setFloat(String name, float value) {
    set(name, Float.toString(value));
}

From source file:erigo.ctstream.CTstream.java

/**
 * //from  w ww  . java2 s. c  o m
 * CTstream constructor
 * 
 * @param argsI  Command line arguments
 */
public CTstream(String[] argsI) {

    // Create a String version of FPS_VALUES
    String FPS_VALUES_STR = new String(FPS_VALUES[0].toString());
    for (int i = 1; i < FPS_VALUES.length; ++i) {
        FPS_VALUES_STR = FPS_VALUES_STR + "," + FPS_VALUES[i].toString();
    }

    // Create a String version of CTsettings.flushIntervalLongs
    String FLUSH_VALUES_STR = String.format("%.1f", CTsettings.flushIntervalLongs[0] / 1000.0);
    for (int i = 1; i < CTsettings.flushIntervalLongs.length; ++i) {
        // Except for the first flush value (handled above, first item in the string) the rest of these
        // are whole numbers, so we will print them out with no decimal places
        FLUSH_VALUES_STR = FLUSH_VALUES_STR + ","
                + String.format("%.0f", CTsettings.flushIntervalLongs[i] / 1000.0);
    }

    //
    // Parse command line arguments
    //
    // 1. Setup command line options
    //
    Options options = new Options();
    // Boolean options (only the flag, no argument)
    options.addOption("h", "help", false, "Print this message.");
    options.addOption("nm", "no_mouse_cursor", false,
            "Don't include mouse cursor in output screen capture images.");
    options.addOption("nz", "no_zip", false, "Turn off ZIP output.");
    options.addOption("x", "debug", false, "Turn on debug output.");
    options.addOption("cd", "change_detect", false, "Save only changed images.");
    options.addOption("fs", "full_screen", false, "Capture the full screen.");
    options.addOption("p", "preview", false, "Display live preview image");
    options.addOption("T", "UI_on_top", false, "Keep CTstream on top of all other windows.");
    options.addOption("sc", "screencap", false, "Capture screen images");
    options.addOption("w", "webcam", false, "Capture webcam images");
    options.addOption("a", "audio", false, "Record audio.");
    options.addOption("t", "text", false, "Capture text.");

    // Command line options that include a flag
    // For example, the following will be for "-outputfolder <folder>   (Location of output files...)"
    Option option = Option.builder("o").longOpt("outputfolder").argName("folder").hasArg()
            .desc("Location of output files (source is created under this folder); default = \"" + outputFolder
                    + "\".")
            .build();
    options.addOption(option);
    option = Option.builder("fps").argName("framespersec").hasArg().desc(
            "Image rate (images/sec); default = " + DEFAULT_FPS + "; accepted values = " + FPS_VALUES_STR + ".")
            .build();
    options.addOption(option);
    option = Option.builder("f").argName("autoFlush").hasArg()
            .desc("Flush interval (sec); amount of data per block; default = "
                    + Double.toString(AUTO_FLUSH_DEFAULT) + "; accepted values = " + FLUSH_VALUES_STR + ".")
            .build();
    options.addOption(option);
    option = Option.builder("s").argName("source name").hasArg()
            .desc("Name of output source; default = \"" + sourceName + "\".").build();
    options.addOption(option);
    option = Option.builder("sc_chan").argName("screencap_chan_name").hasArg()
            .desc("Screen capture image channel name (must end in \".jpg\" or \".jpeg\"); default = \""
                    + screencapStreamName + "\".")
            .build();
    options.addOption(option);
    option = Option.builder("webcam_chan").argName("webcam_chan_name").hasArg()
            .desc("Web camera image channel name (must end in \".jpg\" or \".jpeg\"); default = \""
                    + webcamStreamName + "\".")
            .build();
    options.addOption(option);
    option = Option.builder("audio_chan").argName("audio_chan_name").hasArg()
            .desc("Audio channel name (must end in \".wav\"); default = \"" + audioStreamName + "\".").build();
    options.addOption(option);
    option = Option.builder("text_chan").argName("text_chan_name").hasArg()
            .desc("Text channel name (must end in \".txt\"); default = \"" + textStreamName + "\".").build();
    options.addOption(option);
    option = Option.builder("q").argName("imagequality").hasArg()
            .desc("Image quality, 0.00 - 1.00 (higher numbers are better quality); default = "
                    + Float.toString(imageQuality) + ".")
            .build();
    options.addOption(option);

    //
    // 2. Parse command line options
    //
    CommandLineParser parser = new DefaultParser();
    CommandLine line = null;
    try {
        line = parser.parse(options, argsI);
    } catch (ParseException exp) {
        // oops, something went wrong
        System.err.println("Command line argument parsing failed: " + exp.getMessage());
        return;
    }

    //
    // 3. Retrieve the command line values
    //
    if (line.hasOption("help")) {
        // Display help message and quit
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(160);
        formatter.printHelp("CTstream", options);
        System.exit(0);
    }
    bPreview = line.hasOption("preview");
    bScreencap = line.hasOption("screencap");
    bWebcam = line.hasOption("webcam");
    bAudio = line.hasOption("audio");
    bText = line.hasOption("text");
    // Source name
    sourceName = line.getOptionValue("s", sourceName);
    // Where to write the files to
    outputFolder = line.getOptionValue("outputfolder", outputFolder);
    // Channel names; check filename extensions
    screencapStreamName = line.getOptionValue("sc_chan", screencapStreamName);
    webcamStreamName = line.getOptionValue("webcam_chan", webcamStreamName);
    audioStreamName = line.getOptionValue("audio_chan", audioStreamName);
    textStreamName = line.getOptionValue("text_chan", textStreamName);
    try {
        checkFilenames();
    } catch (Exception e) {
        System.err.println(e.getMessage());
        return;
    }
    // Auto-flush time
    try {
        double autoFlush = Double.parseDouble(line.getOptionValue("f", "" + AUTO_FLUSH_DEFAULT));
        flushMillis = (long) (autoFlush * 1000.);
        boolean bGotMatch = false;
        for (int i = 0; i < CTsettings.flushIntervalLongs.length; ++i) {
            if (flushMillis == CTsettings.flushIntervalLongs[i]) {
                bGotMatch = true;
                break;
            }
        }
        if (!bGotMatch) {
            throw new NumberFormatException("bad input value");
        }
    } catch (NumberFormatException nfe) {
        System.err.println("\nAuto flush time must be one of the following values: " + FLUSH_VALUES_STR);
        return;
    }
    // ZIP output files? (the only way to turn off ZIP is using this command line flag)
    bZipMode = !line.hasOption("no_zip");
    // Include cursor in output screen capture images?
    bIncludeMouseCursor = !line.hasOption("no_mouse_cursor");
    // How many frames (screen or webcam images) to capture per second
    try {
        framesPerSec = Double.parseDouble(line.getOptionValue("fps", "" + DEFAULT_FPS));
        if (framesPerSec <= 0.0) {
            throw new NumberFormatException("value must be greater than 0.0");
        }
        // Make sure framesPerSec is one of the accepted values
        Double userVal = framesPerSec;
        if (!Arrays.asList(FPS_VALUES).contains(userVal)) {
            throw new NumberFormatException(new String("framespersec value must be one of: " + FPS_VALUES_STR));
        }
    } catch (NumberFormatException nfe) {
        System.err.println(
                "\nError parsing \"fps\"; it must be one of the accepted floating point values:\n" + nfe);
        return;
    }
    // Run CT in debug mode?
    bDebugMode = line.hasOption("debug");
    // changeDetect mode? MJM
    bChangeDetect = line.hasOption("change_detect");
    // Capture the full screen?
    bFullScreen = line.hasOption("full_screen");
    // Keep CTstream UI on top of all other windows?
    bStayOnTop = line.hasOption("UI_on_top");
    // Image quality
    String imageQualityStr = line.getOptionValue("q", "" + imageQuality);
    try {
        imageQuality = Float.parseFloat(imageQualityStr);
        if ((imageQuality < 0.0f) || (imageQuality > 1.0f)) {
            throw new NumberFormatException("");
        }
    } catch (NumberFormatException nfe) {
        System.err.println("\nimage quality must be a number in the range 0.0 <= x <= 1.0");
        return;
    }

    //
    // Specify a shutdown hook to catch Ctrl+c
    //
    final CTstream temporaryCTS = this;
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            if (bCallExitFromShutdownHook) {
                temporaryCTS.exit(true);
            }
        }
    });

    // For now, we are going to assume that shaped windows (PERPIXEL_TRANSPARENT) are supported.
    // For a discussion of translucent and shaped windows see https://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html
    // This includes examples on how to check if TRANSLUCENT and PERPIXEL_TRANSPARENT are supported by the graphics.
    // For thread safety: Schedule a job for the event-dispatching thread to create and show the GUI
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            temporaryCTS.createAndShowGUI(true);
        }
    });

}

From source file:net.sbbi.upnp.messages.ActionMessage.java

/**
 * Set the value of an input parameter before a message service call
 * @param parameterName the parameter name
 * @param parameterValue the float parameter value
 * @return the current ActionMessage object instance
 * @throws IllegalArgumentException if the provided parameterName is not valid for this message
 *         or if no input parameters are required for this message
 *//* w ww  . j av a  2s.  co m*/
public ActionMessage setInputParameter(String parameterName, float parameterValue)
        throws IllegalArgumentException {
    return setInputParameter(parameterName, Float.toString(parameterValue));
}

From source file:com.rnd.snapsplit.view.OwedFragment.java

public void onPurchased(boolean withFingerprint, @Nullable FingerprintManager.CryptoObject cryptoObject,
        final PaymentRequest pr) {
    if (withFingerprint) {
        // If the user has authenticated with fingerprint, verify that using cryptography and
        // then show the confirmation message.
        assert cryptoObject != null;
        tryEncrypt(cryptoObject.getCipher());
    } else {// ww  w .ja  va  2 s.com
        // Authentication happened with backup password. Just show the confirmation message.
        //showConfirmation(null);
    }
    // Citi API doesn't work as the five fake accounts all belong to the same person
    // cannot see the updated balance on the other person and also the transaction amount is somehow wrong
    //                (new CitiAPIBase(getContext())).API_MoneyMovement_CreateInternalTransfer(
    //                        "355a515030616a53576b6a65797359506a634175764a734a3238314e4668627349486a676f7449463949453d"
    //                        , Float.toString(pr.getShareAmount()), "SOURCE_ACCOUNT_CURRENCY"
    //                        , "7977557255484c7345546c4e53424766634b6c53756841672b556857626e395253334b70416449676b42673d"
    //                        , "BENEFICIARY", "123456", pr.getDescription(), "MEDICAL_SERVICES", this, pr);
    //
    Toast.makeText(getActivity(), "Payment to " + pr.getRequestorName() + " successful!", Toast.LENGTH_LONG)
            .show();

    // set account balance, "I" paid here so I am the receipt of the request
    FirebaseDatabase.getInstance().getReference().child(pr.getRequestorPhoneNumber())
            .addListenerForSingleValueEvent(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot snapshot) {
                    String updatedRequestorBalance = Float.toString(Float.valueOf(
                            (String) ((HashMap<String, String>) snapshot.getValue()).get("accountBalance"))
                            + pr.getShareAmount());
                    FirebaseDatabase.getInstance().getReference().child(pr.getRequestorPhoneNumber())
                            .child("accountBalance").setValue(updatedRequestorBalance);
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {
                }
            });
    FirebaseDatabase.getInstance().getReference().child(pr.getReceipientPhoneNo())
            .addListenerForSingleValueEvent(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot snapshot) {
                    String updatedRecipientBalance = Float.toString(Float.valueOf(
                            (String) ((HashMap<String, String>) snapshot.getValue()).get("accountBalance"))
                            - pr.getShareAmount());
                    FirebaseDatabase.getInstance().getReference().child(pr.getReceipientPhoneNo())
                            .child("accountBalance").setValue(updatedRecipientBalance);
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {
                }
            });

    // remove the request so that it becomes paid
    mFirebaseDatabaseReference.child(pr.getId()).removeValue();

    // set history
    (new History(getContext())).setPaymentHistory(pr);
    (new History(getContext())).setFriendReceivePaymentHistory(pr);
}

From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java

private void UpdateEntryForm() {
    List<Record> records = this.recordService.GetAllEntitiesByKeyAndRecord(RecordKey.ALL,
            this.currentEntry.getId());
    //load images
    if (currentEntry.getMouldId().getImageBoreA() != null) {
        AppHelper.DisplayImage(currentEntry.getMouldId().getImageBoreA(), this.pnlBoreImage1, 75);
    } else {/*from ww  w.ja  v  a  2 s  .  co m*/
        AppHelper.DisplayImageFromResource("/b1.png", this.pnlBoreImage1, 75);
    }
    if (currentEntry.getMouldId().getImageBoreB() != null) {
        AppHelper.DisplayImage(currentEntry.getMouldId().getImageBoreB(), this.pnlBoreImage2, 75);
    } else {
        AppHelper.DisplayImageFromResource("/b2.png", this.pnlBoreImage2, 75);
    }
    if (currentEntry.getMouldId().getImageNeck() != null) {
        AppHelper.DisplayImage(currentEntry.getMouldId().getImageNeck(), this.pnlNeckImage, 75);
    } else {
        AppHelper.DisplayImageFromResource("/b3.png", this.pnlNeckImage, 75);
    }
    if (currentEntry.getMouldId().getImageTap() != null) {
        AppHelper.DisplayImage(currentEntry.getMouldId().getImageTap(), this.pnlTapImage, 75);
    } else {
        AppHelper.DisplayImageFromResource("/no_photo_small.png", this.pnlTapImage, 75);
    }
    if (currentEntry.getProductId().getDgnondg() != null && currentEntry.getProductId().getDgnondg() == 0) {
        if (currentEntry.getMouldId().getImageDg() != null) {
            AppHelper.DisplayImage(currentEntry.getMouldId().getImageDg(), this.pnlWallImage, 75);
        } else {
            AppHelper.DisplayImageFromResource("/no_photo_small.png", this.pnlWallImage, 75);
        }
    } else {
        if (currentEntry.getMouldId().getImageNonDg() != null) {
            AppHelper.DisplayImage(currentEntry.getMouldId().getImageNonDg(), this.pnlWallImage, 75);
        } else {
            AppHelper.DisplayImageFromResource("/no_photo_small.png", this.pnlWallImage, 75);
        }
    }
    //info
    UpdateProductInfo(this.currentEntry);
    //weight
    this.labWeightStaff.setVisible(false);
    this.txtWeightStaff.setVisible(false);
    datasetWeight = new DefaultCategoryDataset();

    List<Record> recordsWeight = records.stream().filter(x -> x.getRecordKey().equals("PRODUCT_WEIGHT"))
            .collect(Collectors.toList());
    DefaultTableModel modelWeight = (DefaultTableModel) this.tblWeight.getModel();
    modelWeight.setRowCount(0);
    for (Record record : recordsWeight) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        datasetWeight.addValue(record.getNumberValue(), "Weight", time);
        modelWeight.addRow(new Object[] { time, record.getNumberValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblWeight.getModel()).fireTableDataChanged();
    JFreeChart chartWeight = ChartFactory.createLineChart("Product Weight (grams)", "", "", datasetWeight,
            PlotOrientation.VERTICAL, false, true, false);
    ChartPanel cpWeight = new ChartPanel(chartWeight);
    this.pnlChartWeight.removeAll();
    this.pnlChartWeight.add(cpWeight, gridBagConstraints);
    //wall
    List<Record> recordsWall = records.stream().filter(x -> x.getRecordKey().startsWith("WALL_"))
            .collect(Collectors.toList());
    DefaultTableModel modelWall = (DefaultTableModel) this.tblWall.getModel();
    modelWall.setRowCount(0);
    for (Record record : recordsWall) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        String name = record.getRecordKey();
        modelWall.addRow(new Object[] { time, name, record.getNumberValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblWall.getModel()).fireTableDataChanged();
    //Tap
    datasetTap = new DefaultCategoryDataset();

    List<Record> recordsTap = records.stream().filter(x -> x.getRecordKey().equals("TAP_POSITION"))
            .collect(Collectors.toList());
    DefaultTableModel modelTap = (DefaultTableModel) this.tblTap.getModel();
    modelTap.setRowCount(0);
    for (Record record : recordsTap) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        datasetTap.addValue(record.getNumberValue(), "Tap", time);
        modelTap.addRow(new Object[] { time, record.getStringValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblTap.getModel()).fireTableDataChanged();
    JFreeChart chartTap = ChartFactory.createLineChart("Tap Positio", "", "", datasetTap,
            PlotOrientation.VERTICAL, false, true, false);
    ChartPanel cpTap = new ChartPanel(chartTap);
    this.pnlChartTap.removeAll();
    this.pnlChartTap.add(cpTap, gridBagConstraints);
    //Bore
    List<Record> recordsBore = records.stream().filter(x -> x.getRecordKey().startsWith("THREAD_"))
            .collect(Collectors.toList());
    DefaultTableModel modelBore = (DefaultTableModel) this.tblBore.getModel();
    modelBore.setRowCount(0);
    for (Record record : recordsBore) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        String name = record.getRecordKey();
        modelBore.addRow(new Object[] { time, name, record.getNumberValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblBore.getModel()).fireTableDataChanged();
    if (this.currentEntry.getProductId() != null
            && this.currentEntry.getProductId().getClosureType().equals("TWIN")) {
        this.txtBore11.setVisible(true);
        this.txtBore21.setVisible(true);
        this.txtNeck1.setVisible(true);
        this.txtBoreStaff1.setVisible(true);
        this.btnBore1.setVisible(true);
    } else {
        this.txtBore11.setVisible(false);
        this.txtBore21.setVisible(false);
        this.txtNeck1.setVisible(false);
        this.txtBoreStaff1.setVisible(false);
        this.btnBore1.setVisible(false);
    }
    //Check
    List<Record> recordsCheck = records.stream().filter(x -> x.getRecordKey().startsWith("CHECK_"))
            .collect(Collectors.toList());
    DefaultTableModel modelCheck = (DefaultTableModel) this.tblCheck.getModel();
    modelCheck.setRowCount(0);
    for (Record record : recordsCheck) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        String name = record.getRecordKey();
        modelCheck.addRow(new Object[] { time, name, record.getStringValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblCheck.getModel()).fireTableDataChanged();
    //Drop
    List<Record> recordsDrop = records.stream().filter(x -> x.getRecordKey().startsWith("DROP_"))
            .collect(Collectors.toList());
    DefaultTableModel modelDrop = (DefaultTableModel) this.tblDrop.getModel();
    modelDrop.setRowCount(0);
    for (Record record : recordsDrop) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String name = record.getRecordKey();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        modelDrop.addRow(new Object[] { time, name, record.getStringValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblDrop.getModel()).fireTableDataChanged();
    //Bung
    List<Record> recordsBung = records.stream().filter(x -> x.getRecordKey().equals("BUNG"))
            .collect(Collectors.toList());
    DefaultTableModel modelBung = (DefaultTableModel) this.tblBung.getModel();
    modelBung.setRowCount(0);
    for (Record record : recordsBung) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        modelBung.addRow(new Object[] { time, record.getStringValue(), pass, staff });
    }
    //Cycle
    List<Record> recordsCycle = records.stream().filter(x -> x.getRecordKey().equals("CYCLE"))
            .collect(Collectors.toList());
    DefaultTableModel modelCycle = (DefaultTableModel) this.tblCycle.getModel();
    modelCycle.setRowCount(0);
    for (Record record : recordsCycle) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        modelCycle.addRow(new Object[] { time, record.getStringValue(), staff });
    }
    //Seconds
    float totalSeconds = 0f;
    List<Record> recordsSeconds = records.stream().filter(x -> x.getRecordKey().equals("SECONDS"))
            .collect(Collectors.toList());
    DefaultTableModel modelSeconds = (DefaultTableModel) this.tblSeconds.getModel();
    modelSeconds.setRowCount(0);
    for (Record record : recordsSeconds) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        modelSeconds.addRow(new Object[] { time, record.getNumberValue() });
        totalSeconds += record.getNumberValue();
    }
    this.labSecondsTotal.setText(Float.toString(totalSeconds));
    //Rejects
    float totalRejects = 0f;
    List<Record> recordsRejects = records.stream().filter(x -> x.getRecordKey().equals("REJECTS"))
            .collect(Collectors.toList());
    DefaultTableModel modelRejects = (DefaultTableModel) this.tblRejects.getModel();
    modelRejects.setRowCount(0);
    for (Record record : recordsRejects) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        modelRejects.addRow(new Object[] { time, record.getNumberValue() });
        totalRejects += record.getNumberValue();
    }
    this.labRejectsTotal.setText(Float.toString(totalRejects));
    //material
    this.FillPolymerComboBox(this.cbProductPolymer, 0);
    this.FillAdditiveComboBox(this.cbProductAdditive1, 0);
    this.FillAdditiveComboBox(this.cbProductAdditive2, 0);
    this.FillAdditiveComboBox(this.cbProductAdditive3, 0);
    DefaultTableModel modelMaterial = (DefaultTableModel) this.tblMaterial.getModel();
    modelMaterial.setRowCount(0);
    if (currentEntry.getMaterial() != null && !currentEntry.getMaterial().equals("")) {
        FillMaterialTable(currentEntry.getMaterial());
    }
    txtPolymerBatchA.setText("");
    txtPolymerBatchB.setText("");
    txtAdditiveABatchA.setText("");
    txtAdditiveBBatchA.setText("");
    txtAdditiveCBatchA.setText("");
    txtAdditiveABatchB.setText("");
    txtAdditiveBBatchB.setText("");
    txtAdditiveCBatchB.setText("");
    //staff
    this.FillStaffComboBox(this.cbSupervisor1,
            currentEntry.getSupervisor1() != null ? currentEntry.getSupervisor1().getId() : 0, "SUPERVISOR");
    this.FillStaffComboBox(this.cbSupervisor2,
            currentEntry.getSupervisor2() != null ? currentEntry.getSupervisor2().getId() : 0, "SUPERVISOR");
    this.FillStaffComboBox(this.cbSupervisor3,
            currentEntry.getSupervisor3() != null ? currentEntry.getSupervisor3().getId() : 0, "SUPERVISOR");
    this.FillStaffComboBox(this.cbTechnician1,
            currentEntry.getTechnician1() != null ? currentEntry.getTechnician1().getId() : 0, "TECHNICIAN");
    this.FillStaffComboBox(this.cbTechnician2,
            currentEntry.getTechnician2() != null ? currentEntry.getTechnician2().getId() : 0, "TECHNICIAN");
    this.FillStaffComboBox(this.cbTechnician3,
            currentEntry.getTechnician3() != null ? currentEntry.getTechnician3().getId() : 0, "TECHNICIAN");
    this.FillStaffComboBox(this.cbWorker1,
            currentEntry.getWorker1() != null ? currentEntry.getWorker1().getId() : 0, "PROCESS WORKER");
    this.FillStaffComboBox(this.cbWorker2,
            currentEntry.getWorker2() != null ? currentEntry.getWorker2().getId() : 0, "PROCESS WORKER");
    this.FillStaffComboBox(this.cbWorker3,
            currentEntry.getWorker3() != null ? currentEntry.getWorker3().getId() : 0, "PROCESS WORKER");
    //Leak
    List<Record> recordsLeak = records.stream()
            .filter(x -> x.getRecordKey().startsWith("DROP_") || x.getRecordKey().equals("ANY_LEAK"))
            .collect(Collectors.toList());
    DefaultTableModel modelLeak = (DefaultTableModel) this.tblLeak.getModel();
    modelLeak.setRowCount(0);
    for (Record record : recordsLeak) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String name = record.getRecordKey();
        modelLeak.addRow(new Object[] { time, name, record.getStringValue() });
    }
    ((AbstractTableModel) this.tblLeak.getModel()).fireTableDataChanged();
    this.txtLeakNotes.setVisible(false);
    //quantity
    this.txtPalletQuantity.setText(
            currentEntry.getPalletQuantity() == null ? "0" : currentEntry.getPalletQuantity().toString());
    this.txtOtherQuantity.setText(
            currentEntry.getOtherQuantity() == null ? "0" : currentEntry.getOtherQuantity().toString());
    this.txtPalletProducedA.setText(
            currentEntry.getPalletProducedA() == null ? "0" : currentEntry.getPalletProducedA().toString());
    this.txtPalletProducedB.setText(
            currentEntry.getPalletProducedB() == null ? "0" : currentEntry.getPalletProducedB().toString());
    int a1 = 0;
    int a2 = 0;
    int b1 = 0;
    int b2 = 0;
    a1 = Integer.parseInt(this.txtPalletProducedA.getText());
    b1 = Integer.parseInt(this.txtPalletProducedB.getText());
    a2 = Integer.parseInt(this.txtPalletQuantity.getText());
    b2 = Integer.parseInt(this.txtOtherQuantity.getText());
    this.labQuantityTotal.setText(Integer.toString((a1 * a2) + (b1 * b2)));
}

From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.CFLibXmlUtil.java

public static String formatFloat(float val) {
    String retval = Float.toString(val);
    return (retval);
}