Example usage for java.lang Float MIN_VALUE

List of usage examples for java.lang Float MIN_VALUE

Introduction

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

Prototype

float MIN_VALUE

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

Click Source Link

Document

A constant holding the smallest positive nonzero value of type float , 2-149.

Usage

From source file:org.ballerinalang.stdlib.io.data.DataInputOutputTest.java

@DataProvider(name = "DoubleValues")
public static Object[][] doubleValues() {
    return new Object[][] { { 0.0f, BIT_32 }, { 0.0f, BIT_64 }, { -1.0f, BIT_32 }, { -1.0f, BIT_64 },
            { Float.MIN_VALUE, BIT_32 }, { Float.MIN_VALUE, BIT_64 }, { Float.MAX_VALUE, BIT_32 },
            { Float.MAX_VALUE, BIT_64 }, { Double.MIN_VALUE, BIT_64 }, { Double.MAX_VALUE, BIT_64 } };
}

From source file:org.openmicroscopy.shoola.util.ui.NumericalTextField.java

/**
 * Sets to <code>true</code> if negative values are accepted,
 * to <code>false</code> otherwise.
 *
 * @param negativeAccepted The value to set.
 *//*from  w w  w.  j a  v a2 s.  c  o  m*/
public void setNegativeAccepted(boolean negativeAccepted) {
    this.negativeAccepted = negativeAccepted;
    if (negativeAccepted) {
        accepted += "-";
        double min = document.getMinimum();
        if (min >= 0) {
            if (numberType == null || Integer.class.equals(numberType))
                min = Integer.MIN_VALUE;
            else if (Long.class.equals(numberType))
                min = Long.MIN_VALUE;
            else if (Float.class.equals(numberType))
                min = Float.MIN_VALUE;
            else
                min = Double.MIN_VALUE;
            document.setMinimum(min);
        }
    }
}

From source file:org.mskcc.cbio.portal.scripts.ImportExtendedMutationData.java

public void importData() throws IOException, DaoException {
    MySQLbulkLoader.bulkLoadOn();/*  ww  w . j a  va2  s .c  o  m*/

    HashSet<String> sequencedCaseSet = new HashSet<String>();

    Map<MutationEvent, MutationEvent> existingEvents = new HashMap<MutationEvent, MutationEvent>();
    for (MutationEvent event : DaoMutation.getAllMutationEvents()) {
        existingEvents.put(event, event);
    }
    Set<MutationEvent> newEvents = new HashSet<MutationEvent>();

    Map<ExtendedMutation, ExtendedMutation> mutations = new HashMap<ExtendedMutation, ExtendedMutation>();

    long mutationEventId = DaoMutation.getLargestMutationEventId();

    FileReader reader = new FileReader(mutationFile);
    BufferedReader buf = new BufferedReader(reader);

    DaoGeneOptimized daoGene = DaoGeneOptimized.getInstance();

    //  The MAF File Changes fairly frequently, and we cannot use column index constants.
    String line = buf.readLine();
    while (line.startsWith("#")) {
        line = buf.readLine(); // skip comments/meta info
    }

    line = line.trim();

    MafUtil mafUtil = new MafUtil(line);

    boolean fileHasOMAData = false;

    if (mafUtil.getMaFImpactIndex() >= 0) {
        // fail gracefully if a non-essential column is missing
        // e.g. if there is no MA_link.var column, we assume that the value is NA and insert it as such
        fileHasOMAData = true;
        ProgressMonitor.setCurrentMessage(" --> OMA Scores Column Number:  " + mafUtil.getMaFImpactIndex());
    } else {
        fileHasOMAData = false;
    }

    GeneticProfile geneticProfile = DaoGeneticProfile.getGeneticProfileById(geneticProfileId);
    while ((line = buf.readLine()) != null) {
        ProgressMonitor.incrementCurValue();
        ConsoleUtil.showProgress();

        if (!line.startsWith("#") && line.trim().length() > 0) {
            String[] parts = line.split("\t", -1); // the -1 keeps trailing empty strings; see JavaDoc for String
            MafRecord record = mafUtil.parseRecord(line);

            // process case id
            String barCode = record.getTumorSampleID();
            // backwards compatible part (i.e. in the new process, the sample should already be there. TODO - replace this workaround later with an exception:
            Sample sample = DaoSample.getSampleByCancerStudyAndSampleId(geneticProfile.getCancerStudyId(),
                    StableIdUtil.getSampleId(barCode));
            if (sample == null) {
                ImportDataUtil.addPatients(new String[] { barCode }, geneticProfileId);
                // add the sample (except if it is a 'normal' sample):
                ImportDataUtil.addSamples(new String[] { barCode }, geneticProfileId);
            }
            // check again (repeated because of workaround above):
            sample = DaoSample.getSampleByCancerStudyAndSampleId(geneticProfile.getCancerStudyId(),
                    StableIdUtil.getSampleId(barCode));
            // can be null in case of 'normal' sample:
            if (sample == null) {
                assert StableIdUtil.isNormal(barCode);
                //if new sample:
                if (sampleSet.add(barCode))
                    samplesSkipped++;
                continue;
            }

            if (!DaoSampleProfile.sampleExistsInGeneticProfile(sample.getInternalId(), geneticProfileId)) {
                DaoSampleProfile.addSampleProfile(sample.getInternalId(), geneticProfileId);
            }

            String validationStatus = record.getValidationStatus();

            if (validationStatus == null || validationStatus.equalsIgnoreCase("Wildtype")) {
                ProgressMonitor.logWarning("Skipping entry with Validation_Status: Wildtype");
                entriesSkipped++;
                continue;
            }

            String chr = DaoGeneOptimized.normalizeChr(record.getChr().toUpperCase());
            if (chr == null) {
                ProgressMonitor.logWarning("Skipping entry with chromosome value: " + record.getChr());
                entriesSkipped++;
                continue;
            }
            record.setChr(chr);

            if (record.getStartPosition() < 0)
                record.setStartPosition(0);

            if (record.getEndPosition() < 0)
                record.setEndPosition(0);

            String functionalImpactScore = "";
            // using -1 is not safe, FIS can be a negative value
            Float fisValue = Float.MIN_VALUE;
            String linkXVar = "";
            String linkMsa = "";
            String linkPdb = "";

            if (fileHasOMAData) {
                //               functionalImpactScore = getField(parts, "MA:FImpact" );
                //               fisValue = getField(parts, "MA:FIS");
                //               linkXVar = getField(parts, "MA:link.var" );
                //               linkMsa = getField(parts, "MA:link.MSA" );
                //               linkPdb = getField(parts, "MA:link.PDB" );

                functionalImpactScore = record.getMaFuncImpact();
                fisValue = record.getMaFIS();
                linkXVar = record.getMaLinkVar();
                linkMsa = record.getMaLinkMsa();
                linkPdb = record.getMaLinkPdb();

                functionalImpactScore = transformOMAScore(functionalImpactScore);
                linkXVar = linkXVar.replace("\"", "");
            }

            String mutationType, proteinChange, aaChange, codonChange, refseqMrnaId, uniprotName,
                    uniprotAccession;

            int proteinPosStart, proteinPosEnd;

            // determine whether to use canonical or best effect transcript

            // try canonical first
            if (ExtendedMutationUtil.isAcceptableMutation(record.getVariantClassification())) {
                mutationType = record.getVariantClassification();
            }
            // if not acceptable either, use the default value
            else {
                mutationType = ExtendedMutationUtil.getMutationType(record);
            }

            // skip RNA mutations
            if (mutationType != null && mutationType.equalsIgnoreCase("rna")) {
                ProgressMonitor.logWarning("Skipping entry with mutation type: RNA");
                entriesSkipped++;
                continue;
            }

            proteinChange = ExtendedMutationUtil.getProteinChange(parts, record);
            //proteinChange = record.getProteinChange();
            aaChange = record.getAminoAcidChange();
            codonChange = record.getCodons();
            refseqMrnaId = record.getRefSeq();
            uniprotName = record.getSwissprot();
            uniprotAccession = DaoUniProtIdMapping.mapFromUniprotIdToAccession(record.getSwissprot());
            proteinPosStart = ExtendedMutationUtil.getProteinPosStart(record.getProteinPosition(),
                    proteinChange);
            proteinPosEnd = ExtendedMutationUtil.getProteinPosEnd(record.getProteinPosition(), proteinChange);

            //  Assume we are dealing with Entrez Gene Ids (this is the best / most stable option)
            String geneSymbol = record.getHugoGeneSymbol();
            String entrezIdString = record.getGivenEntrezGeneId();

            CanonicalGene gene = null;
            // try to parse entrez if it is not empty nor 0:
            if (!(entrezIdString.isEmpty() || entrezIdString.equals("0"))) {
                Long entrezGeneId;
                try {
                    entrezGeneId = Long.parseLong(entrezIdString);
                } catch (NumberFormatException e) {
                    entrezGeneId = null;
                }
                //non numeric values or negative values should not be allowed:
                if (entrezGeneId == null || entrezGeneId < 0) {
                    ProgressMonitor.logWarning("Ignoring line with invalid Entrez_Id " + entrezIdString);
                    entriesSkipped++;
                    continue;
                } else {
                    gene = daoGene.getGene(entrezGeneId);
                    if (gene == null) {
                        //skip if not in DB:
                        ProgressMonitor.logWarning(
                                "Entrez gene ID " + entrezGeneId + " not found. Record will be skipped.");
                        entriesSkipped++;
                        continue;
                    }
                }
            }

            // If Entrez Gene ID Fails, try Symbol.
            if (gene == null && !(geneSymbol.equals("") || geneSymbol.equals("Unknown"))) {
                gene = daoGene.getNonAmbiguousGene(geneSymbol, chr);
            }

            // assume symbol=Unknown and entrez=0 (or missing Entrez column) to imply an 
            // intergenic, irrespective of what the column Variant_Classification says
            if (geneSymbol.equals("Unknown")
                    && (entrezIdString.equals("0") || mafUtil.getEntrezGeneIdIndex() == -1)) {
                // give extra warning if mutationType is something different from IGR:
                if (mutationType != null && !mutationType.equalsIgnoreCase("IGR")) {
                    ProgressMonitor.logWarning("Treating mutation with gene symbol 'Unknown' "
                            + (mafUtil.getEntrezGeneIdIndex() == -1 ? "" : "and Entrez gene ID 0")
                            + " as intergenic ('IGR') " + "instead of '" + mutationType
                            + "'. Entry filtered/skipped.");
                }
                // treat as IGR:
                myMutationFilter.decisions++;
                myMutationFilter.igrRejects++;
                // skip entry:
                entriesSkipped++;
                continue;
            }

            // skip the record if a gene was expected but not identified
            if (gene == null) {
                ProgressMonitor.logWarning("Ambiguous or missing gene: " + geneSymbol + " ["
                        + record.getGivenEntrezGeneId() + "] or ambiguous alias. Ignoring it "
                        + "and all mutation data associated with it!");
                entriesSkipped++;
                continue;
            } else {
                ExtendedMutation mutation = new ExtendedMutation();

                mutation.setGeneticProfileId(geneticProfileId);
                mutation.setSampleId(sample.getInternalId());
                mutation.setGene(gene);
                mutation.setSequencingCenter(record.getCenter());
                mutation.setSequencer(record.getSequencer());
                mutation.setProteinChange(proteinChange);
                mutation.setAminoAcidChange(aaChange);
                mutation.setMutationType(mutationType);
                mutation.setChr(record.getChr());
                mutation.setStartPosition(record.getStartPosition());
                mutation.setEndPosition(record.getEndPosition());
                mutation.setValidationStatus(record.getValidationStatus());
                mutation.setMutationStatus(record.getMutationStatus());
                mutation.setFunctionalImpactScore(functionalImpactScore);
                mutation.setFisValue(fisValue);
                mutation.setLinkXVar(linkXVar);
                mutation.setLinkPdb(linkPdb);
                mutation.setLinkMsa(linkMsa);
                mutation.setNcbiBuild(record.getNcbiBuild());
                mutation.setStrand(record.getStrand());
                mutation.setVariantType(record.getVariantType());
                mutation.setAllele(record.getTumorSeqAllele1(), record.getTumorSeqAllele2(),
                        record.getReferenceAllele());
                mutation.setDbSnpRs(record.getDbSNP_RS());
                mutation.setDbSnpValStatus(record.getDbSnpValStatus());
                mutation.setMatchedNormSampleBarcode(record.getMatchedNormSampleBarcode());
                mutation.setMatchNormSeqAllele1(record.getMatchNormSeqAllele1());
                mutation.setMatchNormSeqAllele2(record.getMatchNormSeqAllele2());
                mutation.setTumorValidationAllele1(record.getTumorValidationAllele1());
                mutation.setTumorValidationAllele2(record.getTumorValidationAllele2());
                mutation.setMatchNormValidationAllele1(record.getMatchNormValidationAllele1());
                mutation.setMatchNormValidationAllele2(record.getMatchNormValidationAllele2());
                mutation.setVerificationStatus(record.getVerificationStatus());
                mutation.setSequencingPhase(record.getSequencingPhase());
                mutation.setSequenceSource(record.getSequenceSource());
                mutation.setValidationMethod(record.getValidationMethod());
                mutation.setScore(record.getScore());
                mutation.setBamFile(record.getBamFile());
                mutation.setTumorAltCount(ExtendedMutationUtil.getTumorAltCount(record));
                mutation.setTumorRefCount(ExtendedMutationUtil.getTumorRefCount(record));
                mutation.setNormalAltCount(ExtendedMutationUtil.getNormalAltCount(record));
                mutation.setNormalRefCount(ExtendedMutationUtil.getNormalRefCount(record));

                // TODO rename the oncotator column names (remove "oncotator")
                mutation.setOncotatorCodonChange(codonChange);
                mutation.setOncotatorRefseqMrnaId(refseqMrnaId);
                mutation.setOncotatorUniprotName(uniprotName);
                mutation.setOncotatorUniprotAccession(uniprotAccession);
                mutation.setOncotatorProteinPosStart(proteinPosStart);
                mutation.setOncotatorProteinPosEnd(proteinPosEnd);

                // TODO we don't use this info right now...
                mutation.setCanonicalTranscript(true);

                sequencedCaseSet.add(sample.getStableId());

                //  Filter out Mutations
                if (myMutationFilter.acceptMutation(mutation)) {
                    MutationEvent event = existingEvents.get(mutation.getEvent());

                    if (event != null) {
                        mutation.setEvent(event);
                    } else {
                        mutation.setMutationEventId(++mutationEventId);
                        existingEvents.put(mutation.getEvent(), mutation.getEvent());
                        newEvents.add(mutation.getEvent());
                    }

                    ExtendedMutation exist = mutations.get(mutation);
                    if (exist != null) {
                        ExtendedMutation merged = mergeMutationData(exist, mutation);
                        mutations.put(merged, merged);
                    } else {
                        mutations.put(mutation, mutation);
                    }
                    //keep track:
                    sampleSet.add(barCode);
                    geneSet.add(mutation.getEntrezGeneId() + "");
                } else {
                    entriesSkipped++;
                }
            }
        }
    }

    for (MutationEvent event : newEvents) {
        try {
            DaoMutation.addMutationEvent(event);
        } catch (DaoException ex) {
            throw ex;
        }
    }

    for (ExtendedMutation mutation : mutations.values()) {
        try {
            DaoMutation.addMutation(mutation, false);
        } catch (DaoException ex) {
            throw ex;
        }
    }

    if (MySQLbulkLoader.isBulkLoad()) {
        MySQLbulkLoader.flushAll();
    }

    // calculate mutation count for every sample
    DaoMutation.calculateMutationCount(geneticProfileId);

    if (entriesSkipped > 0) {
        ProgressMonitor.setCurrentMessage(
                " --> total number of data entries skipped (see table below):  " + entriesSkipped);
    }
    ProgressMonitor.setCurrentMessage(" --> total number of samples: " + sampleSet.size());
    if (samplesSkipped > 0) {
        ProgressMonitor
                .setCurrentMessage(" --> total number of samples skipped (normal samples): " + samplesSkipped);
    }
    ProgressMonitor.setCurrentMessage(
            " --> total number of genes for which one or more mutation events were stored:  " + geneSet.size());

    ProgressMonitor.setCurrentMessage("Filtering table:\n-----------------");
    ProgressMonitor.setCurrentMessage(myMutationFilter.getStatistics());
}

From source file:javadz.beanutils.locale.converters.FloatLocaleConverter.java

/**
 * Convert the specified locale-sensitive input object into an output object of the
 * specified type.  This method will return Float value or throw exception if value
 * can not be stored in the Float./* w w w.ja v  a  2 s.c  o m*/
 *
 * @param value The input object to be converted
 * @param pattern The pattern is used for the convertion
 * @return The converted value
 *
 * @exception ConversionException if conversion cannot be performed
 *  successfully
 * @throws ParseException if an error occurs parsing a String to a Number
 */
protected Object parse(Object value, String pattern) throws ParseException {
    final Number parsed = (Number) super.parse(value, pattern);
    double doubleValue = parsed.doubleValue();
    double posDouble = (doubleValue >= (double) 0) ? doubleValue : (doubleValue * (double) -1);
    if (posDouble != 0 && (posDouble < Float.MIN_VALUE || posDouble > Float.MAX_VALUE)) {
        throw new ConversionException("Supplied number is not of type Float: " + parsed);
    }
    return new Float(parsed.floatValue()); // unlike superclass it returns Float type
}

From source file:ExposedFloat.java

public boolean action(Event evt, Object arg) {

    if (evt.target instanceof Button) {
        String bname = (String) arg;
        if (bname.equals(incrementButtonString)) {

            ++value;/*from  w  w  w . j a  va 2s  . com*/
        } else if (bname.equals(decrementButtonString)) {

            --value;
        } else if (bname.equals(multByZeroButtonString)) {

            value *= (float) 0.0;
        } else if (bname.equals(piButtonString)) {

            value = (float) Math.PI;
        } else if (bname.equals(positiveInfinityButtonString)) {

            value = Float.POSITIVE_INFINITY;
        } else if (bname.equals(negativeInfinityButtonString)) {

            value = Float.NEGATIVE_INFINITY;
        } else if (bname.equals(maximumButtonString)) {

            value = Float.MAX_VALUE;
        } else if (bname.equals(minimumButtonString)) {

            value = Float.MIN_VALUE;
        } else if (bname.equals(notANumberButtonString)) {

            value = Float.NaN;
        } else if (bname.equals(changeSignButtonString)) {

            value *= -1.0;
        } else if (bname.equals(doubleButtonString)) {

            value *= 2.0;
        } else if (bname.equals(halveButtonString)) {

            value /= 2.0;
        }
        updateNumberFields();
        enableDisableButton(maximumButton, Float.MAX_VALUE);
        enableDisableButton(minimumButton, Float.MIN_VALUE);
        enableDisableButton(positiveInfinityButton, Float.POSITIVE_INFINITY);
        enableDisableButton(negativeInfinityButton, Float.NEGATIVE_INFINITY);
        enableDisableButton(piButton, (float) Math.PI);
        enableDisableButton(notANumberButton, Float.NaN);
        if (!notANumberButton.isEnabled()) {
            if (!Float.isNaN(value)) {
                notANumberButton.enable();
            }
        } else if (Float.isNaN(value)) {
            notANumberButton.disable();
        }
    }
    return true;
}

From source file:fr.immotronic.ubikit.pems.smartbuilding.impl.node.TemperatureNodeImpl.java

@Override
public float getTemperature() {
    if (isLocal()) {
        switch (getPemLocalID()) {
        case ENOCEAN:

            switch (eep) {
            case EEP_07_02_01:
            case EEP_07_02_02:
            case EEP_07_02_03:
            case EEP_07_02_04:
            case EEP_07_02_05:
            case EEP_07_02_06:
            case EEP_07_02_07:
            case EEP_07_02_08:
            case EEP_07_02_09:
            case EEP_07_02_0A:
            case EEP_07_02_0B:
            case EEP_07_02_10:
            case EEP_07_02_11:
            case EEP_07_02_12:
            case EEP_07_02_13:
            case EEP_07_02_14:
            case EEP_07_02_15:
            case EEP_07_02_16:
            case EEP_07_02_17:
            case EEP_07_02_18:
            case EEP_07_02_19:
            case EEP_07_02_1A:
            case EEP_07_02_1B: {
                EEP0702xxData data = (EEP0702xxData) getActualNodeValue();
                if (data == null) {
                    return Float.MIN_VALUE;
                }/*from w  w  w.j a v a  2  s . c  o m*/
                return data.getTemperature();
            }

            case EEP_07_04_01: {
                EEP070401Data data = (EEP070401Data) getActualNodeValue();
                if (data == null) {
                    return Float.MIN_VALUE;
                }
                return data.getTemperature();
            }

            case EEP_07_04_02: {
                EEP070402Data data = (EEP070402Data) getActualNodeValue();
                if (data == null) {
                    return Float.MIN_VALUE;
                }
                return data.getTemperature();
            }

            case EEP_07_08_01: {
                EEP0708xxData data = (EEP0708xxData) getActualNodeValue();
                if (data == null) {
                    return Float.MIN_VALUE;
                }
                return data.getTemperature();
            }

            case EEP_07_09_04: {
                EEP070904Data data = (EEP070904Data) getActualNodeValue();
                if (data == null) {
                    return Float.MIN_VALUE;
                }
                return data.getTemperature();
            }

            case EEP_07_10_01:
            case EEP_07_10_02:
            case EEP_07_10_03:
            case EEP_07_10_04:
            case EEP_07_10_05:
            case EEP_07_10_06:
            case EEP_07_10_07:
            case EEP_07_10_08:
            case EEP_07_10_09:
            case EEP_07_10_10:
            case EEP_07_10_11:
            case EEP_07_10_12:
            case EEP_07_10_13:
            case EEP_07_10_14: {
                EEP0710xxData data = (EEP0710xxData) getActualNodeValue();
                if (data == null) {
                    return Float.MIN_VALUE;
                }
                return data.getTemperature();
            }

            default:
                break;
            }
            break;
        }
    }

    return Float.MIN_VALUE;
}

From source file:hivemall.classifier.multiclass.MulticlassOnlineClassifierUDTF.java

protected final PredictionResult classify(@Nonnull final FeatureValue[] features) {
    float maxScore = Float.MIN_VALUE;
    Object maxScoredLabel = null;

    for (Map.Entry<Object, PredictionModel> label2map : label2model.entrySet()) {// for each class
        Object label = label2map.getKey();
        PredictionModel model = label2map.getValue();
        float score = calcScore(model, features);
        if (maxScoredLabel == null || score > maxScore) {
            maxScore = score;/* w w w  . j a  v  a 2s. c  om*/
            maxScoredLabel = label;
        }
    }

    return new PredictionResult(maxScoredLabel, maxScore);
}

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

private ChartPanel getPanel(ArrayList<ChanDataBuffer> dbufs, boolean compact) throws WebUtilException {
    ChartPanel ret = null;//from  w  w  w.  ja va2  s .  c o  m
    try {
        float tfsMax = 0;
        for (ChanDataBuffer buf : dbufs) {
            ChanInfo ci = buf.getChanInfo();
            float fs = ci.getRate();
            tfsMax = Math.max(fs, tfsMax);
        }
        setFsMax(tfsMax);
        String gtitle = getTitle(dbufs, compact);
        int nbuf = dbufs.size();
        XYSeries[] xys = new XYSeries[nbuf];
        XYSeriesCollection mtds = new XYSeriesCollection();

        int cnum = 0;
        compact = dbufs.size() > 2 ? false : compact;
        float bw = 1.f;
        for (ChanDataBuffer dbuf : dbufs) {
            String legend = getLegend(dbuf, compact);

            xys[cnum] = new XYSeries(legend);

            bw = calcSpectrum(xys[cnum], dbuf);

            mtds.addSeries(xys[cnum]);
        }

        DefaultXYDataset ds = new DefaultXYDataset();
        String yLabel = pwrScale.toString();
        DecimalFormat dform = new DecimalFormat("0.0###");
        String xLabel;
        xLabel = String.format("Frequency Hz - (bw: %1$s, #fft: %2$,d, s/fft: %3$.2f, ov: %4$.2f)",
                dform.format(bw), nfft, secperfft, overlap);

        Double minx, miny, maxx, maxy;
        Double[] rng = new Double[4];
        if (fmin <= 0) {
            fmin = bw;
        }
        float searchFmax = fmax;
        if (fmax <= 0 || fmax == Float.MAX_VALUE) {
            fmax = tfsMax / 2;
            searchFmax = tfsMax / 2 * 0.8f;
        }
        PluginSupport.getRangeLimits(mtds, rng, 2, fmin, searchFmax);
        minx = rng[0];
        miny = rng[1];
        maxx = rng[2];
        maxy = rng[3];

        findSmallest(mtds);
        int exp;
        if (maxy == 0. && miny == 0.) {
            miny = -1.;
            exp = 0;
            logYaxis = false;
        } else {
            miny = miny > 0 ? miny : smallestY;
            maxy = maxy > 0 ? maxy : miny * 10;
            exp = PluginSupport.scaleRange(mtds, miny, maxy);
            if (!logYaxis) {
                yLabel += " x 1e-" + Integer.toString(exp);
            }
        }
        JFreeChart chart = ChartFactory.createXYLineChart(gtitle, xLabel, yLabel, ds, PlotOrientation.VERTICAL,
                true, false, false);
        XYPlot plot = (XYPlot) chart.getPlot();
        if (logYaxis) {
            LogAxis rangeAxis = new LogAxis(yLabel);
            double smallest = miny * Math.pow(10, exp);
            rangeAxis.setSmallestValue(smallest);
            rangeAxis.setMinorTickCount(9);

            LogAxisNumberFormat lanf = new LogAxisNumberFormat();
            lanf.setExp(exp);

            rangeAxis.setNumberFormatOverride(lanf);
            rangeAxis.setRange(smallest, maxy * Math.pow(10, exp));
            rangeAxis.setStandardTickUnits(LogAxis.createLogTickUnits(Locale.US));
            plot.setRangeAxis(rangeAxis);
            plot.setRangeGridlinesVisible(true);
            plot.setRangeGridlinePaint(Color.BLACK);
        }
        if (logXaxis) {
            LogAxis domainAxis = new LogAxis(xLabel);
            domainAxis.setBase(2);
            domainAxis.setMinorTickCount(9);
            domainAxis.setMinorTickMarksVisible(true);
            domainAxis.setSmallestValue(smallestX);
            domainAxis.setNumberFormatOverride(new LogAxisNumberFormat());
            //domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            plot.setDomainAxis(domainAxis);
            plot.setDomainGridlinesVisible(true);
            plot.setDomainGridlinePaint(Color.BLACK);
        }
        ValueAxis domainAxis = plot.getDomainAxis();
        if (fmin > Float.MIN_VALUE) {
            domainAxis.setLowerBound(fmin);
        }
        if (fmax != Float.MAX_VALUE) {
            domainAxis.setUpperBound(fmax);
        }
        plot.setDomainAxis(domainAxis);
        plot.setDataset(0, mtds);
        plot.setDomainGridlinePaint(Color.DARK_GRAY);
        plot.setRangeGridlinePaint(Color.DARK_GRAY);

        // Set the line thickness
        XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
        BasicStroke str = new BasicStroke(lineThickness);
        int n = plot.getSeriesCount();
        for (int i = 0; i < n; i++) {
            r.setSeriesStroke(i, str);
        }
        plot.setBackgroundPaint(Color.WHITE);
        if (compact) {
            chart.removeLegend();
        }
        ret = new ChartPanel(chart);
    } catch (Exception ex) {
        throw new WebUtilException("Creating spectrum plot" + ex.getLocalizedMessage());
    }
    return ret;

}

From source file:org.jts.eclipse.conversion.cjsidl.ConversionUtil.java

/**
 * Used to fill a gap where a minimum value isn't specified in a range.
 * @param val - the current value, if there is one.
 * @param inputType - the input data type that the minimum should fit within
 * /*  ww w. j  av a 2 s .  c o m*/
 * @return - the original value if it exists, or the minimum value allowed within
 * the inputType specified.
 */
public static String getCountMin(String val, String inputType) {
    String result = val;
    if (result == null || result.isEmpty()) {
        if (inputType.equals("byte") || inputType.equals("int8")) {
            result = Byte.toString(Byte.MIN_VALUE);
        } else if (inputType.equals("short integer") || inputType.equals("int16")) {
            result = Short.toString(Short.MIN_VALUE);
        } else if (inputType.equals("integer") || inputType.equals("int32")) {
            result = Integer.toString(Integer.MIN_VALUE);
        } else if (inputType.equals("long integer") || inputType.equals("int64")) {
            result = Long.toString(Long.MIN_VALUE);
        } else if (inputType.equals("unsigned byte") || inputType.equals("uint8")) {
            result = "0";
        } else if (inputType.equals("unsigned short integer") || inputType.equals("uint16")) {
            result = "0";
        } else if (inputType.equals("unsigned integer") || inputType.equals("uint32")) {
            result = "0";
        } else if (inputType.equals("unsigned long integer") || inputType.equals("uint64")) {
            result = "0";
        } else if (inputType.equals("float") || inputType.equals("float")) {
            result = Float.toString(Float.MIN_VALUE);
        } else if (inputType.equals("long float") || inputType.equals("double")) {
            result = Double.toString(Double.MIN_VALUE);
        }
    }

    return result;
}

From source file:de.ma.it.common.excel.ExcelFileManager.java

/**
 * /*from ww  w. j  ava2s  .  co  m*/
 * @param row
 * @param cellIdx
 * @return
 * @throws IllegalArgumentException
 */
public Float readCellAsFloat(HSSFRow row, int cellIdx) throws IllegalArgumentException {
    HSSFCell cell = getCell(row, cellIdx);
    if (cell == null) {
        return null;
    }

    int cellType = cell.getCellType();
    // First evaluate formula if present
    if (cellType == HSSFCell.CELL_TYPE_FORMULA) {
        cellType = evaluator.evaluateFormulaCell(cell);
    }

    Float result;
    switch (cellType) {
    case HSSFCell.CELL_TYPE_NUMERIC:
        double numericCellValue = cell.getNumericCellValue();
        if (numericCellValue > Float.MAX_VALUE) {
            throw new IllegalArgumentException("Value " + numericCellValue + " to big for integer!");
        }
        result = Double.valueOf(numericCellValue).floatValue();
        break;
    case HSSFCell.CELL_TYPE_STRING:
        String stringCellValue = cell.getStringCellValue();
        if (!StringUtils.isNumeric(stringCellValue)) {
            throw new IllegalArgumentException("Value " + stringCellValue + " is not numeric!");
        }
        result = Double.valueOf(stringCellValue).floatValue();
        break;
    default:
        result = Float.MIN_VALUE;
        break;
    }

    return result;
}